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