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 https://github.com/picotech/picosdk-c-e ... pt104con.c
Conclusion: Set things up to use the enumerate function supplied by the usbpt104.dll and see what happens.
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
CT_ALL = 0xFFFFFFFF
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.
Axel
p.s. simply using C instead of python is not an option
EDIT:
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.
#define PICO_SERIAL_BUFFER_TOO_SMALL 0x0000013BUL