Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

Serial port timeout ignored on read

I'm using an NI 8431 8 port PCI serial board, NI driver version 1.8, with CVI 8.0 on a Windows XP Pro PC.
 
It appears to me that the timeout value I establish for the port using the rs-232 library SetComTime() is being ignored.
 
I set a purposely low value (say 2.0 seconds) and then issue a ComRdTerm().  The device (an HP34970A) takes about ten seconds to complete a measurement, with the ComRdTerm pending the entire time.  I should think the read would time out.  But it doesn't - the read returns without error when the terminating character is received some ten seconds or so later.
 
Has anyone seen this problem?  Code below ... SerialConfig is a struct set up with config info including an element timeOut of type double, value 2.0.
 
Hayes
 
// Open the comport. If port is already open, OpenComConfig will close and reopen it.
 
  if ((iStatus = OpenComConfig (SerialConfig.port,
                                "",
                                SerialConfig.bitRate,
                                SerialConfig.parity,
                                SerialConfig.dataWidth,
                                SerialConfig.stopBits,
                                SerialConfig.inQueue,
                                SerialConfig.outQueue)) < 0) {
    return HP34970_CONFIG_ERROR;
  }
 
  if ((iStatus = SetComTime (SerialConfig.port, SerialConfig.timeOut)) < 0) {
    CloseCom (SerialConfig.port);
    return HP34970_CONFIG_ERROR;
  }
 
  if ((iStatus = SetCTSMode (SerialConfig.port, SerialConfig.CTSMode)) < 0) {
    CloseCom (SerialConfig.port);
    return HP34970_CONFIG_ERROR;
  }
 
  if ((iStatus = SetXMode (SerialConfig.port, SerialConfig.XMode)) < 0) {
    CloseCom (SerialConfig.port);
    return HP34970_CONFIG_ERROR;
  }
 
 // Port is open, establish port number.
 
  iHP34970Comport = SerialConfig.port;  // Establish comport number.
 
 
then
 
 
  if ((iStatus = ComRdTerm (iHP34970Comport, pszInString, HP34970_MAX_BUFFER_SIZE, NEWLINE)) <= 0) {
     pszInString[0] = NUL;  // return an empty string
     return HP34970_COM_ERROR;
  }
  if (ReturnRS232Err() != NO_ERROR) {
     pszInString[0] = NUL;  // return an empty string
     return HP34970_COM_ERROR;
  }
  
  pszInString[iStatus] = NUL;  // make returned bytes into a string
  
0 Kudos
Message 1 of 2
(2,916 Views)
As Gilda Radner so famously proclaimed -

Never mind 🙂

The reason I'm not seeing a timeout is because the instrument is returning partial data all along.

Hayes
0 Kudos
Message 2 of 2
(2,901 Views)