]> rtime.felk.cvut.cz Git - pes-rpp/rpp-test-sw.git/commitdiff
New command for FlexRay FIFO creation.
authorMichal Horn <hornmich@fel.cvut.cz>
Wed, 4 Sep 2013 10:44:13 +0000 (12:44 +0200)
committerMichal Horn <hornmich@fel.cvut.cz>
Wed, 4 Sep 2013 10:44:13 +0000 (12:44 +0200)
Parameters structure chaged to be the same as for static and dynamic segment buffers.
Old FIFO configuration code removed.
Functions names rpp prefixes for user configuration changed to cmd prefix.
FIFO buffers parameters in demo commands was modified.

commands/cmd_fr_basic_test.c
commands/fray_demo.txt
rpp-lib

index c5aab48a4c08b26d88e233fecb22e8ea5ec9f315..f10f2ce018ecc72b49de12649dc5252ea76eef5c 100644 (file)
@@ -568,7 +568,7 @@ static uint8_t user_fifo_buffer_depth = 0;
  * @return SUCCESS when all parameters were converted to the array of numbers,
  *         FAILURE when the string was too short, too long or some other error occurred.
  */
-static int8_t rpp_fr_parse_params(const char* params, uint32_t params_cnt, uint32_t* tmp_params) {
+static int8_t cmd_fr_parse_params(const char* params, uint32_t params_cnt, uint32_t* tmp_params) {
        char cpy_params[256];
        char* token;
        int i;
@@ -592,10 +592,10 @@ static int8_t rpp_fr_parse_params(const char* params, uint32_t params_cnt, uint3
        return SUCCESS;
 }
 
-int8_t rpp_fr_config_cluster_params(const char* params) {
+int8_t cmd_fr_config_cluster_params(const char* params) {
        uint32_t tmp_params[FR_CLUSTER_PARAMS_CNT];
 
-       if (rpp_fr_parse_params(params, FR_CLUSTER_PARAMS_CNT, tmp_params) == FAILURE) {
+       if (cmd_fr_parse_params(params, FR_CLUSTER_PARAMS_CNT, tmp_params) == FAILURE) {
                return FAILURE;
        }
 
@@ -629,12 +629,12 @@ int8_t rpp_fr_config_cluster_params(const char* params) {
        return SUCCESS;
 }
 
-int8_t rpp_fr_config_node_params(const char* params) {
+int8_t cmd_fr_config_node_params(const char* params) {
        uint32_t tmp_params[FR_NODE_PARAMS_CNT+2];      // +2 because two more parameters from message RAM structure are expected in the string.
        Fr_ChannelType channels[3] = {FR_CHANNEL_A, FR_CHANNEL_B, FR_CHANNEL_AB};
        Fr_TMS570LS_SecureBuffersType secure[4] = {FR_SB_RECONFIG_ENABLED, FR_SB_STAT_REC_DISABLED_STAT_TR_DISABLED, FR_SB_ALL_REC_DISABLED, FR_SB_ALL_REC_DISABLED_STAT_TR_DISABLED};
 
-       if (rpp_fr_parse_params(params, FR_NODE_PARAMS_CNT+2, tmp_params) == FAILURE) {
+       if (cmd_fr_parse_params(params, FR_NODE_PARAMS_CNT+2, tmp_params) == FAILURE) {
                return FAILURE;
        }
 
@@ -674,6 +674,89 @@ int8_t rpp_fr_config_node_params(const char* params) {
        return SUCCESS;
 }
 
+int cmd_do_fr_config_fifo(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[]) {
+       Fr_TMS570LS_BufferConfigType* fifo_buffer_ptr = &user_fifo_buffer_config[0];
+       int ret, i;
+       char channel[3], rej_static_frames[8], rej_null_frames[8];
+       unsigned depth, slot, cycleset, maxpayload, intr;
+       Fr_TMS570LS_BufferConfigType tmp_buffer;
+
+       ret = sscanf(param[2], "slot%i depth%i %2s cyc%i max%i %10s %10s int%i",
+                    &slot,
+                    &depth,
+                    channel,
+                    &cycleset,
+                    &maxpayload,
+                    rej_null_frames,
+                    rej_static_frames,
+                    &intr
+                    );
+       if (ret != 8) {
+               printf("Error parsing parameter %d\n", ret+1);
+               return -CMDERR_BADPAR;
+       }
+
+       if (depth < 1 || depth >= RPP_FR_MAX_FIFO_BUF_DEPTH)
+               return badpar("Depth too high\n");
+       user_fifo_buffer_depth = depth;
+
+       if (slot > 2047)
+               return badpar("Invalid slot number\n");
+       tmp_buffer.slotId = slot;
+       if (strcmp(channel, "A") == 0) tmp_buffer.channel = FR_CHANNEL_A;
+       else if (strcmp(channel, "B") == 0) tmp_buffer.channel = FR_CHANNEL_B;
+       else if (strcmp(channel, "AB") == 0) tmp_buffer.channel = FR_CHANNEL_AB;
+       else return badpar("Channel parsing error\n");
+       
+       if (cycleset >= 0x80)
+               return badpar("Cycle set must be less than 0x80.\n");
+       tmp_buffer.cycleCounterFiltering = cycleset;
+
+       if (maxpayload >= 128)
+               return badpar("Maximum payload in half-words must be less than 128\n");
+       tmp_buffer.maxPayload = maxpayload;
+       
+       if (strcmp(rej_null_frames, "rejnull") == 0) tmp_buffer.rejectNullFrames = true;
+       else if (strcmp(rej_null_frames, "accnull") == 0) tmp_buffer.rejectNullFrames = false;
+       else return badpar("Reject/accept NULL frames parsing error\n");
+
+       if (strcmp(rej_static_frames, "rejstat") == 0)
+               tmp_buffer.rejectStaticSegment = true;
+       else if (strcmp(rej_static_frames, "accstat") == 0)
+               tmp_buffer.rejectStaticSegment = false;
+       else return badpar("Invalid reject/accept static frame parameter");
+
+       if (intr > 1)
+               return badpar("Interrupt parameter must be 0 or 1");
+       tmp_buffer.msgBufferInterrupt = intr;
+
+       for (i = 0; i < user_fifo_buffer_depth; i++) {
+               fifo_buffer_ptr[i].slotId = tmp_buffer.slotId;  
+               fifo_buffer_ptr[i].maxPayload = tmp_buffer.maxPayload;
+               fifo_buffer_ptr[i].channel= tmp_buffer.channel;
+               fifo_buffer_ptr[i].cycleCounterFiltering = tmp_buffer.cycleCounterFiltering;
+               fifo_buffer_ptr[i].isTx = FALSE;
+               fifo_buffer_ptr[i].singleTransmit = FALSE;
+               fifo_buffer_ptr[i].payloadPreambleIndicatorTr = FALSE;
+               fifo_buffer_ptr[i].rejectNullFrames = tmp_buffer.rejectNullFrames;
+               fifo_buffer_ptr[i].rejectStaticSegment = tmp_buffer.rejectStaticSegment;
+               fifo_buffer_ptr[i].msgBufferInterrupt = tmp_buffer.msgBufferInterrupt;
+       }
+
+       printf("frbtcfgfifo slot%i depth%i %2s cyc%i max%i %10s %10s int%i\n",
+                    slot,
+                    depth,
+                    channel,
+                    cycleset,
+                    maxpayload,
+                    rej_null_frames,
+                    rej_static_frames,
+                    intr
+               );
+       
+       return SUCCESS;
+}
+
 int cmd_do_fr_config_bufer(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[])
 {
        Fr_TMS570LS_BufferConfigType *cfg;
@@ -681,6 +764,7 @@ int cmd_do_fr_config_bufer(cmd_io_t *cmd_io, const struct cmd_des *des, char *pa
        int ret;
        char buf_type, channel[3],rxtx[3], single_continuous[11];
        unsigned buffer, slot, cycleset, maxpayload, intr, preamb;
+       
        ret = sscanf(param[1], "%c%i slot%i %2s cyc%i %2s max%i %10s ppi%i int%i",
                     &buf_type,
                     &buffer,
@@ -693,12 +777,12 @@ int cmd_do_fr_config_bufer(cmd_io_t *cmd_io, const struct cmd_des *des, char *pa
                     &preamb,
                     &intr
                     );
-
        if (ret != 10) {
                printf("Error parsing parameter %d\n", ret+1);
                return -CMDERR_BADPAR;
+       
        }
-
+       
        switch (buf_type) {
        case 'S':
                if (buffer >= RPP_FR_MAX_STATIC_BUF_CNT)
@@ -780,34 +864,6 @@ int cmd_do_fr_config_bufer(cmd_io_t *cmd_io, const struct cmd_des *des, char *pa
        return 0;
 }
 
-int8_t rpp_fr_config_fifo_buffer(const char* params) {
-       uint32_t tmp_params[FR_FIFO_BUF_PARAMS_CNT+1];  // +1 because the first parameter in the string means the depth of the buffer, and the constant means the number of items in the configuration structure.
-       Fr_ChannelType channels[3] = {FR_CHANNEL_A, FR_CHANNEL_B, FR_CHANNEL_AB};
-       Fr_TMS570LS_BufferConfigType* fifo_buffer_ptr = &user_fifo_buffer_config[0];
-
-       if (user_fifo_buffer_depth != 0) {
-               return FAILURE;
-       }
-
-       if (rpp_fr_parse_params(params, FR_FIFO_BUF_PARAMS_CNT+1, tmp_params) == FAILURE) {
-               return FAILURE;
-       }
-
-       if (tmp_params[0] > RPP_FR_MAX_FIFO_BUF_DEPTH) return FAILURE;
-       if (tmp_params[1] > 2) return FAILURE;
-
-       for (fifo_buffer_ptr = &user_fifo_buffer_config[0]; fifo_buffer_ptr < &user_fifo_buffer_config[tmp_params[0]]; fifo_buffer_ptr++) {
-               fifo_buffer_ptr->channel = channels[ tmp_params[1] ];
-               fifo_buffer_ptr->cycleCounterFiltering = tmp_params[2];
-               fifo_buffer_ptr->maxPayload = tmp_params[3];
-               fifo_buffer_ptr->rejectNullFrames = tmp_params[4];
-               fifo_buffer_ptr->rejectStaticSegment = tmp_params[5];
-               fifo_buffer_ptr->slotId = tmp_params[6];
-       }
-       user_fifo_buffer_depth = tmp_params[0];
-
-       return SUCCESS;
-}
 
 
 /**
@@ -822,26 +878,19 @@ int cmd_do_fr_user_config(cmd_io_t *cmd_io, const struct cmd_des *des, char *par
        char* token;
        token = strtok(param[1], " ");
        if (strcmp(token, "cluster") == 0) {
-               if (rpp_fr_config_cluster_params(param[2]) == FAILURE) {
+               if (cmd_fr_config_cluster_params(param[2]) == FAILURE) {
                        rpp_sci_printf("FlexRay cluster configuration not accepted.\n");
                        return -CMDERR_BADPAR;
                }
                rpp_sci_printf("FlexRay cluster configuration accepted.\n");
        }
        else if (strcmp(token, "node") == 0) {
-               if (rpp_fr_config_node_params(param[2]) == FAILURE) {
+               if (cmd_fr_config_node_params(param[2]) == FAILURE) {
                        rpp_sci_printf("FlexRay node configuration not accepted.\n");
                        return -CMDERR_BADPAR;
                }
                rpp_sci_printf("FlexRay node configuration accepted.\n");
        }
-       else if (strcmp(token, "fifo") == 0) {
-               if (rpp_fr_config_fifo_buffer(param[2]) == FAILURE) {
-                       rpp_sci_printf("FIFO buffer configuration not accepted.\n");
-                       return -CMDERR_BADPAR;
-               }
-               rpp_sci_printf("FIFO buffer configuration accepted.\n");
-       }
        else {
                return -CMDERR_BADPAR;
        }
@@ -1718,7 +1767,7 @@ cmd_des_t const cmd_des_fr_user_config={
        "\n"
        "   frbtconfig<TYPE> <PARAMS>\n"
        "where\n"
-       "* <TYPE> is a string specifying the type of parameters to be set. It can be: \"cluster\", \"node\", or \"fifo\",\n"
+       "* <TYPE> is a string specifying the type of parameters to be set. It can be: \"cluster\" or  \"node\"\n"
        "* <PARAMS> is a sequence of numbers separated by spaces. Each number stands for one parameter.\n"
        "\n"
        "=== Description ===\n"
@@ -1791,17 +1840,6 @@ cmd_des_t const cmd_des_fr_user_config={
        "* 27) syncFramePayloadMultiplexEnabled\n"
        "* 28) secureBuffers (0 - FR_SB_RECONFIG_ENABLED, 1 - FR_SB_STAT_REC_DISABLED_STAT_TR_DISABLED, 2 - FR_SB_ALL_REC_DISABLED, 3 - FR_SB_ALL_REC_DISABLED_STAT_TR_DISABLED)\n"
        "\n"
-       "Type \"fifo\" adds a configuration of a new FIFO buffer. No FIFO\n"
-       "buffer is obligatory. It expects a sequence of 7 parameters in this\n"
-       "order:\n"
-       "*1) depth of the FIFO\n"
-       "*2) channel (0 - A, 1 - B, 2 - AB)\n"
-       "*3) cycleCounterFiltering\n"
-       "*4) maxPayload (number of 16b words)\n"
-       "*5) rejectNullFrames\n"
-       "*6) rejectStaticSegment\n"
-       "*7) slotId\n"
-       "\n"
        "=== Example ===\n"
        "\n"
        "   --> frbtconfigcluster 0x2 0xF 0x15E0 0xF 0xF 0xC 0x15A 0x8 0xAE4 0x9 0xF 0x4 0x43 0x1 0x4 0x2 0xAE3 0x0 0x56 0xA 0x12 0x12 0x4C 0xB4 0x3C\n"
@@ -1827,7 +1865,7 @@ cmd_des_t const cmd_des_fr_config_buffer={
        "* <MAX> is the number determining the maximum payload (in hald-words),\n"
        "* <REP> is a string \"s\" or \"single\" for single transmission or \"c\" or \"continuous\" for continuous transmission,\n"
        "* <PPI> is 0 or 1 determining whether the payload preamble indicator is set,\n"
-       "* <INT> is 0 or 1 add is currently ignored.\n"
+       "* <INT> is 0 or 1 and is currently ignored.\n"
        "\n"
        "=== Description ===\n"
        "\n"
@@ -1849,6 +1887,35 @@ cmd_des_t const cmd_des_fr_config_buffer={
        CMD_HANDLER(cmd_do_fr_config_bufer), (void *)&cmd_list_fr_basic_test
 };
 
+cmd_des_t const cmd_des_fr_config_fifo={
+       0, 0,
+       "frbtcfgfifo*","Configure a RX FIFO message buffer in the user configuration",
+       "=== Command syntax ===\n"
+       "\n"
+       "   frbtcfgfifo slot<SLOT> depth<DEPTH> <CHN> cyc<CYC> max<MAX> <REJNULL> <REJSTAT> int<INT>\n"
+       "where\n"
+       "* <SLOT> is the number of the slot,\n"
+       "* <DEPTH> is a number specifying the depth of the FIFO,\n"
+       "* <CHN> is one of 'A', 'B' or 'AB' and identifies the used channel,\n"
+       "* <CYC> is the cycle set when to send the buffer,\n"
+       "* <MAX> is the number determining the maximum payload (in hald-words),\n"
+       "* <REJNULL> is a string \"rejnull\" for rejecting NULL frames or \"accnull\" for accepting NULL frames,\n"
+       "* <REJSTAT> is a string \"rejstat\" for rejecting frames in static segment or \"accstat\" for accepting frames from static segment,\n"
+       "* <INT> is 0 or 1 and is currently ignored.\n"
+       "\n"
+       "=== Description ===\n"
+       "\n"
+       "The command sets the configuration parameters for RX FIFO buffer\n"
+       "in user configuration. The parameters set by this command are\n"
+       "applied by the frbtinitU command. Once frbtinit is called, it is no\n"
+       "longer possible to change the parameters.\n"
+       "\n"
+       "=== Example ===\n"
+       "\n"
+       "   --> frbtcfgfifo slot0 depth5 AB cyc0 max20 rejnull accstat int1\n"
+       "   frbtcfgfifo slot0 depth5 AB cyc0 max20  rejnull accstat int1\n",
+       CMD_HANDLER(cmd_do_fr_config_fifo), (void *)&cmd_list_fr_basic_test
+};
 
 /** Command descriptor for FlexRay init command */
 cmd_des_t const cmd_des_fr_init={
@@ -2538,6 +2605,7 @@ cmd_des_t const cmd_des_fr_readcconfig={
 cmd_des_t const *cmd_list_fr_basic_test[]={
   &cmd_des_fr_user_config,
   &cmd_des_fr_config_buffer,
+  &cmd_des_fr_config_fifo,
   &cmd_des_fr_init,
   &cmd_des_fr_start,
   &cmd_des_fr_allslots,
index 02b563810eeeb682a88de3478746f07ea166aa69..9cd74adcf9adb54ce00b8bcc4df3bebc45393d17 100644 (file)
@@ -47,8 +47,7 @@ Node init:
        frbtcfgbufD0  slot9  A cyc0 tx max0x40 single ppi0 int0
        frbtcfgbufD1  slot10 A cyc0 rx max0x40 single ppi0 int0
        ## RX FIFO buffer
-       #                  dpt ch  cyc  pl  rnf rsf fid
-       frbtconfigfifo 0x5 0x2 0x0 0x20 0x1 0x0 0x0
+       frbtcfgfifo slot0 depth5 A cyc0 max0x20 rejnull accstat int0
        # FlexRay start
        frbtinitU
        frbtstart
@@ -70,8 +69,7 @@ Node init:
        frbtcfgbufD0  slot9  A cyc0 rx max0x40 single ppi0 int0
        frbtcfgbufD1  slot10 A cyc0 tx max0x40 single ppi0 int0
        ## RX FIFO buffer
-    #              dpt ch  cyc  pl  rnf rsf fid
-       frbtconfigfifo 0x5 0x2 0x0 0x20 0x1 0x0 0x0
+       frbtcfgfifo slot0 depth5 A cyc0 max0x20 rejnull accstat int1
        # FlexRay start
        frbtinitU
        frbtstart
diff --git a/rpp-lib b/rpp-lib
index 7518e2d62865494cc507982d331d43c61515868e..621be2ce28d6b5d6c7a5242310ea437ff96dd232 160000 (submodule)
--- a/rpp-lib
+++ b/rpp-lib
@@ -1 +1 @@
-Subproject commit 7518e2d62865494cc507982d331d43c61515868e
+Subproject commit 621be2ce28d6b5d6c7a5242310ea437ff96dd232