def eAddressesIteration(handle, numFrames, aAddresses, aTypes, aWrites, aNumValues, aValues, results): """Function for timit.Timer. Performs an eAddresses call to do LabJack operations. Takes eAddresses parameters and a list for results which will be filled. """ del results[:] r = ljm.eAddresses(handle, numFrames, aAddresses, aTypes, aWrites, aNumValues, aValues) results.extend(r)
Demonstrates how to read the WiFi MAC from a LabJack. """ from labjack import ljm import struct # Open first found LabJack handle = ljm.open(ljm.constants.dtANY, ljm.constants.ctANY, "ANY") #handle = ljm.openS("ANY", "ANY", "ANY") info = ljm.getHandleInfo(handle) print("Opened a LabJack with Device type: %i, Connection type: %i,\n" \ "Serial number: %i, IP address: %s, Port: %i,\nMax bytes per MB: %i" % \ (info[0], info[1], info[2], ljm.numberToIP(info[3]), info[4], info[5])) # Call eAddresses to read the WiFi MAC from the LabJack. Note that we are # reading a byte array which is the big endian binary representation of the # 64-bit MAC. macBytes = ljm.eAddresses(handle, 1, [60024], [ljm.constants.BYTE], [ljm.constants.READ], [8], [0]*8) # Convert returned values to integers macBytes = [int(b) for b in macBytes] # Convert big endian byte array to a 64-bit unsigned integer value mac, = struct.unpack(">Q", struct.pack("B"*8, *macBytes)) print("\nWiFi MAC : %i - %s" % (mac, ljm.numberToMAC(mac))) # Close handle ljm.close(handle)
UINT16 = ljm.constants.UINT16 UINT32 = ljm.constants.UINT32 # Setup and call eAddresses to write/read values to/from the LabJack. # Write 2.5V to DAC0, # write 12345 to TEST_UINT16, # read TEST_UINT16, # read serial number, # read product ID, # and read firmware version. numFrames = 6 # [DAC0, TEST_UINT16, TEST_UINT16, SERIAL_NUMBER, PRODUCT_ID, FIRMWARE_VERSION] aAddresses = [1000, 55110, 55110, 60028, 60000, 60004] aDataTypes = [FLOAT32, UINT16, UINT16, UINT32, FLOAT32, FLOAT32] aWrites = [WRITE, WRITE, READ, READ, READ, READ] aNumValues = [1, 1, 1, 1, 1, 1] aValues = [2.5, 12345, 0, 0, 0, 0] results = ljm.eAddresses(handle, numFrames, aAddresses, aDataTypes, aWrites, aNumValues, aValues) print("\neAddresses results: ") start = 0 for i in range(numFrames): end = start + aNumValues[i] print(" Address - %5i, data type - %i, write - %i, values: %s" % (aAddresses[i], aDataTypes[i], aWrites[i], str(results[start:end]))) start = end # Close handle ljm.close(handle)
from labjack import ljm # Open first found LabJack handle = ljm.open(ljm.constants.dtANY, ljm.constants.ctANY, "ANY") #handle = ljm.openS("ANY", "ANY", "ANY") info = ljm.getHandleInfo(handle) print("Opened a LabJack with Device type: %i, Connection type: %i,\n" \ "Serial number: %i, IP address: %s, Port: %i,\nMax bytes per MB: %i" % \ (info[0], info[1], info[2], ljm.numberToIP(info[3]), info[4], info[5])) # Setup and call eAddresses to write/read values to/from the LabJack. numFrames = 3 aAddresses = [1000, 55110, 55110] # [DAC0, TEST_UINT16, TEST_UINT16] aDataTypes = [ljm.constants.FLOAT32, ljm.constants.UINT16, ljm.constants.UINT16] aWrites = [ljm.constants.WRITE, ljm.constants.WRITE, ljm.constants.READ] aNumValues = [1, 1, 1] aValues = [2.5, 12345, 0] # [write 2.5 V, write 12345, read] results = ljm.eAddresses(handle, numFrames, aAddresses, aDataTypes, aWrites, aNumValues, aValues) print("\neAddresses results: ") start = 0 for i in range(numFrames): end = start + aNumValues[i] print(" Address - %i, data type - %i, write - %i, values: %s" % \ (aAddresses[i], aDataTypes[i], aWrites[i], str(results[start:end]))) start = end # Close handle ljm.close(handle)
Demonstrates how to read the ethernet MAC from a LabJack. """ from labjack import ljm import struct # Open first found LabJack handle = ljm.open(ljm.constants.dtANY, ljm.constants.ctANY, "ANY") #handle = ljm.openS("ANY", "ANY", "ANY") info = ljm.getHandleInfo(handle) print("Opened a LabJack with Device type: %i, Connection type: %i,\n" \ "Serial number: %i, IP address: %s, Port: %i,\nMax bytes per MB: %i" % \ (info[0], info[1], info[2], ljm.numberToIP(info[3]), info[4], info[5])) # Call eAddresses to read the ethernet MAC from the LabJack. Note that we are # reading a byte array which is the big endian binary representation of the # 64-bit MAC. macBytes = ljm.eAddresses(handle, 1, [60020], [ljm.constants.BYTE], [ljm.constants.READ], [8], [0]*8) # Convert returned values to integers macBytes = [int(b) for b in macBytes] # Convert big endian byte array to a 64-bit unsigned integer value mac, = struct.unpack(">Q", struct.pack("B"*8, *macBytes)) print("\nEthernet MAC : %i - %s" % (mac, ljm.numberToMAC(mac))) # Close handle ljm.close(handle)