Raspberry PI 上奇怪的串行端口行为

Raspberry PI 上奇怪的串行端口行为

我正在尝试通过 GPIO15(RXD) 引脚接收 Raspberry Pi 上的串行数据。我有以下 python 脚本:

serPort = serial.Serial("/dev/ttyAMA0", baudrate=2400)
while True:
    rcv = ord(serPort.read())
    print(str(rcv))

曾经在 raspbian 发行版上工作得很顺利。打印所有传入的字节。

在哪里寻找变化的分布。并关注 DietPI。随着 DietPI 发行版。它只接收垃圾字节。 (主要是很多零)。

一些注意事项:

stty -F /dev/ttyAMA0 -a (旧发行版的结果):

speed 2400 baud; rows 0; columns 0; line = 0;
intr = ^C; quit = ^\; erase = ^?; kill = ^U; eof = ^D; eol = <undef>; eol2 = <undef>; swtch = <undef>; start = ^Q; stop = ^S; susp = ^Z; rprnt = ^R; werase = ^W; lnext = ^V; flush = ^O; min = 1; time = 0;
-parenb -parodd -cmspar cs8 hupcl -cstopb cread clocal -crtscts
-ignbrk -brkint -ignpar -parmrk -inpck -istrip -inlcr -igncr icrnl ixon -ixoff -iuclc -ixany -imaxbel -iutf8
opost -olcuc -ocrnl onlcr -onocr -onlret -ofill -ofdel nl0 cr0 tab0 bs0 vt0 ff0
isig icanon iexten echo echoe echok -echonl -noflsh -xcase -tostop -echoprt echoctl echoke

stty -F /dev/ttyAMA0 -a (新 Dietpi 发行版的结果):

speed 2400 baud; rows 24; columns 80; line = 0;
intr = ^C; quit = ^\; erase = ^?; kill = ^U; eof = ^D; eol = <undef>; eol2 = <undef>; swtch = <undef>; start = ^Q; stop = ^S; susp = ^Z; rprnt = ^R; werase = ^W; lnext = ^V; discard = ^O; min = 1; time = 0;
-parenb -parodd -cmspar cs8 hupcl -cstopb cread clocal -crtscts
-ignbrk -brkint -ignpar -parmrk -inpck -istrip -inlcr -igncr -icrnl -ixon -ixoff -iuclc -ixany -imaxbel iutf8
opost -olcuc -ocrnl onlcr -onocr -onlret -ofill -ofdel nl0 cr0 tab0 bs0 vt0 ff0
-isig -icanon -iexten -echo -echoe -echok -echonl -noflsh -xcase -tostop -echoprt -echoctl -echoke -flusho -extproc

当我通过 Dietpi 中的 stty 命令配置波特率时(stty -F /dev/ttyAMA0 2400)。它将其更改为 2400。但是当我用串行数据对其进行爆炸时,它会将其更改回不同的值,大多数时候是 19200。我认为它会尝试自动校准到波特率?我已经验证它仍然适用于旧发行版。这不是硬件问题。 Dietpi 发行版上的串行端口配置是否有问题?

相关内容