Fix unit tests
parent
a0bff0ef3a
commit
ad0b26c5ec
|
|
@ -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 i = 1;
|
||||
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;
|
||||
uint8_t i = BeginEncodeRequest(msg, txbuff);
|
||||
// dump the value
|
||||
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 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] = ' ';
|
||||
++i;
|
||||
uint8_t i = BeginEncodeRequest(msg, txbuff);
|
||||
txbuff[i] = (uint8_t)ar;
|
||||
++i;
|
||||
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 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] = ' ';
|
||||
++i;
|
||||
|
||||
uint8_t i = BeginEncodeRequest(msg, txbuff);
|
||||
if (accepted) {
|
||||
txbuff[i] = (uint8_t)ResponseMsgParamCodes::Accepted;
|
||||
++i;
|
||||
|
|
@ -335,5 +301,20 @@ uint8_t Protocol::Value2Hex(uint16_t value, uint8_t *dst) {
|
|||
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 modules
|
||||
|
|
|
|||
|
|
@ -261,6 +261,8 @@ private:
|
|||
|
||||
/// @returns number of characters written
|
||||
static uint8_t Value2Hex(uint16_t value, uint8_t *dst);
|
||||
|
||||
static uint8_t BeginEncodeRequest(const RequestMsg &msg, uint8_t *txbuff);
|
||||
};
|
||||
|
||||
} // namespace protocol
|
||||
|
|
|
|||
|
|
@ -2,6 +2,8 @@
|
|||
add_executable(
|
||||
cut_filament_tests
|
||||
${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/cut_filament.cpp
|
||||
${CMAKE_SOURCE_DIR}/src/logic/eject_filament.cpp
|
||||
|
|
|
|||
|
|
@ -2,6 +2,8 @@
|
|||
add_executable(
|
||||
eject_filament_tests
|
||||
${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/cut_filament.cpp
|
||||
${CMAKE_SOURCE_DIR}/src/logic/eject_filament.cpp
|
||||
|
|
|
|||
|
|
@ -2,6 +2,8 @@
|
|||
add_executable(
|
||||
failing_tmc_tests
|
||||
${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/cut_filament.cpp
|
||||
${CMAKE_SOURCE_DIR}/src/logic/eject_filament.cpp
|
||||
|
|
|
|||
|
|
@ -2,6 +2,8 @@
|
|||
add_executable(
|
||||
feed_to_bondtech_tests
|
||||
${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/cut_filament.cpp
|
||||
${CMAKE_SOURCE_DIR}/src/logic/eject_filament.cpp
|
||||
|
|
|
|||
|
|
@ -2,6 +2,8 @@
|
|||
add_executable(
|
||||
feed_to_finda_tests
|
||||
${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/cut_filament.cpp
|
||||
${CMAKE_SOURCE_DIR}/src/logic/eject_filament.cpp
|
||||
|
|
|
|||
|
|
@ -2,6 +2,8 @@
|
|||
add_executable(
|
||||
homing_tests
|
||||
${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/cut_filament.cpp
|
||||
${CMAKE_SOURCE_DIR}/src/logic/eject_filament.cpp
|
||||
|
|
|
|||
|
|
@ -2,6 +2,8 @@
|
|||
add_executable(
|
||||
load_filament_tests
|
||||
${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/cut_filament.cpp
|
||||
${CMAKE_SOURCE_DIR}/src/logic/eject_filament.cpp
|
||||
|
|
|
|||
|
|
@ -2,6 +2,8 @@
|
|||
add_executable(
|
||||
tool_change_tests
|
||||
${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/cut_filament.cpp
|
||||
${CMAKE_SOURCE_DIR}/src/logic/eject_filament.cpp
|
||||
|
|
|
|||
|
|
@ -2,6 +2,8 @@
|
|||
add_executable(
|
||||
unload_filament_tests
|
||||
${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/cut_filament.cpp
|
||||
${CMAKE_SOURCE_DIR}/src/logic/eject_filament.cpp
|
||||
|
|
|
|||
|
|
@ -2,6 +2,8 @@
|
|||
add_executable(
|
||||
unload_to_finda_tests
|
||||
${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/cut_filament.cpp
|
||||
${CMAKE_SOURCE_DIR}/src/logic/eject_filament.cpp
|
||||
|
|
|
|||
Loading…
Reference in New Issue