LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Using a serial port opened by a DLL?

We are using TestStand 3.5/Labview 8.0 to control some test simulation hardware, and that hardware is controlled through a serial port.  Unfortunately the code we have to use that opens the COM port is not something I can modify (it's created by another internal group.)  I'm trying to create a vi that will let me write to the hardware through the COM port that the DLL opens and uses.  Is there some way to get the VISA resource name to reference the port opened by the DLL?  The code from the DLL that opens the port is below (it is in VB.)  I have a VI that will work if I set the COM port in the vi, but can't get it to work from within TestStand to use the same COM port.  Any ideas?  Thanks!
-Bill
 
Public Sub InitializeCommPort(CommPortNumber As Integer)
Set SerialComm = CreateObject("MSCOMMLIB.MSCOMM")
If SerialComm.PortOpen = True Then
  SerialComm.PortOpen = False
End If
SerialComm.CommPort = CommPortNumber
SerialComm.Settings = "19200,n,8,1"
SerialComm.InputLen = 1
SerialComm.RThreshold = 1
SerialComm.PortOpen = True

End Sub
 
0 Kudos
Message 1 of 6
(3,390 Views)
If the com port is opened by a different process (in this case mscomm) then the OS will not allow you to connect with a different process (i.e. VISA). If the dll does nothing but open the com port, then I would just not call the dll in TestStand. If however, the dll is performing I/O as well and you don't want to rewrite everything, then your only option would be to use the same object created by the dll in a LabVIEW step.
0 Kudos
Message 2 of 6
(3,380 Views)

Unfortunately modifying the DLL isn't an option for us, and we use it for I/O operations thorugh the serial port.

 

I was trying to figure out how to use the object created by the DLL, but am not sure how to do it.  From what you said I can't use the VISA call to send commands via the serial port?  How would I send a serial command from labview/teststand without using VISA?

0 Kudos
Message 3 of 6
(3,373 Views)

How are you using the dll in TestStand? Are you using the dll, ActiveX, .NET adapter? Are you able to save a reference to the object to a TestStand variable? Or is not being used at all by TestStand right now?

You've only posted a small fraction of the dll and no real details on how it's being used now and the type of VB code it is. For example, if it's an ActiveX object, and if you can save a reference to it, you would pass the reference to a LabVIEW VI and then use the ActiveX Invoke Node or Property Node functions in the LabVIEW program. If it's an c type dll, then you would use the Call Library Function Node in the LabVIEW program.

0 Kudos
Message 4 of 6
(3,369 Views)

We are using an ActiveX/Com adapter.  I've attached a few files that might clarify things:

KeyOff.seq - small sample TestStand sequence that uses the DLL.  The first step reads an initialization file that sets up the I/O mapping for our test hardware, which can be seen in the attached ConfigureHardware.txt file.  The code for the Initialize COM port step is in InitializeCommPort.txt.

We are not able to change the DLL code ourselves although we can request changes to it...

Download All
0 Kudos
Message 5 of 6
(3,297 Views)
I forgot - the InitializeComPort code is in my 1/2/07 post...
0 Kudos
Message 6 of 6
(3,293 Views)