]> rtime.felk.cvut.cz Git - pes-rpp/rpp-test-sw.git/commitdiff
Command for FlexRay buffer reconfiguratin add
authorMichal Horn <hornmich@fel.cvut.cz>
Mon, 9 Sep 2013 15:49:26 +0000 (17:49 +0200)
committerMichal Horn <hornmich@fel.cvut.cz>
Mon, 9 Sep 2013 15:49:26 +0000 (17:49 +0200)
commands/cmd_fr_basic_test.c
rpp-lib

index e983fcea69e7eb04ad1742919c2d0587e07eaee8..454b81487b163d5146b6e6d5fb53c6ef32244514 100644 (file)
@@ -1757,6 +1757,64 @@ int cmd_do_fr_readcconfig(cmd_io_t *cmd_io, const struct cmd_des *des, char *par
        return 0;
 }
 
+/**
+ *     @brief  Reconfigure buffer
+ *
+ * @param[in]  cmd_io  Pointer to IO stack
+ * @param[in]  des             Pointer to command descriptor
+ * @param[in]  param   Parameters of command
+ * @return     0 when OK or error code
+ */
+int cmd_do_fr_reconfigure_buffer(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[]) {
+       int ret;
+       char channel[3];
+       unsigned id, slot, maxpayload, cycleset;
+       Fr_TMS570LS_BufferConfigType tmp_buffer;
+
+       ret = sscanf(param[2], "id%i slot%i %2s cyc%i max%i",
+                    &id,
+                    &slot,
+                    channel,
+                    &cycleset,
+                    &maxpayload
+                    );
+       if (ret != 5) {
+               printf("Error parsing parameter %d\n", ret+1);
+               return -CMDERR_BADPAR;
+       }
+
+       if (slot > 2047 || id > 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 (rpp_fr_reconfigure_lpdu(0, id, tmp_buffer.slotId, tmp_buffer.channel, tmp_buffer.cycleCounterFiltering, tmp_buffer.maxPayload) == SUCCESS) {
+               printf("frbtreconfigbuf id%i slot%i %2s cyc%i max%i",
+                            id,
+                            slot,
+                            channel,
+                            cycleset,
+                            maxpayload
+                            );
+               return 0;
+       }
+       else {
+               printf("Reconfiguration failed.\n");
+       }
+       return -CMDERR_BADPAR;
+}
+
 #endif /* DOCGEN */
 
 /** Command descriptor for FlexRay user config cluster command */
@@ -2604,6 +2662,37 @@ cmd_des_t const cmd_des_fr_readcconfig={
        CMD_HANDLER(cmd_do_fr_readcconfig), (void *)&cmd_list_fr_basic_test
 };
 
+/** Command descriptor for FlexRay reconfigure buffer command */
+cmd_des_t const cmd_des_fr_reconfigure_buffer={
+       0, 0,
+       "frbtreconfigurebuf*","Reconfigure a buffer to communicate in another slot",
+       "=== Command syntax ===\n"
+       "\n"
+       "   frbtreconfigurebuf id<ID> slot<SLOT> <CHN> cyc<CYC> max<MAX>\n"
+       "where\n"
+       "* <ID> is a number specifying a slot, where the buffer is currently communicating,\n"
+       "* <SLOT> is a number, where buffer will be communicating after the reconfiguration,\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"
+       "\n"
+       "=== Description ===\n"
+       "\n"
+       "The command stands for Fr_ReconfigLPDu function from the Autosar\n"
+       "specification. It reconfigures specified buffer to communicate in\n"
+       "different slot.\n"
+       "The reconfiguration must be allowed in node configuration parameter\n"
+       "secureBuffers. Buffers used for synchronization or assigned to the FIFO\n"
+       "are not reconfigurable.\n"
+       "\n"
+       "=== Example ===\n"
+       "\n"
+       "   --> frbtreconfigurebuf id2 slot3 AB 0 9\n"
+       "   frbtreconfigurebuf id2 slot3 AB 0 9\n",
+       CMD_HANDLER(cmd_do_fr_reconfigure_buffer), (void *)&cmd_list_fr_basic_test
+};
+
+
 /** List of commands for flexRay, defined as external */
 cmd_des_t const *cmd_list_fr_basic_test[]={
   &cmd_des_fr_user_config,
@@ -2634,5 +2723,6 @@ cmd_des_t const *cmd_list_fr_basic_test[]={
   &cmd_des_fr_timerirq,
   &cmd_des_fr_getversioninfo,
   &cmd_des_fr_readcconfig,
+  &cmd_des_fr_reconfigure_buffer,
   NULL
 };
diff --git a/rpp-lib b/rpp-lib
index c1a7057834c83faf784ca40bda9fecd42d62d9d9..04ff82f4ee453572e4128cf949d7db9443b29ef0 160000 (submodule)
--- a/rpp-lib
+++ b/rpp-lib
@@ -1 +1 @@
-Subproject commit c1a7057834c83faf784ca40bda9fecd42d62d9d9
+Subproject commit 04ff82f4ee453572e4128cf949d7db9443b29ef0