Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Library code robustness #8

Closed
markusb opened this issue Jul 17, 2012 · 3 comments
Closed

Library code robustness #8

markusb opened this issue Jul 17, 2012 · 3 comments

Comments

@markusb
Copy link
Contributor

markusb commented Jul 17, 2012

I'm opening another can of worms here:

At the moment the library is a very thin wrapper around libusb. I was amazed that one can get away with so little code :-). The main problem with the is the lack of detailed, user-friendly feedback when problems occur.

Here two examples (I'm running everything on Linux):

  • Running the provided examples, like ./blink provids the unhelpful message 'Little Wire could not be found!'. Runnign the same with 'sudo' works. Looking at the code it looks like the original message was 'permission denied', already much closer to the actual problem.
  • There seem to be no error feedback at all from the library. Again, running the 'blink' example, it starts fine, but when I unplug the littleWire 'blink' continues happily with no error message !

When I wrote a daemon, I could not find a way to query the status of the device. I'd like at least to properly bail out with an explaining message, when I detect that my littleWire device is no longer there...

@markusb
Copy link
Contributor Author

markusb commented Jul 18, 2012

Here a first attempt at relief:

  • Add a global variable 'int lwerror' in littleWire.c
  • Modify each call to 'usb_control_msg' to read 'lwerror = usb_control_msg'
    -> This saves the return code of usb_control_msg in lwerror for future reference
  • Add a new subroutine littleWire_error():
    int littleWire_error () {
    if (lwerror < 0) return lwerror;
    else return 0;
    }
    -> This gives access to the error code to applications

For example in my daemon program I can now place a

if (rc=littleWire_error()){printf("littleWire error %d",rc);}
whenever appropriate and such verify that no error occurred.

@kehribar
Copy link
Member

Hi,

I'll definitely look in to that as well. Especially the error feedback is an issue at the moment.

Thanks for the valuable submission!

ihsan.

@kehribar
Copy link
Member

Hi,

This also fixed with the v1.1 firmware!

ihsan.

kehribar added a commit that referenced this issue Jul 30, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants