TCP Open Testing in Python (App Note)
Prerequisites
LabJack with Ethernet or WiFi (T-series or UE9)
T-series - LJM Library
UE9 - UD Library for Windows, Exodriver library for Mac OS X and Linux
Python
Operating system - Windows, Mac OS X, or Linux
LJM (T-series)
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
