summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/stick20_commands.h21
-rw-r--r--unittest/test2.cc6
2 files changed, 27 insertions, 0 deletions
diff --git a/include/stick20_commands.h b/include/stick20_commands.h
index 237118d..42f46ad 100644
--- a/include/stick20_commands.h
+++ b/include/stick20_commands.h
@@ -273,6 +273,27 @@ namespace nitrokey {
CommandTransaction;
};
+ class GetSDCardOccupancy : Command<CommandID::SD_CARD_HIGH_WATERMARK> {
+ public:
+ struct ResponsePayload {
+ uint8_t WriteLevelMin;
+ uint8_t WriteLevelMax;
+ uint8_t ReadLevelMin;
+ uint8_t ReadLevelMax;
+ std::string dissect() const {
+ std::stringstream ss;
+ print_to_ss((int) WriteLevelMin);
+ print_to_ss((int) WriteLevelMax);
+ print_to_ss((int) ReadLevelMin);
+ print_to_ss((int) ReadLevelMax);
+ return ss.str();
+ }
+ } __packed;
+
+ typedef Transaction<command_id(), struct EmptyPayload, struct ResponsePayload>
+ CommandTransaction;
+ };
+
class SetupHiddenVolume : Command<CommandID::SEND_HIDDEN_VOLUME_SETUP> {
public:
diff --git a/unittest/test2.cc b/unittest/test2.cc
index 8db91b7..f5d2b28 100644
--- a/unittest/test2.cc
+++ b/unittest/test2.cc
@@ -124,6 +124,12 @@ TEST_CASE("test device internal status with various commands", "[fast]") {
auto production_status = stick20::ProductionTest::CommandTransaction::run(stick);
REQUIRE(production_status.data().SD_Card_Size_u8 == 8);
REQUIRE(production_status.data().SD_CardID_u32 != 0);
+
+ auto sdcard_occupancy = stick20::GetSDCardOccupancy::CommandTransaction::run(stick);
+ REQUIRE((int) sdcard_occupancy.data().ReadLevelMin >= 0);
+ REQUIRE((int) sdcard_occupancy.data().ReadLevelMax <= 100);
+ REQUIRE((int) sdcard_occupancy.data().WriteLevelMin >= 0);
+ REQUIRE((int) sdcard_occupancy.data().WriteLevelMax <= 100);
}
TEST_CASE("setup hidden volume test", "[hidden]") {