def prepare_stream_trigger(self, ch):
     if ch is None:
         self._command("STREAM_TRIGGER_INDEX",
                       0)  # disable triggered stream
     else:
         self._write_dict({
             f"DIO{ch}_EF_ENABLE": 0,
             f"DIO{ch}_EF_INDEX": 3,
             f"DIO{ch}_EF_OPTIONS": 0,
             f"DIO{ch}_EF_VALUE_A": 2,
             f"DIO{ch}_EF_ENABLE": 1,
             "STREAM_TRIGGER_INDEX": 2000 + ch
         })
         ljm.writeLibraryConfigS('LJM_STREAM_RECEIVE_TIMEOUT_MS',
                                 0)  #disable timeout
Beispiel #2
0
 def prepare_stream_trigger(self, trigger):
     if trigger is None:
         self._command("STREAM_TRIGGER_INDEX",
                       0)  # disable triggered stream
         aNames = ['STREAM_TRIGGER_INDEX']
         aValues = [0]
     else:
         channel = 'DIO%i' % trigger
         aNames = [
             "%s_EF_ENABLE" % channel,
             "%s_EF_INDEX" % channel,
             "%s_EF_OPTIONS" % channel,
             "%s_EF_VALUE_A" % channel,
             "%s_EF_ENABLE" % channel, 'STREAM_TRIGGER_INDEX'
         ]
         aValues = [0, 3, 0, 2, 1, 2000 + trigger]
         ljm.writeLibraryConfigS('LJM_STREAM_RECEIVE_TIMEOUT_MS',
                                 0)  #disable timeout
     self._write_array(aNames, aValues)
Beispiel #3
0
def configure_ljm_for_triggered_stream():
    ljm.writeLibraryConfigS(ljm.constants.STREAM_SCANS_RETURN, ljm.constants.STREAM_SCANS_RETURN_ALL_OR_NONE)
    ljm.writeLibraryConfigS(ljm.constants.STREAM_RECEIVE_TIMEOUT_MS, 0)
Beispiel #4
0
import time

from labjack import ljm


try:
    input = raw_input  # Set input to raw_input for Python 2.x
except:
    pass

def myReconnectCallback(handle):
    print("Reconnected handle: %s" % handle)


# Set the timeouts shorter for testing convenience
ljm.writeLibraryConfigS(ljm.constants.OPEN_TCP_DEVICE_TIMEOUT_MS, 500)
ljm.writeLibraryConfigS(ljm.constants.SEND_RECEIVE_TIMEOUT_MS, 500)

# Open first found LabJack
handle = ljm.openS("ANY", "ANY", "ANY")  # Any device, Any connection, Any identifier
#handle = ljm.openS("T7", "ANY", "ANY")  # T7 device, Any connection, Any identifier
#handle = ljm.openS("T4", "ANY", "ANY")  # T4 device, Any connection, Any identifier
#handle = ljm.open(ljm.constants.dtANY, ljm.constants.ctANY, "ANY")  # Any device, Any connection, Any identifier

ljm.registerDeviceReconnectCallback(handle, myReconnectCallback)

print("\nPress Ctrl+C to exit.")
i = 0
while True:
    try:
        try: