http://meld.mvista.com/group_discussion.aspx?DiscussionID=c8dc021dc52e4ddfa9457b3307e4da91
Hi,
I am currently have the follow code in my program to use the serial
port on my board:
int RS232_ID = open("/dev/ttyS0", O_RDWR | O_NOCTTY | O_SYNC);
int n,i;
while(1){
n = read(RS232_ID, data, sizeof(data));
if( 0 == n || -1 == n )
continue;
else
for(i=0;i<n;i++){
printf("%02X\n",data[i]);fflush(0);
}
}
What I have discover is that if the stream contains 0x11 (ctrl+q)
it will be missed and if the stream contains 0x0D (CR) it becomes 0x0A
(LF) on the printf.
Anybody know what I should do to not let Linux modify my I/O stream?
thanks.
Posted 6/22/2009
8:24 PM |
|
It
sounds like the serial port is still being controlled in cooked mode.
Are you running a getty on the port (i.e., you can log into the serial
port as a console)? If so, that's your problem.
HTH,
Mike
Posted 6/22/2009
8:46 PM |
|
I do start my
Linux through uboot with "boot args=console=ttyS0,115200n8"
If it is my console causing me problems, how do i turn if off or
suspend, so my program can have complete control over that serial
device?
Thanks.
Posted 6/22/2009
11:50 PM |
|
Yup,
that command line means that you're running a console on ttyS0. If you
don't have a 2nd serial port or USB interface to run a USB serial, you
can enable the network console instead. This will require rebuilding
your kernel. The network console support is typically found in the
network devices section of the kernel config. There is also a bit of
documentation in Documentation/networking/netconsole.txt. As
always, Google is your friend here.
Posted 6/23/2009
7:39 AM |
|
Along with
ptmike's suggestion, here is a quick test you can do (assuming you have
Ethernet enabled)
1. Take out console=ttyS0,115200n8 from bootargs.
2. Boot the board.
3. Telnet to the board.
4. Run your program
Posted 6/24/2009
6:31 AM |
|
|