Hi all ,
I have Beagleboard xm where i have insmoded g_serial and receiving some bytes from windows to Beagleboard-xm
i am using the below program’s read function on Beagleboard side .
JAN’s program to talk to uart on linux
http://www.lvr.com/code/usb_serial_port.c
But i am seeing a surprising thing that
whenever my sent data array contains 0x03 , or 0x04 , or some more …
then the data received at Beagle board is corrupted …mostly its broken at places where 0x03 or 0x04 is present …
PLease suggest how should i solve this problem
Thanks
nidhi
It looks like you are doing a very simple setup of the serial port using the ICANON style. Looking at http://linux.die.net/man/3/termios says that it will enable special characters EOF, EOL, EOL2, ERASE, KILL, LNEXT, REPRINT, STATUS, and WERASE, and buffers by lines.
In my own code that I want to talk binary over a serial port, I copy the old port settings into oldtio so I can restore the port to its original state when I’m done, and then modify a bunch of items in newtio. I hope this helps.
tcgetattr(fd,&oldtio); /* save current port settings /
struct termios newtio;
tcgetattr(fd,&newtio);
cfsetispeed(&newtio, B115200);
cfsetospeed(&newtio, B115200);
newtio.c_cflag |= CLOCAL | CREAD;
newtio.c_cflag &= ~CSIZE; / Mask the character size bits /
newtio.c_cflag |= CS8; / Select 8 data bits */
// No parity (8N1):
newtio.c_cflag &= ~PARENB;
newtio.c_cflag &= ~CSTOPB;
newtio.c_cflag &= ~CSIZE;
newtio.c_cflag |= CS8;
// disable hardware flow control:
//newtio.c_cflag &= ~CNEW_RTSCTS;
newtio.c_cflag &= ~CRTSCTS;
// Choosing Raw Input:
newtio.c_lflag &= ~(ICANON | ECHO | ECHOE | ISIG);
// disable software flow control simply mask those bits:
newtio.c_iflag &= ~(IXON | IXOFF | IXANY);
// Choosing Raw Output
newtio.c_oflag &= ~OPOST;
tcsetattr(fd,TCSANOW,&newtio);