cornernote
Posts: 3
Joined: Tue Oct 01, 2013 2:04 pm

problem logging RS232 serial data

Tue Oct 01, 2013 2:17 pm

I have a Model B Raspberry Pi and an Serial Pi RS232 Interface. I am running Raspbian Wheezy on my RPi.

I used a null modem to connect a Windows PC to the RPi. The PC ran TeraTerm and the RPi ran minicom. I configured both as follows:
Baud Rate = 115200, Data Bits = 8, Parity = NONE, Stop Bits = 1, Flow Control = NONE

This worked perfectly in both directions.

I need to log the data, I assumed something like this would work:
cat /dev/ttyAMA0 > /var/log/ttyAMA0.log

But it doesn't log anything. I tried just this, and still nothing:
cat /dev/ttyAMA0

Does anyone have any ideas or suggestions?


View this question on StackExchange:
http://raspberrypi.stackexchange.com/qu ... spberry-pi
Last edited by cornernote on Thu Oct 03, 2013 6:54 am, edited 1 time in total.


cornernote
Posts: 3
Joined: Tue Oct 01, 2013 2:04 pm

Re: problem logging RS232 serial data

Thu Oct 03, 2013 6:44 am

Hi AndrewS,

Thank you so much for the tips. This helped me get it mostly sorted.

This script did the trick:
https://github.com/lurch/rpi-serial-console

It seems it added this line to the bottom of the /etc/inittab file:

Code: Select all

T0:23:respawn:/sbin/getty -L ttyAMA0 115200 vt100
And changed the /boot/cmdline.txt to be like this:

Code: Select all

dwc_otg.lpm_enable=0 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline rootwait console=ttyAMA0,115200 kgdboc=ttyAMA0,115200
I ran 'cat /dev/ttyAMA0' and it worked, also 'echo "test" > /dev/ttyAMA0' worked.

Only problem was during boot I get all the RPi output to the screen.

The guides on this page helped with that:
http://elinux.org/RPi_Serial_Connection

I simply changed /boot/cmdline.txt to be

Code: Select all

dwc_otg.lpm_enable=0 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline rootwait
And I commented out the line in /etc/inittab

Code: Select all

#T0:23:respawn:/sbin/getty -L ttyAMA0 115200 vt100
The only issue was that I had to change the PC baud rate to 9600. Where can I set the baud on the RPi?

User avatar
AndrewS
Posts: 3625
Joined: Sun Apr 22, 2012 4:50 pm
Location: Cambridge, UK
Contact: Website

Re: problem logging RS232 serial data

Fri Oct 04, 2013 1:01 am

cornernote wrote: This script did the trick:
https://github.com/lurch/rpi-serial-console

It seems it added this line to the bottom of the /etc/inittab file:

Code: Select all

T0:23:respawn:/sbin/getty -L ttyAMA0 115200 vt100
And changed the /boot/cmdline.txt to be like this:

Code: Select all

dwc_otg.lpm_enable=0 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline rootwait console=ttyAMA0,115200 kgdboc=ttyAMA0,115200
I ran 'cat /dev/ttyAMA0' and it worked, also 'echo "test" > /dev/ttyAMA0' worked.

I simply changed /boot/cmdline.txt to be

Code: Select all

dwc_otg.lpm_enable=0 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline rootwait
And I commented out the line in /etc/inittab

Code: Select all

#T0:23:respawn:/sbin/getty -L ttyAMA0 115200 vt100
Errr, so you've just undone exactly what rpi-serial-console did? :? You could have just done the same with 'sudo rpi-serial-console disable' ;)
The only issue was that I had to change the PC baud rate to 9600. Where can I set the baud on the RPi?
I haven't done this myself, but https://www.google.co.uk/search?q=linux+stty+baud+rate seems to be what you're looking for?

cornernote
Posts: 3
Joined: Tue Oct 01, 2013 2:04 pm

Re: problem logging RS232 serial data

Fri Oct 04, 2013 1:07 am

So I ran enable, and it fixed it, then I ran disable and it remains fixed.

I'm trying to understand what made it work, but as long as it works.

Thanks again.

User avatar
AndrewS
Posts: 3625
Joined: Sun Apr 22, 2012 4:50 pm
Location: Cambridge, UK
Contact: Website

Re: problem logging RS232 serial data

Fri Oct 04, 2013 1:13 am

How bizarre! rpi-serial-update only automates the exact steps as described at http://elinux.org/RPi_Serial_Connection ... erial_port
*shrug*

But good to hear that it's working, whatever the problem was :)

Return to “General discussion”