def setLJName(self, name):
     self.errorCheck()
     
     name = str(name)
     if len(name) > 49 or "." in name:
         raise TypeError("Expected a string instead of " + 
                         str(type(name)) + 
                         " with less than 49 characters and no periods.")
     
     ljm.eWriteNameString(self.handle, "DEVICE_NAME_DEFAULT",
                              name)
Пример #2
0
    def WriteRegister(self, name, value):
        with self.lock:
            if name not in self.driver.registers:
                raise LabJackException("%s not a register",
                                       LJD_NOT_A_VALID_REGISTER)

            type_info = self.driver._typeraw(name)
            print("Read: type_info for %s is %s" % (name, type_info))

            if 'W' not in self.driver.registers[name]['readwrite']:
                raise LabJackException("Cannot read %s" % name,
                                       LJD_REGISTER_NOT_WRITABLE)

            if type_info in ["INT16", "INT32", "UINT16", "UINT32"]:
                ljm.eWriteName(self.handle, name, int(value))

            elif type_info in ["STRING"]:
                value = ljm.eWriteNameString(self.handle, name, str(value))

            elif type_info in ["FLOAT32", "FLOAT64"]:
                value = ljm.eWriteName(self.handle, float(name))

            else:
                raise LabJackException(
                    "%s type unknown for %s" % (type_info, name),
                    LJD_UNKNOWN_TYPE)
Пример #3
0
numFrames = 3
names = ["WIFI_IP_DEFAULT", "WIFI_SUBNET_DEFAULT",
         "WIFI_GATEWAY_DEFAULT"]
aValues = [ljm.ipToNumber("192.168.1.207"), ljm.ipToNumber("255.255.255.0"),
           ljm.ipToNumber("192.168.1.1")]
ljm.eWriteNames(handle, numFrames, names, aValues)

print("\nSet WiFi configuration:")
for i in range(numFrames):
    print("    %s : %.0f - %s" %
          (names[i], aValues[i], ljm.numberToIP(aValues[i])))

# Setup and call eWriteString to configure the default WiFi SSID on the LabJack.
name = "WIFI_SSID_DEFAULT"
string = "LJOpen"
ljm.eWriteNameString(handle, name, string)
print("    %s : %s" % (name, string))

# Setup and call eWriteString to configure the default WiFi password on the
# LabJack.
name = "WIFI_PASSWORD_DEFAULT"
string = "none"
ljm.eWriteNameString(handle, name, string)
print("    %s : %s" % (name, string))

# Setup and call eWriteName to apply the new WiFi configuration on the LabJack.
name = "WIFI_APPLY_SETTINGS"
value = 1
ljm.eWriteName(handle, name, value)
print("    %s : %.0f" % (name, value))
"""
Demonstrates how to set the device name string on a LabJack.

"""

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]))

# Call eWriteNameString to set the name string on the LabJack.
string = "LJTest"
ljm.eWriteNameString(handle, "DEVICE_NAME_DEFAULT", string)

print("\nSet device name : %s" % string)

# Close handle
ljm.close(handle)
Пример #5
0
numFrames = 3
names = ["WIFI_IP_DEFAULT", "WIFI_SUBNET_DEFAULT",
         "WIFI_GATEWAY_DEFAULT"]
aValues = [ljm.ipToNumber("192.168.1.207"), ljm.ipToNumber("255.255.255.0"),
           ljm.ipToNumber("192.168.1.1")]
ljm.eWriteNames(handle, numFrames, names, aValues)

print("\nSet WiFi configuration:")
for i in range(numFrames):
    print("    %s : %.0f - %s" % \
        (names[i], aValues[i], ljm.numberToIP(aValues[i])))

# Setup and call eWriteString to configure the default WiFi SSID on the LabJack.
name = "WIFI_SSID_DEFAULT"
string = "LJOpen"
ljm.eWriteNameString(handle, name, string)
print("    %s : %s" % (name, string))

# Setup and call eWriteString to configure the default WiFi password on the
# LabJack.
name = "WIFI_PASSWORD_DEFAULT"
string = "none"
ljm.eWriteNameString(handle, name, string)
print("    %s : %s" % (name, string))

# Setup and call eWriteName to apply the new WiFi configuration on the LabJack.
name = "WIFI_APPLY_SETTINGS"
value = 1
ljm.eWriteName(handle, name, value)
print("    %s : %.0f" % (name, value))
Пример #6
0
"""
Demonstrates how to set the device name string on a LabJack.

"""

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]))

# Call eWriteNameString to set the name string on the LabJack.
string = "LJTest"
ljm.eWriteNameString(handle, "DEVICE_NAME_DEFAULT", string)

print("\nSet device name : %s" % string)

# Close handle
ljm.close(handle)