« Close

Datasheets and User Guides

App Notes

Software & Driver

 

TCP Open Testing in Python (App Note)

Prerequisites

 

LJM (T7, T4)

Install Python and the Python_LJM module as described on our Python for LJM page.

Go to a console window and run Python.

 

A.  Native TCP Open

>>> import socket
>>> sock = socket.socket()
>>> sock.connect(("192.168.1.207", 502))
>>> sock.close()

This shows success.  If there was a problem Python would have displayed an error message.

 

B.  LJM Search Open

>>> from labjack import ljm
>>> handle = ljm.openS("any", "any", "any")
>>> info = ljm.getHandleInfo(handle)
>>> info
(7, 3, 470013239, -1062731281, 502, 1040)
>>> ljm.close(handle)

 

C.  LJM Specific Open

>>> handle = ljm.openS("t7", "ethernet", "192.168.1.239")
>>> info = ljm.getHandleInfo(handle)
>>> info
(7, 3, 470013239, -1062731281, 502, 1040)
>>> ljm.close(handle)

 

 

UD (UE9)

Install Python and the LabJackPython module as described on our LabJackPython page.

Go to a console window and run Python.

 

A.  Native TCP Open

>>> import socket
>>> sock = socket.socket()
>>> sock.connect(("192.168.1.209", 52360))
>>> sock.close()

This shows success.  If there was a problem Python would have displayed an error message.

 

B-1.  UD Specific Open on Windows

>>> import ue9
>>> dev = ue9.UE9(ethernet=True, firstFound=False, ipAddress="192.168.1.209")
>>> dev.close()  # Close this UE9's handle

 

B-2.  Exodriver Specific Open on Mac OS X and Linux

>>> import ue9, LabJackPython
>>> dev = ue9.UE9(ethernet=True, firstFound=False, ipAddress="192.168.1.209")
>>> LabJackPython.Close()  # Close all handles in the process

 

UE9 TCP Tests in Python