Archlinux 3.12 + weird app UART problem when reading

Started by karrister, February 07, 2014, 11:39:59 PM

Previous topic - Next topic

karrister

Hi all,

I have a weird problem reading UART from a specific chip, using cat to read on the UART.

I have the imx233 micro board (B2 rev). I built the 3.12 kernel myself and use Archlinux rootfs. I am attempting to operate the application UART (ttyAPP0) to talk with a GSM chip (SIM900).

I am able to give AT commands successfully on UART to the SIM900 but I am not really able to read back from it. For instance I do the following:

cat /dev/ttyAPP0

and I now make a phone call to the GSM chip. When I have a USB->UART connected to the GSM chip, I see the RING notifications just fine on the UART. However, when I have the imx233 application UART connected to the GSM chip, I just get a hell of a lot of new lines, RING and then ERROR.
When I connect the imx233 app UART and the USB->UART I am able to read&write on UART just fine, with no such weird issues.

Anyone has any idea what could it be about? I mean it somehow looks like the UART RX pin of the imx233 is not acting nicely with the SIM900 chip, it looks as if it's sending something back on the line, or something weird like that.

Anyone ever saw something like that?

The correct output should be like this:

RING

RING

RING


Instead, what I get on the imx233 RX is this:

RING











RING























RING















































RING































































































RING































































































































































































RING































































































































































































































































































































































































RING





















































































ERROR

RING

NO CARRIER


Any ideas are welcome :) Thanks!

JohnS

It's a tty so what mode is it set to?

See stty man pages

John

karrister

#2
Quote from: JohnS on February 08, 2014, 11:39:03 AM
It's a tty so what mode is it set to?

See stty man pages

John

Well now that was embarrassing...

Thanks for the help! It was the stty configuration!

But the thing is that I had already did the configuration with:

stty -F /dev/ttyAPP0 19200 clocal cread cs8 -cstopb -parenb

And that one did not work on the imx233. However, the exactly same configuration worked between the PC USB->UART and the SIM900 chip so I did not suspect that too much, even though when reviewing the settings with:

stty -F /dev/ttyAPP0

my PC showed much more options. So I guess by default my PC stty sets some stuff automatically that the stty on the archlinux on the imx233 does not. I just copied those settings from my PC to the stty on the imx233 and BAM it works now!! (even though that there is still some extra linefeeds but now it's something I can work with and I prooved it's only about the stty configuration). This is what I used:

stty -F /dev/ttyAPP0 19200 clocal cread cs8 -cstopb -parenb -isig -icanon -iexten -echo -echoe -echok -echoctl -echoke -opost -onlcr ignbrk -brkint -icrnl -imaxbel line 0 time 0 min 1 eof ^A


Thanks a lot!!

EDIT:
I wanted to add that the UART worked two ways just fine between the imx233 and my Linux PC so it gave me even more to wonder if something else is wrong. Happy it was only the configuration.

JohnS

What may be happening is that the mode gets restored when the line is closed i.e. you may need to keep it open during the time you use it.  Which probably means using the stty syscall from your program rather than the command line.

Don't be embarrassed - many things are only obvious AFTER you know the answer!  (Even when you "knew" it.)

John

Kean

A technique I've used in the past to make sure the stty settings stick is:

(stty 19200 clocal cread cs8 -cstopb -parenb; sleep 300) </dev/ttyAPP0 &

the sleep keeps the device open long enough for the next thing you run (e.g. cat </dev/ttyAPP0) to not loose the setting

Or in simpler shell syntax:

sleep 300 </dev/ttyAPP0 &
stty -F /dev/ttyAPP0 19200 clocal cread cs8 -cstopb -parenb