Fix unit tests
parent
107e8e4fae
commit
3ca4b6c3a9
|
|
@ -125,18 +125,7 @@ uint8_t Protocol::EncodeRequest(const RequestMsg &msg, uint8_t *txbuff) {
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t Protocol::EncodeWriteRequest(const RequestMsg &msg, uint16_t value2, uint8_t *txbuff) {
|
uint8_t Protocol::EncodeWriteRequest(const RequestMsg &msg, uint16_t value2, uint8_t *txbuff) {
|
||||||
uint8_t i = 1;
|
uint8_t i = BeginEncodeRequest(msg, txbuff);
|
||||||
txbuff[0] = (uint8_t)msg.code;
|
|
||||||
uint8_t v = msg.value >> 4;
|
|
||||||
if (v != 0) { // skip the first '0' if any
|
|
||||||
txbuff[i] = Nibble2Char(v);
|
|
||||||
++i;
|
|
||||||
}
|
|
||||||
v = msg.value & 0xf;
|
|
||||||
txbuff[i] = Nibble2Char(v);
|
|
||||||
++i;
|
|
||||||
txbuff[i] = ' ';
|
|
||||||
++i;
|
|
||||||
// dump the value
|
// dump the value
|
||||||
i += Value2Hex(value2, txbuff + i);
|
i += Value2Hex(value2, txbuff + i);
|
||||||
|
|
||||||
|
|
@ -231,18 +220,7 @@ DecodeStatus Protocol::DecodeResponse(uint8_t c) {
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t Protocol::EncodeResponseCmdAR(const RequestMsg &msg, ResponseMsgParamCodes ar, uint8_t *txbuff) {
|
uint8_t Protocol::EncodeResponseCmdAR(const RequestMsg &msg, ResponseMsgParamCodes ar, uint8_t *txbuff) {
|
||||||
uint8_t i = 1;
|
uint8_t i = BeginEncodeRequest(msg, txbuff);
|
||||||
txbuff[0] = (uint8_t)msg.code;
|
|
||||||
uint8_t v = msg.value >> 4U;
|
|
||||||
if (v != 0) { // skip the first '0' if any
|
|
||||||
txbuff[i] = Nibble2Char(v);
|
|
||||||
++i;
|
|
||||||
}
|
|
||||||
v = msg.value & 0xfU;
|
|
||||||
txbuff[i] = Nibble2Char(v);
|
|
||||||
++i;
|
|
||||||
txbuff[i] = ' ';
|
|
||||||
++i;
|
|
||||||
txbuff[i] = (uint8_t)ar;
|
txbuff[i] = (uint8_t)ar;
|
||||||
++i;
|
++i;
|
||||||
txbuff[i] = '\n';
|
txbuff[i] = '\n';
|
||||||
|
|
@ -287,19 +265,7 @@ uint8_t Protocol::EncodeResponseQueryOperation(const RequestMsg &msg, ResponseCo
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t Protocol::EncodeResponseRead(const RequestMsg &msg, bool accepted, uint16_t value2, uint8_t *txbuff) {
|
uint8_t Protocol::EncodeResponseRead(const RequestMsg &msg, bool accepted, uint16_t value2, uint8_t *txbuff) {
|
||||||
uint8_t i = 1;
|
uint8_t i = BeginEncodeRequest(msg, txbuff);
|
||||||
txbuff[0] = (uint8_t)msg.code;
|
|
||||||
uint8_t v = msg.value >> 4U;
|
|
||||||
if (v != 0) { // skip the first '0' if any
|
|
||||||
txbuff[i] = Nibble2Char(v);
|
|
||||||
++i;
|
|
||||||
}
|
|
||||||
v = msg.value & 0xfU;
|
|
||||||
txbuff[i] = Nibble2Char(v);
|
|
||||||
++i;
|
|
||||||
txbuff[i] = ' ';
|
|
||||||
++i;
|
|
||||||
|
|
||||||
if (accepted) {
|
if (accepted) {
|
||||||
txbuff[i] = (uint8_t)ResponseMsgParamCodes::Accepted;
|
txbuff[i] = (uint8_t)ResponseMsgParamCodes::Accepted;
|
||||||
++i;
|
++i;
|
||||||
|
|
@ -335,5 +301,20 @@ uint8_t Protocol::Value2Hex(uint16_t value, uint8_t *dst) {
|
||||||
return charsOut;
|
return charsOut;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint8_t Protocol::BeginEncodeRequest(const RequestMsg &msg, uint8_t *txbuff) {
|
||||||
|
uint8_t i = 1;
|
||||||
|
txbuff[0] = (uint8_t)msg.code;
|
||||||
|
uint8_t v = msg.value >> 4U;
|
||||||
|
if (v != 0) { // skip the first '0' if any
|
||||||
|
txbuff[i] = Nibble2Char(v);
|
||||||
|
++i;
|
||||||
|
}
|
||||||
|
v = msg.value & 0xfU;
|
||||||
|
txbuff[i] = Nibble2Char(v);
|
||||||
|
++i;
|
||||||
|
txbuff[i] = ' ';
|
||||||
|
return i + 1;
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace protocol
|
} // namespace protocol
|
||||||
} // namespace modules
|
} // namespace modules
|
||||||
|
|
|
||||||
|
|
@ -261,6 +261,8 @@ private:
|
||||||
|
|
||||||
/// @returns number of characters written
|
/// @returns number of characters written
|
||||||
static uint8_t Value2Hex(uint16_t value, uint8_t *dst);
|
static uint8_t Value2Hex(uint16_t value, uint8_t *dst);
|
||||||
|
|
||||||
|
static uint8_t BeginEncodeRequest(const RequestMsg &msg, uint8_t *txbuff);
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace protocol
|
} // namespace protocol
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,8 @@
|
||||||
add_executable(
|
add_executable(
|
||||||
cut_filament_tests
|
cut_filament_tests
|
||||||
${CMAKE_SOURCE_DIR}/src/application.cpp
|
${CMAKE_SOURCE_DIR}/src/application.cpp
|
||||||
|
${CMAKE_SOURCE_DIR}/src/registers.cpp
|
||||||
|
${CMAKE_SOURCE_DIR}/src/version.c
|
||||||
${CMAKE_SOURCE_DIR}/src/logic/command_base.cpp
|
${CMAKE_SOURCE_DIR}/src/logic/command_base.cpp
|
||||||
${CMAKE_SOURCE_DIR}/src/logic/cut_filament.cpp
|
${CMAKE_SOURCE_DIR}/src/logic/cut_filament.cpp
|
||||||
${CMAKE_SOURCE_DIR}/src/logic/eject_filament.cpp
|
${CMAKE_SOURCE_DIR}/src/logic/eject_filament.cpp
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,8 @@
|
||||||
add_executable(
|
add_executable(
|
||||||
eject_filament_tests
|
eject_filament_tests
|
||||||
${CMAKE_SOURCE_DIR}/src/application.cpp
|
${CMAKE_SOURCE_DIR}/src/application.cpp
|
||||||
|
${CMAKE_SOURCE_DIR}/src/registers.cpp
|
||||||
|
${CMAKE_SOURCE_DIR}/src/version.c
|
||||||
${CMAKE_SOURCE_DIR}/src/logic/command_base.cpp
|
${CMAKE_SOURCE_DIR}/src/logic/command_base.cpp
|
||||||
${CMAKE_SOURCE_DIR}/src/logic/cut_filament.cpp
|
${CMAKE_SOURCE_DIR}/src/logic/cut_filament.cpp
|
||||||
${CMAKE_SOURCE_DIR}/src/logic/eject_filament.cpp
|
${CMAKE_SOURCE_DIR}/src/logic/eject_filament.cpp
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,8 @@
|
||||||
add_executable(
|
add_executable(
|
||||||
failing_tmc_tests
|
failing_tmc_tests
|
||||||
${CMAKE_SOURCE_DIR}/src/application.cpp
|
${CMAKE_SOURCE_DIR}/src/application.cpp
|
||||||
|
${CMAKE_SOURCE_DIR}/src/registers.cpp
|
||||||
|
${CMAKE_SOURCE_DIR}/src/version.c
|
||||||
${CMAKE_SOURCE_DIR}/src/logic/command_base.cpp
|
${CMAKE_SOURCE_DIR}/src/logic/command_base.cpp
|
||||||
${CMAKE_SOURCE_DIR}/src/logic/cut_filament.cpp
|
${CMAKE_SOURCE_DIR}/src/logic/cut_filament.cpp
|
||||||
${CMAKE_SOURCE_DIR}/src/logic/eject_filament.cpp
|
${CMAKE_SOURCE_DIR}/src/logic/eject_filament.cpp
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,8 @@
|
||||||
add_executable(
|
add_executable(
|
||||||
feed_to_bondtech_tests
|
feed_to_bondtech_tests
|
||||||
${CMAKE_SOURCE_DIR}/src/application.cpp
|
${CMAKE_SOURCE_DIR}/src/application.cpp
|
||||||
|
${CMAKE_SOURCE_DIR}/src/registers.cpp
|
||||||
|
${CMAKE_SOURCE_DIR}/src/version.c
|
||||||
${CMAKE_SOURCE_DIR}/src/logic/command_base.cpp
|
${CMAKE_SOURCE_DIR}/src/logic/command_base.cpp
|
||||||
${CMAKE_SOURCE_DIR}/src/logic/cut_filament.cpp
|
${CMAKE_SOURCE_DIR}/src/logic/cut_filament.cpp
|
||||||
${CMAKE_SOURCE_DIR}/src/logic/eject_filament.cpp
|
${CMAKE_SOURCE_DIR}/src/logic/eject_filament.cpp
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,8 @@
|
||||||
add_executable(
|
add_executable(
|
||||||
feed_to_finda_tests
|
feed_to_finda_tests
|
||||||
${CMAKE_SOURCE_DIR}/src/application.cpp
|
${CMAKE_SOURCE_DIR}/src/application.cpp
|
||||||
|
${CMAKE_SOURCE_DIR}/src/registers.cpp
|
||||||
|
${CMAKE_SOURCE_DIR}/src/version.c
|
||||||
${CMAKE_SOURCE_DIR}/src/logic/command_base.cpp
|
${CMAKE_SOURCE_DIR}/src/logic/command_base.cpp
|
||||||
${CMAKE_SOURCE_DIR}/src/logic/cut_filament.cpp
|
${CMAKE_SOURCE_DIR}/src/logic/cut_filament.cpp
|
||||||
${CMAKE_SOURCE_DIR}/src/logic/eject_filament.cpp
|
${CMAKE_SOURCE_DIR}/src/logic/eject_filament.cpp
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,8 @@
|
||||||
add_executable(
|
add_executable(
|
||||||
homing_tests
|
homing_tests
|
||||||
${CMAKE_SOURCE_DIR}/src/application.cpp
|
${CMAKE_SOURCE_DIR}/src/application.cpp
|
||||||
|
${CMAKE_SOURCE_DIR}/src/registers.cpp
|
||||||
|
${CMAKE_SOURCE_DIR}/src/version.c
|
||||||
${CMAKE_SOURCE_DIR}/src/logic/command_base.cpp
|
${CMAKE_SOURCE_DIR}/src/logic/command_base.cpp
|
||||||
${CMAKE_SOURCE_DIR}/src/logic/cut_filament.cpp
|
${CMAKE_SOURCE_DIR}/src/logic/cut_filament.cpp
|
||||||
${CMAKE_SOURCE_DIR}/src/logic/eject_filament.cpp
|
${CMAKE_SOURCE_DIR}/src/logic/eject_filament.cpp
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,8 @@
|
||||||
add_executable(
|
add_executable(
|
||||||
load_filament_tests
|
load_filament_tests
|
||||||
${CMAKE_SOURCE_DIR}/src/application.cpp
|
${CMAKE_SOURCE_DIR}/src/application.cpp
|
||||||
|
${CMAKE_SOURCE_DIR}/src/registers.cpp
|
||||||
|
${CMAKE_SOURCE_DIR}/src/version.c
|
||||||
${CMAKE_SOURCE_DIR}/src/logic/command_base.cpp
|
${CMAKE_SOURCE_DIR}/src/logic/command_base.cpp
|
||||||
${CMAKE_SOURCE_DIR}/src/logic/cut_filament.cpp
|
${CMAKE_SOURCE_DIR}/src/logic/cut_filament.cpp
|
||||||
${CMAKE_SOURCE_DIR}/src/logic/eject_filament.cpp
|
${CMAKE_SOURCE_DIR}/src/logic/eject_filament.cpp
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,8 @@
|
||||||
add_executable(
|
add_executable(
|
||||||
tool_change_tests
|
tool_change_tests
|
||||||
${CMAKE_SOURCE_DIR}/src/application.cpp
|
${CMAKE_SOURCE_DIR}/src/application.cpp
|
||||||
|
${CMAKE_SOURCE_DIR}/src/registers.cpp
|
||||||
|
${CMAKE_SOURCE_DIR}/src/version.c
|
||||||
${CMAKE_SOURCE_DIR}/src/logic/command_base.cpp
|
${CMAKE_SOURCE_DIR}/src/logic/command_base.cpp
|
||||||
${CMAKE_SOURCE_DIR}/src/logic/cut_filament.cpp
|
${CMAKE_SOURCE_DIR}/src/logic/cut_filament.cpp
|
||||||
${CMAKE_SOURCE_DIR}/src/logic/eject_filament.cpp
|
${CMAKE_SOURCE_DIR}/src/logic/eject_filament.cpp
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,8 @@
|
||||||
add_executable(
|
add_executable(
|
||||||
unload_filament_tests
|
unload_filament_tests
|
||||||
${CMAKE_SOURCE_DIR}/src/application.cpp
|
${CMAKE_SOURCE_DIR}/src/application.cpp
|
||||||
|
${CMAKE_SOURCE_DIR}/src/registers.cpp
|
||||||
|
${CMAKE_SOURCE_DIR}/src/version.c
|
||||||
${CMAKE_SOURCE_DIR}/src/logic/command_base.cpp
|
${CMAKE_SOURCE_DIR}/src/logic/command_base.cpp
|
||||||
${CMAKE_SOURCE_DIR}/src/logic/cut_filament.cpp
|
${CMAKE_SOURCE_DIR}/src/logic/cut_filament.cpp
|
||||||
${CMAKE_SOURCE_DIR}/src/logic/eject_filament.cpp
|
${CMAKE_SOURCE_DIR}/src/logic/eject_filament.cpp
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,8 @@
|
||||||
add_executable(
|
add_executable(
|
||||||
unload_to_finda_tests
|
unload_to_finda_tests
|
||||||
${CMAKE_SOURCE_DIR}/src/application.cpp
|
${CMAKE_SOURCE_DIR}/src/application.cpp
|
||||||
|
${CMAKE_SOURCE_DIR}/src/registers.cpp
|
||||||
|
${CMAKE_SOURCE_DIR}/src/version.c
|
||||||
${CMAKE_SOURCE_DIR}/src/logic/command_base.cpp
|
${CMAKE_SOURCE_DIR}/src/logic/command_base.cpp
|
||||||
${CMAKE_SOURCE_DIR}/src/logic/cut_filament.cpp
|
${CMAKE_SOURCE_DIR}/src/logic/cut_filament.cpp
|
||||||
${CMAKE_SOURCE_DIR}/src/logic/eject_filament.cpp
|
${CMAKE_SOURCE_DIR}/src/logic/eject_filament.cpp
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue