]> rtime.felk.cvut.cz Git - pes-rpp/rpp-test-sw.git/commitdiff
Commands parameters parsing was simplified, rpp-lib changes added.
authorMichal Horn <hornmich@fel.cvut.cz>
Fri, 9 Aug 2013 17:22:25 +0000 (19:22 +0200)
committerMichal Horn <hornmich@fel.cvut.cz>
Fri, 9 Aug 2013 17:22:25 +0000 (19:22 +0200)
commands/cmd_fr_basic_test.c
rpp-lib

index 52213813fb07845781f13ccbf057e1554d4697e1..4a21b1c17dcecfc513b327c5cae51cfde83d5140 100644 (file)
@@ -252,14 +252,12 @@ Fr_ConfigType Fr_config_node_B= {
  * @return     0 when OK or error code
  */
 int cmd_do_fr_init(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[]) {
-       char* p = NULL;
        const Fr_ConfigType* Fr_ConfigPtr = NULL;
 
-       p = param[1];
-       if (*p == 'A') {
+       if (*param[1] == 'A') {
                Fr_ConfigPtr = &Fr_config_node_A;
        }
-       else if (*p == 'B') {
+       else if (*param[1] == 'B') {
                Fr_ConfigPtr = &Fr_config_node_B;
        }
        else {
@@ -530,13 +528,11 @@ int cmd_do_fr_sendwup(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[]
 int cmd_do_fr_setwuchannel(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[]) {
        Std_ReturnType retVal = ERR_PARAM_NO_ERROR;
        Fr_ChannelType channel = FR_CHANNEL_A;
-       char* p = NULL;
 
-       p = param[1];
-       if (*p == 'A') {
+       if (*param[1] == 'A') {
                channel = FR_CHANNEL_A;
        }
-       else if (*p == 'B') {
+       else if (*param[1] == 'B') {
                channel = FR_CHANNEL_B;
        }
        else {
@@ -636,19 +632,16 @@ int cmd_do_fr_transmittxlpdu(cmd_io_t *cmd_io, const struct cmd_des *des, char *
        uint8_t dataLength;
        int values[MAX_PARAM_VALUES_NUM];
        uint8_t data[MAX_PARAM_VALUES_NUM];
-       char* p = NULL;
        char* token = NULL;
 
-       p=param[1];
-       if (sscanf(p, "%d", &slotID) != 1) {
+       if (sscanf(param[1], "%d", &slotID) != 1) {
                return -CMDERR_BADPAR;
        }
-       p=param[2];
-       if (sscanf(p, " %2x", &values[0]) != 1) {
+       if (sscanf(param[2], " %2x", &values[0]) != 1) {
                return -CMDERR_BADPAR;
        }
        data[0] = (uint8_t)values[0];
-       token = strtok(p, " ");
+       token = strtok(param[2], " ");
        token = strtok(NULL, " ");
        dataLength = 1;
        while (dataLength < MAX_PARAM_VALUES_NUM && token != NULL) {
@@ -690,10 +683,8 @@ int cmd_do_fr_transmittxlpdu(cmd_io_t *cmd_io, const struct cmd_des *des, char *
 int cmd_do_fr_canceltxlpdu(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[]) {
        Std_ReturnType retVal = ERR_PARAM_NO_ERROR;
        uint32_t slotID;
-       char* p = NULL;
 
-       p=param[1];
-       if (sscanf(p, "%d", &slotID) != 1) {
+       if (sscanf(param[1], "%d", &slotID) != 1) {
                return -CMDERR_BADPAR;
        }
        if (param[2] != NULL) {
@@ -731,14 +722,12 @@ int cmd_do_fr_canceltxlpdu(cmd_io_t *cmd_io, const struct cmd_des *des, char *pa
 int cmd_do_fr_receiverxlpdu(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[]) {
        Std_ReturnType retVal = ERR_PARAM_NO_ERROR;
        uint32_t slotID;
-       char* p = NULL;
        uint8_t data[cPayloadLengthMax];
        Fr_RxLPduStatusType status;
        uint8_t receivedLength = 0;
        uint8_t i;
 
-       p=param[1];
-       if (sscanf(p, "%d", &slotID) != 1) {
+       if (sscanf(param[1], "%d", &slotID) != 1) {
                return -CMDERR_BADPAR;
        }
        if (param[2] != NULL) {
@@ -788,12 +777,10 @@ int cmd_do_fr_receiverxlpdu(cmd_io_t *cmd_io, const struct cmd_des *des, char *p
 int cmd_do_fr_checktxlpdustatus(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[]) {
        Std_ReturnType retVal = ERR_PARAM_NO_ERROR;
        uint32_t slotID;
-       char* p = NULL;
        Fr_TxLPduStatusType status;
        char* statusStrings[] = {"was", "was not yet"};
 
-       p=param[1];
-       if (sscanf(p, "%d", &slotID) != 1) {
+       if (sscanf(param[1], "%d", &slotID) != 1) {
                return -CMDERR_BADPAR;
        }
        if (param[2] != NULL) {
@@ -831,10 +818,8 @@ int cmd_do_fr_checktxlpdustatus(cmd_io_t *cmd_io, const struct cmd_des *des, cha
 int cmd_do_fr_disablelpdu(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[]) {
        Std_ReturnType retVal = ERR_PARAM_NO_ERROR;
        uint32_t slotID;
-       char* p = NULL;
 
-       p=param[1];
-       if (sscanf(p, "%d", &slotID) != 1) {
+       if (sscanf(param[1], "%d", &slotID) != 1) {
                return -CMDERR_BADPAR;
        }
        if (param[2] != NULL) {
@@ -1035,10 +1020,8 @@ int cmd_do_fr_getsyncframelist(cmd_io_t *cmd_io, const struct cmd_des *des, char
        uint16_t channelBOddList[FR_MAX_SYNC_FRAME_LIST_SIZE];
        uint32_t listSize = 0;
        uint8_t i;
-       char* p = NULL;
 
-       p=param[1];
-       if (sscanf(p, "%d", &listSize) != 1) {
+       if (sscanf(param[1], "%d", &listSize) != 1) {
                return -CMDERR_BADPAR;
        }
        if (param[2] != NULL) {
@@ -1127,15 +1110,12 @@ int cmd_do_fr_settimer(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[
        int timer = 0;
        int cycle = 0;
        int offset = 0;
-       char* p = NULL;
        char* token = NULL;
 
-       p=param[1];
-       if (sscanf(p, "%d", &timer) != 1) {
+       if (sscanf(param[1], "%d", &timer) != 1) {
                return -CMDERR_BADPAR;
        }
-       p=param[2];
-       if ((token = strtok(p, " ")) == NULL) {
+       if ((token = strtok(param[2], " ")) == NULL) {
                return -CMDERR_BADPAR;
        }
        if (sscanf(token, " %d", &cycle) != 1) {
@@ -1181,10 +1161,8 @@ int cmd_do_fr_settimer(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[
 int cmd_do_fr_canceltimer(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[]) {
        Std_ReturnType retVal = ERR_PARAM_NO_ERROR;
        int timer = 0;
-       char* p = NULL;
 
-       p=param[1];
-       if (sscanf(p, "%d", &timer) != 1) {
+       if (sscanf(param[1], "%d", &timer) != 1) {
                return -CMDERR_BADPAR;
        }
 
diff --git a/rpp-lib b/rpp-lib
index de5a3233f069673cf99533c57b74780195d53d65..5e8aff91b83bfdabd975b32e5bddb33e268bf88f 160000 (submodule)
--- a/rpp-lib
+++ b/rpp-lib
@@ -1 +1 @@
-Subproject commit de5a3233f069673cf99533c57b74780195d53d65
+Subproject commit 5e8aff91b83bfdabd975b32e5bddb33e268bf88f