I have been working on some pure Python wrappers for the Maestro and Jrk controllers, initially writing the serial commands over pyserial and then using WinUSB to communicate directly to the USB endpoint. After doing this, I have a questions/comment:
- After writing the USB wrappers, I realized that the controlTransfers do not support the communication with chained devices, like the Pololu protocol over the serial command port works. Is this correct?
If the above is correct, I would request that the ability to target chained devices be added to the controlTransfer mechanism.
If this is not possible, have you tested the case where a program is controlling a device from both the pure USB level and the Command channel? That is, our program would use the USB interface to send new scripts, and use the serial commands to send servo and script commands. Any issues with this?
Correct - sending bytes to the serial port via the custom USB interface is not something we had anticipated, since we expect that most people can just use multiple USB ports or a USB hub. However, that is something we will definitely keep in mind for a future firmware release. Would you be interested in getting this feature in a pre-release version of the firmware, even if it will not immediately be on the controllers we are shipping?
Another option would be for you to rewrite our .inf file and reinstall your device so that WinUSB has control over the TTL port endpoints. We can discuss this more if you want to do it that way, but it could be a pain to deal with multiple incompatible .inf files.
In general, there should be no problems with the pure USB and virtual COM ports operating at the same time. You might want to have special code to monitor the device through WinUSB and close the COM port if it gets disconnected, so that if the device is unplugged and plugged back in you do not lose access to the COM port.
It would be interesting to see an updated USB protocol which could support the daisy-chaining of controllers. I would expect (and hope, since I already have code) you could simply use the Pololu serial protocol over the USB channel.
I am not a fan or re-writing INF files. Hard enough to just get one working properly across Windows platforms. Also, the idea of using WinUSB to handle the serial part of the device may not work out. I looked at doing this a while back on a previous project, and WinUSB at that time could not do that.
I like the idea of watching the main USB port to know when the virutal COM ports go away. Especially since that is one of the cases we are trying to handle gracefully.
I’m not sure how much of this is possible in Python, but I think the best way to monitor for removal of any USB device (including a COM port or a native USB interface) in Windows would be to call RegisterDeviceNotification to register your application to receive WM_DEVICECHANGE messages from the OS. Then whenever you get one of those messages, use SetupAPI to check that the your device is still present.
Also, if your COM ports get in a bad state, you might still be able to use them if you specify “\.\USBSER000” or “\.\USBSER001” as the COM port name instead of, for example, “COM3”. There should be some way to figure out the correspondence between those USBSER objects and Maestros, but I don’t know how.