From c3d9938192e08ced452da83d817e217a10e33d8c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A1szl=C3=B3=20Monda?= Date: Sun, 23 Jul 2017 20:20:13 +0200 Subject: [PATCH] Expose hardware config size and user config size as system properties. --- right/src/system_properties.h | 2 ++ right/src/usb_protocol_handler.c | 12 +++++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/right/src/system_properties.h b/right/src/system_properties.h index 5938496..14ea8ba 100644 --- a/right/src/system_properties.h +++ b/right/src/system_properties.h @@ -15,6 +15,8 @@ SystemPropertyId_BridgeProtocolVersion = 1, SystemPropertyId_DataModelVersion = 2, SystemPropertyId_FirmwareVersion = 3, + SystemPropertyId_HardwareConfigSize = 4, + SystemPropertyId_UserConfigSize = 5, } system_property_t; #endif diff --git a/right/src/usb_protocol_handler.c b/right/src/usb_protocol_handler.c index 47d68b0..517907c 100644 --- a/right/src/usb_protocol_handler.c +++ b/right/src/usb_protocol_handler.c @@ -24,12 +24,16 @@ void setGenericError(void) setError(UsbResponse_GenericError); } -// Set a single byte as the response. void SetResponseByte(uint8_t response) { GenericHidOutBuffer[1] = response; } +void SetResponseWord(uint16_t response) +{ + *((uint16_t*)(GenericHidOutBuffer+1)) = response; +} + // Per command protocol command handlers void getSystemProperty(void) { @@ -48,6 +52,12 @@ void getSystemProperty(void) { case SystemPropertyId_FirmwareVersion: SetResponseByte(SYSTEM_PROPERTY_FIRMWARE_VERSION); break; + case SystemPropertyId_HardwareConfigSize: + SetResponseWord(HARDWARE_CONFIG_SIZE); + break; + case SystemPropertyId_UserConfigSize: + SetResponseWord(USER_CONFIG_SIZE); + break; default: setGenericError(); break;