>Here is the simple C program I wrote just to test the port. All it
>does is open the port, read 20 characters and output them to the
>console, then reprint all of them again as a string then quite.
...
>{
> fs=fopen("/dev/ttyAM1","rb");
> for (n=0; n<20 ;n++){
> int temp = fgetc(fs);
If you don't explicitly set it, you usually get a default serial port
behaviour that is set up for somebody typing on a terminal. In this mode,
received characters are echoed back (so the user can see what they are
typing), backspace deletes the previous character typed, and the input
is not made available to the program until you press return.
You can control the serial port behaviour with termios (see "man
termios"). Also, try a google search for "posix serial port programming"
to find a few tutorials.
I don't recommend using stdio with serial ports. (You can do it,
but I expect it will give you problems sometimes.) Instead, use
open/close/read/write directly.
Another thing to watch for is whether the open() call is waiting for
carrier detect. This is why you see O_NDELAY in the call to open in a lot
of examples. I don't recall if ttyAM1 does this on the TS boards, but it
causes problems for a lot of people. Whenever debugging a serial program
that appears to hang, always print something like "open finished" so
you know whether your program in hanging in the open() or the read() call.
Mark S.
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/ts-7000/
<*> Your email settings:
Individual Email | Traditional
<*> To change settings online go to:
http://groups.yahoo.com/group/ts-7000/join
(Yahoo! ID required)
<*> To change settings via email:
<*> To unsubscribe from this group, send an email to:
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/
|