I have a laser shutter that operates through a serial port, say COM1.
The only input the shutter needs is a "\n@" command that sets the
shutter to open/closed position. I have no problem controlling the
shutter through a hyperterminal.
But when I try to control the instrument through an MFC .NET 2003 app
I get very slow response, and I can't get the shutter to open/close. I
copied all the COM1 settings I have set in the hyperterminal:
CSerial serial;
LONG lLastError = ERROR_SUCCESS;
lLastError = serial.Open("COM1");
OutputDebugString("Opened serial port for shutter control!\n");
lLastError =
serial.Setup(CSerial::EBaud300,CSerial::EData8,CSerial::EParNone,CSerial::EStop1);
OutputDebugString("Settings for serial port for shutter control OK!
\n");
lLastError = serial.SetupHandshaking(CSerial::EHandshakeHardware);
OutputDebugString("Hanshaking for serial port for shutter control OK!
\n");
lLastError = serial.Write("\n\@");
OutputDebugString("Sent data for shutter control!\n");
serial.Close();
The delay between the "handshaking OK" message and the "sent data"
message can be as long as ~10 seconds, and the shutter does not open/
close anyway. So the communucation seems to be there, but smth is
wrong. How can I debug this? The original working hyperterminal
connection is set at 300 baud rate, 8 data bits, no parity, 1 stop
bit, and no flow control. It also needs ASCII echoed, but that
probably is irrelevant.
The above routine works just fine for COM3 which controls another
instrument, with different settings.