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