I've probably given more information than necessary but at this point I'm not sure what is relevant or not.
I have a program that has multiple classes on a single thread making calls to a static instance of SerialPort to communicate with testing hardware (via a Prologix GPIB card but I don't think that's relevant). This static SerialPort instance is managed by a PrologixGPIB class the devices use to interface with it.
This code has been working for months but last week I changed one of the classes to write a double that I called ToString on instead of the hard coded placeholder string. On my development machine this was no problem but on my deployment machine I get the error: "The I/O operation has been aborted because of either a thread exit or an application request."
Here is my SerialPort setup:
Expand|Select|Wrap|Line Numbers
- public PrologixGPIB(byte primaryAddress)
- {
- if (sp == null)
- {
- sp = new SerialPort();
- // COM port parameters
- ConfigAddress addr = Config.findAddress("GPIB_Controller.DeviceType", "PrologixGPIB");
- addr.attribute = "Tag";
- Log.writeLog(log, "Loading Configured Port");
- sp.PortName = Config.getValue(addr);
- sp.BaudRate = 115200;
- sp.DataBits = 8;
- sp.Parity = Parity.None;
- sp.StopBits = StopBits.One;
- // RTS/CTS handshaking
- sp.Handshake = Handshake.RequestToSend;
- sp.DtrEnable = true;
- sp.WriteTimeout = 10000;
- sp.ReadTimeout = 10000;
- // Error handling
- sp.DiscardNull = false;
- sp.ParityReplace = 0;
- sp.Open();
- // Sets the prologix GPIB to controller mode.
- sp.WriteLine("++mode 1");
- }
- this.address = primaryAddress;
- setAddress();
- Log.writeLog(log, "GPIB Configured");
- }
- ~PrologixGPIB()
- {
- if (sp != null)
- {
- sp.DiscardInBuffer();
- sp.DiscardOutBuffer();
- sp.Close();
- sp = null;
- Log.writeLog(log, "GPIB Closed");
- }
- }
Expand|Select|Wrap|Line Numbers
- public override void write(string data)
- {
- try
- {
- setAddress();
- Log.writeLog(log, "Writing GPIB Command | " + data);
- string newData = data;
- foreach (char c in END_OF_LINE_CHARS)
- {
- newData += c;
- }
- sp.DiscardInBuffer();
- sp.Write(newData);
- }
- catch (TimeoutException e)
- {
- throw new GPIBException("The GPIB write timed out | " + data,e);
- }
- }
Expand|Select|Wrap|Line Numbers
- public override void setGateTime(string time)
- {
- this.write("GATE" + time);
- }
- public override void setGateTime(double time)
- {
- this.setGateTime(time.ToString("##.###"));
- }
EDIT: Forgot to mention the dev machine is running Windows XP SP3 and the deployment machine is Windows 2000 SPwhatever the last was