UrbanskiDawid / usb2lin06-HID-in-linux-for-LINAK-Desk-Control-Cable

Basic functionality of usb2lin06 device implemented for use in linux
40 stars 11 forks source link

Provide exit codes on error #5

Closed Biont closed 7 years ago

Biont commented 7 years ago

Hello again!

Would it be possible to return different exit codes when something goes wrong? There do not seem to be any right now, so I have to actually parse the error message to get a clue on what went wrong. It would be very useful if I could just look at the exit code and infer the meaning from that. (Also the error message might change in the future, while the exit code would probably not)

There are a couple of reasons why there can be an error:

Maybe there are more and I just havent encountered them yet. I'm not sure I have a reliable way of telling these apart, except for regex matching maybe.

What do you think?

UrbanskiDawid commented 7 years ago

sounds OK to me, expect new version soon.

UrbanskiDawid commented 7 years ago

DONE, please let me know it current solution works for you.

exit code is now: libusb error: http://libusb.sourceforge.net/api-1.0/group__misc.html#gab2323aa0f04bc22038e7e1740b2f29ef or application errors: https://github.com/ranma1988/usb2lin06-HID-in-linux-for-LINAK-Desk-Control-Cable/blob/master/usb2linException.h

Biont commented 7 years ago

Thank you! I am now getting "Error: can't find device" in all of the examples whenever I run them.

I do get a 200 back so that apparently works already :)

UrbanskiDawid commented 7 years ago

" "Error: can't find device" in all of the examples whenever I run them." thats interesting could you please make a debug build: $ make debug then run one example (as root) and copy paste output?

Biont commented 7 years ago
# ./example-getHeight 
DEBUG getHeight.cpp:29 main() - init
DEBUG ../usb2lin06Controler.cpp:25 usb2lin06Controler()
DEBUG ../usb2lin06Controler.cpp:32 usb2lin06Controler() - find and open device
DEBUG ../usb2lin06Controler.cpp:220 openDevice() find & open
[timestamp] [threadID] facility level [function call] <message>
--------------------------------------------------------------------------------
[ 0.005214] [00001110] libusb: debug [libusb_get_device_list] 
[ 0.005226] [00001110] libusb: debug [discovered_devs_append] need to increase capacity
[ 0.005231] [00001110] libusb: debug [libusb_get_device_descriptor] 
[ 0.005298] [00001110] libusb: debug [libusb_exit] 
[ 0.005306] [00001110] libusb: debug [libusb_exit] destroying default context
Error:  can't find device
UrbanskiDawid commented 7 years ago

OK, updated 'find device' now works nearly identical as in prev. version. please let me know it this has resolved this issue

Biont commented 7 years ago

Yup, looks like it's working fine again now. Error handling just got much more convenient. Thank you.