1

I'm trying to receive serial data on a Raspberry Pi through the GPIO15(RXD) pin. I have the following python script:

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

Used to work like a charm on raspbian distribution. Printing all the bytes as they came in.

Where looking into changing distributions. and have our eyes on DietPI. With the DietPI distribution. It receives only garbage bytes. (mainly lots of zero's).

Some considerations:

stty -F /dev/ttyAMA0 -a (result on old distribution):

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 (result on new dietpi distribution):

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

When i configure the baudrate via stty command in dietpi (stty -F /dev/ttyAMA0 2400). It changes it to 2400. But when i blast it with serial data, it changes it back to a different value, most of the time 19200. I think it tries to auto calibrate to a baudrate? I've verified that it still works on the old distribution. This is NOT a hardware issue. Is there something wrong with the serial port configuration on a dietpi distribution?

  • I don't know DietPI but maybe you need to disable shell and kernel messages on the serial connection? – laktak Jun 14 '18 at 9:23
  • Could you elaborate? Do you mean in cmdline.txt? – Oht Jun 14 '18 at 11:55
  • see github.com/Fourdee/DietPi/issues/306 – laktak Jun 14 '18 at 14:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.