OpenThermal / libseek-thermal

SEEK thermal compact camera driver supporting the thermal Compact, thermal CompactXR and and thermal CompactPRO
MIT License
286 stars 99 forks source link

Compact Pro on RPi Zero W LIBUSB_ERROR_TIMEOUT #35

Closed mormass closed 3 years ago

mormass commented 5 years ago

Hi. Im trying to work with Seek Thermal Pro on Raspberry Pi Zero W. After few frames seek_viewer give me error LIBUSB_ERROR_TIMEOUT. Some times it happens after couple frames, some times little bit longer. So i decide to try to sniff usb exchange with wireshark to see whats going on. And saw that usual frame size is 177840 bytes (sended by 13 chunks 13680 bytes size). But right before timeout error chunks size reduced to 8560 bytes, or 10608 bytes, or 9584 bytes. Total size in this case was 135856 bytes. As i see frame size in your code is hard coded, so fetch_frame() try to get more bytes then device want to send, but device is nothing to give and after 10 seconds (by default) libusb generate timeout error. Have your idea why some frames have less size than usual? I made some change in source SeekDevice.cpp to ignore timeout error and return that strange frame. As result seek_viewer work without errors (i test program with output to window).

mormass commented 5 years ago

Some addition: a)usual frame size in raw is 342x260x2(bytes per pixel)=177840 bytes b)lesser size frame 135744 bytes (in my first message i was made mistake with calculation). I think its equal 303x224x2. Lesser frame have ID 6. So possible fix is make some additional check in fetch_frame(). If camera type is seekpro after first bulk transmission read frameID, and if its have ID 6 reduce desired size of raw data.

mormass commented 5 years ago

Its me again)) More presure searching in my last captchered usb exchange say that frames with ID 6 and size in byte 135744 more exception then rules. So maybe its only one option remain is ignore LIBUSB_ERROR_TIMEOUT at all.

kpetrykin commented 5 years ago

Hello! I'm trying to use Compact Pro on RPi too and I have the same error. Could you please show me your code? Thanks!

kpetrykin commented 5 years ago

@mormass, what do you mean under "ignore LIBUSB_ERROR_TIMEOUT at all"? If I exclude this error from the "(res != 0)" check, the program just stop returning frames.

kpetrykin commented 5 years ago

I think, I got it. Just added "return true" in case of LIBUSB_ERROR_TIMEOUT and everything works. Thank you!

SciProj-LDN commented 5 years ago

@kpetrykin could you describe what you changed? Where did you add that line? in the .cpp or thre args.h perhaps? I'm nearly there but can't figure what you've done exactly!

kpetrykin commented 5 years ago

@SciProj-LDN, you can find my code here: https://github.com/CopterExpress/libseek-thermal/blob/f007e4315dd5486fd455424c5bbf742f88a5b52d/src/SeekDevice.cpp#L121

SciProj-LDN commented 5 years ago

Thankyou @kpetrykin that solves the problem. I've had the camera running for a few hours now with no problems.

mormass commented 4 years ago

I think, I got it. Just added "return true" in case of LIBUSB_ERROR_TIMEOUT and everything works. Thank you!

Hi. Sorry i didnt answer you question, i was switch on other projects. But as i see you already got an answer. Yes, i just rewrite source to return "true". For better performance you may try to reduce timeout value for usb request in SeekDevice.h file. I think its not need to wait so much becouse you expect that some requests will return an error.

Bostwickenator commented 3 years ago

This should have been fixed in #52 but I forgot to close this issue