Problem w/ 'read' system call - RH 7.3
Hello, all. Here is a snippet of kernel space code written to test read/write of an rs485 interface board. Ports 1 & 2 are connected via a loopback cable. System is Pentium 4 PC running RedHat 7.3
unsigned char tempChar, buf;
fs = get_fs();
if((fd_ttyS4 = open("/dev/ttyS4", O_RDWR | O_NOCTTY, 0)) < 0)
if((fd_ttyS5 = open("/dev/ttyS5", O_RDWR | O_NDELAY | O_NONBLOCK , 0)) < 0)
Seems simple. The loopback works fine when tempChar is initialized to a value between 0 and 0x7f. But when tempChar is 0x80 or greater, the subsequent read hangs forever. I am new to linux, so maybe I am missing something simple??? Thank you for any help you may provide.
Also, here is how I set the port attributes:
newtio.c_cflag = BAUDRATE | CRTSCTS | CS8 | CLOCAL | CREAD;
newtio.c_iflag = IGNPAR | ICRNL;
newtio.c_oflag = 0;
newtio.c_lflag = ICANON;
newtio.c_cc[VTIME] = 0;
newtio.c_cc[VMIN] = 1;
Last edited by buckles; 05-04-2005 at 02:38 PM.