From fbef2e2c8878acec949c2323f53a1ced2c56d19d Mon Sep 17 00:00:00 2001 From: jacobperron Date: Mon, 28 Mar 2016 22:31:23 -0700 Subject: [PATCH] Implement 'getMode' --- include/create/types.h | 5 +++-- src/create.cpp | 10 ++++++++++ src/data.cpp | 2 +- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/include/create/types.h b/include/create/types.h index 3fcb3b1..9e65c08 100644 --- a/include/create/types.h +++ b/include/create/types.h @@ -80,7 +80,7 @@ namespace create { ID_UNUSED_2 = 32, ID_UNUSED_3 = 33, ID_CHARGE_SOURCE = 34, - ID_IO_MODE = 35, + ID_OI_MODE = 35, ID_SONG_NUM = 36, ID_PLAYING = 37, ID_NUM_STREAM_PACKETS = 38, @@ -156,7 +156,8 @@ namespace create { MODE_OFF = OC_POWER, MODE_PASSIVE = OC_START, MODE_SAFE = OC_SAFE, - MODE_FULL = OC_FULL + MODE_FULL = OC_FULL, + MODE_UNAVAILABLE = -1 }; enum CleanMode { diff --git a/src/create.cpp b/src/create.cpp index 5456751..3c12fdb 100644 --- a/src/create.cpp +++ b/src/create.cpp @@ -687,6 +687,16 @@ namespace create { } } + create::CreateMode Create::getMode() const { + if (data->isValidPacketID(ID_OI_MODE)) { + return (create::CreateMode) GET_DATA(ID_OI_MODE); + } + else { + CERR("[create::Create] ", "Querying Mode not supported!"); + return create::MODE_UNAVAILABLE; + } + } + const Pose& Create::getPose() const { return pose; } diff --git a/src/data.cpp b/src/data.cpp index 25616c9..fe6dc29 100644 --- a/src/data.cpp +++ b/src/data.cpp @@ -25,6 +25,7 @@ namespace create { ADD_PACKET(ID_CHARGE , 2, "battery_charge"); ADD_PACKET(ID_CAPACITY, 2, "battery_capacity"); ADD_PACKET(ID_VIRTUAL_WALL, 1, "virtual_wall"); + ADD_PACKET(ID_OI_MODE, 1, "oi_mode"); if (model == CREATE_1) { ADD_PACKET(ID_DISTANCE, 2, "distance"); @@ -42,7 +43,6 @@ namespace create { //ADD_PACKET(ID_UNUSED_2, 1, "unused 2"); //ADD_PACKET(ID_UNUSED_3, 2, "unused 3"); //ADD_PACKET(ID_CHARGE_SOURCE, 1, "charger_available"); - //ADD_PACKET(ID_IO_MODE, 1, "oi_mode"); //ADD_PACKET(ID_SONG_NUM, 1, "song_number"); //ADD_PACKET(ID_PLAYING, 1, "song_playing"); //ADD_PACKET(ID_NUM_STREAM_PACKETS, 1, "oi_stream_num_packets");