Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions example/basic.c
Original file line number Diff line number Diff line change
Expand Up @@ -146,16 +146,16 @@ static struct cat_io_interface iface = {

int main(int argc, char **argv)
{
struct cat_object at;
struct cat_object at;

/* initializing */
cat_init(&at, &desc, &iface, NULL);
cat_init(&at, &desc, &iface, NULL);

/* main loop with exit code conditions */
while ((cat_service(&at) != 0) && (quit_flag == 0)) {};

/* goodbye message */
printf("Bye!\n");

return 0;
return 0;
}
14 changes: 7 additions & 7 deletions example/demo.c
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ static int bytesbuf_write(const struct cat_variable *var, size_t write_size)
{
int i = 0;

printf("bytes_buf variable updated %lu bytes internally to: ", write_size);
printf("bytes_buf variable updated %lu bytes internally to: ", write_size);
for (i = 0; i < sizeof(bytes_buf); i++)
printf("%02X", bytes_buf[i]);
printf("\n");
Expand All @@ -84,15 +84,15 @@ static int bytesbuf_write(const struct cat_variable *var, size_t write_size)
static int go_write(const struct cat_command *cmd, const uint8_t *data, const size_t data_size, const size_t args_num)
{
int i = 0;

printf("<%s>: x=%d y=%d msg=%s @ speed=%d\n",
cmd->name,
*(uint8_t*)(cmd->var[0].data),
*(uint8_t*)(cmd->var[1].data),
msg,
speed
);

printf("<bytes>: ");
for (i = 0; i < sizeof(bytes_buf); i++)
printf("%02X", bytes_buf[i]);
Expand Down Expand Up @@ -169,7 +169,7 @@ static struct cat_variable set_vars[] = {
.data = &adr,
.data_size = sizeof(adr),
.write = adr_write,
.name = "address"
.name = "address"
},
{
.type = CAT_VAR_BUF_HEX,
Expand Down Expand Up @@ -248,13 +248,13 @@ static struct cat_io_interface iface = {

int main(int argc, char **argv)
{
struct cat_object at;
struct cat_object at;

cat_init(&at, &desc, &iface, NULL);
cat_init(&at, &desc, &iface, NULL);

while ((cat_service(&at) != 0) && (quit_flag == 0)) {};

printf("Bye!\n");

return 0;
return 0;
}
6 changes: 3 additions & 3 deletions example/unsolicited.c
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ static cat_return_state scan_read(const struct cat_command *cmd, uint8_t *data,
scan_index++;
if (scan_index > max)
return CAT_RETURN_STATE_HOLD_EXIT_OK;

load_scan_results(scan_index);
cat_trigger_unsolicited_read(&at, &scan_cmd);

Expand Down Expand Up @@ -239,13 +239,13 @@ static struct cat_io_interface iface = {
int main(int argc, char **argv)
{
/* initializing */
cat_init(&at, &desc, &iface, NULL);
cat_init(&at, &desc, &iface, NULL);

/* main loop with exit code conditions */
while ((cat_service(&at) != 0) && (quit_flag == 0)) {};

/* goodbye message */
printf("Bye!\n");

return 0;
return 0;
}
6 changes: 3 additions & 3 deletions src/cat.h
Original file line number Diff line number Diff line change
Expand Up @@ -291,11 +291,11 @@ typedef enum {
CAT_UNSOLICITED_STATE_READ_LOOP,
CAT_UNSOLICITED_STATE_TEST_LOOP,
CAT_UNSOLICITED_STATE_FLUSH_IO_WRITE_WAIT,
CAT_UNSOLICITED_STATE_FLUSH_IO_WRITE,
CAT_UNSOLICITED_STATE_FLUSH_IO_WRITE,
CAT_UNSOLICITED_STATE_AFTER_FLUSH_RESET,
CAT_UNSOLICITED_STATE_AFTER_FLUSH_OK,
CAT_UNSOLICITED_STATE_AFTER_FLUSH_FORMAT_READ_ARGS,
CAT_UNSOLICITED_STATE_AFTER_FLUSH_FORMAT_TEST_ARGS,
CAT_UNSOLICITED_STATE_AFTER_FLUSH_FORMAT_TEST_ARGS,
} cat_unsolicited_state;

/* enum type with fsm type */
Expand All @@ -318,7 +318,7 @@ struct cat_unsolicited_fsm {
char const *write_buf; /* working buffer pointer used for asynch writing to io */
int write_state; /* before, data, after flush io write state */
cat_unsolicited_state write_state_after; /* parser state to set after flush io write */

struct cat_unsolicited_cmd unsolicited_cmd_buffer[CAT_UNSOLICITED_CMD_BUFFER_SIZE]; /* buffer with unsolicited commands used to unsolicited event */
size_t unsolicited_cmd_buffer_tail; /* tail index of unsolicited cmd buffer */
size_t unsolicited_cmd_buffer_head; /* head index of unsolicited cmd buffer */
Expand Down
6 changes: 3 additions & 3 deletions tests/test_cmd_list.c
Original file line number Diff line number Diff line change
Expand Up @@ -327,14 +327,14 @@ static void print_raw_text(char *p)

int main(int argc, char **argv)
{
struct cat_object at;
struct cat_object at;

cat_init(&at, &desc, &iface, NULL);
cat_init(&at, &desc, &iface, NULL);

prepare_input("\nAT#HELP\n");
while (cat_service(&at) != 0) {};

assert(strcmp(ack_results, "\nAT+V1?\nAT+V1=\nAT+V1=?\n\nAT+V1RO?\nAT+V1RO=?\n\nAT+V1RW=\nAT+V1RW=?\n\nAT+V11?\nAT+V11=\nAT+V11=?\n\nAT+V11RO?\nAT+V11RO=\nAT+V11RO=?\n\nAT+V11WO?\nAT+V11WO=\nAT+V11WO=?\n\nAT+V2?\nAT+V2=\nAT+V2=?\n\nAT+V3?\nAT+V3=\nAT+V3=?\n\nAT+V4?\nAT+V4=\nAT+V4=?\n\nAT+V5\nAT+V5?\nAT+V5=\nAT+V5=?\n\nAT+S2=\n\nAT+S3?\nAT+S3=\n\nAT+S4?\nAT+S4=\nAT+S4=?\n\nAT+S5\nAT+S5?\nAT+S5=\nAT+S5=?\n\nAT+T1=?\n\nAT#HELP\n\nOK\n") == 0);

return 0;
return 0;
}
4 changes: 2 additions & 2 deletions tests/test_hold_state.c
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ int main(int argc, char **argv)
{
cat_status s;

cat_init(&at, &desc, &iface, NULL);
cat_init(&at, &desc, &iface, NULL);

prepare_input(test_case_1);
while (cat_service(&at) != 0) {};
Expand All @@ -225,5 +225,5 @@ int main(int argc, char **argv)
assert(strcmp(cmd_results, " write:+CMD read1:+U1CMD read1:+U1CMD read1:+U1CMD write:+CMD read2:+U2CMD read2:+U2CMD read2:+U2CMD read2:+U2CMD") == 0);
assert(strcmp(var_read_results, " var_read:U1 var_read:U1 var_read:U1 var_read:U2 var_read:U2 var_read:U2 var_read:U2") == 0);

return 0;
return 0;
}
6 changes: 3 additions & 3 deletions tests/test_mutex.c
Original file line number Diff line number Diff line change
Expand Up @@ -150,9 +150,9 @@ static const char test_case_1[] = "\nAT\nAT+test\n";

int main(int argc, char **argv)
{
struct cat_object at;
struct cat_object at;

cat_init(&at, &desc, &iface, &mutex);
cat_init(&at, &desc, &iface, &mutex);

prepare_input(test_case_1);
while (cat_service(&at) != 0) {};
Expand Down Expand Up @@ -181,5 +181,5 @@ int main(int argc, char **argv)
assert(cat_service(&at) == CAT_STATUS_OK);
assert(cat_is_busy(&at) == CAT_STATUS_OK);

return 0;
return 0;
}
6 changes: 3 additions & 3 deletions tests/test_order.c
Original file line number Diff line number Diff line change
Expand Up @@ -193,9 +193,9 @@ static const char test_case_1[] = "\nATE\n\nATE0\n\nATE1\n";

int main(int argc, char **argv)
{
struct cat_object at;
struct cat_object at;

cat_init(&at, &desc_1, &iface, NULL);
cat_init(&at, &desc_1, &iface, NULL);

prepare_input(test_case_1);
while (cat_service(&at) != 0) {};
Expand All @@ -219,5 +219,5 @@ int main(int argc, char **argv)
assert(strcmp(ack_results, "\nOK\n\nOK\n\nOK\n") == 0);
assert(strcmp(run_results, " E:E E0:E0 E1:E1") == 0);

return 0;
return 0;
}
6 changes: 3 additions & 3 deletions tests/test_parse.c
Original file line number Diff line number Diff line change
Expand Up @@ -132,9 +132,9 @@ static const char test_case_1[] = "\nsa\rAT\n\r\nAT\nAT+\n\nATA\r\natap\naaaattt

int main(int argc, char **argv)
{
struct cat_object at;
struct cat_object at;

cat_init(&at, &desc, &iface, NULL);
cat_init(&at, &desc, &iface, NULL);

prepare_input(test_case_1);
while (cat_service(&at) != 0) {};
Expand Down Expand Up @@ -191,5 +191,5 @@ int main(int argc, char **argv)
assert(strcmp(ack_results, "\nERROR\n\nERROR\n\nERROR\n") == 0);
assert(strcmp(run_results, "") == 0);

return 0;
return 0;
}
6 changes: 3 additions & 3 deletions tests/test_read.c
Original file line number Diff line number Diff line change
Expand Up @@ -150,9 +150,9 @@ static const char test_case_1[] = "\nAT\r\nAT+\nAT+?\nATA?\r\nATAP\nATAP?\nATAPA

int main(int argc, char **argv)
{
struct cat_object at;
struct cat_object at;

cat_init(&at, &desc, &iface, NULL);
cat_init(&at, &desc, &iface, NULL);

prepare_input(test_case_1);
while (cat_service(&at) != 0) {};
Expand All @@ -161,5 +161,5 @@ int main(int argc, char **argv)
assert(strcmp(run_results, " A_A") == 0);
assert(strcmp(read_results, " A:A AP:AP +TEST:+TEST +TEST:+TEST") == 0);

return 0;
return 0;
}
6 changes: 3 additions & 3 deletions tests/test_read_args.c
Original file line number Diff line number Diff line change
Expand Up @@ -196,9 +196,9 @@ static const char test_case_2[] = "\nAT+TEST?\n";

int main(int argc, char **argv)
{
struct cat_object at;
struct cat_object at;

cat_init(&at, &desc, &iface, NULL);
cat_init(&at, &desc, &iface, NULL);

prepare_input(test_case_1);
while (cat_service(&at) != 0) {};
Expand All @@ -212,5 +212,5 @@ int main(int argc, char **argv)
assert(strcmp(ack_results, "\n+TEST=test\n\nOK\n") == 0);
assert(common_cntr == 7);

return 0;
return 0;
}
6 changes: 3 additions & 3 deletions tests/test_return_read.c
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ int main(int argc, char **argv)
{
cat_status s;

cat_init(&at, &desc, &iface, NULL);
cat_init(&at, &desc, &iface, NULL);

ret = CAT_RETURN_STATE_ERROR;
prepare_input(test_case_1);
Expand All @@ -171,7 +171,7 @@ int main(int argc, char **argv)

assert(strcmp(ack_results, "\n+CMD=1\n\n+CMD=2\n\nOK\n") == 0);
assert(strcmp(cmd_results, " read:+CMD read:+CMD") == 0);

ret = CAT_RETURN_STATE_NEXT;
prepare_input(test_case_1);
while (cat_service(&at) != 0) {};
Expand Down Expand Up @@ -202,5 +202,5 @@ int main(int argc, char **argv)
assert(strcmp(ack_results, "\n+CMD=1\n\n+CMD=2\n\ntest\n\nERROR\n") == 0);
assert(strcmp(cmd_results, " read:+CMD read:+CMD read:+CMD read:+CMD read:+CMD") == 0);

return 0;
return 0;
}
6 changes: 3 additions & 3 deletions tests/test_return_run.c
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ int main(int argc, char **argv)
{
cat_status s;

cat_init(&at, &desc, &iface, NULL);
cat_init(&at, &desc, &iface, NULL);

ret = CAT_RETURN_STATE_ERROR;
prepare_input(test_case_1);
Expand Down Expand Up @@ -215,7 +215,7 @@ int main(int argc, char **argv)
assert(strcmp(ack_results, "\n+CMD=2\n\n+CMD=3\n\ntest\n\nERROR\n") == 0);
assert(strcmp(cmd_results, " run:+CMD read:+CMD read:+CMD read:+CMD read:+CMD") == 0);
assert(var_x == 6);

ret = CAT_RETURN_STATE_HOLD_EXIT_ERROR;
prepare_input(test_case_1);
while (cat_service(&at) != 0) {};
Expand All @@ -232,5 +232,5 @@ int main(int argc, char **argv)
assert(strcmp(cmd_results, " run:+CMD") == 0);
assert(var_x == 2);

return 0;
return 0;
}
6 changes: 3 additions & 3 deletions tests/test_return_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ int main(int argc, char **argv)
{
cat_status s;

cat_init(&at, &desc, &iface, NULL);
cat_init(&at, &desc, &iface, NULL);

ret = CAT_RETURN_STATE_ERROR;
prepare_input(test_case_1);
Expand All @@ -171,7 +171,7 @@ int main(int argc, char **argv)

assert(strcmp(ack_results, "\n+CMD=<X:INT32[RW]>\n\n+CMD=<X:INT32[RW]>\n\nOK\n") == 0);
assert(strcmp(cmd_results, " test:+CMD test:+CMD") == 0);

ret = CAT_RETURN_STATE_NEXT;
prepare_input(test_case_1);
while (cat_service(&at) != 0) {};
Expand Down Expand Up @@ -202,5 +202,5 @@ int main(int argc, char **argv)
assert(strcmp(ack_results, "\n+CMD=<X:INT32[RW]>\n\n+CMD=<X:INT32[RW]>\n\ntest\n\nERROR\n") == 0);
assert(strcmp(cmd_results, " test:+CMD test:+CMD test:+CMD test:+CMD test:+CMD") == 0);

return 0;
return 0;
}
6 changes: 3 additions & 3 deletions tests/test_return_write.c
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ int main(int argc, char **argv)
{
cat_status s;

cat_init(&at, &desc, &iface, NULL);
cat_init(&at, &desc, &iface, NULL);

ret = CAT_RETURN_STATE_ERROR;
prepare_input(test_case_1);
Expand Down Expand Up @@ -215,7 +215,7 @@ int main(int argc, char **argv)
assert(strcmp(ack_results, "\n+CMD=2\n\n+CMD=3\n\ntest\n\nERROR\n") == 0);
assert(strcmp(cmd_results, " write:+CMD read:+CMD read:+CMD read:+CMD read:+CMD") == 0);
assert(var_x == 6);

ret = CAT_RETURN_STATE_HOLD_EXIT_ERROR;
prepare_input(test_case_1);
while (cat_service(&at) != 0) {};
Expand All @@ -232,5 +232,5 @@ int main(int argc, char **argv)
assert(strcmp(cmd_results, " write:+CMD") == 0);
assert(var_x == 2);

return 0;
return 0;
}
8 changes: 4 additions & 4 deletions tests/test_run.c
Original file line number Diff line number Diff line change
Expand Up @@ -143,15 +143,15 @@ static const char test_case_1[] = "\nAT\nAT+\nATA\r\nATAP\nATAPA\nAT+TEST\nAT+te

int main(int argc, char **argv)
{
struct cat_object at;
struct cat_object at;

cat_init(&at, &desc, &iface, NULL);
cat_init(&at, &desc, &iface, NULL);

prepare_input(test_case_1);
while (cat_service(&at) != 0) {};

assert(strcmp(ack_results, "\nOK\n\nERROR\n\r\nOK\r\n\nOK\n\nERROR\n\nOK\n\nOK\n\nERROR\n\nERROR\n\nERROR\n\nERROR\n") == 0);
assert(strcmp(run_results, " A:A AP:AP +TEST:+TEST +TEST:+TEST FORCE:FORCE FORCE:FORCE") == 0);
return 0;

return 0;
}
Loading