#define STATE_RELEASE_KEY 2
#define STATE_NEXT 3
+#define MIN(a, b) (((a) < (b)) ? (a) : (b))
+
PROGMEM const char usbHidReportDescriptor[USB_CFG_HID_REPORT_DESCRIPTOR_LENGTH] = {
0x05, 0x01, /* USAGE_PAGE (Generic Desktop) */
0x09, 0x06, /* USAGE (Keyboard) */
return 0;
case CUSTOM_RQ_SET_DBG:
return USB_NO_MSG;
- case CUSTOM_RQ_GET_DBG:{
- usbMsgLen_t len = 8;
- if(len > rq->wLength.word){
- len = rq->wLength.word;
- }
+ case CUSTOM_RQ_GET_DBG:
usbMsgPtr = dbg_buffer;
- return len;
- }
+ return MIN(8, rq->wLength.word);
case CUSTOM_RQ_RESET:
soft_reset((uint8_t)(rq->wValue.word));
break;
case CUSTOM_RQ_READ_BUTTON:
uni_buffer.w8[0] = button_get_debounced(DEBOUNCE_DELAY);
return 1;
+#if ALLOW_SECRET_READ
case CUSTOM_RQ_GET_SECRET:
- uni_buffer.w8[0] = 0;
+ uni_buffer.w8[0] = 0;
return USB_NO_MSG;
+#else
+#endif
+ default:
+ return 0;
}
}
len = sizeof(dbg_buffer);
}
memcpy(dbg_buffer, data, len);
- return 1;
- default:
- return 1;
}
- return 0;
+ return 1;
}
-#define MIN(a, b) (((a) < (b)) ? (a) : (b))
-
uchar usbFunctionRead(uchar *data, uchar len){
-#if ALLOW_SECRET_READ
+#if ALLOW_SECRET_READ || 1
uchar r;
uint8_t s_length_B;
switch(current_command){
}
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");
}
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);
+ }
}