7 Oct 2003 17:37
Hanging on Reads
Andrew Hogue <hogue <at> cs.yorku.ca>
2003-10-07 15:37:47 GMT
2003-10-07 15:37:47 GMT
Hi, I'm currently experiencing a problem with my serial port code and was hoping that someone has a solution to this problem. Basically, I open the serial port, set the attributes, write to the device and then since I expect a response, I call read(), but it seems to hang on the read indefinitely. The weird thing is that there is a workaround to this problem which makes everything work, but it is ugly. The workaround is to simply open() the serial port, close() the serial port and then re-open it at the beginning of the program. Here is a piece of my code, /* stupid workaround here */ f = fopen(SERIALPORT, O_RDWR); close(f); f = fopen(SERIALPORT, O_RDWR); ... tcgetattr(f,&termold); term.c_cflag = B38400 | CS8 | CLOCAL | CREAD; term.c_iflag = 0; term.c_oflag = 0; term.c_lflag = 0; term.c_cc[VMIN] = 1; term.c_cc[VTIME] = 0;(Continue reading)
RSS Feed