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

[HSM] Add debugging functions #18

Open
wants to merge 1 commit into
base: hsm
Choose a base branch
from

Conversation

FlorianUekermann
Copy link
Contributor

@FlorianUekermann FlorianUekermann commented Sep 3, 2016

Adds two simple functions for debugging.

Debugf works exactly like printf.
Debug takes an array of bytes and a length.
Example code on device:

Debugf("Hello world %d", 123)

Output on host:

$python debug.py
Hello world 123

Debugging is disabled by default. Both functions do nothing unless debugging in is enabled by uncommenting line 8 in debug.h (this should be done via make target at some point)

To try it uncomment line 8 in src/inc/debug.h and run "python debug.py" in the repository root. Then plug in the Nitrokey HSM. You should see this as soon as the device is done with the basic setup:

Entering loop after USB startup

This code should have no side effects and be compatible with the master branch as well. As long as pyusb is installed it should work on every OS ('apt-get install python-usb'). More extensive documentation in debug.py and debug.h.

Don't use floating point math (that means don't print them either).

@szszszsz
Copy link
Member

Hi @MaVo159 !
We should add guards also to interface creation, so it would not be available in release binary even when nothing is printed there. Additional interfaces could make device blocked on VM environments.

@FlorianUekermann
Copy link
Contributor Author

That is definitely the plan. I would like to wait with that until I have time to merge the two branches though, since I'll need to do something more elegant for the device descriptor anyway. Unless there are immediate plans to release a new version firmware version of course.
I wouldn't expect VM problems, because this is not an HID interface. Or have you encountered VMs that don't forward devices for other reasons.

@szszszsz
Copy link
Member

OK!
As for VMs I have not heard about other block causes, just blind guess.

@szszszsz szszszsz changed the title Add debugging functions [HSM] Add debugging functions Dec 3, 2016
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

Successfully merging this pull request may close these issues.

2 participants