Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

Serial device driver doesn't support DTR escape code

Gary,

Looks like we need to change the code to the following:

#include <rs232.h>
#include <utility.h>

int main (void)
{
    int iStatus;

     iStatus = OpenComConfig (3, "com3", 9600, 1, 8, 2, 512, 512);
                                     
    EnableBreakOnLibraryErrors ();

    if (iStatus == 0)
    {
        SetXMode (3, 0);
        SetCTSMode (3, LWRS_HWHANDSHAKE_CTS_RTS);
        SetComTime (3, 1);
    }

    // Configure com ports for 2-wire mode communication.
    iStatus = ComSetEscape (3, WIRE_2_ECHO);
  


    iStatus = ComSetEscape (3, SETDTR);
    iStatus = ComWrt (3, "abcdefg", 7);
    iStatus = ComSetEscape (3, CLRDTR);

    return 0;
  

}


We don't need niserial.h since we're using the CVI serial library and the handshaking mode needs to be set to LWRS_HWHANDSHAKE_CTS_RTS.  Using LWRS_HWHANDSHAKE_CTS_RTS_DTR turns control of the DTR line over to the driver; that's why we get the error.

Here's some other comments from R&D about bias resistors:

- We don't have bias resistors on the Tx pins and so when in 2-wire mode and not transmitting they will float unless a 2-wire cable is attached (since that will connect the Rx pins which are biased to the same lines as Tx)
- For RS-485, Rx biasing causes "Rx+ minus Rx-" to be pulled positive (which is equivalent to the idle state, i.e. no data being communicated).  It's kind of the opposite for RS-232 in that the idle state is with "Rx minus Gnd" being negative.  Also, RS-232 isn't biased.


Please test out this code and let me know if it fixes the error for you.

Thanks for your patience,
Robert Mortensen
Software Engineer
National Instruments
0 Kudos
Message 11 of 11
(847 Views)