I'm also guessing that you are using a Pi 3B. On a Pi 3B, "/dev/ttyAMA0" is normally reserved for Bluetooth.
To use the Serial Port on the Pi 3B (or any model of Pi running updated Raspbian Jessie):
Remove the phrase "console=serial0,115200" from the file '/boot/cmdline.txt'. Note that this file must only contain 1 line, do not split the line when editing, or try to add comments. This prevents Linux sending boot messages to the Serial Port.
Add the line "enable_uart=1" to the end of the file '/boot/config.txt'. Ensure that this file does not contain any other commands referring to the uart. This takes care of all the background tasks needed to use the Serial Port on the Pi 3B.
Reboot.
Refer to your Serial Port in code as "/dev/serial0", that's serialZero, not serialOh!
No need to change groups or permissions from the defaults.
翻译:
(1)移除/boot/cmdline.txt中的console-serial,115200这一段
(2)在/boot/config.txt中添加enable_uar

在树莓派3B上,/dev/ttyAMA0默认用于蓝牙。要启用串口,需从'/boot/cmdline.txt'中移除'console=serial0,115200',在'/boot/config.txt'末尾添加'enable_uart=1',然后重启。2019年的更新表明,还需要通过raspi-config配置以访问/dev/ttyS0,并注意确认选项。完成这些步骤后,用户将能够正常读写该串口。"
133626635,20015842,修复MySQL复制联机重做日志文件教程,"['数据库', 'mysql']
2001

被折叠的 条评论
为什么被折叠?



