3#include "externals/unity.h"
15#define regFmtStr "%02zX"
16#elif REGWIDTHBYTES == 2
20#define regFmtStr "%04zX"
21#elif REGWIDTHBYTES == 4
22#define zerohex "00000000"
23#define onehex "00000001"
24#define maxhex "FFFFFFFF"
25#define regFmtStr "%08zX"
33 for (
size_t i = 0; i < nRegs; i++) {
42void test_ascii_serial_com_register_block_write(
void) {
51 char ascVersion, appVersion, command, data[MAXDATALEN + 1];
54 char validationStr[MAXMESSAGELEN + 1];
55 for (
size_t iReg = 0; iReg < 0x100; iReg++) {
56 for (
size_t iVal = 0; iVal < 0x100; iVal += 0x5) {
61 sprintf(data,
"%04zX," regFmtStr, iReg, iVal);
62 dataLen = 5 + REGWIDTHBYTES * 2;
63 sprintf(validationStr,
">%c%c%c%04zX.", ascVersion, appVersion, command,
66 &asc, ascVersion, appVersion, command, data, dataLen, &ascrb);
67 TEST_ASSERT_EQUAL_size_t(10 + 4,
69 TEST_ASSERT_EQUAL_CHAR_ARRAY(validationStr, out_buf->
buffer, 5 + 4);
72 TEST_ASSERT_EQUAL_MESSAGE(iVal, regs[iReg],
73 "Register didn't get set to correct value!");
76 sprintf(data,
"%04zX", iReg);
78 sprintf(validationStr,
">%c%c%c%04zX," regFmtStr
".", ascVersion,
79 appVersion, command, iReg, iVal);
81 &asc, ascVersion, appVersion, command, data, dataLen, &ascrb);
82 TEST_ASSERT_EQUAL_size_t(15 + REGWIDTHBYTES * 2,
84 TEST_ASSERT_EQUAL_CHAR_ARRAY(validationStr, out_buf->
buffer,
85 10 + REGWIDTHBYTES * 2);
91 printf(
"Uncaught exception: %u\n", e1);
92 TEST_FAIL_MESSAGE(
"Uncaught exception!");
98 RUN_TEST(test_ascii_serial_com_register_block_write);
circular_buffer_uint8 * ascii_serial_com_get_output_buffer(ascii_serial_com *asc)
ASCII Serial Com get output buffer.
void ascii_serial_com_init(ascii_serial_com *asc)
ASCII Serial Com Interface init method.
void ascii_serial_com_register_block_handle_message(ascii_serial_com *asc, char ascVersion, char appVersion, char command, char *data, size_t dataLen, void *register_block_state_vp)
ASCII Serial Com Register Block handle message.
void ascii_serial_com_register_block_init(ascii_serial_com_register_block *register_block_state, REGTYPE *block, uint16_t n_regs)
ASCII Serial Com Register Block init.
ASCII Serial Com Register Block.
size_t circular_buffer_get_size_uint8(const circular_buffer_uint8 *circ_buf)
circular buffer get number of elements
void circular_buffer_clear_uint8(circular_buffer_uint8 *circ_buf)
circular buffer clear
ASCII Serial Com Interface State struct.
ASCII Serial Com Register Block State struct.