I will try to clarify and also add some new things I discovered as I tried to debug the system.
The program is run through a user interface. It initializes everything and pauses for the user to press a button to start a test.
The port is opened during initialization with:
OpenComConfig(com_port, "", 9600, 0, 8, 1, 512, 512);
If I initialize, wait a minute and then try a test the program breaks.
If I initialize, run a test, wait a minute, then try to run the test again the program breaks.
Normally, a green LED on the front panel of ENET/RS-232 box goes on when the port is opened. The LED goes off about 60 seconds of sitting idle after initialization or a test. If I run a test when the LED went off, the test always gives me the same error. If I reinitialize, the LED goes back on and can run the tests without problems.
The error itself shows up in the following piece of code.
The ComRdTerm times out and returns 0 bytes, so the program enters the if statement and gets terminated with an error message:
nbytes = ComRdTerm(com_port, in_buf, CM6K6_MAX_CMD, 13);
if (nbytes <= 0)
{
Fmt(msg, "%s<# bytes in = %i, problem receiving RS232 input", nbytes);
cm6k6_error(msg);
return -1;
}
In my mind everything, including the fact that it breaks after exactly 1 minute (which I confirmed yesterday), indicates that something is breaking the connection to the port.
I tried to connect another ENET/RS-232 box in place of the one that gives me trouble, but the problem didn't go away.
I got a PCI serial card and connected the motor controller to it. The problem I experience disappeared.
But I still want to figure out what is going on, because our lab uses many ENET/RS-232. It's just that nobody seems to leave their box sitting idle with a com port open.