(another) serial port question
- From: "kid_kei" <Chris.Reath@xxxxxxxxx>
- Date: 31 May 2006 12:42:16 -0700
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
1
2
3
4
5
6
7
8
9
A
B
C
D
E
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.
Chris.
.
- Follow-Ups:
- Re: (another) serial port question
- From: Dan Espen
- Re: (another) serial port question
- Prev by Date: Knoppix 5.0.1 Released
- Next by Date: Re: Bearshare like client for suse linux 10
- Previous by thread: Knoppix 5.0.1 Released
- Next by thread: Re: (another) serial port question
- Index(es):
Relevant Pages
|