X-Git-Url: https://git.cryptolib.org/?p=labortage2013badge.git;a=blobdiff_plain;f=hostware%2Fcommandline%2Fmain.c;h=18e9547e483611010ffb550d6298f7bd5bb19734;hp=202dbeea6e92390411421fade9c54251631a3281;hb=46e9b3d1c8a23c3884c8edf4ace96ff650333648;hpb=48646597db7ce609b6a3e0ba3d44a4723587cc0c diff --git a/hostware/commandline/main.c b/hostware/commandline/main.c index 202dbee..18e9547 100644 --- a/hostware/commandline/main.c +++ b/hostware/commandline/main.c @@ -78,7 +78,7 @@ void set_dbg(char *hex_string){ } void get_dbg(char *param){ - uint16_t buffer[256]; + uint8_t buffer[256]; int cnt; cnt = usb_control_msg(handle, USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_ENDPOINT_IN, CUSTOM_RQ_GET_DBG, 0, 0, (char*)buffer, 256, 5000); printf("DBG-Buffer:\n"); @@ -191,11 +191,15 @@ void read_button(char* param){ } void get_secret(char *param){ - uint16_t buffer[256]; + uint8_t buffer[64]; int cnt; - cnt = usb_control_msg(handle, USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_ENDPOINT_IN, CUSTOM_RQ_GET_SECRET, 0, 0, (char*)buffer, 256, 5000); - printf("Secret:\n"); - hexdump_block(stdout, buffer, 0, cnt, 16); + cnt = usb_control_msg(handle, USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_ENDPOINT_IN, CUSTOM_RQ_GET_SECRET, 0, 0, (char*)buffer, 32, 5000); + if (cnt > 0) { + printf("Secret (%d):\n", cnt); + hexdump_block(stdout, buffer, NULL, cnt, 16); + } else { + fprintf(stderr, "Error: usb_control_msg(...) returned %d\n", cnt); + } }