Using python to access T7-Pro over ethernet and reading AIN | LabJack
 

Using python to access T7-Pro over ethernet and reading AIN

4 posts / 0 new
Last post
miriya52
miriya52's picture
Using python to access T7-Pro over ethernet and reading AIN

Hello,

I am trying to use python to read input or control output on a T7-Pro.  I would like to access the T7-Pro over ethernet.

I tried the "list_all" but the no labjacks show up when my T7-Pro is only connected over ethernet.  Currently, the T7-Pro is configured for DHCP, and I can ping the IP address (when I read the network configuration while connected over USB).  However, when I tried reading AIN over TCP modbus with pymodbus, it doesn't detect the T7-Pro.

The next step is to configure the Labjack for static IP.  Is there a python API for accessing the T7-Pro over ethernet, or is TCP modbus via pymodbus the only way?

Thanks,

Anna

LabJack Support
labjack support's picture
Start with the Ethernet

Start with the Ethernet Troubleshooting section towards the end of this page:

https://labjack.com/support/app-notes/basic-networking-troubleshooting

There are 8 steps there and usually 1 of them will point you towards your problem or help us solve your problem.

miriya52
miriya52's picture
Thanks, it seems that

Thanks, it seems that configuring the T7-Pro for static IP on our office network has made it possible to access via python TCP modbus from both Mac OS and BeagleBone Black Debian Linux.

Just a note that I think there is a bug in the "t7_test.py" example in this link: https://labjack.com/support/software/examples/modbus/python

$ python t7_test.py 

Traceback (most recent call last):

  File "t7_test.py", line 25, in <module>

    rq = client.write_registers(55110,uint16_to_data(1234))

  File "/usr/local/lib/python2.7/dist-packages/pymodbus/client/common.py", line 97, in write_registers

    request = WriteMultipleRegistersRequest(address, values, **kwargs)

  File "/usr/local/lib/python2.7/dist-packages/pymodbus/register_write_message.py", line 138, in __init__

    self.count = len(self.values)

TypeError: object of type 'int' has no len()

When I comment out "rq = client.write_registers(55110,uint16_to_data(1234))", the script runs fine.

LabJack Support
labjack support's picture
Thanks for bringing that

Thanks for bringing that error to our attention. The example has been fixed, and now uses write_register instead of write_registers for that particular call since uint16_to_data returns a 1 register data value.