From 4e8c2da50e134951a833bd135fc87e89808ec59b Mon Sep 17 00:00:00 2001 From: Szczepan Zalega Date: Mon, 1 Aug 2016 13:23:46 +0200 Subject: Get device status command for storage stick Signed-off-by: Szczepan Zalega --- include/stick20_commands.h | 42 +++++++++++++++++++++++++++++++++++------- 1 file changed, 35 insertions(+), 7 deletions(-) (limited to 'include') diff --git a/include/stick20_commands.h b/include/stick20_commands.h index ec1b088..c684e95 100644 --- a/include/stick20_commands.h +++ b/include/stick20_commands.h @@ -2,8 +2,8 @@ #define STICK20_COMMANDS_H #include "inttypes.h" #include "command.h" -//#include -//#include +#include +#include #include "device_proto.h" @@ -182,11 +182,39 @@ class SendPasswordMatrixSetup : semantics::non_constructible { struct EmptyPayload> CommandTransaction; }; -class GetDeviceStatus : semantics::non_constructible { - public: - typedef Transaction CommandTransaction; -}; +#define d(x) ss << #x":\t" << x << std::endl; + + class GetDeviceStatus : Command { + public: + static const int OUTPUT_CMD_RESULT_STICK20_STATUS_START = 20 +1; + static const int payload_absolute_begin = 8; + static const int padding_size = OUTPUT_CMD_RESULT_STICK20_STATUS_START - payload_absolute_begin; + struct ResponsePayload { + uint8_t _padding[padding_size]; + //data starts from 21st byte of packet -> 13th byte of payload + uint8_t command_counter; + uint8_t last_command; + uint8_t status; + uint8_t progress_bar_value; + bool isValid() const { return true; } + + std::string dissect() const { + std::stringstream ss; + d(command_counter); + d(last_command); + d(status); + d(progress_bar_value); + ss << "_padding:\t" + << ::nitrokey::misc::hexdump((const char *)(_padding), + sizeof _padding); + return ss.str(); + } + } __packed; + + typedef Transaction + CommandTransaction; + }; + class SendPassword : semantics::non_constructible { public: -- cgit v1.2.3