seeing-things / zwo

ZWO SDK and custom software for debugging and using it.
23 stars 4 forks source link

Implement working SWIG bindings for ASIGetSerialNumber, ASIGetID, ASISetID #44

Open jgottula opened 4 years ago

jgottula commented 4 years ago

We very likely need these bindings for camera selection logic. The current auto-generated ones don't work and just segfault Python.

Based on initial investigations, it will probably take hundreds of man-hours to figure out how the hell to pass eight bytes between Python and a C function.

jgottula commented 4 years ago

Like I could literally do this much faster in raw x86-64 assembly code.

ASIGetID/ASIGetSerialNumber Put camera ID in rdi. Put pointer to 8-byte destination buffer in rsi. Call the function. Error code is now in rax. Destination buffer now contains ID or SN bytes if the call was successful. Done.

ASISetID Put camera ID in rdi. Put pointer to 8-byte source buffer in rsi. Call the function. Error code is now in rax. Done.

:man_facepalming:

Why does everything suck

bgottula commented 3 years ago

We've managed to avoid needing these functions since we can distinguish between cameras purely by reading their names.

If we do decide we still want these and SWIG is too painful we could consider replacing SWIG bindings with something like pybind11: https://pybind11.readthedocs.io/en/stable/