silly question about serial port

Feb 13, 2006 0 Replies

i want to communicate with a serial device in raw mode when ever i want to send 10 40 40 16 i want to received back e5(hex) but when i read from /dev/ttyS0 i get 44(hex).



i don't want to use any flow control and baud rate is 19200



my initialization into /dev/ttyS0 is



ioctl(fd,TCGETS,&options); cfsetispeed(&options, B19200); cfsetospeed(&options, B19200); options.c_cflag |= ( CLOCAL | CREAD | HUPCL); options.c_cflag |= PARENB; options.c_cflag &= ~PARODD; options.c_cflag &= ~CSTOPB; options.c_cflag &= ~CSIZE; options.c_cflag |= CS8; options.c_cflag &= ~( CRTSCTS ); options.c_iflag |= ( INPCK ); options.c_iflag &= ~( IXON | ICRNL ); options.c_oflag = 0; options.c_lflag=0; options.c_cc[VMIN]=0; options.c_cc[VTIME]=1; ioctl(fd,TCSETS,&options);



i have the sending data in array 'data' so i do write(fd,data,5); //from sniffer in the other box i see that sending //is ok



i receive data into array 'received_data' read(fd,received_data,1); //sniffer in the other box tells me that it has //send the desired e5 character.



when i printf 'received_data[0]' in hex i don't get e5 but 44



any ideas?



Join the Discussion

Have something to add? Share your thoughts — no account required.

Didn't find your answer?

Ask the community — no account required