PT-104 Python

Post any questions you may have about our current range of USB data loggers
Post Reply
Posts: 1
Joined: Fri Jun 02, 2017 7:27 am

PT-104 Python

Post by laser-axel » Thu Apr 05, 2018 4:19 pm


I am trying to use a PT-104 from python 2.7. The PT-104 is connected via USB a operable
I could not find any good description of what to do to communitate with a PT-104, so I looked into ... pt104con.c
Conclusion: Set things up to use the enumerate function supplied by the usbpt104.dll and see what happens.

I also found the forum thread topic27941.html?hilit=python.

I tried to get the example in abovementioned thread running.
First I got an error from the section:
class CommunicationType(CtypesEnum):
CT_USB = 0x00000001
CT_ETHERNET = 0x00000002

OverflowError: Python int too large to convert to C long

This is consistent with the usbPT104Api.h, but IIRC enums in C are mapped to int and not unsigned int ??
So I changed the 0xffffffff to 0x7fffffff.
The skript is running without errors but enum_string remains empty

Also changed the communication type resulting in
mydll.UsbPt104Enumerate (enum_string, ctypes.byref(enum_len),CommunicationType.CT_USB)

In the interactive console I get
IN[xx]: mydll.UsbPt104Enumerate (enum_string, ctypes.byref(enum_len),CommunicationType.CT_ALL)
Out[xx]: 315

So I think, I am close to get this up, but I messed up with setting the f*'#*ng datatypes in python. Maybe there is someone out there, to set me on track again.

Thanks in advance.

p.s. simply using C instead of python is not an option :-(

changed the call to the enumerate function to
status = mydll.UsbPt104Enumerate (enum_string, ctypes.byref(enum_len),CommunicationType.CT_ALL)
print('Found PicoTech at... %s' % enum_string.value)
print('status returned ' + format(status,'X'))

Which gets me the output
Found PicoTech at...
status returned 13B

In the PicoStatus.h I found:
// The serial buffer is too small for the required information.

Posts: 1
Joined: Fri Jun 02, 2017 7:27 am

Re: PT-104 Python

Post by laser-axel » Fri Apr 06, 2018 12:39 pm

A night of sleep and a few cups of coffe did it.

Will add the lines to get a temperature reading in the thread topic27941.html

Site Admin
Site Admin
Posts: 3803
Joined: Fri Jun 10, 2011 8:15 am
Location: St. Neots

Re: PT-104 Python

Post by Martyn » Fri Apr 06, 2018 1:38 pm

Good to hear :)

The power of coffee :D
Technical Support Manager

Post Reply