(another) serial port qusetion.
- From: Chris.Reath@xxxxxxxxx
- Date: 31 May 2006 12:40:56 -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.
.
- Prev by Date: Re: Supported hardware
- Next by Date: Re: Freecom USB DVB-T issues
- Previous by thread: Supported hardware
- Next by thread: Philips speakers DGX320 (USB) not recognised
- Index(es):
Relevant Pages
|