I have two applications which are communicationg with serial
ports. Problem is totally blocking application when there is no device
attached to serial port. It looks like app is jammed when reading
port, regardless use of select, O_NONBLOCK, DevRead.
To details:
- Serial drivers are started like this:
/bin/Dev.ser -N/dev/ser1 3f8,4 &
/bin/Dev.ser -N/dev/ser2 2f8,3 &
For 5554/8
/bin/Dev.ser -F -N/dev/ser3 100,7 -b 38400 108,7 110,7 118,7 &
\
- Opening & using serial port:
serfile = open( serdev, O_RDWR | O_NONBLOCK );
tcgetattr(serfile, &CommSettings);
cfsetispeed(&CommSettings,portspeed);
cfsetospeed(&CommSettings,portspeed);
CommSettings.c_iflag = IGNBRK;
CommSettings.c_oflag &= ~OPOST;
CommSettings.c_cflag = CS8 | CSIZE | CREAD | CLOCAL| OHFLOW |
IHFLOW | CSTOPB;
CommSettings.c_lflag = IEXTEN;
RetVal = tcsetattr(serfile,TCSANOW, &CommSettings);
rval = write(serfile,&b,1);
FD_ZERO(&rfds);
FD_SET(serfile,&rfds);
memset(&timeout,0,sizeof(timeout));
if( select(serfile+1, &rfds, NULL, NULL, &timeout ) > 0) {
nBytesRead = dev_read( serfile, ((BYTE *)(&buff)),NUM_OF_ELEMENTS(buff),
0,0,0,0,0 );
…
–
M. Tavasti / tavastixx@iki.fi / +358-40-5078254
Poista sähköpostiosoitteesta molemmat x-kirjaimet
Remove x-letters from my e-mail address