xgqfrms™, xgqfrms® : xgqfrms's offical website of cnblogs! xgqfrms™, xgqfrms® : xgqfrms's offical website of GitHub!

Minicom All In One

Minicom All In One

minicom bugs / minicom errors

Minicom 2.8

# 0000000000001 ❌
$ minicom -b 115200 -o -D /dev/tty.usbmodem0000000000001

# tty ❌
$ minicom -b 115200 -o -D /dev/tty.usbmodem14601

# cu ✅
$ minicom -b 115200 -o -D /dev/cu.usbmodem14601

Raspberry Pi 3 B

$ sudo apt-get install minicom

$ minicom --help
Usage: minicom [OPTION]... [configuration]
A terminal program for Linux and other unix-like systems.

  -b, --baudrate         : set baudrate (ignore the value from config) # 波特率
  -D, --device           : set device name (ignore the value from config) # 设置设备名称
  -s, --setup            : enter setup mode
  -o, --noinit           : do not initialize modem & lockfiles at startup # 不要在启动时初始化调制解调器和锁定文件
  -m, --metakey          : use meta or alt key for commands
  -M, --metakey8         : use 8bit meta key for commands
  -l, --ansi             : literal; assume screen uses non IBM-PC character set
  -L, --iso              : don't assume screen uses ISO8859
  -w, --wrap             : Linewrap on
  -H, --displayhex       : display output in hex
  -z, --statline         : try to use terminal's status line
  -7, --7bit             : force 7bit mode
  -8, --8bit             : force 8bit mode
  -c, --color=on/off     : ANSI style color usage on or off
  -a, --attrib=on/off    : use reverse or highlight attributes on or off
  -t, --term=TERM        : override TERM environment variable
  -S, --script=SCRIPT    : run SCRIPT at startup
  -d, --dial=ENTRY       : dial ENTRY from the dialing directory
  -p, --ptty=TTYP        : connect to pseudo terminal
  -C, --capturefile=FILE : start capturing to FILE
  -F, --statlinefmt      : format of status line
  -R, --remotecharset    : character set of communication partner
  -v, --version          : output version information and exit
  -h, --help             : show help
  configuration          : configuration file to use

These options can also be specified in the MINICOM environment variable.
This variable is currently unset.
The configuration directory for the access file and the configurations
is compiled to /etc/minicom.

Report bugs to <minicom-devel@lists.alioth.debian.org>.

$ minicom -v
minicom version 2.7.1 (compiled Aug 13 2017)
Copyright (C) Miquel van Smoorenburg.

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version
2 of the License, or (at your option) any later version.

# ❌
$ minicom -b 115200 -o -D /dev/cu.usbmodem14601
# ❌
$ minicom -b 115200 -o -D /dev/tty.usbmodem0000000000001

$ cd /dev

$ cd /Volumes

macOS ❌

Setup /dev/ path to PICO not being seen on Mac

$ cd / && ls

$ cd /dev

$ cd /Volumes

https://forums.raspberrypi.com/viewtopic.php?t=321228

# 过滤 tty ✅
$ cd /dev && ls | grep "tty.usbmodem*"
tty.usbmodem14601

$ /dev minicom -b 115200 -o -D /dev/tty.usbmodem14601

$ cd /dev && ls | grep "usbmodem"
cu.usbmodem14601
tty.usbmodem14601

# cu ✅
$ minicom -b 115200 -o -D /dev/cu.usbmodem14601

image

官方 SDK 文档 ❌ bug

https://datasheets.raspberrypi.com/pico/raspberry-pi-pico-python-sdk.pdf

Thonny IDE

https://electrocredible.com/raspberry-pi-pico-with-macos-thonny-getting-started/

https://microcontrollerslab.com/getting-started-raspberry-pi-pico-thonny-ide/

MicroPython REPL

MicroPython v1.19.1-994-ga4672149b on 2023-03-29; Raspberry Pi Pico with RP2040

>>> pin25 = machine.Pin(25)
>>> print("pin25 =", type(pin25))
>>> pin25 = <class 'Pin'>

>>> import time
>>> from time import sleep
>>>
>>> GPIO_PIN = 25
>>> led = machine.Pin(GPIO_PIN, machine.Pin.OUT)
>>>
>>> led.value(1)
>>> time.sleep(1)
>>> led.value(0)
>>>
>>> led.high()
>>> time.sleep(1)
>>> led.low()
>>>

https://micropython.org/help/


MPY: soft reboot
MicroPython v1.19.1-994-ga4672149b on 2023-03-29; Raspberry Pi Pico with RP2040
Type "help()" for more information.
>>> help()
Welcome to MicroPython!

For online help please visit https://micropython.org/help/.

For access to the hardware use the 'machine' module.  RP2 specific commands
are in the 'rp2' module.

Quick overview of some objects:
  machine.Pin(pin) -- get a pin, eg machine.Pin(0)
  machine.Pin(pin, m, [p]) -- get a pin and configure it for IO mode m, pull mode p
    methods: init(..), value([v]), high(), low(), irq(handler)
  machine.ADC(pin) -- make an analog object from a pin
    methods: read_u16()
  machine.PWM(pin) -- make a PWM object from a pin
    methods: deinit(), freq([f]), duty_u16([d]), duty_ns([d])
  machine.I2C(id) -- create an I2C object (id=0,1)
    methods: readfrom(addr, buf, stop=True), writeto(addr, buf, stop=True)
             readfrom_mem(addr, memaddr, arg), writeto_mem(addr, memaddr, arg)
  machine.SPI(id, baudrate=1000000) -- create an SPI object (id=0,1)
    methods: read(nbytes, write=0x00), write(buf), write_readinto(wr_buf, rd_buf)
  machine.Timer(freq, callback) -- create a software timer object
    eg: machine.Timer(freq=1, callback=lambda t:print(t))

Pins are numbered 0-29, and 26-29 have ADC capabilities
Pin IO modes are: Pin.IN, Pin.OUT, Pin.ALT
Pin pull modes are: Pin.PULL_UP, Pin.PULL_DOWN

Useful control commands:
  CTRL-C -- interrupt a running program
  CTRL-D -- on a blank line, do a soft reset of the board
  CTRL-E -- on a blank line, enter paste mode

For further help on a specific object, type help(obj)
For a list of available modules, type help('modules')
>>>
Meta-Z for help | 115200 8N1 | NOR | Minicom 2.8 | VT102 | Offline | cu.usbmodem14601

machine

Pin

# machine.Pin(pin)
# -- get a pin, eg machine.Pin(0)

# machine.Pin(pin, m, [p])
# -- get a pin and configure it for IO mode m, pull mode p
    methods: init(..), value([v]), high(), low(), irq(handler)

# machine.Pin(pin, m, [p])
led = machine.Pin(25, machine.Pin.OUT)

# value([v])
led.value(1)
led.value(0)

# high(), low()
led.high()
led.low()

# init(..) ???
led.init()

# irq(handler) ???
def handler():
  print("function")

led.irq(handler)

ADC

PWM

I2C

minicom 无法退出 bug ❌

如何退出 minicom
how to exit minicom

不好使呀,垃圾

Ctrl + A 可以切换到 > 模式;但是再依次按 Z 键,X 键 也无法退出 ❓ 不好使 ❌
Ctrl + A 连续按两次也不好使 ❌

Ctrl + B 可以切换到 >>> MicroPython 的 REPL 模式;
>>> help() 可以正常使用 ✅

minicom 使用文档 / minicom 使用教程

Ctrl + A => C-A

image

Q Exit minicom without resetting the modem. If macros changed and were not saved, you will have a chance to do so.

Q 退出 minicom 而不重置调制解调器。如果宏改变了 并没有得救,你将有机会这样做。

X Exit minicom, reset modem. If macros changed and were not saved, you will have a chance to do so.

X 退出 minicom,重置调制解调器。如果宏已更改且未更改 已保存,您将有机会这样做

https://man7.org/linux/man-pages/man1/minicom.1.html#USE

macOS 配置 Python 环境变量

Python 3

$ which python
# python not found

$ python --version
# zsh: command not found: python

$ which python3
# /usr/bin/python3
$ python3 --version
# Python 3.9.6

#  ✅
$ cd /usr/bin/ && ls | grep "python"

#  ✅
$ cd /usr/bin/ && ls -al | grep "python"

image

$ code .zshrc
$ source ~/.zshrc

# Python 3 ✅ alias
alias python=/usr/bin/python3

# export PATH="/usr/bin/python3:$PATH"
# export PATH="/usr/bin/:$PATH"
# $ cd /usr/bin/ && ls | grep "python" ✅
# $ cd /usr/bin/ && ls -al | grep "python" ✅


# .bash_profile
source ~/.bash_profile

# end zsh
# source ~/.zshrc

image

https://www.python.org/downloads/

https://docs.python.org/3/using/mac.html

macOS 安装多个 Python 版本 ???

$ brew install python3

Raspberry Pi 3 B

$ ssh pi@192.168.18.135
pi@192.168.18.135's password: 
Linux raspberrypi 4.19.118-v7+ #1311 SMP Mon Apr 27 14:21:24 BST 2020 armv7l

The programs included with the Debian GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.

Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
Last login: Wed Mar 29 00:18:23 2023 from 192.168.18.195

SSH is enabled and the default password for the 'pi' user has not been changed.
This is a security risk - please login as the 'pi' user and type 'passwd' to set a new password.
$ python --version
Python 2.7.16
$ which python
/usr/bin/python

$  python3 --version
Python 3.7.3
$ which python3
/usr/bin/python3

$ vim test.py
$ python ./test.py 10

$ python3 ./test.py 10
# #!/usr/bin/env python3 ✅
# #!/usr/bin/python3
# # coding: utf8 ✅

gpio.py

#!/usr/bin/env python3

# coding: utf8

import RPi.GPIO as GPIO
import time

import sys

arg1 = sys.argv[1]

print("arg1 =", arg1);

# 指定 BCM 模式下的GPIO 针脚编号
PIN = 12
# BCM 模式
GPIO.setmode(GPIO.BCM)

# 指定 GPIO 针脚为一个电流输出针脚
GPIO.setup(PIN, GPIO.OUT)

# 输出低电平
GPIO.output(PIN, GPIO.LOW)

# index
i = 0
# max
# n = 7

# 类型转换,str => int
n = int(arg1)

print("n =", n)

print('开始闪烁⏳')

while (i < n):
    print("i =", i)
    # 高电平,LED 点亮
    GPIO.output(PIN, GPIO.HIGH)
    # 休眠 1 秒,防止 LED 长时间点亮烧坏了
    time.sleep(1.0)
    # 低电平,LED 熄灭
    GPIO.output(PIN, GPIO.LOW)
    # 休眠 1 秒
    time.sleep(1.0)
    i = i + 1

# 输出低电平,LED 关闭
# GPIO.output(PIN, GPIO.LOW)

# 清除,释放内存
GPIO.cleanup()

print('结束闪烁 👌🏻')

# ip, wlan0 ??? grep
$ ifconfig

# 查看内存占用
$ df -h
文件系统        容量  已用  可用 已用% 挂载点
/dev/root        29G  6.4G   22G   23% /
devtmpfs        243M     0  243M    0% /dev
tmpfs           248M     0  248M    0% /dev/shm
tmpfs           248M  6.6M  241M    3% /run
tmpfs           5.0M  4.0K  5.0M    1% /run/lock
tmpfs           248M     0  248M    0% /sys/fs/cgroup
/dev/mmcblk0p1  253M   51M  202M   21% /boot
tmpfs            50M     0   50M    0% /run/user/1000

nvm

$ curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.3/install.sh | bash
#  port 443: 拒绝连接

$ sudo vim /etc/hosts
$ cat /etc/hosts
127.0.0.1	localhost
::1		localhost ip6-localhost ip6-loopback
ff02::1		ip6-allnodes
ff02::2		ip6-allrouters

127.0.1.1		raspberrypi

# github
185.199.108.133 raw.githubusercontent.com

image

https://www.cnblogs.com/xgqfrms/p/16852071.html#5163462

image

# ✅ ---lts !== --lst ❌
$ nvm ls-remote --lst

image

$ sudo apt-get install imagemagick

# display ❌
$ display css-轮播图.gif 
# display-im6.q16: unable to open X server `' @ error/display.c/DisplayImageCommand/433.

$ echo $DISPLAY
$ export DISPLAY=:0.0
$ sudo apt-get update
获取:1 http://archive.raspberrypi.org/debian buster InRelease [32.6 kB]
获取:2 http://raspbian.raspberrypi.org/raspbian buster InRelease [15.0 kB]             
正在读取软件包列表... 完成          
E: 仓库'http://archive.raspberrypi.org/debian buster InRelease'将其'Suite'值从'testing'修改到了'oldstable'
N: 为了让这个仓库能够应用,这必须在更新之前显式接受。更多细节请参阅 apt-secure(8) 手册。
E: 仓库'http://raspbian.raspberrypi.org/raspbian buster InRelease'将其'Suite'值从'stable'修改到了'oldstable'
N: 为了让这个仓库能够应用,这必须在更新之前显式接受。更多细节请参阅 apt-secure(8) 手册。


$ sudo vim /etc/apt/sources.list 

$ sudo vim /etc/apt/sources.list.d/raspi.list


$ sudo cat /etc/apt/sources.list.d/raspi.list
# new ✅
deb http://mirrors.ustc.edu.cn/archive.raspberrypi.org/debian/ buster main

# old ❌
#deb http://archive.raspberrypi.org/debian/ buster main

# Uncomment line below then 'apt-get update' to enable 'apt-get source'
#deb-src http://archive.raspberrypi.org/debian/ buster main

$ sudo cat /etc/apt/sources.list
# new ✅
deb http://mirrors.ustc.edu.cn/raspbian/raspbian/ buster main contrib non-free rpi

# tsinghua 不好使 ❌
# deb http://mirror.tuna.tsinghua.edu.cn/raspberrypi/ stretch main ui
# deb-src http://mirror.tuna.tsinghua.edu.cn/raspberrypi/ stretch main ui

# old ❌
# deb http://raspbian.raspberrypi.org/raspbian/ buster main contrib non-free rpi

# Uncomment line below then 'apt-get update' to enable 'apt-get source'
#deb-src http://raspbian.raspberrypi.org/raspbian/ buster main contrib non-free rpi

zh-Hans

# 中文输入法 设置成功

\`\`\`sh
# 1. 更新
$ sudo apt-get update

# 2. 安装中文输入法 chinese input
$ sudo apt-get install scim-pinyin

# 3. 重启系统
$ sudo reboot
# 或者
$ sudo shutdown -r now

# sudo apt-get install fcitx fcitx-googlepinyin fcitx-module-cloudpinyin fcitx-sunpinyin

\`\`\`

切换中英文输入法方式

1. Shift
2. Ctrl + Space

https://blog.csdn.net/u012313335/article/details/53519302

截图 ?

\`\`\`sh

sudo shutdown -r +1 "一分钟后重启系统"

\`\`\`


## emoji bug

 ✅
🇨🇳 China flag

https://www.emojicopy.com/ 

(🐞 反爬虫测试!打击盗版⚠️)如果你看到这个信息, 说明这是一篇剽窃的文章,请访问 https://www.cnblogs.com/xgqfrms/ 查看原创文章!

refs

https://www.cnblogs.com/xgqfrms/p/17274811.html



©xgqfrms 2012-2021

www.cnblogs.com/xgqfrms 发布文章使用:只允许注册用户才可以访问!

原创文章,版权所有©️xgqfrms, 禁止转载 🈲️,侵权必究⚠️!


posted @ 2023-03-31 11:56  xgqfrms  阅读(32)  评论(6编辑  收藏  举报