From d1317d01ba705596b86aebbdbdc72dfb21365b02 Mon Sep 17 00:00:00 2001 From: Bernhard Tittelbach Date: Wed, 11 Dec 2013 20:05:40 +0000 Subject: json stateless info update, topheater pwm, etc git-svn-id: https://svn.spreadspace.org/avr/trunk@249 aa12f405-d877-488e-9caf-2d797e2a1cc7 --- pcr-controller/cmd_queue.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'pcr-controller/cmd_queue.c') diff --git a/pcr-controller/cmd_queue.c b/pcr-controller/cmd_queue.c index 6d12296..9af0f8a 100644 --- a/pcr-controller/cmd_queue.c +++ b/pcr-controller/cmd_queue.c @@ -29,6 +29,7 @@ typedef struct { uint8_t num_args; + uint8_t cmd; void* function_ptr; int16_t input_list[CMDQ_INPUT_LIST_LEN]; uint8_t num_args_read; @@ -78,16 +79,17 @@ uint8_t cmdq_addCharToArgumentBuffer(uint8_t c) return 0; } -void cmdq_queueCmdWithNumArgs(void* fptr, uint8_t num_args) +void cmdq_queueCmdWithNumArgs(void* fptr, uint8_t num_args, uint8_t cmd) { if (num_args > CMDQ_INPUT_LIST_LEN) { - printf("{\"cmd_ok\":false,\"error\":\"max args == %d\"}\r\n", CMDQ_INPUT_LIST_LEN); - return; //can't do that Would hang cmdq + printf("{\"cmd\":\"%c\",\"cmd_ok\":false,\"error\":\"max args == %d\"}\r\n", cmd, CMDQ_INPUT_LIST_LEN); + return; //to continue would hang cmdq, so we don't } if ((cmd_queue_next_here_ +1) % CMQ_QUEUE_LENGTH == cmd_queue_todo_pos_) //for this check REQUIRED: CMQ_QUEUE_LENGTH > 2 cmdq_doWork(); //no more space in queue -> execute now ! cmd_queue_[cmd_queue_next_here_].num_args = num_args; + cmd_queue_[cmd_queue_next_here_].cmd = cmd; cmd_queue_[cmd_queue_next_here_].function_ptr = fptr; cmd_queue_[cmd_queue_next_here_].num_args_read = 0; cmd_queue_fillargs_pos_ = cmd_queue_next_here_; @@ -117,11 +119,13 @@ void cmdq_doWork(void) ((void(*)(int16_t,int16_t)) cmd_queue_[cmd_queue_todo_pos_].function_ptr)(cmd_queue_[cmd_queue_todo_pos_].input_list[0], cmd_queue_[cmd_queue_todo_pos_].input_list[1]); break; } + char cmd = cmd_queue_[cmd_queue_todo_pos_].cmd; cmd_queue_[cmd_queue_todo_pos_].num_args_read = 0; cmd_queue_[cmd_queue_todo_pos_].num_args = 0; cmd_queue_[cmd_queue_todo_pos_].function_ptr = 0; + cmd_queue_[cmd_queue_todo_pos_].cmd = 0; cmd_queue_todo_pos_++; cmd_queue_todo_pos_ %= CMQ_QUEUE_LENGTH; - printf("{\"cmd_ok\":true}\r\n"); + printf("{\"cmd\":\"%c\",\"cmd_ok\":true}\r\n",cmd); } -} \ No newline at end of file +} -- cgit v1.2.3