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;
+ unsigned id, slot, maxpayload, cycleset, cycleoffset;
Fr_TMS570LS_BufferConfigType tmp_buffer;
+ boolean_t is_pow2;
+ uint8_t pow2;
- ret = sscanf(param[2], "id%i slot%i %2s cyc%i max%i",
+ ret = sscanf(param[2], "id%i slot%i %2s cycset%i cycoffset%i max%i",
&id,
&slot,
channel,
&cycleset,
+ &cycleoffset,
&maxpayload
);
- if (ret != 5) {
+ if (ret != 6) {
printf("Error parsing parameter %d\n", ret+1);
return -CMDERR_BADPAR;
}
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 == 0) cycleset = 1;
+ for (pow2 = 1, is_pow2 = FALSE; pow2 < 128; pow2*=2) {
+ if (cycleset == pow2) {
+ is_pow2 = TRUE;
+ break;
+ }
+ }
+ if (!is_pow2) {
+ return badpar("Cycle set must be one of 0, 1, 2, 4, 8, 16, 32, 64.\n");
+ }
+ if (cycleoffset >= cycleset) {
+ return badpar("Cycle offset must in range 0 - cycset-1.\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");
+ if (maxpayload >= 256)
+ return badpar("Maximum payload in bytes must be less than 256\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\n",
+ if (rpp_fr_reconfigure_lpdu(0, id, tmp_buffer.slotId, tmp_buffer.channel, cycleset, cycleoffset, tmp_buffer.maxPayload, 0) == SUCCESS) {
+ printf("id%i slot%i %2s cycset%i cycoffset%i max%i\n",
id,
slot,
channel,
cycleset,
+ cycleoffset,
maxpayload
);
return 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"
+ " frbtreconfigurebuf id<ID> slot<SLOT> <CHN> cycset<CYCS> cycoffset<CYCO> 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"
+ "* <CYCS> is the cycle set. It has to be one of 0, 1, 2, 4, 8, 16, 32, 64. It specifies together with <CYCO> the cycle filtering.\n"
+ "* <CYCO> is the cycle offset. It has to be in range 0 - <CYCS>-1"
"* <MAX> is the number determining the maximum payload (in hald-words).\n"
"\n"
"=== Description ===\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"
+ "The command can be called any time when the communication is running.\n"
"\n"
"=== Example ===\n"
"\n"
- " --> frbtreconfigurebuf id2 slot3 AB 0 9\n"
- " frbtreconfigurebuf id2 slot3 AB 0 9\n",
+ " --> frbtreconfigurebuf id2 slot3 AB cycset1 cycoffset0 max9\n"
+ " frbtreconfigurebuf id2 slot3 AB cycset1 cycoffset0 max9\n",
CMD_HANDLER(cmd_do_fr_reconfigure_buffer), (void *)&cmd_list_fr_basic_test
};
Node C
simulink demo fray_motor_demo
-
-
+FlexRay commands example
+===========================================
Node init:
------------
#Node A configuration
frbtcfgbufS3 slot5 AB cyc0 rx max9 continuous ppi1 int1
frbtcfgbufS4 slot4 AB cyc0 tx max9 continuous ppi1 int1
## Dynamic buffers for TX and RX, single shot mode
- frbtcfgbufD0 slot9 A cyc0 tx max0x40 single ppi0 int0
- frbtcfgbufD1 slot10 A cyc0 rx max0x40 single ppi0 int0
+ frbtcfgbufD0 slot9 A cyc0 tx max9 single ppi0 int0
+ frbtcfgbufD1 slot10 A cyc0 rx max9 single ppi0 int0
## RX FIFO buffer to accept messages from all aother slots
frbtcfgfifo rejslot0 slotmask0 depth5 AB cyc0 max0x20 rejnull accstat
# FlexRay start
frbtcfgbufS3 slot4 AB cyc0 rx max9 continuous ppi1 int1
frbtcfgbufS4 slot5 AB cyc0 tx max9 continuous ppi1 int1
## Dynamic buffers for TX and RX, single shot mode
- frbtcfgbufD0 slot9 A cyc0 rx max0x40 single ppi0 int0
- frbtcfgbufD1 slot10 A cyc0 tx max0x40 single ppi0 int0
+ frbtcfgbufD0 slot9 A cyc0 rx max9 single ppi0 int0
+ frbtcfgbufD1 slot10 A cyc0 tx max9 single ppi0 int0
## RX FIFO buffer to accept messages from all buffers except 0x#9, 0x#B, 0x#D, 0x#F
frbtcfgfifo rejslot9 slotmask6 depth5 B cyc0 max0x20 rejnull accstat
# FlexRay start
Node B:
frbtreceive4
+Buffer reconfiguration example:
+--------------------
+Reconfigures message buffer on the node A to transmit in slot 11 channel B instead of slot 9 channel A
+Reconfigures message buffer on the node B to receive from slot 11 channel B instead of slot 9 channel A.
+Node A:
+ frbtreconfigurebuf id9 slot11 B cycset1 cycoffset0 max9
+Node B:
+ frbtreconfigurebuf id9 slot11 B cycset1 cycoffset0 max9
+
Three nodes test
===========================================
Node A is sending a message in single-shot mode in slot 4. This message is received by nodes B and C into the static segment RX buffer.