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