Re: (another) serial port question
- From: Dan Espen <daneNO@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Wed, 31 May 2006 16:14:41 -0400
"kid_kei" <Chris.Reath@xxxxxxxxx> writes:
While programming for the serial port, I've come across a strange....
phenomenon. I can now successfully send an unsigned character array
sizeof 255 with hex values from 0 to FF over serial and receive this
array and display it. Strangely, however, 0x0D (13) being transmitted
appears as 0x0A (10) on the receiving end. My hardware setup is as
follows: two serial cards (one used to send - one used to receive) on
one Linux machine.
Example of problem:
Transmitted:
0
F
...etc.
Received:
0
1
2
3
4
5
6
7
8
9
A
B
C
A
E
F
...(rest received is ok)
Here are my setup options:
struct termios options;
fd= open("/dev/ttyS0", O_RDWR | O_NOCTTY | O_NDELAY);
fcntl(fd, FSETFL, 0);
tcgetattr(fd, &options);
cfsetispeed(&options, B115200);
cfsetospeed(&options, B115200);
options.c_cflag |= (CLOCAL|CREAD);
options.c_lflag &=~(ICANON | ECHO | ECHOE | ISIG);
options.c_oflag &=~OPOST;
options. &= ~(IXON | IXOFF | IXANY);
options.c_cflag |= CRTSCTS;
options.c_cflag &= ~PARENB;
options.c_cflag &= ~CSTOPB;
options.c_cflag &= ~CSIZE;
options.c_cflag |= CS8;
tcsetattr(fd, TCSANOW, &options)
Since 10 and 13 are LF (Line Feed) and CR (Carriage Return)
respectively, I think I might be confusing the machine somehow. Any
input would be greatly appreciated.
man termios
Look at OCRNL, ICRNL.
I have no experience with this but looked around a bit.
.
- References:
- (another) serial port question
- From: kid_kei
- (another) serial port question
- Prev by Date: Booting Linux from a FAT32 partitioned SD card?
- Next by Date: Re: vnc - anyone here ever used?
- Previous by thread: (another) serial port question
- Next by thread: Booting Linux from a FAT32 partitioned SD card?
- Index(es):
Relevant Pages
|