]> rtime.felk.cvut.cz Git - pes-rpp/rpp-test-sw.git/blob - rpp-test-sw/commands/cmd_fr_basic_test.c
2f053a77d3ee4612f699ea9536bc5e5486f48f19
[pes-rpp/rpp-test-sw.git] / rpp-test-sw / commands / cmd_fr_basic_test.c
1 /*
2  * Copyright (C) 2012-2013 Czech Technical University in Prague
3  *
4  * Created on: 6.8.2013
5  *
6  * Authors:
7  *     - Michal Horn
8  *
9  * This document contains proprietary information belonging to Czech
10  * Technical University in Prague. Passing on and copying of this
11  * document, and communication of its contents is not permitted
12  * without prior written authorization.
13  *
14  * File : cmd_fr_basic_test.c
15  *
16  * Abstract:
17  *              The file contains a set of commands to control the FlexRay driver.
18  *              Those commands can be used to configure RPP board as a FlexRay node,
19  *              configure a set of TX and RX buffers, get status of the buffers and
20  *              the FlexRay controller, manipulate with timers and control the transmission
21  *              of messages.
22  */
23
24
25 #include "cmd_fr_basic_test.h"
26
27 #ifndef DOCGEN
28
29 #include <string.h>
30 #include "cmdproc_utils.h"
31 #include "drv/drv.h"
32 #include "rpp/rpp.h"
33 #include "hal/hal.h"
34 #include "stdio.h"
35
36 #define printf rpp_sci_printf
37
38 static inline int badpar(const char *msg)
39 {
40         printf("%s", msg);
41         return -CMDERR_BADPAR;
42 }
43
44 /**
45  * Flag to recognize whether the FlexRay driver was already initialized. If it was, no further configuration is allowed.
46  */
47 static boolean_t fr_initialized = FALSE;
48
49 /**
50  * This structure contains global FlexRay configuration.
51  * All nodes in the network have to use the same values for
52  * all parameters of this structure.
53  */
54 static Fr_TMS570LS_ClusterConfigType Fr_cluster_config = {
55         .gColdStartAttempts = 0x2,
56         .gListenNoise = 0xF,
57         .gMacroPerCycle = 0x15E0,   // (cycle period, 5.6us)
58         .gMaxWithoutClockCorrectionFatal = 0xF,
59         .gMaxWithoutClockCorrectionPassive = 0xF,
60         .gNetworkManagementVectorLength = 12,
61         .gNumberOfMinislots = 0x15A,
62         .gNumberOfStaticSlots = 0x8,
63         .gOffsetCorrectionStart = 0xAE4,
64         .gPayloadLengthStatic = 0x9,
65         .gSyncNodeMax = 0xF,
66         .gdActionPointOffset = 0x4,
67         .gdCASRxLowMax = 0x43,
68         .gdDynamicSlotIdlePhase = 0x1,
69         .gdMinislot = 0x4,
70         .gdMinislotActionPointOffset = 0x2,
71         .gdNIT = 0xAE3,
72         .gdSampleClockPeriod = 0,       // 10mbit/sec
73         .gdStaticSlot = 0x56,
74         .gdTSSTransmitter = 0xA,
75         .gdWakeupSymbolRxIdle = 18,
76         .gdWakeupSymbolRxLow = 18,
77         .gdWakeupSymbolRxWindow = 76,
78         .gdWakeupSymbolTxIdle = 180,
79         .gdWakeupSymbolTxLow = 60
80 };
81
82 /**
83  * This structure contains local configuration of the FlexRay node A.
84  * All nodes in the network shall have their own local configuraion,
85  * but it does not matters if they share some together, until their
86  * buffer configuration differs.
87  */
88 static Fr_TMS570LS_NodeConfigType Fr_node_A_config = {
89         .pAllowHaltDueToClock = 0,
90         .pAllowPassiveToActive = 0xF,
91         .pChannels = FR_CHANNEL_AB,
92         .pClusterDriftDamping = 0x1,
93         .pDelayCompensationA = 0x3,
94         .pDelayCompensationB = 0x3,
95         .pExternOffsetCorrection = 0,
96         .pExternRateCorrection = 0,
97         .pKeySlotUsedForStartup = TRUE,
98         .pKeySlotUsedForSync = TRUE,
99         .pLatestTx = 0x10D,
100         .pMacroInitialOffsetA = 0x6,
101         .pMacroInitialOffsetB = 0x6,
102         .pMicroInitialOffsetA = 0x18,
103         .pMicroInitialOffsetB = 0x18,
104         .pMicroPerCycle = 0x36B00,
105         .pRateCorrectionOut = 0xCD,
106         .pOffsetCorrectionOut = 0x151,
107         .pSamplesPerMicrotick = 0,      // 10 mbit/sec
108         .pSingleSlotEnabled = TRUE,
109         .pWakeupChannel = FR_CHANNEL_A,
110         .pWakeupPattern = 2,
111         .pdAcceptedStartupRange = 0x81,
112         .pdListenTimeout = 0x36DA2,
113         .pdMaxDrift = 0x151,
114         .pDecodingCorrection = 0x33
115 };
116
117 /**
118  * This structure contains local configuration of the FlexRay node B.
119  * All nodes in the network shall have their own local configuraion,
120  * but it does not matters if they share some together, until their
121  * buffer configuration differs.
122  */
123 static Fr_TMS570LS_NodeConfigType Fr_node_B_config = {
124         .pAllowHaltDueToClock = 0,
125         .pAllowPassiveToActive = 0xF,
126         .pChannels = FR_CHANNEL_AB,
127         .pClusterDriftDamping = 0x1,
128         .pDelayCompensationA = 0x3,
129         .pDelayCompensationB = 0x3,
130         .pExternOffsetCorrection = 0,
131         .pExternRateCorrection = 0,
132         .pKeySlotUsedForStartup = TRUE,
133         .pKeySlotUsedForSync = TRUE,
134         .pLatestTx = 0x10D,
135         .pMacroInitialOffsetA = 0x6,
136         .pMacroInitialOffsetB = 0x6,
137         .pMicroInitialOffsetA = 0x18,
138         .pMicroInitialOffsetB = 0x18,
139         .pMicroPerCycle = 0x36B00,
140         .pRateCorrectionOut = 0xCD,
141         .pOffsetCorrectionOut = 0x151,
142         .pSamplesPerMicrotick = 0,          // 10 mbit/sec
143         .pSingleSlotEnabled = TRUE,
144         .pWakeupChannel = FR_CHANNEL_A,
145         .pWakeupPattern = 2,
146         .pdAcceptedStartupRange = 0x81,
147         .pdListenTimeout = 0x36DA2,
148         .pdMaxDrift = 0x151,
149         .pDecodingCorrection = 0x33
150 };
151
152 static Fr_TMS570LS_MsgRAMConfig Fr_node_A_msgRAM_config = {
153         .dynSegmentBufferCount = 3,
154         .fifoBufferCount = 5,
155         .secureBuffers = FR_SB_RECONFIG_ENABLED,
156         .statSegmentBufferCount = 5,
157         .syncFramePayloadMultiplexEnabled = 0
158 };
159
160 static Fr_TMS570LS_MsgRAMConfig Fr_node_B_msgRAM_config = {
161         .dynSegmentBufferCount = 3,
162         .fifoBufferCount = 5,
163         .secureBuffers = FR_SB_RECONFIG_ENABLED,
164         .statSegmentBufferCount = 5,
165         .syncFramePayloadMultiplexEnabled = 0
166 };
167
168 static Fr_TMS570LS_BufferConfigType Fr_node_A_static_buffers_config[] = {
169         {
170                 .channel = FR_CHANNEL_AB,
171                 .cycleCounterFiltering = 0,
172                 .fidMask = 0,
173                 .isTx = TRUE,
174                 .maxPayload = 9,
175                 .msgBufferInterrupt = TRUE,
176                 .payloadPreambleIndicatorTr = FALSE,
177                 .rejectNullFrames = FALSE,
178                 .rejectStaticSegment = FALSE,
179                 .singleTransmit = FALSE,
180                 .slotId = 1
181         },
182         {
183                 .channel = FR_CHANNEL_AB,
184                 .cycleCounterFiltering = 0,
185                 .fidMask = 0,
186                 .isTx = FALSE,
187                 .maxPayload = 9,
188                 .msgBufferInterrupt = TRUE,
189                 .payloadPreambleIndicatorTr = FALSE,
190                 .rejectNullFrames = FALSE,
191                 .rejectStaticSegment = FALSE,
192                 .singleTransmit = FALSE,
193                 .slotId = 2
194         },
195         {
196                 .channel = FR_CHANNEL_AB,
197                 .cycleCounterFiltering = 0,
198                 .fidMask = 0,
199                 .isTx = TRUE,
200                 .maxPayload = 9,
201                 .msgBufferInterrupt = TRUE,
202                 .payloadPreambleIndicatorTr = FALSE,
203                 .rejectNullFrames = FALSE,
204                 .rejectStaticSegment = FALSE,
205                 .singleTransmit = TRUE,
206                 .slotId = 3
207         },
208         {
209                 .channel = FR_CHANNEL_AB,
210                 .cycleCounterFiltering = 0,
211                 .fidMask = 0,
212                 .isTx = FALSE,
213                 .maxPayload = 9,
214                 .msgBufferInterrupt = TRUE,
215                 .payloadPreambleIndicatorTr = FALSE,
216                 .rejectNullFrames = FALSE,
217                 .rejectStaticSegment = FALSE,
218                 .singleTransmit = TRUE,
219                 .slotId = 4
220         },
221         {
222                 .channel = FR_CHANNEL_AB,
223                 .cycleCounterFiltering = 0,
224                 .fidMask = 0,
225                 .isTx = TRUE,
226                 .maxPayload = 9,
227                 .msgBufferInterrupt = TRUE,
228                 .payloadPreambleIndicatorTr = TRUE,
229                 .rejectNullFrames = FALSE,
230                 .rejectStaticSegment = FALSE,
231                 .singleTransmit = FALSE,
232                 .slotId = 5
233         }
234
235 };
236
237 static Fr_TMS570LS_BufferConfigType Fr_node_B_static_buffers_config[] = {
238         {
239                 .channel = FR_CHANNEL_AB,
240                 .cycleCounterFiltering = 0,
241                 .fidMask = 0,
242                 .isTx = TRUE,
243                 .maxPayload = 9,
244                 .msgBufferInterrupt = TRUE,
245                 .payloadPreambleIndicatorTr = FALSE,
246                 .rejectNullFrames = FALSE,
247                 .rejectStaticSegment = FALSE,
248                 .singleTransmit = FALSE,
249                 .slotId = 2
250         },
251         {
252                 .channel = FR_CHANNEL_AB,
253                 .cycleCounterFiltering = 0,
254                 .fidMask = 0,
255                 .isTx = FALSE,
256                 .maxPayload = 9,
257                 .msgBufferInterrupt = TRUE,
258                 .payloadPreambleIndicatorTr = FALSE,
259                 .rejectNullFrames = FALSE,
260                 .rejectStaticSegment = FALSE,
261                 .singleTransmit = FALSE,
262                 .slotId = 1
263         },
264         {
265                 .channel = FR_CHANNEL_AB,
266                 .cycleCounterFiltering = 0,
267                 .fidMask = 0,
268                 .isTx = TRUE,
269                 .maxPayload = 9,
270                 .msgBufferInterrupt = TRUE,
271                 .payloadPreambleIndicatorTr = FALSE,
272                 .rejectNullFrames = FALSE,
273                 .rejectStaticSegment = FALSE,
274                 .singleTransmit = TRUE,
275                 .slotId = 4
276         },
277         {
278                 .channel = FR_CHANNEL_AB,
279                 .cycleCounterFiltering = 0,
280                 .fidMask = 0,
281                 .isTx = FALSE,
282                 .maxPayload = 9,
283                 .msgBufferInterrupt = TRUE,
284                 .payloadPreambleIndicatorTr = FALSE,
285                 .rejectNullFrames = FALSE,
286                 .rejectStaticSegment = FALSE,
287                 .singleTransmit = TRUE,
288                 .slotId = 3
289         },
290         {
291                 .channel = FR_CHANNEL_AB,
292                 .cycleCounterFiltering = 0,
293                 .fidMask = 0,
294                 .isTx = FALSE,
295                 .maxPayload = 9,
296                 .msgBufferInterrupt = TRUE,
297                 .payloadPreambleIndicatorTr = TRUE,
298                 .rejectNullFrames = FALSE,
299                 .rejectStaticSegment = FALSE,
300                 .singleTransmit = FALSE,
301                 .slotId = 5
302         }
303 };
304
305 static Fr_TMS570LS_BufferConfigType Fr_node_A_dynamic_buffers_config[] = {
306         {
307                 .channel = FR_CHANNEL_A,
308                 .cycleCounterFiltering = 0,
309                 .fidMask = 0,
310                 .isTx = TRUE,
311                 .maxPayload = 64,
312                 .msgBufferInterrupt = TRUE,
313                 .payloadPreambleIndicatorTr = FALSE,
314                 .rejectNullFrames = FALSE,
315                 .rejectStaticSegment = FALSE,
316                 .singleTransmit = FALSE,
317                 .slotId = 9
318         },
319         {
320                 .channel = FR_CHANNEL_B,
321                 .cycleCounterFiltering = 0,
322                 .fidMask = 0,
323                 .isTx = FALSE,
324                 .maxPayload = 32,
325                 .msgBufferInterrupt = TRUE,
326                 .payloadPreambleIndicatorTr = FALSE,
327                 .rejectNullFrames = FALSE,
328                 .rejectStaticSegment = FALSE,
329                 .singleTransmit = FALSE,
330                 .slotId = 10
331         },
332         {
333                 .channel = FR_CHANNEL_A,
334                 .cycleCounterFiltering = 0,
335                 .fidMask = 0,
336                 .isTx = TRUE,
337                 .maxPayload = 16,
338                 .msgBufferInterrupt = TRUE,
339                 .payloadPreambleIndicatorTr = FALSE,
340                 .rejectNullFrames = FALSE,
341                 .rejectStaticSegment = FALSE,
342                 .singleTransmit = TRUE,
343                 .slotId = 11
344         }
345 };
346
347
348 static Fr_TMS570LS_BufferConfigType Fr_node_B_dynamic_buffers_config[] = {
349         {
350                 .channel = FR_CHANNEL_B,
351                 .cycleCounterFiltering = 0,
352                 .fidMask = 0,
353                 .isTx = TRUE,
354                 .maxPayload = 32,
355                 .msgBufferInterrupt = TRUE,
356                 .payloadPreambleIndicatorTr = FALSE,
357                 .rejectNullFrames = FALSE,
358                 .rejectStaticSegment = FALSE,
359                 .singleTransmit = TRUE,
360                 .slotId = 10
361         },
362         {
363                 .channel = FR_CHANNEL_A,
364                 .cycleCounterFiltering = 0,
365                 .fidMask = 0,
366                 .isTx = FALSE,
367                 .maxPayload = 64,
368                 .msgBufferInterrupt = TRUE,
369                 .payloadPreambleIndicatorTr = FALSE,
370                 .rejectNullFrames = FALSE,
371                 .rejectStaticSegment = FALSE,
372                 .singleTransmit = TRUE,
373                 .slotId = 9
374         },
375         {
376                 .channel = FR_CHANNEL_A,
377                 .cycleCounterFiltering = 0,
378                 .fidMask = 0,
379                 .isTx = TRUE,
380                 .maxPayload = 9,
381                 .msgBufferInterrupt = TRUE,
382                 .payloadPreambleIndicatorTr = FALSE,
383                 .rejectNullFrames = FALSE,
384                 .rejectStaticSegment = FALSE,
385                 .singleTransmit = TRUE,
386                 .slotId = 12
387         }
388 };
389
390 static Fr_TMS570LS_BufferConfigType Fr_node_A_fifo_buffers_config[] = {
391         {
392                 .channel = FR_CHANNEL_AB,
393                 .cycleCounterFiltering = 0,
394                 .fidMask = 0,
395                 .isTx = FALSE,
396                 .maxPayload = 127,
397                 .msgBufferInterrupt = FALSE, // Recomended for FIFO buffers
398                 .payloadPreambleIndicatorTr = FALSE,
399                 .rejectNullFrames = TRUE,
400                 .rejectStaticSegment = FALSE,
401                 .singleTransmit = FALSE,
402                 .slotId = 12
403         },
404         {
405                 .channel = FR_CHANNEL_AB,
406                 .cycleCounterFiltering = 0,
407                 .fidMask = 0,
408                 .isTx = FALSE,
409                 .maxPayload = 127,
410                 .msgBufferInterrupt = FALSE, // Recomended for FIFO buffers
411                 .payloadPreambleIndicatorTr = FALSE,
412                 .rejectNullFrames = TRUE,
413                 .rejectStaticSegment = FALSE,
414                 .singleTransmit = FALSE,
415                 .slotId = 12
416         },
417         {
418                 .channel = FR_CHANNEL_AB,
419                 .cycleCounterFiltering = 0,
420                 .fidMask = 0,
421                 .isTx = FALSE,
422                 .maxPayload = 127,
423                 .msgBufferInterrupt = FALSE, // Recomended for FIFO buffers
424                 .payloadPreambleIndicatorTr = FALSE,
425                 .rejectNullFrames = TRUE,
426                 .rejectStaticSegment = FALSE,
427                 .singleTransmit = FALSE,
428                 .slotId = 12
429         },
430         {
431                 .channel = FR_CHANNEL_AB,
432                 .cycleCounterFiltering = 0,
433                 .fidMask = 0,
434                 .isTx = FALSE,
435                 .maxPayload = 127,
436                 .msgBufferInterrupt = FALSE, // Recomended for FIFO buffers
437                 .payloadPreambleIndicatorTr = FALSE,
438                 .rejectNullFrames = TRUE,
439                 .rejectStaticSegment = FALSE,
440                 .singleTransmit = FALSE,
441                 .slotId = 12
442         },
443         {
444                 .channel = FR_CHANNEL_AB,
445                 .cycleCounterFiltering = 0,
446                 .fidMask = 0,
447                 .isTx = FALSE,
448                 .maxPayload = 127,
449                 .msgBufferInterrupt = FALSE, // Recomended for FIFO buffers
450                 .payloadPreambleIndicatorTr = FALSE,
451                 .rejectNullFrames = TRUE,
452                 .rejectStaticSegment = FALSE,
453                 .singleTransmit = FALSE,
454                 .slotId = 12
455         }
456 };
457
458 static Fr_TMS570LS_BufferConfigType Fr_node_B_fifo_buffers_config[] = {
459         {
460                 .channel = FR_CHANNEL_AB,
461                 .cycleCounterFiltering = 0,
462                 .fidMask = 0,
463                 .isTx = FALSE,
464                 .maxPayload = 64,
465                 .msgBufferInterrupt = FALSE, // Recommended for FIFO buffers
466                 .payloadPreambleIndicatorTr = FALSE,
467                 .rejectNullFrames = TRUE,
468                 .rejectStaticSegment = FALSE,
469                 .singleTransmit = FALSE,
470                 .slotId = 0 // No Frame is rejected
471         },
472         {
473                 .channel = FR_CHANNEL_AB,
474                 .cycleCounterFiltering = 0,
475                 .fidMask = 0,
476                 .isTx = FALSE,
477                 .maxPayload = 64,
478                 .msgBufferInterrupt = FALSE, // Recommended for FIFO buffers
479                 .payloadPreambleIndicatorTr = FALSE,
480                 .rejectNullFrames = TRUE,
481                 .rejectStaticSegment = FALSE,
482                 .singleTransmit = FALSE,
483                 .slotId = 0 // No Frame is rejected
484         },
485         {
486                 .channel = FR_CHANNEL_AB,
487                 .cycleCounterFiltering = 0,
488                 .fidMask = 0,
489                 .isTx = FALSE,
490                 .maxPayload = 64,
491                 .msgBufferInterrupt = FALSE, // Recommended for FIFO buffers
492                 .payloadPreambleIndicatorTr = FALSE,
493                 .rejectNullFrames = TRUE,
494                 .rejectStaticSegment = FALSE,
495                 .singleTransmit = FALSE,
496                 .slotId = 0 // No Frame is rejected
497         },
498         {
499                 .channel = FR_CHANNEL_AB,
500                 .cycleCounterFiltering = 0,
501                 .fidMask = 0,
502                 .isTx = FALSE,
503                 .maxPayload = 64,
504                 .msgBufferInterrupt = FALSE, // Recommended for FIFO buffers
505                 .payloadPreambleIndicatorTr = FALSE,
506                 .rejectNullFrames = TRUE,
507                 .rejectStaticSegment = FALSE,
508                 .singleTransmit = FALSE,
509                 .slotId = 0 // No Frame is rejected
510         },
511         {
512                 .channel = FR_CHANNEL_AB,
513                 .cycleCounterFiltering = 0,
514                 .fidMask = 0,
515                 .isTx = FALSE,
516                 .maxPayload = 64,
517                 .msgBufferInterrupt = FALSE, // Recommended for FIFO buffers
518                 .payloadPreambleIndicatorTr = FALSE,
519                 .rejectNullFrames = TRUE,
520                 .rejectStaticSegment = FALSE,
521                 .singleTransmit = FALSE,
522                 .slotId = 0 // No Frame is rejected
523         }
524 };
525
526 /**
527  * This is an unifying configuration structure for the node A.
528  * It joins all the configuration structure together.
529  */
530 static Fr_ConfigType Fr_config_node_A = {
531         .clusterConfiguration = &Fr_cluster_config,
532         .dynamicBufferConfigs = Fr_node_A_dynamic_buffers_config,
533         .fifoBufferConfigs = Fr_node_A_fifo_buffers_config,
534         .msgRAMConfig = &Fr_node_A_msgRAM_config,
535         .nodeConfiguration = &Fr_node_A_config,
536         .staticBufferConfigs = Fr_node_A_static_buffers_config
537 };
538
539 /**
540  * This is an unifying configuration structure for the node A.
541  * It joins all the configuration structure together.
542  */
543 static Fr_ConfigType Fr_config_node_B = {
544         .clusterConfiguration = &Fr_cluster_config,
545         .dynamicBufferConfigs = Fr_node_B_dynamic_buffers_config,
546         .fifoBufferConfigs = Fr_node_B_fifo_buffers_config,
547         .msgRAMConfig = &Fr_node_B_msgRAM_config,
548         .nodeConfiguration = &Fr_node_B_config,
549         .staticBufferConfigs = Fr_node_B_static_buffers_config
550 };
551
552 /* User configuration */
553
554 static Fr_TMS570LS_ClusterConfigType user_cluster_config;
555 static Fr_TMS570LS_NodeConfigType user_node_config;
556 static Fr_TMS570LS_MsgRAMConfig user_msg_ram_config;
557 static Fr_TMS570LS_BufferConfigType user_static_buffer_config[RPP_FR_MAX_STATIC_BUF_CNT];
558 static Fr_TMS570LS_BufferConfigType user_dynamic_buffer_config[RPP_FR_MAX_DYNAMIC_BUF_CNT];
559 static Fr_TMS570LS_BufferConfigType user_fifo_buffer_config[RPP_FR_MAX_FIFO_BUF_DEPTH];
560 static Fr_ConfigType user_configuration = {
561         .clusterConfiguration = &user_cluster_config,
562         .nodeConfiguration = &user_node_config,
563         .msgRAMConfig = &user_msg_ram_config,
564         .staticBufferConfigs = user_static_buffer_config,
565         .dynamicBufferConfigs = user_dynamic_buffer_config,
566         .fifoBufferConfigs = user_fifo_buffer_config,
567 };
568 ;
569
570 #define USER_CONFIG_NOT_DONE        0x0
571 #define USER_CONFIG_CLUSTER         0x1
572 #define USER_CONFIG_NODE            0x2
573
574 static uint8_t user_configuration_state = USER_CONFIG_NOT_DONE;
575 static uint8_t user_static_buffer_configured = 0;
576 static uint8_t user_dynamic_buffer_configured = 0;
577 static uint8_t user_fifo_buffer_depth = 0;
578
579 /**
580  * Split string into numbers
581  *
582  * The function takes a string with hexadecimal numbers,
583  * separated by spaces, and converts it into an array of numbers.
584  *
585  * For example "0x2 0xA 0XDD 0xABCD" -> {0x2, 0xA, 0XDD, 0xABCD}
586  *
587  * @param [in] params Address of the string which will be converted
588  * @param [in] params_cnt A number of parameters, which should be found and converted from the string params
589  * @param [out] tmp_params Address, where converted array of numbers will be stored
590  *
591  * @return SUCCESS when all parameters were converted to the array of numbers,
592  *         FAILURE when the string was too short, too long or some other error occurred.
593  */
594 static int8_t cmd_fr_parse_params(const char *params, uint32_t params_cnt, uint32_t *tmp_params)
595 {
596         char cpy_params[256];
597         char *token;
598         int i;
599
600         if (params == NULL || tmp_params == NULL)
601                 return FAILURE;
602         strncpy(cpy_params, params, 256);
603         token = strtok(cpy_params, " ");
604         if (token == NULL)
605                 return FAILURE;
606         for (i = 0; i < params_cnt; i++) {
607                 if (sscanf(token, "%i", &tmp_params[i]) == EOF)     // No number found
608                         return FAILURE;
609                 if ((token = strtok(NULL, " ")) == NULL && i < params_cnt-1)    // Not enough parameters in the string
610                         return FAILURE;
611         }
612         return SUCCESS;
613 }
614
615 int8_t cmd_fr_config_cluster_params(const char *params)
616 {
617         uint32_t tmp_params[FR_CLUSTER_PARAMS_CNT];
618
619         if (cmd_fr_parse_params(params, FR_CLUSTER_PARAMS_CNT, tmp_params) == FAILURE)
620                 return FAILURE;
621
622         user_cluster_config.gColdStartAttempts = tmp_params[0];
623         user_cluster_config.gListenNoise = tmp_params[1];
624         user_cluster_config.gMacroPerCycle = tmp_params[2];
625         user_cluster_config.gMaxWithoutClockCorrectionFatal = tmp_params[3];
626         user_cluster_config.gMaxWithoutClockCorrectionPassive = tmp_params[4];
627         user_cluster_config.gNetworkManagementVectorLength = tmp_params[5];
628         user_cluster_config.gNumberOfMinislots = tmp_params[6];
629         user_cluster_config.gNumberOfStaticSlots = tmp_params[7];
630         user_cluster_config.gOffsetCorrectionStart = tmp_params[8];
631         user_cluster_config.gPayloadLengthStatic = tmp_params[9];
632         user_cluster_config.gSyncNodeMax = tmp_params[10];
633         user_cluster_config.gdActionPointOffset = tmp_params[11];
634         user_cluster_config.gdCASRxLowMax = tmp_params[12];
635         user_cluster_config.gdDynamicSlotIdlePhase = tmp_params[13];
636         user_cluster_config.gdMinislot = tmp_params[14];
637         user_cluster_config.gdMinislotActionPointOffset = tmp_params[15];
638         user_cluster_config.gdNIT = tmp_params[16];
639         user_cluster_config.gdSampleClockPeriod = tmp_params[17];
640         user_cluster_config.gdStaticSlot = tmp_params[18];
641         user_cluster_config.gdTSSTransmitter = tmp_params[19];
642         user_cluster_config.gdWakeupSymbolRxIdle = tmp_params[20];
643         user_cluster_config.gdWakeupSymbolRxLow = tmp_params[21];
644         user_cluster_config.gdWakeupSymbolRxWindow = tmp_params[22];
645         user_cluster_config.gdWakeupSymbolTxIdle = tmp_params[23];
646         user_cluster_config.gdWakeupSymbolTxLow = tmp_params[24];
647
648         user_configuration_state |= USER_CONFIG_CLUSTER;
649         return SUCCESS;
650 }
651
652 int8_t cmd_fr_config_node_params(const char *params)
653 {
654         uint32_t tmp_params[FR_NODE_PARAMS_CNT+2];  // +2 because two more parameters from message RAM structure are expected in the string.
655         Fr_ChannelType channels[3] = {FR_CHANNEL_A, FR_CHANNEL_B, FR_CHANNEL_AB};
656         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};
657
658         if (cmd_fr_parse_params(params, FR_NODE_PARAMS_CNT+2, tmp_params) == FAILURE)
659                 return FAILURE;
660
661         user_node_config.pAllowHaltDueToClock = tmp_params[0];
662         user_node_config.pAllowPassiveToActive = tmp_params[1];
663         if (tmp_params[2] > 2) return FAILURE;
664         user_node_config.pChannels = channels[ tmp_params[2] ];
665         user_node_config.pClusterDriftDamping = tmp_params[3];
666         user_node_config.pDelayCompensationA = tmp_params[4];
667         user_node_config.pDelayCompensationB = tmp_params[5];
668         user_node_config.pExternOffsetCorrection = tmp_params[6];
669         user_node_config.pExternRateCorrection = tmp_params[7];
670         user_node_config.pKeySlotUsedForStartup = tmp_params[8];
671         user_node_config.pKeySlotUsedForSync = tmp_params[9];
672         user_node_config.pLatestTx = tmp_params[10];
673         user_node_config.pMacroInitialOffsetA = tmp_params[11];
674         user_node_config.pMacroInitialOffsetB = tmp_params[12];
675         user_node_config.pMicroInitialOffsetA = tmp_params[13];
676         user_node_config.pMicroInitialOffsetB = tmp_params[14];
677         user_node_config.pMicroPerCycle = tmp_params[15];
678         user_node_config.pRateCorrectionOut = tmp_params[16];
679         user_node_config.pOffsetCorrectionOut = tmp_params[17];
680         user_node_config.pSamplesPerMicrotick = tmp_params[18];
681         user_node_config.pSingleSlotEnabled = tmp_params[19];
682         if (tmp_params[20] > 1) return FAILURE;
683         user_node_config.pWakeupChannel = channels[ tmp_params[20] ];
684         user_node_config.pWakeupPattern = tmp_params[21];
685         user_node_config.pdAcceptedStartupRange = tmp_params[22];
686         user_node_config.pdListenTimeout = tmp_params[23];
687         user_node_config.pdMaxDrift = tmp_params[24];
688         user_node_config.pDecodingCorrection = tmp_params[25];
689         user_msg_ram_config.syncFramePayloadMultiplexEnabled = tmp_params[26];
690         if (tmp_params[27] > 3) return FAILURE;
691         user_msg_ram_config.secureBuffers = secure[ tmp_params[27] ];
692
693         user_configuration_state |= USER_CONFIG_NODE;
694         return SUCCESS;
695 }
696
697 int cmd_do_fr_config_fifo(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[])
698 {
699         Fr_TMS570LS_BufferConfigType *fifo_buffer_ptr = &user_fifo_buffer_config[0];
700         int ret, i;
701         char channel[3], rej_static_frames[8], rej_null_frames[8];
702         unsigned depth, slot, cycleset, maxpayload, mask;
703         Fr_TMS570LS_BufferConfigType tmp_buffer;
704
705         if (fr_initialized) {
706                 rpp_sci_printf("FlexRay configuration can not be modified after frbtinit was called.\n");
707                 return -CMDERR_BADCFG;
708         }
709
710         ret = sscanf(param[2], "rejslot%i slotmask%i depth%i %2s cyc%i max%i %10s %10s",
711                                  &slot,
712                                  &mask,
713                                  &depth,
714                                  channel,
715                                  &cycleset,
716                                  &maxpayload,
717                                  rej_null_frames,
718                                  rej_static_frames
719                                  );
720         if (ret != 8) {
721                 printf("Error parsing parameter %d\n", ret+1);
722                 return -CMDERR_BADPAR;
723         }
724
725         if (depth < 1 || depth >= RPP_FR_MAX_FIFO_BUF_DEPTH)
726                 return badpar("Depth too high\n");
727         user_fifo_buffer_depth = depth;
728
729         if (slot > 2047)
730                 return badpar("Invalid slot number\n");
731         tmp_buffer.slotId = slot;
732         if (slot > 2047)
733                 return badpar("Invalid mask\n");
734         tmp_buffer.fidMask = mask;
735         if (strcmp(channel, "A") == 0) tmp_buffer.channel = FR_CHANNEL_A;
736         else if (strcmp(channel, "B") == 0) tmp_buffer.channel = FR_CHANNEL_B;
737         else if (strcmp(channel, "AB") == 0) tmp_buffer.channel = FR_CHANNEL_AB;
738         else return badpar("Channel parsing error\n");
739
740         if (cycleset >= 0x80)
741                 return badpar("Cycle set must be less than 0x80.\n");
742         tmp_buffer.cycleCounterFiltering = cycleset;
743
744         if (maxpayload >= 128)
745                 return badpar("Maximum payload in half-words must be less than 128\n");
746         tmp_buffer.maxPayload = maxpayload;
747
748         if (strcmp(rej_null_frames, "rejnull") == 0) tmp_buffer.rejectNullFrames = true;
749         else if (strcmp(rej_null_frames, "accnull") == 0) tmp_buffer.rejectNullFrames = false;
750         else return badpar("Reject/accept NULL frames parsing error\n");
751
752         if (strcmp(rej_static_frames, "rejstat") == 0)
753                 tmp_buffer.rejectStaticSegment = true;
754         else if (strcmp(rej_static_frames, "accstat") == 0)
755                 tmp_buffer.rejectStaticSegment = false;
756         else return badpar("Invalid reject/accept static frame parameter");
757
758         for (i = 0; i < user_fifo_buffer_depth; i++) {
759                 fifo_buffer_ptr[i].slotId = tmp_buffer.slotId;
760                 fifo_buffer_ptr[i].fidMask = tmp_buffer.fidMask;
761                 fifo_buffer_ptr[i].maxPayload = tmp_buffer.maxPayload;
762                 fifo_buffer_ptr[i].channel = tmp_buffer.channel;
763                 fifo_buffer_ptr[i].cycleCounterFiltering = tmp_buffer.cycleCounterFiltering;
764                 fifo_buffer_ptr[i].isTx = FALSE;
765                 fifo_buffer_ptr[i].singleTransmit = FALSE;
766                 fifo_buffer_ptr[i].payloadPreambleIndicatorTr = FALSE;
767                 fifo_buffer_ptr[i].rejectNullFrames = tmp_buffer.rejectNullFrames;
768                 fifo_buffer_ptr[i].rejectStaticSegment = tmp_buffer.rejectStaticSegment;
769                 fifo_buffer_ptr[i].msgBufferInterrupt = 0;
770         }
771
772         printf("frbtcfgfifo rejslot%i slotmask%i depth%i %2s cyc%i max%i %10s %10s\n",
773                    slot,
774                    mask,
775                    depth,
776                    channel,
777                    cycleset,
778                    maxpayload,
779                    rej_null_frames,
780                    rej_static_frames
781                    );
782
783         return SUCCESS;
784 }
785
786 int cmd_do_fr_config_bufer(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[])
787 {
788         Fr_TMS570LS_BufferConfigType *cfg;
789
790         int ret;
791         char buf_type, channel[3],rxtx[3], single_continuous[11];
792         unsigned buffer, slot, cycleset, maxpayload, intr, preamb;
793
794         if (fr_initialized) {
795                 rpp_sci_printf("FlexRay configuration can not be modified after frbtinit was called.\n");
796                 return -CMDERR_BADCFG;
797         }
798
799         ret = sscanf(param[1], "%c%i slot%i %2s cyc%i %2s max%i %10s ppi%i int%i",
800                                  &buf_type,
801                                  &buffer,
802                                  &slot,
803                                  channel,
804                                  &cycleset,
805                                  rxtx,
806                                  &maxpayload,
807                                  single_continuous,
808                                  &preamb,
809                                  &intr
810                                  );
811         if (ret != 10) {
812                 printf("Error parsing parameter %d\n", ret+1);
813                 return -CMDERR_BADPAR;
814
815         }
816
817         switch (buf_type) {
818         case 'S':
819                 if (buffer >= RPP_FR_MAX_STATIC_BUF_CNT)
820                         return badpar("Buffer index too high\n");
821                 cfg = &user_static_buffer_config[buffer];
822                 break;
823         case 'D':
824                 if (buffer >= RPP_FR_MAX_DYNAMIC_BUF_CNT)
825                         return badpar("Buffer index too high\n");
826                 cfg = &user_dynamic_buffer_config[buffer];
827                 break;
828         default:
829                 return badpar("Invalid buffer type (S, D)\n");
830         }
831
832         if (slot < 1 || slot > 2047)
833                 return badpar("Invalid slot number\n");
834         cfg->slotId = slot;
835
836         if (strcmp(channel, "A") == 0) cfg->channel = FR_CHANNEL_A;
837         else if (strcmp(channel, "B") == 0) cfg->channel = FR_CHANNEL_B;
838         else if (strcmp(channel, "AB") == 0) cfg->channel = FR_CHANNEL_AB;
839         else return badpar("Channel parsing error\n");
840         if (buf_type == 'D' && cfg->channel == FR_CHANNEL_AB)
841                 return badpar("Dynamic segment buffers cannot have AB channels.\n");
842
843         if (cycleset >= 0x80)
844                 return badpar("Cycle set must be less than 0x80.\n");
845         cfg->cycleCounterFiltering = cycleset;
846
847         if (strcmp(rxtx, "tx") == 0) cfg->isTx = true;
848         else if (strcmp(rxtx, "rx") == 0) cfg->isTx = false;
849         else return badpar("RX/TX parsing error\n");
850
851         if (maxpayload >= 128)
852                 return badpar("Maximum payload in half-words must be less than 128\n");
853         cfg->maxPayload = maxpayload;
854
855         if (0 == strcmp(single_continuous, "single") ||
856                 0 == strcmp(single_continuous, "s"))
857                 cfg->singleTransmit = true;
858         else if (0 == strcmp(single_continuous, "continuous") ||
859                          0 == strcmp(single_continuous, "c"))
860                 cfg->singleTransmit = false;
861         else return badpar("Invalid single/continuous parameter");
862
863         if (preamb > 1)
864                 return badpar("Payload preamble indicator must be 0 or 1");
865         cfg->payloadPreambleIndicatorTr = preamb;
866
867         if (intr > 1)
868                 return badpar("Interrupt parameter must be 0 or 1");
869         cfg->msgBufferInterrupt = intr;
870
871         switch (buf_type) {
872         case 'S':
873                 if (buffer >= user_static_buffer_configured)
874                         user_static_buffer_configured = buffer + 1;
875                 break;
876         case 'D':
877                 if (buffer >= user_dynamic_buffer_configured)
878                         user_dynamic_buffer_configured = buffer + 1;
879                 break;
880         }
881
882         printf("frbtcfgbuf%c%i slot%i %2s cyc%i %2s max%i %10s ppi%i int%i\n",
883                    buf_type,
884                    buffer,
885                    slot,
886                    channel,
887                    cycleset,
888                    rxtx,
889                    maxpayload,
890                    single_continuous,
891                    preamb,
892                    intr
893                    );
894
895         return 0;
896 }
897
898
899
900 /**
901  *  @brief      Do the user configuration of the FlexRay cluster parameters
902  *
903  * @param[in]   cmd_io  Pointer to IO stack
904  * @param[in]   des             Pointer to command descriptor
905  * @param[in]   param   Parameters of command
906  * @return      0 when OK or error code
907  */
908 int cmd_do_fr_user_config(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[])
909 {
910         char *token;
911
912         if (fr_initialized) {
913                 rpp_sci_printf("FlexRay configuration can not be modified after frbtinit was called.\n");
914                 return -CMDERR_BADCFG;
915         }
916
917         token = strtok(param[1], " ");
918         if (strcmp(token, "cluster") == 0) {
919                 if (cmd_fr_config_cluster_params(param[2]) == FAILURE) {
920                         rpp_sci_printf("FlexRay cluster configuration not accepted.\n");
921                         return -CMDERR_BADPAR;
922                 }
923                 rpp_sci_printf("FlexRay cluster configuration accepted.\n");
924         }
925         else if (strcmp(token, "node") == 0) {
926                 if (cmd_fr_config_node_params(param[2]) == FAILURE) {
927                         rpp_sci_printf("FlexRay node configuration not accepted.\n");
928                         return -CMDERR_BADPAR;
929                 }
930                 rpp_sci_printf("FlexRay node configuration accepted.\n");
931         }
932         else
933                 return -CMDERR_BADPAR;
934
935         return 0;
936 }
937
938 /**
939  *  @brief      Initialize the device as FlexRay node.
940  *
941  * @param[in]   cmd_io  Pointer to IO stack
942  * @param[in]   des             Pointer to command descriptor
943  * @param[in]   param   Parameters of command
944  * @return      0 when OK or error code
945  */
946 int cmd_do_fr_init(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[])
947 {
948         const Fr_ConfigType *Fr_ConfigPtr = NULL;
949         int8_t retVal = SUCCESS;
950         uint32_t error = ERR_PARAM_NO_ERROR;
951
952         if (*param[1] == 'A')
953                 Fr_ConfigPtr = &Fr_config_node_A;
954         else if (*param[1] == 'B')
955                 Fr_ConfigPtr = &Fr_config_node_B;
956         else if (*param[1] == 'U') {    // Select the user configuration  -  call config commands first
957                 user_msg_ram_config.statSegmentBufferCount = user_static_buffer_configured;
958                 user_msg_ram_config.dynSegmentBufferCount = user_dynamic_buffer_configured;
959                 user_msg_ram_config.fifoBufferCount = user_fifo_buffer_depth;
960                 Fr_ConfigPtr = &user_configuration;
961         }
962         else
963                 return -CMDERR_BADPAR;
964
965         retVal = rpp_fr_init_driver(Fr_ConfigPtr, &error);
966         if (retVal == SUCCESS) {
967                 rpp_sci_printf("FlexRay driver initialized.\r\n");
968                 fr_initialized = TRUE;
969         }
970         else {
971                 retVal = rpp_fr_init_controller(0, &error);
972                 if (retVal == SUCCESS) {
973                         rpp_sci_printf("FlexRay controller reinitialized.\r\n");
974                         return 0;
975                 }
976                 else {
977                         rpp_sci_printf("FlexRay needs to be configured before initialization.\r\n");
978                         return -CMDERR_BADCFG;
979                 }
980         }
981
982         retVal = rpp_fr_init_controller(0, &error);
983         if (retVal == SUCCESS)
984                 rpp_sci_printf("FlexRay controller initialized.\r\n");
985         else {
986                 if (error & FR_INIT_ERR_CLUSTER_CONFIG)
987                         rpp_sci_printf("Cluster configuration data error: %x\r\n", (retVal & 0x3FFFFFE) >> 1 );
988                 else if (error & FR_INIT_ERR_NODE_CONFIG)
989                         rpp_sci_printf("Node configuration data error: %x\r\n", (retVal & 0x3FFFFFE) >> 1 );
990                 else if (error & FR_INIT_ERR_MSGRAM_CONFIG)
991                         rpp_sci_printf("Message RAM configuration data error: %x\r\n", (retVal & 0x3FFFFFE) >> 1 );
992                 else if (error & FR_INIT_ERR_BUFFPARAM_CONFIG)
993                         rpp_sci_printf("Buffer configuration data error: %x\r\n", (retVal & 0x3FFFFFE) >> 1 );
994                 else if (error & (uint32_t)FR_INIT_ERR_BUFF_CONFIG)
995                         rpp_sci_printf("Buffer configuration error: %x\r\n", (retVal & 0x3FFFFFE) >> 1 );
996                 else
997                         rpp_sci_printf("POC state switching error.\r\n");
998                 return -CMDERR_BADCFG;
999         }
1000         return 0;
1001 }
1002
1003 /**
1004  *  @brief      Starts FlexRay communication
1005  *
1006  * @param[in]   cmd_io  Pointer to IO stack
1007  * @param[in]   des             Pointer to command descriptor
1008  * @param[in]   param   Parameters of command
1009  * @return      0 when OK or error code
1010  */
1011 int cmd_do_fr_start(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[])
1012 {
1013         int8_t retVal = SUCCESS;
1014         uint32_t error = ERR_PARAM_NO_ERROR;
1015
1016         retVal = rpp_fr_start_communication(0, &error);
1017         if (retVal == SUCCESS)
1018                 rpp_sci_printf("FlexRay communication is running.\r\n");
1019         else {
1020                 if (error & FR_STARTUP_ERR_SW_STUP_FOLLOW)
1021                         rpp_sci_printf("Can not switch POC to RUN state.\r\n");
1022                 else if (error & FR_STARTUP_ERR_CSINH_DIS)
1023                         rpp_sci_printf("Cold start inhibit disabled error.\r\n");
1024                 else if (error & FR_STARTUP_ERR_SW_STUP_READY)
1025                         rpp_sci_printf("Can not switch back to READY from STARTUP.\r\n");
1026                 else if (error & FR_STARTUP_ERR_SW_STUP_AS_NCOLD)
1027                         rpp_sci_printf("Can not switch to STARTUP as non-coldstarter.\r\n");
1028                 else
1029                         rpp_sci_printf("General error.\r\n");
1030                 return -CMDERR_BADCFG;
1031         }
1032         return 0;
1033 }
1034
1035 /**
1036  *  @brief      Invokes POC command ALL_SLOTS
1037  *
1038  * @param[in]   cmd_io  Pointer to IO stack
1039  * @param[in]   des             Pointer to command descriptor
1040  * @param[in]   param   Parameters of command
1041  * @return      0 when OK or error code
1042  */
1043 int cmd_do_fr_allslots(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[])
1044 {
1045         int8_t retVal = ERR_PARAM_NO_ERROR;
1046
1047         retVal = rpp_fr_all_slots(0);
1048         if (retVal == SUCCESS)
1049                 rpp_sci_printf("FlexRay node started communication in all slots.\r\n");
1050         else {
1051                 rpp_sci_printf("General error.\r\n");
1052                 return -CMDERR_BADCFG;
1053         }
1054         return 0;
1055 }
1056
1057 /**
1058  *  @brief      Halt FlexRay communication
1059  *
1060  * @param[in]   cmd_io  Pointer to IO stack
1061  * @param[in]   des             Pointer to command descriptor
1062  * @param[in]   param   Parameters of command
1063  * @return      0 when OK or error code
1064  */
1065 int cmd_do_fr_halt(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[])
1066 {
1067         int8_t retVal = ERR_PARAM_NO_ERROR;
1068
1069         retVal = rpp_fr_halt_communication(0);
1070         if (retVal == SUCCESS)
1071                 rpp_sci_printf("FlexRay node communication halted.\r\n");
1072         else {
1073                 rpp_sci_printf("General error.\r\n");
1074                 return -CMDERR_BADCFG;
1075         }
1076         return 0;
1077 }
1078
1079 /**
1080  *  @brief      Abort FlexRay communication
1081  *
1082  * @param[in]   cmd_io  Pointer to IO stack
1083  * @param[in]   des             Pointer to command descriptor
1084  * @param[in]   param   Parameters of command
1085  * @return      0 when OK or error code
1086  */
1087 int cmd_do_fr_abort(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[])
1088 {
1089         int8_t retVal = ERR_PARAM_NO_ERROR;
1090
1091         retVal = rpp_fr_abort_communication(0);
1092         if (retVal == SUCCESS)
1093                 rpp_sci_printf("FlexRay node communication aborted.\r\n");
1094         else {
1095                 rpp_sci_printf("General error.\r\n");
1096                 return -CMDERR_BADCFG;
1097         }
1098         return 0;
1099 }
1100
1101 /**
1102  *  @brief      Send wake up pattern
1103  *
1104  * @param[in]   cmd_io  Pointer to IO stack
1105  * @param[in]   des             Pointer to command descriptor
1106  * @param[in]   param   Parameters of command
1107  * @return      0 when OK or error code
1108  */
1109 int cmd_do_fr_sendwup(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[])
1110 {
1111         int8_t retVal = ERR_PARAM_NO_ERROR;
1112
1113         retVal = rpp_fr_send_wup(0);
1114         if (retVal == SUCCESS)
1115                 rpp_sci_printf("Wake up pattern has been sent.\r\n");
1116         else {
1117                 rpp_sci_printf("General error.\r\n");
1118                 return -CMDERR_BADCFG;
1119         }
1120         return 0;
1121 }
1122
1123 /**
1124  *  @brief      Set channel for wake up pattern sending.
1125  *
1126  * @param[in]   cmd_io  Pointer to IO stack
1127  * @param[in]   des             Pointer to command descriptor
1128  * @param[in]   param   Parameters of command
1129  * @return      0 when OK or error code
1130  */
1131 int cmd_do_fr_setwuchannel(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[])
1132 {
1133         int8_t retVal = ERR_PARAM_NO_ERROR;
1134         Fr_ChannelType channel = FR_CHANNEL_A;
1135
1136         if (*param[1] == 'A')
1137                 channel = FR_CHANNEL_A;
1138         else if (*param[1] == 'B')
1139                 channel = FR_CHANNEL_B;
1140         else
1141                 return -CMDERR_BADPAR;
1142         retVal = rpp_fr_set_wu_channel(0, channel);
1143         if (retVal == SUCCESS)
1144                 rpp_sci_printf("Wake up channel has been set.\r\n");
1145         else {
1146                 rpp_sci_printf("General error.\r\n");
1147                 return -CMDERR_BADCFG;
1148         }
1149         return 0;
1150 }
1151
1152 /**
1153  *  @brief      Get and print POC status of the FlexRay controller.
1154  *
1155  * @param[in]   cmd_io  Pointer to IO stack
1156  * @param[in]   des             Pointer to command descriptor
1157  * @param[in]   param   Parameters of command
1158  * @return      0 when OK or error code
1159  */
1160 int cmd_do_fr_getpocstatus(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[])
1161 {
1162         int8_t retVal = ERR_PARAM_NO_ERROR;
1163         Fr_POCStatusType status;
1164         char *ErrorModeStrings[] = {"ACTIVE", "HALT", "PASSIVE"};
1165         char *SlotModeStrings[]  = {"KEYSLOT", "ALL_PENDING", "ALL"};
1166         char *StartupStateStrings[]  = {
1167                 "UNDEFINED", "COLDSTART_LISTEN", "COLDSTART_CHECK", "COLDSTART_JOIN",
1168                 "COLDSTART_CONSISTENCY_CHECK", "INTEGRATION_LISTEN", "INITIALIZE_SCHEDULE", "INTEGRATION_CONSISTENCY_CHECK",
1169                 "COLDSTART_GAP", "EXTERNAL_STARTUP", "ABORT", "COLDSTART_COLLISION_RESOLUTION",
1170                 "PREPARE"
1171         };
1172         char *StateStrings[]  = {
1173                 "CONFIG", "DEFAULT_CONFIG", "HALT", "NORMAL_ACTIVE",
1174                 "NORMAL_PASSIVE", "READY", "STARTUP", "LOOPBACK",
1175                 "MONITOR", "WAKEUP"
1176         };
1177         char *WakeupStatusStrings[]  = {
1178                 "UNDEFINED", "RECEIVED_HEADER", "RECEIVED_WUP", "COLLISION_HEADER",
1179                 "COLLISION_WUP", "COLLISION_UNKNOWN", "TRANSMITTED"
1180         };
1181
1182         retVal = rpp_fr_get_poc_status(0, &status);
1183         if (retVal == SUCCESS) {
1184                 rpp_sci_printf("POC status:\r\n");
1185                 rpp_sci_printf("CHIHaltRequest: %s\r\n", (status.CHIHaltRequest == TRUE) ? "TRUE" : "FALSE");
1186                 rpp_sci_printf("CHIReadyRequest: %s\r\n", (status.CHIReadyRequest == TRUE) ? "TRUE" : "FALSE");
1187                 rpp_sci_printf("ColdstartNoise: %s\r\n", (status.ColdstartNoise == TRUE) ? "TRUE" : "FALSE");
1188                 rpp_sci_printf("Freeze: %s\r\n", (status.Freeze == TRUE) ? "TRUE" : "FALSE");
1189                 rpp_sci_printf("ErrorMode: %s\r\n", ErrorModeStrings[status.ErrorMode]);
1190                 rpp_sci_printf("SlotMode: %s\r\n", SlotModeStrings[status.SlotMode]);
1191                 rpp_sci_printf("StartupState: %s\r\n", StartupStateStrings[status.StartupState]);
1192                 rpp_sci_printf("State: %s\r\n", StateStrings[status.State]);
1193                 rpp_sci_printf("WakeupStatus: %s\r\n", WakeupStatusStrings[status.WakeupStatus]);
1194         }
1195         else {
1196                 rpp_sci_printf("General error.\r\n");
1197                 return -CMDERR_BADCFG;
1198         }
1199         return 0;
1200 }
1201
1202 /**
1203  *  @brief      Send given data through the FlexRay in selected slot.
1204  *
1205  * @param[in]   cmd_io  Pointer to IO stack
1206  * @param[in]   des             Pointer to command descriptor
1207  * @param[in]   param   Parameters of command
1208  * @return      0 when OK or error code
1209  */
1210 int cmd_do_fr_transmittxlpdu(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[])
1211 {
1212         int8_t retVal = ERR_PARAM_NO_ERROR;
1213         uint32_t bufferID;
1214         uint8_t dataLength;
1215         int values[MAX_PARAM_VALUES_NUM];
1216         uint8_t data[MAX_PARAM_VALUES_NUM];
1217         char *token = NULL;
1218
1219         if (sscanf(param[1], "%d", &bufferID) != 1)
1220                 return -CMDERR_BADPAR;
1221         if (sscanf(param[2], " %2x", &values[0]) != 1)
1222                 return -CMDERR_BADPAR;
1223         data[0] = (uint8_t)values[0];
1224         token = strtok(param[2], " ");
1225         token = strtok(NULL, " ");
1226         dataLength = 1;
1227         while (dataLength < MAX_PARAM_VALUES_NUM && token != NULL) {
1228                 if (sscanf(token, "%2x", &values[dataLength]) == EOF)
1229                         break;
1230                 data[dataLength] = (uint8_t)values[dataLength];
1231                 token = strtok(NULL, " ");
1232                 dataLength++;
1233         }
1234
1235         retVal = rpp_fr_transmit_lpdu(0, bufferID, data, dataLength);
1236         if (retVal == SUCCESS)
1237                 rpp_sci_printf("Data were set for transmission.\r\n");
1238         else {
1239                 rpp_sci_printf("General error.\r\n");
1240                 return -CMDERR_BADCFG;
1241         }
1242         return 0;
1243 }
1244
1245 /**
1246  *  @brief      Cancel the transmission in the selected slot.
1247  *
1248  * @param[in]   cmd_io  Pointer to IO stack
1249  * @param[in]   des             Pointer to command descriptor
1250  * @param[in]   param   Parameters of command
1251  * @return      0 when OK or error code
1252  */
1253 int cmd_do_fr_canceltxlpdu(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[])
1254 {
1255         int8_t retVal = ERR_PARAM_NO_ERROR;
1256         uint32_t bufferID;
1257
1258         if (sscanf(param[1], "%d", &bufferID) != 1)
1259                 return -CMDERR_BADPAR;
1260         if (param[2] != NULL)
1261                 return -CMDERR_BADPAR;
1262
1263         retVal = rpp_fr_cancel_transmit_lpdu(0, bufferID);
1264         if (retVal == SUCCESS)
1265                 rpp_sci_printf("Transmission canceled.\r\n");
1266         else {
1267                 rpp_sci_printf("General error.\r\n");
1268                 return -CMDERR_BADCFG;
1269         }
1270         return 0;
1271 }
1272
1273 /**
1274  *  @brief      Receive data from selected slot.
1275  *
1276  * @param[in]   cmd_io  Pointer to IO stack
1277  * @param[in]   des             Pointer to command descriptor
1278  * @param[in]   param   Parameters of command
1279  * @return      0 when OK or error code
1280  */
1281 int cmd_do_fr_receiverxlpdu(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[])
1282 {
1283         int8_t retVal = ERR_PARAM_NO_ERROR;
1284         uint32_t bufferID;
1285         uint8_t data[cPayloadLengthMax];
1286         Fr_RxLPduStatusType status;
1287         uint8_t receivedLength = 0;
1288         uint8_t i;
1289
1290         if (sscanf(param[1], "%d", &bufferID) != 1)
1291                 return -CMDERR_BADPAR;
1292         if (param[2] != NULL)
1293                 return -CMDERR_BADPAR;
1294
1295         memset(data, 0, sizeof(data));
1296
1297         retVal = rpp_fr_receive_lpdu(0, bufferID, data, &status, &receivedLength);
1298         if (retVal == SUCCESS) {
1299                 switch (status) {
1300                 case FR_RECEIVED_MORE_DATA_AVAILABLE:
1301                         rpp_sci_printf("More messages are still in FIFO:\r\n");
1302                 case FR_RECEIVED:
1303                         rpp_sci_printf("Received message (%d B):\r\n", receivedLength);
1304                         for (i = 0; i < receivedLength; i++) {
1305                                 rpp_sci_printf(" %02x", data[i]);
1306                         }
1307                         rpp_sci_printf("\r\n");
1308                         break;
1309                 default:
1310                         rpp_sci_printf("No message received.\r\n");
1311                         break;
1312                 }
1313         }
1314         else {
1315                 rpp_sci_printf("General error.\r\n");
1316                 return -CMDERR_BADCFG;
1317         }
1318         return 0;
1319 }
1320
1321 /**
1322  *  @brief      Returns TX LPdu status.
1323  *
1324  * @param[in]   cmd_io  Pointer to IO stack
1325  * @param[in]   des             Pointer to command descriptor
1326  * @param[in]   param   Parameters of command
1327  * @return      0 when OK or error code
1328  */
1329 int cmd_do_fr_checktxlpdustatus(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[])
1330 {
1331         int8_t retVal = ERR_PARAM_NO_ERROR;
1332         uint32_t bufferID;
1333         Fr_TxLPduStatusType status;
1334         char *statusStrings[] = {"is not", "is"};
1335
1336         if (sscanf(param[1], "%d", &bufferID) != 1)
1337                 return -CMDERR_BADPAR;
1338         if (param[2] != NULL)
1339                 return -CMDERR_BADPAR;
1340
1341         retVal = rpp_fr_check_tx_lpdu_status(0, bufferID, &status);
1342         if (retVal == SUCCESS)
1343                 rpp_sci_printf("Message transmission %s pending.\r\n", statusStrings[status]);
1344         else {
1345                 rpp_sci_printf("General error.\r\n");
1346                 return -CMDERR_BADCFG;
1347         }
1348         return 0;
1349 }
1350
1351 /**
1352  *  @brief      Disable buffer.
1353  *
1354  * @param[in]   cmd_io  Pointer to IO stack
1355  * @param[in]   des             Pointer to command descriptor
1356  * @param[in]   param   Parameters of command
1357  * @return      0 when OK or error code
1358  */
1359 int cmd_do_fr_disablelpdu(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[])
1360 {
1361         int8_t retVal = ERR_PARAM_NO_ERROR;
1362         uint32_t bufferID;
1363
1364         if (sscanf(param[1], "%d", &bufferID) != 1)
1365                 return -CMDERR_BADPAR;
1366         if (param[2] != NULL)
1367                 return -CMDERR_BADPAR;
1368
1369         retVal = rpp_fr_disable_lpdu(0, bufferID);
1370         if (retVal == SUCCESS)
1371                 rpp_sci_printf("Buffer disabled.\r\n");
1372         else {
1373                 rpp_sci_printf("General error.\r\n");
1374                 return -CMDERR_BADCFG;
1375         }
1376         return 0;
1377 }
1378
1379 /**
1380  *  @brief      Print global time of the FlexRay network.
1381  *
1382  * @param[in]   cmd_io  Pointer to IO stack
1383  * @param[in]   des             Pointer to command descriptor
1384  * @param[in]   param   Parameters of command
1385  * @return      0 when OK or error code
1386  */
1387 int cmd_do_fr_getglobaltime(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[])
1388 {
1389         int8_t retVal = ERR_PARAM_NO_ERROR;
1390         uint8_t cycle = 0;
1391         uint16_t macroTick = 0;
1392
1393         retVal = rpp_fr_get_global_time(0, &cycle, &macroTick);
1394         if (retVal == SUCCESS)
1395                 rpp_sci_printf("Cycle number: %d\r\nMacrotick number: %d\r\n", cycle, macroTick);
1396         else {
1397                 rpp_sci_printf("General error.\r\n");
1398                 return -CMDERR_BADCFG;
1399         }
1400         return 0;
1401 }
1402
1403 /**
1404  *  @brief      Print network management vector of the FlexRay node.
1405  *
1406  * @param[in]   cmd_io  Pointer to IO stack
1407  * @param[in]   des             Pointer to command descriptor
1408  * @param[in]   param   Parameters of command
1409  * @return      0 when OK or error code
1410  */
1411 int cmd_do_fr_getnmvector(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[])
1412 {
1413         int8_t retVal = ERR_PARAM_NO_ERROR;
1414         uint8_t nmVector[12];
1415         uint8_t i;
1416
1417         retVal = rpp_fr_get_network_management_vector(0, nmVector);
1418         if (retVal == SUCCESS) {
1419                 rpp_sci_printf("Network management vector:");
1420                 for (i = 0; i < Fr_cluster_config.gNetworkManagementVectorLength; i++) {
1421                         rpp_sci_printf(" %x", nmVector[i]);
1422                 }
1423                 rpp_sci_printf("\r\n");
1424         }
1425         else {
1426                 rpp_sci_printf("General error.\r\n");
1427                 return -CMDERR_BADCFG;
1428         }
1429         return 0;
1430 }
1431
1432 int cmd_do_fr_nmwatch(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[])
1433 {
1434         int8_t retVal = ERR_PARAM_NO_ERROR;
1435         uint8_t nmVector[12];
1436         uint8_t i;
1437
1438         // Calculate wait time in OS ticks
1439         static const portTickType freq_ticks = 100 /* ms */ / portTICK_RATE_MS;
1440         portTickType last_wake_time = xTaskGetTickCount();
1441
1442         while (cmd_io->getc(cmd_io) < 0) {
1443                 retVal = rpp_fr_get_network_management_vector(0, nmVector);
1444                 if (retVal == SUCCESS) {
1445                         rpp_sci_printf("Network management vector:");
1446                         for (i = 0; i < Fr_cluster_config.gNetworkManagementVectorLength; i++) {
1447                                 rpp_sci_printf(" %02x", nmVector[i]);
1448                         }
1449                         rpp_sci_printf("\r");
1450                 }
1451                 else {
1452                         rpp_sci_printf("General error.\r\n");
1453                         return -CMDERR_BADCFG;
1454                 }
1455                 vTaskDelayUntil(&last_wake_time, freq_ticks);
1456         }
1457         rpp_sci_printf("\n");
1458         return 0;
1459 }
1460
1461 /**
1462  *  @brief      Print both channels status of the FlexRay node.
1463  *
1464  * @param[in]   cmd_io  Pointer to IO stack
1465  * @param[in]   des             Pointer to command descriptor
1466  * @param[in]   param   Parameters of command
1467  * @return      0 when OK or error code
1468  */
1469 int cmd_do_fr_getchannelstatus(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[])
1470 {
1471         int8_t retVal = ERR_PARAM_NO_ERROR;
1472         uint8_t index;
1473         uint8_t channel;
1474         char *decodeStrings[] = {
1475                 "aggregated channel status vSS!ValidFrame",
1476                 "aggregated channel status vSS!SyntaxError",
1477                 "aggregated channel status vSS!ContentError",
1478                 "aggregated channel status additional communication",
1479                 "aggregated channel status vSS!Bviolation",
1480                 "aggregated channel status vSS!TxConflict",
1481                 "Not used (0)",
1482                 "Not used (0)",
1483                 "symbol window status data vSS!ValidMTS",
1484                 "symbol window status data vSS!SyntaxError",
1485                 "symbol window status data vSS!Bviolation",
1486                 "symbol window status data vSS!TxConflict",
1487                 "NIT status data vSS!SyntaxError",
1488                 "NIT status data vSS!Bviolation",
1489                 "Not used (0)",
1490                 "Not used (0)"
1491         };
1492         char *channelNames[] = {"A", "B"};
1493         char *boolStrings[] = {"FALSE", "TRUE"};
1494         uint16_t channelStatuses[2];
1495
1496         retVal = rpp_fr_get_channel_status(0, &channelStatuses[0], &channelStatuses[1]);
1497         if (retVal == SUCCESS)
1498                 for (channel = 0; channel < 2; channel++) {
1499                         rpp_sci_printf("Channel %s status:\r\n", channelNames[channel]);
1500                         for (index = 0; index < 16; index++) {
1501                                 rpp_sci_printf("\t%s: %s\r\n", decodeStrings[index], boolStrings[ (channelStatuses[channel] >> index) & 0x1 ] );
1502                         }
1503                 }
1504         else {
1505                 rpp_sci_printf("General error.\r\n");
1506                 return -CMDERR_BADCFG;
1507         }
1508         return 0;
1509 }
1510
1511 /**
1512  *  @brief      Print clock correction of the FlexRay node
1513  *
1514  * @param[in]   cmd_io  Pointer to IO stack
1515  * @param[in]   des             Pointer to command descriptor
1516  * @param[in]   param   Parameters of command
1517  * @return      0 when OK or error code
1518  */
1519 int cmd_do_fr_getclockcorrection(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[])
1520 {
1521         int8_t retVal = ERR_PARAM_NO_ERROR;
1522         int16_t rateCorrection;
1523         int32_t offsetCorrection;
1524
1525         retVal = rpp_fr_get_clock_correction(0, &rateCorrection, &offsetCorrection);
1526         if (retVal == SUCCESS)
1527                 rpp_sci_printf("Rate correction: %d\r\nOffset correction: %d\r\n", rateCorrection, offsetCorrection);
1528         else {
1529                 rpp_sci_printf("General error.\r\n");
1530                 return -CMDERR_BADCFG;
1531         }
1532         return 0;
1533 }
1534
1535 /**
1536  *  @brief      Print list of syncframec transmitted on both channels via the even and odd cycle.
1537  *
1538  * @param[in]   cmd_io  Pointer to IO stack
1539  * @param[in]   des             Pointer to command descriptor
1540  * @param[in]   param   Parameters of command
1541  * @return      0 when OK or error code
1542  */
1543 int cmd_do_fr_getsyncframelist(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[])
1544 {
1545         int8_t retVal = ERR_PARAM_NO_ERROR;
1546         uint16_t channelAEvenList[FR_MAX_SYNC_FRAME_LIST_SIZE];
1547         uint16_t channelBEvenList[FR_MAX_SYNC_FRAME_LIST_SIZE];
1548         uint16_t channelAOddList[FR_MAX_SYNC_FRAME_LIST_SIZE];
1549         uint16_t channelBOddList[FR_MAX_SYNC_FRAME_LIST_SIZE];
1550         uint32_t listSize = 0;
1551         uint8_t i;
1552
1553         if (sscanf(param[1], "%d", &listSize) != 1)
1554                 return -CMDERR_BADPAR;
1555         if (param[2] != NULL)
1556                 return -CMDERR_BADPAR;
1557         if (listSize > FR_MAX_SYNC_FRAME_LIST_SIZE)
1558                 return -CMDERR_BADPAR;
1559
1560         retVal = rpp_fr_get_sync_frame_list(0, listSize, channelAEvenList, channelBEvenList, channelAOddList, channelBOddList);
1561         if (retVal == SUCCESS) {
1562                 rpp_sci_printf("| Channel A even | channel B even | channel A odd  | channel B odd  |\r\n");
1563                 rpp_sci_printf("|----------------|----------------|----------------|----------------|\r\n");
1564                 for (i = 0; i < listSize; i++) {
1565                         rpp_sci_printf("| %-14x | %-14x | %-14x | %-14x |\r\n", channelAEvenList[i], channelBEvenList[i], channelAOddList[i], channelBOddList[i]);
1566                 }
1567                 rpp_sci_printf("|----------------|----------------|----------------|----------------|\r\n");
1568
1569         }
1570         else {
1571                 rpp_sci_printf("General error.\r\n");
1572                 return -CMDERR_BADCFG;
1573         }
1574         return 0;
1575 }
1576
1577 /**
1578  *  @brief      Print status of wakeup on each channels (wakeup received on channel or not yet received).
1579  *
1580  * @param[in]   cmd_io  Pointer to IO stack
1581  * @param[in]   des             Pointer to command descriptor
1582  * @param[in]   param   Parameters of command
1583  * @return      0 when OK or error code
1584  */
1585 int cmd_do_fr_getwakeuprxstatus(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[])
1586 {
1587         int8_t retVal = ERR_PARAM_NO_ERROR;
1588         uint8_t status = 0;
1589         char *statusStrings[] = {"was not yet", "was"};
1590         char *channelNames[] = {"A", "B"};
1591         uint8_t i;
1592
1593         retVal = rpp_fr_get_wakeup_rx_status(0, &status);
1594         if (retVal == SUCCESS)
1595                 for (i = 0; i < 2; i++) {
1596                         rpp_sci_printf("Wake up pattern %s received on channel %s.\r\n", statusStrings[(status >> i) & 0x1], channelNames[i]);
1597                 }
1598         else {
1599                 rpp_sci_printf("General error.\r\n");
1600                 return -CMDERR_BADCFG;
1601         }
1602         return 0;
1603 }
1604
1605 /**
1606  *  @brief      Set and start absolute timer.
1607  *
1608  * @param[in]   cmd_io  Pointer to IO stack
1609  * @param[in]   des             Pointer to command descriptor
1610  * @param[in]   param   Parameters of command
1611  * @return      0 when OK or error code
1612  */
1613 int cmd_do_fr_settimer(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[])
1614 {
1615         int8_t retVal = ERR_PARAM_NO_ERROR;
1616         int timer = 0;
1617         int cycle = 0;
1618         int offset = 0;
1619
1620         if (sscanf(param[1], "%i %i %i", &timer, &cycle, &offset) != 3)
1621                 return -CMDERR_BADPAR;
1622
1623         retVal = rpp_fr_set_timer(0, timer, cycle, offset);
1624         if (retVal == SUCCESS) {
1625                 uint8_t i = 0x40;
1626                 while (i && (cycle & i) == 0)
1627                         i >>= 1;
1628                 if (!i)
1629                         i = 1;
1630
1631                 rpp_sci_printf("Timer was set for every %d-th cycle, offset %d, macrotick %d\n",
1632                                            i, cycle & ~i, offset);
1633         }
1634         else {
1635                 rpp_sci_printf("General error.\r\n");
1636                 return -CMDERR_BADCFG;
1637         }
1638         return 0;
1639 }
1640
1641 /**
1642  *  @brief      Cancel selected timer
1643  *
1644  * @param[in]   cmd_io  Pointer to IO stack
1645  * @param[in]   des             Pointer to command descriptor
1646  * @param[in]   param   Parameters of command
1647  * @return      0 when OK or error code
1648  */
1649 int cmd_do_fr_canceltimer(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[])
1650 {
1651         int8_t retVal = ERR_PARAM_NO_ERROR;
1652         int timer = 0;
1653
1654         if (sscanf(param[1], "%d", &timer) != 1)
1655                 return -CMDERR_BADPAR;
1656
1657         if (param[2] != NULL)
1658                 return -CMDERR_BADPAR;
1659
1660         retVal = rpp_fr_cancel_timer(0, timer);
1661         if (retVal == SUCCESS)
1662                 rpp_sci_printf("Timer was canceled.\r\n");
1663         else {
1664                 rpp_sci_printf("General error.\r\n");
1665                 return -CMDERR_BADCFG;
1666         }
1667         return 0;
1668 }
1669
1670 /**
1671  *  @brief      Enable/disable, acknowledge, get timer IRQ
1672  *
1673  * @param[in]   cmd_io  Pointer to IO stack
1674  * @param[in]   des             Pointer to command descriptor
1675  * @param[in]   param   Parameters of command
1676  * @return      0 when OK or error code
1677  */
1678 int cmd_do_fr_timerirq(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[])
1679 {
1680         int8_t retVal = ERR_PARAM_NO_ERROR;
1681         int timer = 0;
1682         char str[4];
1683         boolean_t status = FALSE;
1684         char *boolStrings[] = {"FALSE", "TRUE"};
1685
1686
1687         if (sscanf(param[1], "%d", &timer) != 1)
1688                 return -CMDERR_BADPAR;
1689
1690         if (param[2] == NULL) {     // Get timer IRQ
1691                 retVal = rpp_fr_get_timer_irq_status(0, timer, &status);
1692                 if (retVal == SUCCESS)
1693                         rpp_sci_printf("IRQ = %s\r\n", boolStrings[status]);
1694                 else {
1695                         rpp_sci_printf("General error.\r\n");
1696                         return -CMDERR_BADCFG;
1697                 }
1698         }
1699         else {  // Some set action
1700                 if (sscanf(param[2], "%4s", str) != 1)
1701                         return -CMDERR_BADPAR;
1702                 if (strcmp(str, "EN") == 0)   // Enable IRQ
1703                         retVal = SUCCESS;   // No interrupts imlemented
1704                 else if (strcmp(str, "DIS") == 0)   // Disable IRQ
1705                         retVal = SUCCESS;   // No interrupts implemented
1706                 else if  (strcmp(str, "ACK") == 0)   // Clear IRQ
1707                         retVal = rpp_fr_clear_timer_irq(0, timer);
1708                 else    // Bad argument
1709                         return -CMDERR_BADPAR;
1710
1711                 if (retVal == SUCCESS)
1712                         rpp_sci_printf("OK\r\n");
1713                 else {
1714                         rpp_sci_printf("General error.\r\n");
1715                         return -CMDERR_BADCFG;
1716                 }
1717         }
1718         return 0;
1719 }
1720
1721 /**
1722  *  @brief      Print FlexRay driver version info.
1723  *
1724  * @param[in]   cmd_io  Pointer to IO stack
1725  * @param[in]   des             Pointer to command descriptor
1726  * @param[in]   param   Parameters of command
1727  * @return      0 when OK or error code
1728  */
1729 int cmd_do_fr_getversioninfo(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[])
1730 {
1731         Std_VersionInfoType versionInfo;
1732
1733         rpp_fr_get_driver_version(&versionInfo);
1734         rpp_sci_printf("vendorID: %#x\r\n", versionInfo.vendorID);
1735         rpp_sci_printf("moduleID: %#x\r\n", versionInfo.moduleID);
1736         rpp_sci_printf("sw_major_version: %#x\r\n", versionInfo.sw_major_version);
1737         rpp_sci_printf("sw_minor_version: %#x\r\n", versionInfo.sw_minor_version);
1738         rpp_sci_printf("sw_patch_version: %#x\r\n", versionInfo.sw_patch_version);
1739
1740         return 0;
1741 }
1742
1743 /**
1744  *  @brief      Print value of FlexRay configuratoin parameter.
1745  *
1746  * @param[in]   cmd_io  Pointer to IO stack
1747  * @param[in]   des             Pointer to command descriptor
1748  * @param[in]   param   Parameters of command
1749  * @return      0 when OK or error code
1750  */
1751 int cmd_do_fr_readcconfig(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[])
1752 {
1753         int8_t retVal = ERR_PARAM_NO_ERROR;
1754         int index = 0;
1755         uint32_t value = 0;
1756
1757         if (sscanf(param[1], "%d", &index) != 1)
1758                 return -CMDERR_BADPAR;
1759
1760         if (param[2] != NULL)
1761                 return -CMDERR_BADPAR;
1762
1763         retVal = rpp_fr_read_com_ctrl_config(0, index, &value);
1764         if (retVal == SUCCESS)
1765                 rpp_sci_printf("Value = %#x\r\n", value);
1766         else {
1767                 rpp_sci_printf("General error.\r\n");
1768                 return -CMDERR_BADCFG;
1769         }
1770         return 0;
1771 }
1772
1773 /**
1774  *  @brief      Reconfigure buffer
1775  *
1776  * @param[in]   cmd_io  Pointer to IO stack
1777  * @param[in]   des             Pointer to command descriptor
1778  * @param[in]   param   Parameters of command
1779  * @return      0 when OK or error code
1780  */
1781 int cmd_do_fr_reconfigure_buffer(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[])
1782 {
1783         int ret;
1784         char channel[3];
1785         unsigned bufferID, slot, maxpayload, cycleset, cycleoffset;
1786         Fr_TMS570LS_BufferConfigType tmp_buffer;
1787         boolean_t is_pow2;
1788         uint8_t pow2;
1789
1790         ret = sscanf(param[2], "id%i slot%i %2s cycset%i cycoffset%i max%i",
1791                                  &bufferID,
1792                                  &slot,
1793                                  channel,
1794                                  &cycleset,
1795                                  &cycleoffset,
1796                                  &maxpayload
1797                                  );
1798         if (ret != 6) {
1799                 printf("Error parsing parameter %d\n", ret+1);
1800                 return -CMDERR_BADPAR;
1801         }
1802
1803         if (slot > 2047 || bufferID > FR_MAX_BUFFERS_CNT)
1804                 return badpar("Invalid slot number\n");
1805         tmp_buffer.slotId = slot;
1806         if (strcmp(channel, "A") == 0) tmp_buffer.channel = FR_CHANNEL_A;
1807         else if (strcmp(channel, "B") == 0) tmp_buffer.channel = FR_CHANNEL_B;
1808         else if (strcmp(channel, "AB") == 0) tmp_buffer.channel = FR_CHANNEL_AB;
1809         else return badpar("Channel parsing error\n");
1810         if (cycleset == 0) cycleset = 1;
1811         for (pow2 = 1, is_pow2 = FALSE; pow2 < 128; pow2 *= 2) {
1812                 if (cycleset == pow2) {
1813                         is_pow2 = TRUE;
1814                         break;
1815                 }
1816         }
1817         if (!is_pow2)
1818                 return badpar("Cycle set must be one of 0, 1, 2, 4, 8, 16, 32, 64.\n");
1819         if (cycleoffset >= cycleset)
1820                 return badpar("Cycle offset must in range 0 - cycset-1.\n");
1821
1822         if (maxpayload >= 256)
1823                 return badpar("Maximum payload in bytes must be less than 256\n");
1824         tmp_buffer.maxPayload = maxpayload;
1825
1826         if (rpp_fr_reconfigure_lpdu(0, bufferID, tmp_buffer.slotId, tmp_buffer.channel, cycleset, cycleoffset, tmp_buffer.maxPayload, 0) == SUCCESS) {
1827                 printf("id%i slot%i %2s cycset%i cycoffset%i max%i\n",
1828                            bufferID,
1829                            slot,
1830                            channel,
1831                            cycleset,
1832                            cycleoffset,
1833                            maxpayload
1834                            );
1835                 return 0;
1836         }
1837         else
1838                 printf("Reconfiguration failed.\n");
1839         return -CMDERR_BADPAR;
1840 }
1841
1842 #endif  /* DOCGEN */
1843
1844 /** Command descriptor for FlexRay user config cluster command */
1845 cmd_des_t const cmd_des_fr_user_config = {
1846         0, 0,
1847         "frbtconfig*","Set the user configuration parameters",
1848         "### Command syntax ###\n"
1849         "\n"
1850         "    frbtconfig<TYPE> <PARAMS>\n"
1851         "where\n"
1852         "\n"
1853         "- `<TYPE>` is a string specifying the type of parameters to be set. It can be: \"cluster\" or  \"node\"\n"
1854         "- `<PARAMS>` is a sequence of numbers separated by spaces. Each number stands for one parameter.\n"
1855         "\n"
1856         "### Description ###\n"
1857         "\n"
1858         "The command takes the configuration parameters in the form of a string\n"
1859         "and sets the appropriate type of the FlexRay parameters. It is\n"
1860         "necessary to configure parameters of at least cluster, and node and\n"
1861         "one static buffer (see frbtcfgbuf command). The parameters set by this\n"
1862         "command are applied by the frbtinitU command. Once frbtinit is called,\n"
1863         "it is no longer possible to change the parameters.\n"
1864         "\n"
1865         "The type of the parameters can be selected by the `<TYPE>` selector.\n"
1866         "\n"
1867         "Type \"cluster\" sets global FlexRay network parameters. It expects a\n"
1868         "sequence of 25 parameters in this order:\n"
1869         "\n"
1870         "- 1) gColdStartAttempts\n"
1871         "- 2) gListenNoise\n"
1872         "- 3) gMacroPerCycle\n"
1873         "- 4) gMaxWithoutClockCorrectionFatal\n"
1874         "- 5) gMaxWithoutClockCorrectionPassive\n"
1875         "- 6) gNetworkManagementVectorLength\n"
1876         "- 7) gNumberOfMinislots\n"
1877         "- 8) gNumberOfStaticSlots\n"
1878         "- 9) gOffsetCorrectionStart\n"
1879         "- 10) gPayloadLengthStatic\n"
1880         "- 11) gSyncNodeMax\n"
1881         "- 12) gdActionPointOffset\n"
1882         "- 13) gdCASRxLowMax\n"
1883         "- 14) gdDynamicSlotIdlePhase\n"
1884         "- 15) gdMinislot\n"
1885         "- 16) gdMinislotActionPointOffset\n"
1886         "- 17) gdNIT\n"
1887         "- 18) gdSampleClockPeriod\n"
1888         "- 19) gdStaticSlot\n"
1889         "- 20) gdTSSTransmitter\n"
1890         "- 21) gdWakeupSymbolRxIdle\n"
1891         "- 22) gdWakeupSymbolRxLow\n"
1892         "- 23) gdWakeupSymbolRxWindow\n"
1893         "- 24) gdWakeupSymbolTxIdle\n"
1894         "- 25) gdWakeupSymbolTxLow\n"
1895         "\n"
1896         "Type \"node\" sets local FlexRay network parameters. It expects a\n"
1897         "sequence of 28 parameters in this order:\n"
1898         "\n"
1899         "- 1) pAllowHaltDueToClock\n"
1900         "- 2) pAllowPassiveToActive\n"
1901         "- 3) pChannels (0 - A, 1 - B, 2 - AB)\n"
1902         "- 4) pClusterDriftDamping\n"
1903         "- 5) pDelayCompensationA\n"
1904         "- 6) pDelayCompensationB\n"
1905         "- 7) pExternOffsetCorrection\n"
1906         "- 8) pExternRateCorrection\n"
1907         "- 9) pKeySlotUsedForStartup\n"
1908         "- 10) pKeySlotUsedForSync\n"
1909         "- 11) pLatestTx\n"
1910         "- 12) pMacroInitialOffsetA\n"
1911         "- 13) pMacroInitialOffsetB\n"
1912         "- 14) pMicroInitialOffsetA\n"
1913         "- 15) pMicroInitialOffsetB\n"
1914         "- 16) pMicroPerCycle\n"
1915         "- 17) pRateCorrectionOut\n"
1916         "- 18) pOffsetCorrectionOut\n"
1917         "- 19) pSamplesPerMicrotick\n"
1918         "- 20) pSingleSlotEnabled\n"
1919         "- 21) pWakeupChannel (0 - A, 1 - B)\n"
1920         "- 22) pWakeupPattern\n"
1921         "- 23) pdAcceptedStartupRange\n"
1922         "- 24) pdListenTimeout\n"
1923         "- 25) pdMaxDrift\n"
1924         "- 26) pDecodingCorrection\n"
1925         "- 27) syncFramePayloadMultiplexEnabled\n"
1926         "- 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"
1927         "\n"
1928         "### Example ###\n"
1929         "\n"
1930         "    --> 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"
1931         "    FlexRay cluster configuration accepted.\n"
1932         "    --> frbtconfignode 0x0 0x0 0x2 0x1 0x3 0x3 0x0 0x0 0x1 0x1 0x10D 0x6 0x6 0x18 0x18 0x36B00 0xCD 0x151 0x0 0x1 0x0 0x2 0x81 0x36DA2 0x151 0x33 0x0 0x0\n"
1933         "    FlexRay node configuration accepted.\n",
1934         CMD_HANDLER(cmd_do_fr_user_config), (void *)&cmd_list_fr_basic_test
1935 };
1936
1937 cmd_des_t const cmd_des_fr_config_buffer = {
1938         0, 0,
1939         "frbtcfgbuf?*","Configure a message buffer in the user configuration",
1940         "### Command syntax ###\n"
1941         "\n"
1942         "    frbtcfgbuf<TYPE><BUFID> slot<SLOT> <CHN> cyc<CYC> <RXTX> max<MAX> <REP> ppi<PPI> int<INT>\n"
1943         "where\n"
1944         "\n"
1945         "- `<TYPE>` is 'S' for static segment buffers and 'D' for dynamic segment buffers,\n"
1946         "- `<BUFID>` is the number of the buffer. Both static and dynamic buffers are numbered independently starting from zero,\n"
1947         "- `<SLOT>` is the number of the slot,\n"
1948         "- `<CHN>` is one of 'A', 'B' or 'AB' and identifies the used channel,\n"
1949         "- `<CYC>` is the cycle set when to send the buffer,\n"
1950         "- `<RXTX>` is either string \"rx\" or \"tx\",\n"
1951         "- `<MAX>` is the number determining the maximum payload (in hald-words),\n"
1952         "- `<REP>` is a string \"s\" or \"single\" for single transmission or \"c\" or \"continuous\" for continuous transmission,\n"
1953         "- `<PPI>` is 0 or 1 determining whether the payload preamble indicator is set,\n"
1954         "- `<INT>` is 0 or 1 and is currently ignored.\n"
1955         "\n"
1956         "### Description ###\n"
1957         "\n"
1958         "The command sets the configuration parameters for static or dynamic\n"
1959         "buffers in user configuration. The parameters set by this command are\n"
1960         "applied by the frbtinitU command. Once frbtinit is called, it is no\n"
1961         "longer possible to change the parameters.\n"
1962         "\n"
1963         "### Example ###\n"
1964         "\n"
1965         "    --> frbtcfgbufS0 slot2 AB cyc0 tx max9 continous ppi0 int1\n"
1966         "    frbtcfgbufS0 slot2 AB cyc0 tx max9  continous ppi0 int1\n"
1967         "    --> frbtcfgbufS1 slot1 AB cyc0 rx max9 continuous ppi0 int1\n"
1968         "    frbtcfgbufS1 slot1 AB cyc0 rx max9 continuous ppi0 int1\n"
1969         "    --> frbtcfgbufD0  slot9  A cyc0 rx max0x40 single ppi0 int0\n"
1970         "    frbtcfgbufD0 slot9  A cyc0 rx max64 single ppi0 int0\n"
1971         "    --> frbtcfgbufD1  slot10 A cyc0 tx max0x40 single ppi0 int0\n"
1972         "    frbtcfgbufD1 slot10  A cyc0 tx max64 single ppi0 int0\n",
1973         CMD_HANDLER(cmd_do_fr_config_bufer), (void *)&cmd_list_fr_basic_test
1974 };
1975
1976 cmd_des_t const cmd_des_fr_config_fifo = {
1977         0, 0,
1978         "frbtcfgfifo*","Configure a RX FIFO message buffer in the user configuration",
1979         "### Command syntax ###\n"
1980         "\n"
1981         "    frbtcfgfifo rejslot<SLOT> slotmask<MASK> depth<DEPTH> <CHN> cyc<CYC> max<MAX> <REJNULL> <REJSTAT>\n"
1982         "where\n"
1983         "- `<SLOT>` is the number of the slot that will be rejected. If it is 0, no slot will be rejected,\n"
1984         "- `<MASK>` is a number specifying which bits of the `<SLOT>` will be ignored,"
1985         "- `<DEPTH>` is a number specifying the depth of the FIFO,\n"
1986         "- `<CHN>` is one of 'A', 'B' or 'AB' and identifies the used channel,\n"
1987         "- `<CYC>` is the cycle set when to send the buffer,\n"
1988         "- `<MAX>` is the number determining the maximum payload (in hald-words),\n"
1989         "- `<REJNULL>` is a string \"rejnull\" for rejecting NULL frames or \"accnull\" for accepting NULL frames,\n"
1990         "- `<REJSTAT>` is a string \"rejstat\" for rejecting frames in static segment or \"accstat\" for accepting frames from static segment,\n"
1991         "\n"
1992         "### Description ###\n"
1993         "\n"
1994         "The command sets the configuration parameters for RX FIFO buffer\n"
1995         "in user configuration. The parameters set by this command are\n"
1996         "applied by the frbtinitU command. Once frbtinit is called, it is no\n"
1997         "longer possible to change the parameters.\n"
1998         "Those messages, which are not accepted by any other buffer and pass the\n"
1999         "FIFO rejection filter will be stored in the RX FIFO buffer.\n"
2000         "\n"
2001         "### Example ###\n"
2002         "\n"
2003         "    --> frbtcfgfifo rejslot6 slotmask6 depth5 AB cyc0 max0x20 rejnull accstat\n"
2004         "    frbtcfgfifo rejslot6 slotmask6 depth5 AB cyc0 max0x20 rejnull accstat\n",
2005         CMD_HANDLER(cmd_do_fr_config_fifo), (void *)&cmd_list_fr_basic_test
2006 };
2007
2008 /** Command descriptor for FlexRay init command */
2009 cmd_des_t const cmd_des_fr_init = {
2010         0, 0,
2011         "frbtinit?","Initialize a FlexRay node",
2012         "### Command syntax ###\n"
2013         "\n"
2014         "    frbtinit<CFG>\n"
2015         "\n"
2016         "where `<CFG>` identifies the configuration to use. It can be one of A, B\n"
2017         "or U. The A and B are predefined configurations. If U is specified,\n"
2018         "the user configuration previously set by frbtconfig command is used.\n"
2019         "\n"
2020         "### Description ###\n"
2021         "\n"
2022         "The command stands for Fr_Init and Fr_ControllerInit functions from\n"
2023         "the Autosar specification. It initializes the internal data structures\n"
2024         "of the driver and then, based on those data, the controller\n"
2025         "configuration is done. During the controller configuration the\n"
2026         "parameters of the cluster, node, message RAM and buffers are checked.\n"
2027         "If anything goes bad, the command returns an error number, which can\n"
2028         "be decoded by macros defined in driver header file fr_tms570.h with\n"
2029         "prefix ERR_PARAM. If all parameters are OK, all necessary registers of\n"
2030         "the controller are initialized according to the specified\n"
2031         "configuration parameters. At the end of the command, the FlexRay\n"
2032         "controller is switched into READY state and all buffers are configured\n"
2033         "to send NULL frames. This command should be called as the very first\n"
2034         "command, when trying to communicate over the FlexRay bus.\n"
2035         "\n"
2036         "### Example ###\n"
2037         "\n"
2038         "    --> frbtinitA\n"
2039         "    FlexRay driver initialized.\n"
2040         "    FlexRay controller initialized.\n",
2041         CMD_HANDLER(cmd_do_fr_init), (void *)&cmd_list_fr_basic_test
2042 };
2043
2044 /** Command descriptor for FlexRay controller init command */
2045 cmd_des_t const cmd_des_fr_start = {
2046         0, 0,
2047         "frbtstart","Start a new FlexRay network or join to the existing one",
2048         "### Command syntax ###\n"
2049         "\n"
2050         "    frbtstart\n"
2051         "\n"
2052         "### Description ###\n"
2053         "\n"
2054         "The command stands for Fr_StartCommunication function from the Autosar\n"
2055         "specification.\n"
2056         "If the FlexRay node is configured as a coldstarter node\n"
2057         "(as for example by frbtinitA/B command), then the command first listen\n"
2058         "on the bus. When it does not detect any existing bus communication, it\n"
2059         "tries to initiate a new network. If the initiation fails, the FlexRay\n"
2060         "controller is switched back to the ready state for another attempt\n"
2061         "(calling frbtstart again). If the FlexRay node is configured as\n"
2062         "non-coldstarter, it is listening on the bus until some existing\n"
2063         "communication is detected.\n"
2064         "\n"
2065         "The command should be called after the frbtinit command.\n"
2066         "\n"
2067         "You may also want to call frbtallslots command to allow the communication\n"
2068         "for all other slots besides the key slots.\n"
2069         "\n"
2070         "### Example ###\n"
2071         "\n"
2072         "    --> frbtstart\n"
2073         "    FlexRay communication is running.\n",
2074         CMD_HANDLER(cmd_do_fr_start), (void *)&cmd_list_fr_basic_test
2075 };
2076
2077 /** Command descriptor for FlexRay controller all slots command */
2078 cmd_des_t const cmd_des_fr_allslots = {
2079         0, 0,
2080         "frbtallslots","Enables communication for all frames",
2081         "### Command syntax ###\n"
2082         "\n"
2083         "    frbtallslots\n"
2084         "\n"
2085         "### Description ###\n"
2086         "\n"
2087         "The command stands for Fr_AllSlots function from the Autosar\n"
2088         "specification.\n"
2089         "\n"
2090         "The node can be configured to communicate only on key frames by\n"
2091         "default (as in the case of frbtinitA/B). This command can be used to\n"
2092         "allow the communication on all configured frames. The command invokes\n"
2093         "the FlexRay POC command ALL_SLOTS which enables the communication on\n"
2094         "all frames. The command can be called after the controller\n"
2095         "initialization.\n"
2096         "\n"
2097         "### Example ###\n"
2098         "\n"
2099         "    --> frbtallslots\n"
2100         "    FlexRay node started communication on all slots.\n",
2101         CMD_HANDLER(cmd_do_fr_allslots), (void *)&cmd_list_fr_basic_test
2102 };
2103
2104 /** Command descriptor for FlexRay controller halt command */
2105 cmd_des_t const cmd_des_fr_halt = {
2106         0, 0,
2107         "frbthalt","Halt FlexRay communication after the end of the actual communication cycle",
2108         "### Command syntax ###\n"
2109         "\n"
2110         "    frbthalt\n"
2111         "\n"
2112         "### Description ###\n"
2113         "\n"
2114         "The command stands for Fr_HaltCommunication function from the Autosar\n"
2115         "specification. The command invokes the FlexRay POC command HALT, which\n"
2116         "means that communication is stopped after the end of the actual\n"
2117         "communication cycle. On the opposite side, there is a frbtfreeze\n"
2118         "command, which stops the communication immediately. To restart the\n"
2119         "communication, the frbtinit and frbtstart commands have to be called.\n"
2120         "\n"
2121         "### Example ###\n"
2122         "\n"
2123         "    --> frbthalt\n"
2124         "    FlexRay node communication halted.\n",
2125         CMD_HANDLER(cmd_do_fr_halt), (void *)&cmd_list_fr_basic_test
2126 };
2127
2128 /** Command descriptor for FlexRay controller abort command */
2129 cmd_des_t const cmd_des_fr_abort = {
2130         0, 0,
2131         "frbtabort","Abort FlexRay communication immediately",
2132         "### Command syntax ###\n"
2133         "\n"
2134         "    frbtabort\n"
2135         "\n"
2136         "### Description ###\n"
2137         "\n"
2138         "The command stands for Fr_AbortCommunication function from the Autosar\n"
2139         "specification. The command invokes the FlexRay POC command FREEZE,\n"
2140         "which means that the communication is stopped immediately. On the\n"
2141         "opposite side there is a frbthalt command, which stops the\n"
2142         "communication after the end of the actual communication cycle. To\n"
2143         "restart the communication, the frbtinit and frbtstart commands have\n"
2144         "to be called.\n"
2145         "\n"
2146         "### Example ###\n"
2147         "\n"
2148         "    --> frbtabort\n"
2149         "    FlexRay node communication aborted.\n",
2150         CMD_HANDLER(cmd_do_fr_abort), (void *)&cmd_list_fr_basic_test
2151 };
2152
2153 /** Command descriptor for FlexRay controller send wake up pattern command */
2154 cmd_des_t const cmd_des_fr_sendwup = {
2155         0, 0,
2156         "frbtwup","Initiate the wake up procedure",
2157         "### Command syntax ###\n"
2158         "\n"
2159         "    frbtwup\n"
2160         "\n"
2161         "### Description ###\n"
2162         "\n"
2163         "The command stands for Fr_SendWUP function from the Autosar\n"
2164         "specification. It initiates the wake up procedure by switching FlexRay\n"
2165         "controller state machine to WAKEUP state.\n"
2166         "\n"
2167         "### Example ###\n"
2168         "\n"
2169         "    --> frbtwup\n"
2170         "    Wake up pattern has been sent.\n",
2171         CMD_HANDLER(cmd_do_fr_sendwup), (void *)&cmd_list_fr_basic_test
2172 };
2173
2174 /** Command descriptor for FlexRay controller sent wake up pattern channel command */
2175 cmd_des_t const cmd_des_fr_setwuchannel = {
2176         0, 0,
2177         "frbtsetwuch?","Set wake up channel",
2178         "### Command syntax ###\n"
2179         "\n"
2180         "    frbtsetwuch<CHANNEL>\n"
2181         "\n"
2182         "where `<CHANNEL>` is a character A or B, specifying the channel.\n"
2183         "\n"
2184         "### Description ###\n"
2185         "\n"
2186         "The command stands for Fr_SetWakeupChannel function from the Autosar\n"
2187         "specification. Wake up channel is the channel, where Wake Up Pattern\n"
2188         "is sent. The channel can be set after the driver and controller are\n"
2189         "initialized and before the communication is running. The actual\n"
2190         "wake-up pattern is sent by the frbtwup command.\n"
2191         "\n"
2192         "### Example ###\n"
2193         "\n"
2194         "    --> frbtsetwuchA\n"
2195         "    Wake up channel has been set.\n",
2196         CMD_HANDLER(cmd_do_fr_setwuchannel), (void *)&cmd_list_fr_basic_test
2197 };
2198
2199 /** Command descriptor for FlexRay controller get POC status command */
2200 cmd_des_t const cmd_des_fr_getpocstatus = {
2201         0, 0,
2202         "frbtgetpocst","Print FlexRay POC status",
2203         "### Command syntax ###\n"
2204         "\n"
2205         "    frbtgetpocst\n"
2206         "\n"
2207         "### Description ###\n"
2208         "\n"
2209         "The command stands for Fr_GetPOCStatus function from the Autosar\n"
2210         "specification. It prints the main FlexRay POC status values in the\n"
2211         "form of a table. The command should be called after the frbtinit\n"
2212         "command.\n"
2213         "\n"
2214         "### Example ###\n"
2215         "\n"
2216         "    --> frbtgetpocst\n"
2217         "    POC status:\n"
2218         "    CHIHaltRequest: FALSE\n"
2219         "    CHIReadyRequest: FALSE\n"
2220         "    ColdstartNoise: FALSE\n"
2221         "    Freeze: FALSE\n"
2222         "    ErrorMode: ACTIVE\n"
2223         "    SlotMode: ALL\n"
2224         "    StartupState: UNDEFINED\n"
2225         "    State: READY\n"
2226         "    WakeupStatus: UNDEFINED\n",
2227         CMD_HANDLER(cmd_do_fr_getpocstatus), (void *)&cmd_list_fr_basic_test
2228 };
2229
2230 /** Command descriptor for FlexRay transmit tx lpdu command */
2231 cmd_des_t const cmd_des_fr_transmittxlpdu = {
2232         0, 0,
2233         "frbttransmit*","Transmit data from the selected frame buffer",
2234         "### Command syntax ###\n"
2235         "\n"
2236         "    frbttransmit<BUFID> <DATA>\n"
2237         "where\n"
2238         "\n"
2239         "- `<BUFID>` is a decimal number specifying the ID of the frame\n"
2240         "            buffer configured for data transmission\n"
2241         "- `<DATA>`  is a sequence of hexadecimal numbers separated by spaces.\n"
2242         "            Each number represents one byte of the message.\n"
2243         "\n"
2244         "### Description ###\n"
2245         "\n"
2246         "The command stands for Fr_TransmitTxLPdu function from the Autosar\n"
2247         "specification. The command copies the given data into the buffers data\n"
2248         "section in the message RAM. Transmit request is set after the data are\n"
2249         "copied, so transmission starts at the next occurrence of the frame in the\n"
2250         "communication cycle.\n"
2251         "\n"
2252         "### Example ###\n"
2253         "\n"
2254         "    --> frbttransmit1 12 34 56 AA BB CC\n"
2255         "    Data were set for transmission.\n",
2256         CMD_HANDLER(cmd_do_fr_transmittxlpdu), (void *)&cmd_list_fr_basic_test
2257 };
2258
2259 /** Command descriptor for FlexRay cancel tx lpdu command */
2260 cmd_des_t const cmd_des_fr_canceltxlpdu = {
2261         0, 0,
2262         "frbtcanceltx*","Stop the transmission from the frame buffer",
2263         "### Command syntax ###\n"
2264         "\n"
2265         "    frbtcanceltx<BUFID>\n"
2266         "\n"
2267         "where `<BUFID>` is a decimal number specifying the ID of a configured\n"
2268         "frame buffer\n"
2269         "\n"
2270         "### Description ###\n"
2271         "\n"
2272         "The command stands for Fr_CancelTxLPdu function from the Autosar\n"
2273         "specification. The command reconfigures the selected buffer to stop\n"
2274         "data transmission. The command finishes successfully only if the\n"
2275         "reconfiguration is allowed in message RAM configuration (secureBuffers\n"
2276         "configuration parameter). Only TX buffers and buffers not used for startup\n"
2277         "frames can be canceled.\n"
2278         "\n"
2279         "### Example ###\n"
2280         "\n"
2281         "    --> frbtcanceltx3\n"
2282         "    Transmission canceled.\n",
2283         CMD_HANDLER(cmd_do_fr_canceltxlpdu), (void *)&cmd_list_fr_basic_test
2284 };
2285
2286 /** Command descriptor for FlexRay receive rx lpdu command */
2287 cmd_des_t const cmd_des_fr_receiverxlpdu = {
2288         0, 0,
2289         "frbtreceive*","Receive a new message",
2290         "### Command syntax ###\n"
2291         "\n"
2292         "    frbtreceive<BUFID>\n"
2293         "\n"
2294         "where `<BUFID>` is a decimal number specifying the ID of a configured\n"
2295         "frame buffer.\n"
2296         "\n"
2297         "### Description ###\n"
2298         "\n"
2299         "The command stands for Fr_ReceiveRxLPdu function from the Autosar\n"
2300         "specification. The command tries to read a new message from the selected\n"
2301         "buffer. If new message is available, it is copied out of the buffer and\n"
2302         "printed. If no message is available, \"No message received\" is printed.\n"
2303         "If a new message was retrieved from a FIFO buffer and more messages are\n"
2304         "available in it, \"More messages are still in FIFO\" is printed.\n"
2305         "\n"
2306         "### Example ###\n"
2307         "\n"
2308         "    --> frbtreceive0\n"
2309         "    More messages are still in FIFO:\n"
2310         "    Received message (32 B):\n"
2311         "     ee ff 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00\n"
2312         "     00 00 00 00 00 00 00 00 00\n",
2313         CMD_HANDLER(cmd_do_fr_receiverxlpdu), (void *)&cmd_list_fr_basic_test
2314 };
2315
2316 /** Command descriptor for FlexRay check TX LPdu status command */
2317 cmd_des_t const cmd_des_fr_checktxlpdustatus = {
2318         0, 0,
2319         "frbtchecktx*","Print the status of the transmit buffer",
2320         "### Command syntax ###\n"
2321         "\n"
2322         "    frbtchecktx<BUFID>\n"
2323         "\n"
2324         "where `<BUFID>` is a decimal number specifying the ID of a configured\n"
2325         "frame buffer.\n"
2326         "\n"
2327         "### Description ###\n"
2328         "\n"
2329         "The command stands for Fr_CheckTxLPduStatus function from the Autosar\n"
2330         "specification. The command reads and prints status of the selected frame buffer.\n"
2331         "The buffer can be in one of the two states:\n"
2332         "\n"
2333         "- Message transmission is pending, which means that the buffer has not yet sent its\n"
2334         "  message in single shot mode or that it is in continuous mode.\n"
2335         "- No message transmission is pending, which means that the buffer is in single shot\n"
2336         "  mode and the message has already been sent.\n"
2337         "\n"
2338         "### Example ###\n"
2339         "\n"
2340         "    --> frbtchecktx1\n"
2341         "    Message transmission is not pending.\n",
2342         CMD_HANDLER(cmd_do_fr_checktxlpdustatus), (void *)&cmd_list_fr_basic_test
2343 };
2344
2345 /** Command descriptor for FlexRay disable LPdu command */
2346 cmd_des_t const cmd_des_fr_disablelpdu = {
2347         0, 0,
2348         "frbtdisable*","Disable the buffers assigned to the frame",
2349         "### Command syntax ###\n"
2350         "\n"
2351         "    frbtdisable<BUFID>\n"
2352         "\n"
2353         "where `<BUFID>` is a decimal number specifying the ID of a frame buffer.\n"
2354         "The buffer configured will be disabled.\n"
2355         "\n"
2356         "### Description ###\n"
2357         "\n"
2358         "The command stands for Fr_DisableLPdu function from the Autosar\n"
2359         "specification. The command disables the selected buffer. This means\n"
2360         "that this buffer will be unavailable for the communication until\n"
2361         "their reconfiguration (which is not yet implemented). Buffers used\n"
2362         "for startup frames and FIFO RX buffers cannot be disabled.\n"
2363         "\n"
2364         "### Example ###\n"
2365         "\n"
2366         "    --> frbtdisable3\n"
2367         "    Buffer disabled.\n",
2368         CMD_HANDLER(cmd_do_fr_disablelpdu), (void *)&cmd_list_fr_basic_test
2369 };
2370
2371 /** Command descriptor for FlexRay get global time command */
2372 cmd_des_t const cmd_des_fr_getglobaltime = {
2373         0, 0,
2374         "frbtglobtime","Print actual global time of the network",
2375         "### Command syntax ###\n"
2376         "\n"
2377         "    frbtglobtime\n"
2378         "\n"
2379         "### Description ###\n"
2380         "\n"
2381         "The command stands for Fr_GetGlobalTime function from the Autosar\n"
2382         "specification. The command prints the time as a number of the current\n"
2383         "cycle and the offset in the cycle in macroticks.\n"
2384         "\n"
2385         "### Example ###\n"
2386         "\n"
2387         "    --> frbtglobtime\n"
2388         "    Cycle number: 23\n"
2389         "    Macrotick number: 6\n",
2390         CMD_HANDLER(cmd_do_fr_getglobaltime), (void *)&cmd_list_fr_basic_test
2391 };
2392
2393 /** Command descriptor for FlexRay get network management vector command */
2394 cmd_des_t const cmd_des_fr_getnmvector = {
2395         0, 0,
2396         "frbtnmvector","Print network management vector of the node",
2397         "### Command syntax ###\n"
2398         "\n"
2399         "    frbtnmvector\n"
2400         "\n"
2401         "### Description ###\n"
2402         "\n"
2403         "The command stands for Fr_GetNmVector function from the Autosar\n"
2404         "specification. It prints the values of the network management vector\n"
2405         "as hexadecimal numbers.\n"
2406         "\n"
2407         "### Example ###\n"
2408         "\n"
2409         "    --> frbtnmvector\n"
2410         "    Network management vector: 0 0 0 0 0 0 0 0 0 0 0 0\n",
2411         CMD_HANDLER(cmd_do_fr_getnmvector), (void *)&cmd_list_fr_basic_test
2412 };
2413
2414 /** Command descriptor for FlexRay get network management vector command */
2415 cmd_des_t const cmd_des_fr_nmwatch = {
2416         0, 0,
2417         "frbtnmwatch","Watch the changes of the network managment vector in real-time",
2418         "### Command syntax ###\n"
2419         "\n"
2420         "    frbtnmwatch\n"
2421         "\n"
2422         "### Description ###\n"
2423         "\n"
2424         "Reads the network management vector every 100 ms and prints it out.\n"
2425         "\n"
2426         "### Example ###\n"
2427         "\n"
2428         "    --> frbtnmwatch\n"
2429         "    Network management vector: 0 0 0 0 0 0 0 0 0 0 0 0\n",
2430         CMD_HANDLER(cmd_do_fr_nmwatch), (void *)&cmd_list_fr_basic_test
2431 };
2432
2433 /** Command descriptor for FlexRay get channel status command */
2434 cmd_des_t const cmd_des_fr_getchannelstatus = {
2435         0, 0,
2436         "frbtchstat","Print channel A and B status",
2437         "### Command syntax ###\n"
2438         "\n"
2439         "    frbtchstat\n"
2440         "\n"
2441         "### Description ###\n"
2442         "\n"
2443         "The command stands for Fr_GetChannelStatus function from the Autosar\n"
2444         "specification.\n"
2445         "\n"
2446         "### Example ###\n"
2447         "\n"
2448         "    --> frbtchstat\n"
2449         "    Channel A status:\n"
2450         "       aggregated channel status vSS!ValidFrame: TRUE\n"
2451         "       aggregated channel status vSS!SyntaxError: FALSE\n"
2452         "       aggregated channel status vSS!ContentError: FALSE\n"
2453         "       aggregated channel status additional communication: FALSE\n"
2454         "       aggregated channel status vSS!Bviolation: FALSE\n"
2455         "       aggregated channel status vSS!TxConflict: FALSE\n"
2456         "       Not used (0): FALSE\n"
2457         "       Not used (0): FALSE\n"
2458         "       symbol window status data vSS!ValidMTS: FALSE\n"
2459         "       symbol window status data vSS!SyntaxError: FALSE\n"
2460         "       symbol window status data vSS!Bviolation: FALSE\n"
2461         "       symbol window status data vSS!TxConflict: FALSE\n"
2462         "       NIT status data vSS!SyntaxError: FALSE\n"
2463         "       NIT status data vSS!Bviolation: FALSE\n"
2464         "       Not used (0): FALSE\n"
2465         "       Not used (0): FALSE\n"
2466         "    Channel B status:\n"
2467         "       aggregated channel status vSS!ValidFrame: TRUE\n"
2468         "       aggregated channel status vSS!SyntaxError: FALSE\n"
2469         "       aggregated channel status vSS!ContentError: FALSE\n"
2470         "       aggregated channel status additional communication: FALSE\n"
2471         "       aggregated channel status vSS!Bviolation: FALSE\n"
2472         "       aggregated channel status vSS!TxConflict: FALSE\n"
2473         "       Not used (0): FALSE\n"
2474         "       Not used (0): FALSE\n"
2475         "       symbol window status data vSS!ValidMTS: FALSE\n"
2476         "       symbol window status data vSS!SyntaxError: FALSE\n"
2477         "       symbol window status data vSS!Bviolation: FALSE\n"
2478         "       symbol window status data vSS!TxConflict: FALSE\n"
2479         "       NIT status data vSS!SyntaxError: FALSE\n"
2480         "       NIT status data vSS!Bviolation: FALSE\n"
2481         "       Not used (0): FALSE\n"
2482         "       Not used (0): FALSE\n",
2483         CMD_HANDLER(cmd_do_fr_getchannelstatus), (void *)&cmd_list_fr_basic_test
2484 };
2485
2486 /** Command descriptor for FlexRay get clock correction command */
2487 cmd_des_t const cmd_des_fr_getclockcorrection = {
2488         0, 0,
2489         "frbtclkcor","Print clock correction (rate and offset)",
2490         "### Command syntax ###\n"
2491         "\n"
2492         "    frbtclkcor\n"
2493         "\n"
2494         "### Description ###\n"
2495         "\n"
2496         "The command stands for Fr_GetClockCorrection function from the Autosar\n"
2497         "specification.\n"
2498         "\n"
2499         "### Example ###\n"
2500         "\n"
2501         "    --> frbtclkcor\n"
2502         "    Rate correction: 0\n"
2503         "    Offset correction: 0\n",
2504         CMD_HANDLER(cmd_do_fr_getclockcorrection), (void *)&cmd_list_fr_basic_test
2505 };
2506
2507 /** Command descriptor for FlexRay get sync frame list command */
2508 cmd_des_t const cmd_des_fr_getsyncframelist = {
2509         0, 0,
2510         "frbtgetsyncfrlist*","Print the list of sync frames transmitted on both channels via the odd and even communication cycle",
2511         "### Command syntax ###\n"
2512         "\n"
2513         "    frbtgetsyncfrlist<LENGTH>\n"
2514         "\n"
2515         "where `<LENGTH>` is a decimal number in range 0 - 15, specifying the\n"
2516         "length of the list to be printed.\n"
2517         "\n"
2518         "### Description ###\n"
2519         "\n"
2520         "The command stands for Fr_GetSyncFrameList function from the Autosar\n"
2521         "specification.\n"
2522         "\n"
2523         "### Example ###\n"
2524         "\n"
2525         "    --> frbtgetsyncfrlist2\n"
2526         "    | Channel A even | channel B even | channel A odd  | channel B odd  |\n"
2527         "    |----------------|----------------|----------------|----------------|\n"
2528         "    | 1              | 1              | 1              | 1              |\n"
2529         "    | 2              | 2              | 2              | 2              |\n"
2530         "    |----------------|----------------|----------------|----------------|\n",
2531         CMD_HANDLER(cmd_do_fr_getsyncframelist), (void *)&cmd_list_fr_basic_test
2532 };
2533
2534 /** Command descriptor for FlexRay get sync frame list command */
2535 cmd_des_t const cmd_des_fr_getwakeuprxstatus = {
2536         0, 0,
2537         "frbtgetwurxstat","Prints whether the wake up pattern has been or has not been received",
2538         "### Command syntax ###\n"
2539         "\n"
2540         "    frbtgetwurxstat\n"
2541         "\n"
2542         "### Description ###\n"
2543         "\n"
2544         "The command stands for Fr_GetWakeupRxStatus function from the Autosar\n"
2545         "specification. The status of the wake up receiving is bitcoded in the\n"
2546         "controller. This command decodes and prints it in a readable format.\n"
2547         "\n"
2548         "### Example ###\n"
2549         "\n"
2550         "    --> frbtgetwurxstat\n"
2551         "    Wake up pattern was not yet received on channel A.\n"
2552         "    Wake up pattern was not yet received on channel B.\n",
2553         CMD_HANDLER(cmd_do_fr_getwakeuprxstatus), (void *)&cmd_list_fr_basic_test
2554 };
2555
2556 /** Command descriptor for FlexRay set absolute timer command */
2557 cmd_des_t const cmd_des_fr_settimer = {
2558         0, 0,
2559         "frbtsettimer*","Set and start timer",
2560         "### Command syntax ###\n"
2561         "\n"
2562         "    frbtsettimer<TMID> <CYCLE> <OFFSET>\n"
2563         "where\n"
2564         "\n"
2565         "- `<TMID>` is a number (0, 1) specifying the timer.\n"
2566         "- `<CYCLE>` is a 7-bit number (0 - 127) specifying the set of cycles, in which timer interrupt should be requested. The first set bit determines the period (1, 2, ..., 64) and the lower bits determine the offset in cycles within the period.\n"
2567         "- `<OFFSET>` is a decimal number (0 - 16383) specifying the offset in macroticks, where precisely in the cycle should be the timer interrupt requested.\n"
2568         "\n"
2569         "### Description ###\n"
2570         "\n"
2571         "The command is similar to Fr_SetAbsoluteTimer function from the\n"
2572         "Autosar specification. The difference is that the command allows to\n"
2573         "specify a set of cycles, not only one of 64 cycles. It sets the timer\n"
2574         "selected by the parameter and enables it.\n"
2575         "\n"
2576         "Before using this command, FlexRay communication has to be started\n"
2577         "(see frbtstart).\n"
2578         "\n"
2579         "### Example ###\n"
2580         "\n"
2581         "    --> frbtsettimer0 32 50\n"
2582         "    Timer was set for every 32-th cycle, offset 0, macrotick 50\n"
2583         "    --> frbtsettimer0 31 50\n"
2584         "    Timer was set for every 16-th cycle, offset 15, macrotick 50\n"
2585         "    --> frbtsettimer0 0x42 0\n"
2586         "    Timer was set for every 64-th cycle, offset 2, macrotick 0\n",
2587         CMD_HANDLER(cmd_do_fr_settimer), (void *)&cmd_list_fr_basic_test
2588 };
2589
2590 /** Command descriptor for FlexRay cancel absolute timer command */
2591 cmd_des_t const cmd_des_fr_canceltimer = {
2592         0, 0,
2593         "frbtcanceltimer*","Stop the timer",
2594         "### Command syntax ###\n"
2595         "\n"
2596         "    frbtcanceltimer<TMID>\n"
2597         "where `<TMID>` is a number (0 or 1) specifying the timer.\n"
2598         "\n"
2599         "### Description ###\n"
2600         "\n"
2601         "The command stands for Fr_CancelAbsoluteTimer function from the\n"
2602         "Autosar specification. It stops the timer selected by the parameter.\n"
2603         "\n"
2604         "### Example ###\n"
2605         "\n"
2606         "    --> frbtcanceltimer0\n"
2607         "    Timer was canceled.\n",
2608         CMD_HANDLER(cmd_do_fr_canceltimer), (void *)&cmd_list_fr_basic_test
2609 };
2610
2611 /** Command descriptor for FlexRay absolute timer irq manipulation command */
2612 cmd_des_t const cmd_des_fr_timerirq = {
2613         0, 0,
2614         "frbttimerirq*","Perform selected action on the timer IRQ",
2615         "### Command syntax ###\n"
2616         "\n"
2617         "    frbttimerirq<TMID> <ACTION> - Run the <ACTION> on specified timer\n"
2618         "    frbttimerirq<TMID> - Get timer IRQ status\n"
2619         "\n"
2620         "where\n"
2621         "\n"
2622         "- `<TMID>` is a number (0, 1) specifying the timer.\n"
2623         "- where `<ACTION>` is a string specifying the action  to be performed on the selected timer IRQ.\n"
2624         "\n"
2625         "`<ACTIONS>` can be one of:\n"
2626         "\n"
2627         "- EN - Enable the IRQ on the selected timer\n"
2628         "- DIS - Disable the IRQ on the selected timer\n"
2629         "- ACK - Acknowledge the IRQ on the selected timer (reset flag in the register).\n"
2630         "\n"
2631         "### Description ###\n"
2632         "\n"
2633         "The command stands for Fr_EnableAbsoluteTimerIRQ,\n"
2634         "Fr_AckAbsoluteTimerIRQ, Fr_DisableAbsoluteTimerIRQ and\n"
2635         "Fr_GetAbsoluteTimerIRQStatus functions from the Autosar specification.\n"
2636         "It masks or demasks the IRQ for the timer, or acknowledges the\n"
2637         "interrupt request. If no action is specified it prints whether the IRQ\n"
2638         "is pending for the timer.\n"
2639         "\n"
2640         "### Example ###\n"
2641         "\n"
2642         "    --> frbttimerirq0\n"
2643         "    IRQ = FALSE\n"
2644         "\n"
2645         "    --> frbttimerirq0 EN\n"
2646         "    OK\n",
2647         CMD_HANDLER(cmd_do_fr_timerirq), (void *)&cmd_list_fr_basic_test
2648 };
2649
2650 /** Command descriptor for FlexRay get version info command */
2651 cmd_des_t const cmd_des_fr_getversioninfo = {
2652         0, 0,
2653         "frbtversion","Print FlexRay driver version information",
2654         "### Command syntax ###\n"
2655         "\n"
2656         "    frbtversion\n"
2657         "\n"
2658         "### Description ###\n"
2659         "\n"
2660         "The command stands for Fr_GetVersionInfo function from the Autosar\n"
2661         "specification.\n"
2662         "It reads and prints the information about vendor, module and version of\n"
2663         "the FlexRay driver\n"
2664         "\n"
2665         "### Example ###\n"
2666         "\n"
2667         "    --> frbtversion\n"
2668         "    vendorID: 0xAAAA\n"
2669         "    moduleID: 0xBBBB\n"
2670         "    sw_major_version: 0x1\n"
2671         "    sw_minor_version: 0x2\n"
2672         "    sw_patch_version: 0x4\n",
2673         CMD_HANDLER(cmd_do_fr_getversioninfo), (void *)&cmd_list_fr_basic_test
2674 };
2675
2676 /** Command descriptor for FlexRay get controller configuration command */
2677 cmd_des_t const cmd_des_fr_readcconfig = {
2678         0, 0,
2679         "frbtccconfig*","Print value of a FlexRay cluster and node configuration parameter",
2680         "### Command syntax ###\n"
2681         "\n"
2682         "    frbtccconfig<INDEX>\n"
2683         "\n"
2684         "where `<INDEX>` is an identifier of the parameter.\n"
2685         "\n"
2686         "### Description ###\n"
2687         "\n"
2688         "The command stands for Fr_ReadCCConfig function from the Autosar\n"
2689         "specification. The driver stores the configuration parameters as an\n"
2690         "array. Each parameter can be indexed and returned by this command. See\n"
2691         "Autosar specification of the FlexRay driver\n"
2692         "(http://www.autosar.org/download/R4.1/AUTOSAR_SWS_FlexRayDriver.pdf),\n"
2693         "section 8.2.1 for parameter indexes.\n"
2694         "\n"
2695         "### Example ###\n"
2696         "\n"
2697         "    --> frbtccconfig1\n"
2698         "    Value = 0x1\n",
2699         CMD_HANDLER(cmd_do_fr_readcconfig), (void *)&cmd_list_fr_basic_test
2700 };
2701
2702 /** Command descriptor for FlexRay reconfigure buffer command */
2703 cmd_des_t const cmd_des_fr_reconfigure_buffer = {
2704         0, 0,
2705         "frbtreconfigurebuf*","Reconfigure a buffer to communicate in another slot",
2706         "### Command syntax ###\n"
2707         "\n"
2708         "    frbtreconfigurebuf id<BUFID> slot<SLOT> <CHN> cycset<CYCS> cycoffset<CYCO> max<MAX>\n"
2709         "where\n"
2710         "\n"
2711         "- `<BUFID>` is a number specifying a slot, where the buffer is currently communicating,\n"
2712         "- `<SLOT>` is a number, where buffer will be communicating after the reconfiguration,\n"
2713         "- `<CHN>` is one of 'A', 'B' or 'AB' and identifies the used channel,\n"
2714         "- `<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"
2715         "- `<CYCO>` is the cycle offset. It has to be in range 0 - `<CYCS>`-1"
2716         "- `<MAX>` is the number determining the maximum payload (in hald-words).\n"
2717         "\n"
2718         "### Description ###\n"
2719         "\n"
2720         "The command stands for Fr_ReconfigLPDu function from the Autosar\n"
2721         "specification. It reconfigures specified buffer to communicate in\n"
2722         "different slot.\n"
2723         "The reconfiguration must be allowed in node configuration parameter\n"
2724         "secureBuffers. Buffers used for synchronization or assigned to the FIFO\n"
2725         "are not reconfigurable.\n"
2726         "The command can be called any time when the communication is running.\n"
2727         "\n"
2728         "### Example ###\n"
2729         "\n"
2730         "    --> frbtreconfigurebuf id2 slot3 AB cycset1 cycoffset0 max9\n"
2731         "    frbtreconfigurebuf id2 slot3 AB cycset1 cycoffset0 max9\n",
2732         CMD_HANDLER(cmd_do_fr_reconfigure_buffer), (void *)&cmd_list_fr_basic_test
2733 };
2734
2735
2736 /** List of commands for flexRay, defined as external */
2737 cmd_des_t const *cmd_list_fr_basic_test[] = {
2738         &cmd_des_fr_user_config,
2739         &cmd_des_fr_config_buffer,
2740         &cmd_des_fr_config_fifo,
2741         &cmd_des_fr_init,
2742         &cmd_des_fr_start,
2743         &cmd_des_fr_allslots,
2744         &cmd_des_fr_halt,
2745         &cmd_des_fr_abort,
2746         &cmd_des_fr_sendwup,
2747         &cmd_des_fr_setwuchannel,
2748         &cmd_des_fr_getpocstatus,
2749         &cmd_des_fr_transmittxlpdu,
2750         &cmd_des_fr_canceltxlpdu,
2751         &cmd_des_fr_receiverxlpdu,
2752         &cmd_des_fr_checktxlpdustatus,
2753         &cmd_des_fr_disablelpdu,
2754         &cmd_des_fr_getglobaltime,
2755         &cmd_des_fr_getnmvector,
2756         &cmd_des_fr_nmwatch,
2757         &cmd_des_fr_getchannelstatus,
2758         &cmd_des_fr_getclockcorrection,
2759         &cmd_des_fr_getsyncframelist,
2760         &cmd_des_fr_getwakeuprxstatus,
2761         &cmd_des_fr_settimer,
2762         &cmd_des_fr_canceltimer,
2763         &cmd_des_fr_timerirq,
2764         &cmd_des_fr_getversioninfo,
2765         &cmd_des_fr_readcconfig,
2766         &cmd_des_fr_reconfigure_buffer,
2767         NULL
2768 };