From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

USB/Virtual COM port Communication Problem with ESP301/LabWindows/CVI

Solved!
Go to solution

Hi All,

I went through different threads posted in this forum for the similar issues and tried all, but didn't helped.

 

I'm trying to communicate to ESP 301 Stage Controller through a USB port configured as a serial COM port which uses a CR. The 'VE' command is to get the version of the controller . The write command "ComWrt" works fine but the read command throws and error("-99   I/O operation timed out"). I tried all the suggessions; introducing delays etc.. which explained (solved by Mr RobertoBozzolo )in thread posted here which explains an issue similar to that of mine, but the couln't help.

 

 The code is attached!

 

I'm Using LabWindows 2012/Windows7 64bit multicore

 

int Get_Version () {

 

comport =3;

baudrate = 9600;

parity = 0;

databits = 8;

stopbits = 1;

inputq = 512;

outputq = 512;

ctsmode = 1;

xmode   = -1;

timeout = 5.0;

com_status = 1;

char comstring[6];

devicename[] = "COM3";

int status = 0;

char *error;

int bytes_written = 0;

 char Cmnd_String[50] = "";

char Read_String[512] = "";

 

    strcat(Cmnd_String,"VE?")

    strcat (Cmnd_String, "\r");  // Tried 0x0d 
    strcat (Cmnd_String, "\0");

    length = strlen( Cmnd_String);

    assert(Cmnd_String[length] == 'VE?\r\0'); // Tried Cmnd_String[50] = "VE?\r\0"

 

   DisableBreakOnLibraryErrors ();  

   RS232Error = OpenComConfig (comport, devicename, baudrate, parity, databits, stopbits, inputq, outputq);// tried ouputq = -1 too 

         EnableBreakOnLibraryErrors ();       

          if (RS232Error == 0)        {         

             com_status= SetCTSMode (comport, LWRS_HWHANDSHAKE_CTS_RTS_DTR);       

             MessagePopup ("Comport verified", "CTS Mode is working fine");            

             com_status = SetComTime (comport, timeout);

 

           }

 

       bytes_written = ComWrt (3,  Cmnd_String, StringLength(Cmnd_String));

       if (GetOutQLen(3) != strlen( Cmnd_String))
           ComWrt (3, Cmnd_String, strlen( Cmnd_String)); 
  
        status = ReturnRS232Err ();      // Status is 0
        error = GetRS232ErrorString (status);// No Error

         Delay(5.0);// Tried to add delay up to 20.0

 

         //GetInQLen (3); //  returns 0

        ComRdTerm ( 3, Read_String, 512, 13); // Read from inputQ

        status = ReturnRS232Err ();               // Status return error code "-99"
        error = GetRS232ErrorString (status); // Error Message "I/O Operation timed out"
 

 

        return status;

 

 }

 

Can anybody suggest where am i doing wrong?

Thanking you in advance.

 

0 Kudos
Message 1 of 5
(5,863 Views)

Heve you tried with a different handshake settings?

If the device you are working with is a Newport unit whose user guide is this one, it speaks about CTS and RTS signals only: with your settings you are using DTR signal also, which may not working the way the device expects. You could test bytes_written for negative error codes on write (if handshaking is wrongly configured you can expect a timeout on write).

 

Additionally, it's not clear to me the way you are using GetOutQLen on write: the output queue should always be 0, meaning no values are ready to be written to the port or to the buffer (i.e. the message is output completely): if you want to be sure the message is sent you can simply wait until GetOutQLen returns 0.

 



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
0 Kudos
Message 2 of 5
(5,851 Views)
Solution
Accepted by topic author Dosth

Another thing you should check is the baud rate.  The ESP301 over the USB expects the baud rate to be 921600.  The function panel for OpenComConfig() implies that it doesn't support that baud rate setting, but it seems to work just fine.

Message 3 of 5
(5,840 Views)

Hello Roberto,

Sorry for being late to reply since i was off!

Changing the baud rate iself solved the problem. Selected the baudspeed what " MS device Manager " Projected and got carried away by that.

 

Regarding the handshaking the helpfile says that both LWRS_HWHANDSHAKE_CTS_RTS_DTR & LWRS_HWHANDSHAKE_CTS_RTS both uses DTR line. I tried both before posting.

The GetOutQLen was  an attempt to capture some input. Forgot to delete before posting.

 

Thanks for your time!!

 

 

 

0 Kudos
Message 4 of 5
(5,814 Views)
Thank you tstanley!
0 Kudos
Message 5 of 5
(5,812 Views)