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 */
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,
&cmd_des_fr_timerirq,
&cmd_des_fr_getversioninfo,
&cmd_des_fr_readcconfig,
+ &cmd_des_fr_reconfigure_buffer,
NULL
};