Aharoni-Lab / Miniscope-DAQ-Cypress-firmware

DAQ firmware for V3 and V4 Miniscope platforms
15 stars 8 forks source link

Allow Linux and other OSes to query BNO information #12

Closed ximion closed 1 year ago

ximion commented 1 year ago

Hi!

This patch fixes another case of the DAQ firmware not following the UVC specification, with Windows not caring about that, while Linux aggressively sanitizes values and ensures that hardware is forced to behave according to spec. UVC controls can be auto-updating (AUTO_UPDATE) or not, and unfortunately all but the HUE control which were used to query BNO values were not auto-updating. The AUTO_UPDATE property allows the device to change values, as opposed to the user changing them. So Linux pays attention to that, for caching and various optimizations, and ensures devices don't change their values when they are not supposed to. This would normally be great as it ensures correctly behaving cameras, but of course it's bad for what we are doing here, where we want the device to change these values autonomously.

So this patch changes the firmware to use the PANTILT control to submit BNO quaternions to the client. This has the added benefit that we will only use one, possibly two queries to get all BNO values as opposed to requiring 4 - which is a small timing optimization (I still need to measure it, but tbh, I don't expect it to make a huge difference - it's nice to have though). In addition, we add a way to query the firmware "ABI" version, so clients can detect which properties are, or are not, supported.

The change is implemented in a way that should ensure existing clients continue to work, on any OS. I tested this on Linux, with the Git master version of PoMiDAQ and the original Miniscope-DAQ-QT-Software. I did not yet run any tests on Windows! This change seems to be working very well, and enables Linux users to use the BNO.

The commits also contain a precompiled new image for v3.3 DAQ boards. Please have a look and tell me what you think and if there are any issues. Thanks for considering this change! :-D

daharoni commented 1 year ago

This looks great @ximion. We will test it on Windows soon but I looked through all the changes and doesn't look like it can/should affect everything still being compatible with current/older versions of DAQ software.

ximion commented 1 year ago

Thank you! :-)

doesn't look like it can/should affect everything still being compatible with current/older versions of DAQ software

Yes, I also think it's fairly safe, but I have seen enough weirdness in software engineering (and especially when hardware is directly involved...) that I am happier if someone's tested it :laughing:. And then I wonder how we can alert OEPS / LabMaker & Co to update their firmware copies so new preprogrammed devices ship with this by default ;-)