This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
Is there a way to control the LMX EVMs via a python script instead of going through TICS Pro? I can operate the EVM device via TICS PRO, but cannot find the serial port that the device registers in Device Manager. Is there a way to send SPI commands through the USB2ANY, to get to the LMX board?
Thanks,
Darren
I see this page which seems to suggest there is a path, but that covers a different target device. I am able to find the USB device in the windows "devices and printers" explorer folder, it is identified as an HID device.
Maybe this page will help? Has anyone done this with python in the 3 years since these forum posts?
Darren,
The post by Dean Banerjee shows how to use TICS Pro's ActiveX interface to perform basic TICS Pro automation. However, you specifically requested a way to go around TICS Pro to talk to the USB2ANY directly. There is a way to do this, but I must advise you that it is not officially supported - any issues you encounter will be yours to deal with :)
With python, you can wrap the USB2ANY DLL included in TICS Pro using ctypes module's WinDLL wrapper. From there you can call any of the functions provided by the USB2ANY DLL. I've included a code snippet showing a basic example below. I caution that I have not tested this code, but it's based off an example script in our development repository so I assume anything wrong with it should be very quick to identify.
import ctypes u2adll = ctypes.WinDLL(r"C:\path\to\USB2ANY.dll") # Scan available USB2ANY devices controllers = [] buf = ctypes.c_buffer(80) for i in range(u2adll.u2aFindControllers()): controllers.append(u2adll.u2aGetSerialNumber(i, buf)) # Open a session with whatever the first USB2ANY is if not controllers: raise Exception('no USB2ANY found') handle = u2adll.u2aOpen(controllers[0]) # Configure SPI bus bitRateKbps = 400 divider = int(24000 / bitRateKbps) dividerHigh = (divider >> 8) & 0xFF dividerLow = (divider & 0xFF) errCode = u2adll.u2aSPI_Control(handle, #u2a handle 1, #SPI capture on leading edge 0, #SPI inactive state low 1, #SPI MSB first 0, #SPI 8-bit 1, #SPI with every packet 1, #SPI active low dividerHigh, dividerLow) if errCode < 0: raise Exception('failed to configure SPI bus: ' + str(errCode)) # Write and Read numerator = 0xDEADBEEF packet1 = 0x260000 + ((numerator >> 16) & 0xFFFF) packet2 = 0x270000 + (numerator & 0xFFFF) buf = ctypes.c_buffer(3) #register length is three bytes for LMX2594 buf[0] = (packet1 >> 16) & 0xFF buf[1] = (packet1 >> 8) & 0xFF buf[2] = packet1 & 0xFF errCode = u2adll.u2aSPI_WriteAndRead(handle, 3, buf) if errCode < 0: raise Exception('failed to write first packet') buf[0] = (packet2 >> 16) & 0xFF buf[1] = (packet2 >> 8) & 0xFF buf[2] = packet2 & 0xFF errCode = u2adll.u2aSPI_WriteAndRead(handle, 3, buf) if errCode < 0: raise Exception('failed to write second packet') buf[0] = 0xEF buf[1] = 0x00 buf[2] = 0x00 errCode = u2adll.u2aSPI_WriteAndRead(handle, 3, buf) if errCode < 0: raise Exception('failed to read R111') rb_VCO_CAPCTRL = ord(buf[2]) # R111[7:0] # Close session u2adll.u2aClose(handle)
There is an API document attached below which details the functions that are made available by the USB2ANY DLL - this is where I am getting the function names for the u2adll object in the code snippet. I never found a non-preliminary copy of the API document for firmware revision 2.7.0.0, but it should still be accurate - we use this to target the USB2ANY DLL and firmware revision packaged with TICS Pro.
api_reference_for_usb2any_sdk_2.7.0.pdf
Regards,
Derek Payne
derek,
What a helpful response. I'm working on this today to get it going, but thanks for such a great start! I'll let you know how it goes.
Is there a 64 bit version of the usb2any dll? I'm having trouble importing using windll with my 64 bit python. Thanks
Darren,
There is technically a 64-bit version of the DLL, but it's for a different firmware revision than the one we use on our EVMs. You would have to load new firmware onto the USB2ANY, which requires the USB2ANY firmware loader application (typically we do not provide this outside of TI, but as far as I know there is no strict enforcement on that policy - I would offer to email you the files, but one of our email filters would scrub the attachment). This would also render the USB2ANY incompatible with TICS Pro until the firmware is downgraded. And you'd need a different API document, since there were some changes from revision 2.7.0.0 to the version which supports 64-bit operations.
The easier solution is to use 32-bit python. If this is not possible for some reason e.g. a critical dependency in your other software requirements, I'll try to supply the firmware loader and updated firmware through E2E. That would be a total experiment, as we've never tried using the USB2ANY on 64-bit firmware to communicate with any of our devices - you're on your own if it doesn't work.
Regards,
Derek Payne
Again, I appreciate your very informative response. I'll see if I can switch my python to 32bit. If we close the issue, can I still ping you if it doesn't work? Thanks, Darren
I'll mark the thread as TI Thinks Resolved. You retain the ability to re-open the thread for up to 30 days by replying, and you also have the ability to open a thread that references this thread. If you have more questions, feel free to ask; they will get routed back to me since this is subject matter that I cover.
Regards,
Derek Payne