I have some code I’m debugging, where I am talking to a device over a standard com port, and every once in a while the process hangs and stops receiving pulses and other messages. I did some searches to see if anyone else has had this issue, and it didn’t turn up much.
When I catch it with the debugger, it says it is stuck in a MsgSend() call after the readcond(), and the debugger also claims that is has just received a SIGINT signal. That seems odd to me since I’m not doing any interrupt handling myself, unless I am inheriting that from the devc-ser8250 process.
At this point in the code, I am attempting to open the serial device, and flush the buffer before I start taking real data from it.
other vitals:
x86
QNX6.3 SP1
the com port code is below:
//Open COM port
char * temp = new char[80];
sprintf(temp, “/dev/ser%d”, port);
mComPort = open(temp, O_RDWR);
if (mComPort == -1)
{
fprintf(stderr, “Unable to open COM%d port\n”, port);
//exit(1);
}
else
{
// Configure the serial port. The serial port is configured such
// that the baud rate is 38400 with no parity checking, 8 bit data,
// and one stop bit.
struct termios termio;
if (tcgetattr(mComPort, &termio))
{
fprintf(stderr, "Cannot configure COM%d port\n", port);
exit(1);
}
cfsetispeed(&termio, B38400);
cfsetospeed(&termio, B38400);
termio.c_iflag &= ~(ICRNL|INLCR);
termio.c_iflag |= IGNPAR;
termio.c_oflag &= ~(OPOST);
termio.c_cflag &= ~(CSIZE|PARENB);
termio.c_cflag |= CREAD|CS8|CLOCAL;
termio.c_lflag &= ~(ECHO|ECHOE|ECHOK|ECHONL|ICANON|ISIG);
termio.c_cflag &= ~(IHFLOW|OHFLOW);
tcsetattr(mComPort, TCSANOW, &termio);
//initialize pulse event to occur when data is received on the serial port
SIGEV_PULSE_INIT(&mSerialEvent, mCoid, SIGEV_PULSE_PRIO_INHERIT, PULSE_SERIAL_INPUT, 0);
tcflush(mComPort, TCIOFLUSH);
mSerialFlags = ionotify(mComPort,_NOTIFY_ACTION_POLLARM,
_NOTIFY_COND_INPUT,&mSerialEvent);
while (mSerialFlags & _NOTIFY_COND_INPUT)
{
while (readcond(mComPort, temp, 80,1,0,10) > 0)
{
}
mSerialFlags = ionotify(mComPort, _NOTIFY_ACTION_POLLARM,
_NOTIFY_COND_INPUT,&mSerialEvent);
}
}