LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

RS232 : Port error (No port found) on windows 64bits (but OK on Windows 32 bits)

Hello,

I use a com port for communication in RS232 (USB/RS adaptor). It works well on a PC with Windows 7, 32Bits.

But if I use it on a Windows 64Bits (Windows 7 or 10), I got error : "No port found".

The program finds the port to make port list (open and close), but when I want to use it (OpenComConfig + InstallComCallback), the error occurs.

Someone have an idea ?

0 Kudos
Message 1 of 11
(5,054 Views)

The first question that comes to my mind is does the USB/RS232 converter have a driver for Win64?

Additionally, I do not understand if and how you detect the port is present in your program.

 

If you can detail a little bit more the last item and double check the correct driver is installed we can go on discussing the situation.



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 11
(5,054 Views)

The driver is installed (configuration panel indicated that this peripheral is OK) and I can see that communication works well with TeraTerm (I close it before executing my software).

 

The detection of port is done by trying to open all port from 1 to 256 and regarding the status returned by function :

 for(unsigned long ComPort = 1; ComPort <= MAXNUMCOMPORT;ComPort++)
 {
  long ComStatus = OpenComConfig (ComPort, "", BAUDRATE, PARITY, DATABITS, STOPBITS, INQUEUESIZE, OUTQUEUESIZE);
  if ((ComStatus == 0) || (ComStatus == kRS_CanNotOpenPort))//Com port free or open but exists
      PortList[(*NbPorts)++] = ComPort;//Add com port number to list and increase the number of ports
  CloseCom(ComPort);
 }

Once I got the list, I choose the correct port and I open and configure it. I think that I can open it because it's done in previous step, and that problem come from SetCTSMode or InstallComCallback functions :

long ComPort_Initialize(const long ComPortNum)
{
 long error = NoComError;
 long detailerror = NoComError;
 CurrentComPort = ComPortNum;
 ComPortOpen = false;
 
 ErrOpenComPort(OpenComConfig (ComPortNum, "", BAUDRATE, PARITY, DATABITS, STOPBITS, INQUEUESIZE, OUTQUEUESIZE))
 //Turn off Hardware handshaking (loopback test will not function with it on)
 SetCTSMode (ComPortNum, LWRS_HWHANDSHAKE_OFF);
 //Empty serial buffers
 FlushInQ (ComPortNum);
 FlushOutQ (ComPortNum);
 SetComTime(ComPortNum, 0.1);
 //Install the callback
 ErrOpenComPort(InstallComCallback(ComPortNum, LWRS_RXFLAG, NOTIFYCOUNT, LF, ReceiveComPortCB , 0));

0 Kudos
Message 3 of 11
(4,982 Views)

Driver seems correctly installed, it is what is said in configuration panel of COM port and I am able to see the communication working with TeraTerm (i close TeraTerm before using my software).

 

To list the port, I try to open every port from 1 to 256 and use the status returned by the function :

for(unsigned long ComPort = 1; ComPort <= MAXNUMCOMPORT;ComPort++)
 {
  long ComStatus = OpenComConfig (ComPort, "", BAUDRATE, PARITY, DATABITS, STOPBITS, INQUEUESIZE, OUTQUEUESIZE);
  if ((ComStatus == 0) || (ComStatus == kRS_CanNotOpenPort))//Com port free or open but exists
      PortList[(*NbPorts)++] = ComPort;//Add com port number to list and increase the number of ports
  CloseCom(ComPort);
 }

 

So I choose the correct port in the list and I Re-open it and try to configure it (I think that error occurs here) :

 ErrOpenComPort(OpenComConfig (ComPortNum, "", BAUDRATE, PARITY, DATABITS, STOPBITS, INQUEUESIZE, OUTQUEUESIZE))
 //Turn off Hardware handshaking (loopback test will not function with it on)
 SetCTSMode (ComPortNum, LWRS_HWHANDSHAKE_OFF);
 //Empty serial buffers
 FlushInQ (ComPortNum);
 FlushOutQ (ComPortNum);
 SetComTime(ComPortNum, 0.1);
 //Install the callback
 ErrOpenComPort(InstallComCallback(ComPortNum, LWRS_RXFLAG, NOTIFYCOUNT, LF, ReceiveComPortCB , 0));

 

0 Kudos
Message 4 of 11
(4,982 Views)

Driver seems correctly installed, it is what is said in configuration panel of COM port and I am able to see the communication working with TeraTerm (i close TeraTerm before using my software).

 

To list the port, I try to open every port from 1 to 256 and use the status returned by the function :

for(unsigned long ComPort = 1; ComPort <= MAXNUMCOMPORT;ComPort++)
 {
  long ComStatus = OpenComConfig (ComPort, "", BAUDRATE, PARITY, DATABITS, STOPBITS, INQUEUESIZE, OUTQUEUESIZE);
  if ((ComStatus == 0) || (ComStatus == kRS_CanNotOpenPort))//Com port free or open but exists
      PortList[(*NbPorts)++] = ComPort;//Add com port number to list and increase the number of ports
  CloseCom(ComPort);
 }


So I choose the correct port in the list and I Re-open it and try to configure it (I think that error occurs here) :

 ErrOpenComPort(OpenComConfig (ComPortNum, "", BAUDRATE, PARITY, DATABITS, STOPBITS, INQUEUESIZE, OUTQUEUESIZE))
 //Turn off Hardware handshaking (loopback test will not function with it on)
 SetCTSMode (ComPortNum, LWRS_HWHANDSHAKE_OFF);
 //Empty serial buffers
 FlushInQ (ComPortNum);
 FlushOutQ (ComPortNum);
 SetComTime(ComPortNum, 0.1);
 //Install the callback
 ErrOpenComPort(InstallComCallback(ComPortNum, LWRS_RXFLAG, NOTIFYCOUNT, LF, ReceiveComPortCB , 0));

 

0 Kudos
Message 5 of 11
(4,983 Views)

Driver seems correctly installed, it is what is said in configuration panel of COM port and I am able to see the communication working with TeraTerm (i close TeraTerm before using my software).

 

To list the port, I try to open every port from 1 to 256 and use the status returned by the function :

for(unsigned long ComPort = 1; ComPort <= MAXNUMCOMPORT;ComPort++)
 {
  long ComStatus = OpenComConfig (ComPort, "", BAUDRATE, PARITY, DATABITS, STOPBITS, INQUEUESIZE, OUTQUEUESIZE);
  if ((ComStatus == 0) || (ComStatus == kRS_CanNotOpenPort))//Com port free or open but exists
      PortList[(*NbPorts)++] = ComPort;//Add com port number to list and increase the number of ports
  CloseCom(ComPort);
 }


So I choose the correct port in the list and I Re-open it and try to configure it (I think that error occurs here) :

 ErrOpenComPort(OpenComConfig (ComPortNum, "", BAUDRATE, PARITY, DATABITS, STOPBITS, INQUEUESIZE, OUTQUEUESIZE))
 //Turn off Hardware handshaking (loopback test will not function with it on)
 SetCTSMode (ComPortNum, LWRS_HWHANDSHAKE_OFF);
 //Empty serial buffers
 FlushInQ (ComPortNum);
 FlushOutQ (ComPortNum);
 SetComTime(ComPortNum, 0.1);
 //Install the callback
 ErrOpenComPort(InstallComCallback(ComPortNum, LWRS_RXFLAG, NOTIFYCOUNT, LF, ReceiveComPortCB , 0));

 

0 Kudos
Message 6 of 11
(4,983 Views)

Driver seems correctly installed, it is what is said in configuration panel of COM port and I am able to see the communication working with TeraTerm (i close TeraTerm before using my software).

To list the port, I try to open every port from 1 to 256 and use the status returned by the function :

for(unsigned long ComPort = 1; ComPort <= MAXNUMCOMPORT;ComPort++)
 {
  long ComStatus = OpenComConfig (ComPort, "", BAUDRATE, PARITY, DATABITS, STOPBITS, INQUEUESIZE, OUTQUEUESIZE);
  if ((ComStatus == 0) || (ComStatus == kRS_CanNotOpenPort))//Com port free or open but exists
      PortList[(*NbPorts)++] = ComPort;//Add com port number to list and increase the number of ports
  CloseCom(ComPort);
 }

So I choose the correct port in the list and I Re-open it and try to configure it (I think that error occurs here) :

 ErrOpenComPort(OpenComConfig (ComPortNum, "", BAUDRATE, PARITY, DATABITS, STOPBITS, INQUEUESIZE, OUTQUEUESIZE))
 //Turn off Hardware handshaking (loopback test will not function with it on)
 SetCTSMode (ComPortNum, LWRS_HWHANDSHAKE_OFF);
 //Empty serial buffers
 FlushInQ (ComPortNum);
 FlushOutQ (ComPortNum);
 SetComTime(ComPortNum, 0.1);
 //Install the callback
 ErrOpenComPort(InstallComCallback(ComPortNum, LWRS_RXFLAG, NOTIFYCOUNT, LF, ReceiveComPortCB , 0));

0 Kudos
Message 7 of 11
(5,002 Views)

And where are you getting errors? Put a breakpoint in the code and run it step-by-step checking which function results in error.

 

Going a little bit further, are you sure you are not opening a port that was listed despite the result of the first Open was Cannot Open port? What is the goal of listing ports that the program cannot open anyway?

 

As a side note, turning handhaking off is useless since OpenComConfig, as you can read in the command help, already does this by itself.



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 8 of 11
(4,997 Views)

I am not able to put a breakpoint since the software works on the PC with Labwindows, I only have problem on other PC (which have not labwindows, I use a distribution).

I also think that the port cannot be open during list detection , but user do not see the problem since code treat it as OK even if port is already open.

For me, the code is correct since it works on the labwindows PC, and on another 32bits PC. But I am not able have the same behavior on 64bits PCs.

For info, I use Labwindows version 2013 SP2 + distribution for 64bits

0 Kudos
Message 9 of 11
(4,984 Views)

Even without breakpoints, in case of errors you can still format a message that lists both the error code and the code line where it arises: a MessagePopup will be enough to detect where the error is.

The code must not proceed in case of errors, and should not mark a port as active if it is not possible to open it.



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 10 of 11
(4,968 Views)