]> rtime.felk.cvut.cz Git - pes-rpp/rpp-test-sw.git/commitdiff
FlexRay communication test rewritten to use new RPP FlexRay library.
authorMichal Horn <hornmich@fel.cvut.cz>
Thu, 15 Aug 2013 11:24:23 +0000 (13:24 +0200)
committerMichal Horn <hornmich@fel.cvut.cz>
Thu, 15 Aug 2013 11:24:23 +0000 (13:24 +0200)
The test now has two nodes. Node A is transmitting 100 messages, node B is receiving the messages and checking if it fits the pattern.

commands/cmd_fray.c

index 11cde38d70fc78d0ab7395220529a4007d239a13..fc6ebac3280bdcafe5aa8b88a49343463a0d46c5 100644 (file)
  *  - Sending test data on FRAY
  *  - Receiving test data on FRAY
  *
- *  There are FlexRay test commands, which creates node A and node B, wait for network to be started and than
- *  messages are being transmitted.
- *  Node A transmits short message in frame 1 from buffer 0 and longer message in frame 9 from buffer 9.
- *  Node B transmits short message in frame 2 from buffer 0 and longer message in frame 10 from buffer 10.
- *  Node A receives short message from frame 2 to buffer 1 and longer message from frame 10 to buffer 10.
- *  Node B receives short message from frame 1 to buffer 1 and longer message from frame 9 to buffer 9.
- *  Commands are counting number of received messages, number of errors in messages and they print results at the end.
+ *  There are FlexRay test commands, to test the connection between two FlexRay nodes A and B
+ *  The node A is sending a message 100 times with some period.
+ *  The node B is receiving this message and check if it fits the pattern.
+ *  Commands are counting the number of errors, which is printed at the end of the test.
  *  After 100 transmissions both nodes are halted.
- *
  */
 
 #include "cmd_fray.h"
 #include "drv/fray.h"
 #include "cmdproc_utils.h"
 #include "hal/hal.h"
+#include "cmdproc.h"
 
 /**
- *     Fill  data structure with global configuration parameters.
- *     @param  Fr_ConfigPtr    Pointer to data structure to be filled
+ * This structure contains global FlexRay configuration.
+ * All nodes in the network have to use the same values for
+ * all parameters of this structure.
  */
-void configure_global_parameters(cfg *Fr_ConfigPtr) {
-       // GTUs (Global Time Unit ), PRTC configuration
-       Fr_ConfigPtr->gtu1  = 0x00036B00; // pMicroPerCycle = 224000d = 36B00h (has to be x40 of MacroPerCyle)
-                                         // [19:0]: These bits configure the duration of the communication cycle in microticks
-       Fr_ConfigPtr->gtu2  = 0x000F15E0; // gSyncodeMax = Fh, gMacroPerCycle = 5600d = 15E0h  (cycle period, 5.6us)
-                                         //[13:0]: Macrotick per cycle (in macroticks). These bits configure the duration of one communication cycle
-                                         //        in macroticks. The cycle length must be identical in all nodes of a cluster.
-                                         //[19:16]: Sync node max (in frames). These bits configure the maximum number of frames within a cluster
-                                         //         with sync frame indicator bit SYN set. The number of frames must be identical in all nodes of a cluster.
-       Fr_ConfigPtr->gtu3  = 0x00061818; // gMacroInitialOffset = 6h, pMicroInitialOffset = 24d = 18h
-       Fr_ConfigPtr->gtu4  = 0x0AE40AE3; // gOffsetCorrectionStart - 1 = 2788d = AE4h, gMacroPerCycle - gdNIT - 1 = 2787d = AE3h
-       Fr_ConfigPtr->gtu5  = 0x33010303; // pDecodingCorrection = 51d = 33h, pClusterDriftDamping = 1h, pDelayCompensation = 3h
-       Fr_ConfigPtr->gtu6  = 0x01510081; // pdMaxDrift = 337d = 151h, pdAcceptedStartupRange = 129d = 81h
-
-       Fr_ConfigPtr->gtu7  = 0x00080056; // gNumberOfStaticSlots = 8h, gdStaticSlot = 86d = 56h
-                                         // [25:16]: These bits configure the number of static slots in a cycle.
-                                      // [9:0]: These bits configure the duration of a static slot (macroticks).
-
-       Fr_ConfigPtr->gtu8  = 0x015A0004; // gNumberOfMinislots = 346d = 15Ah, gdMinislot = 4h
-                                         // [28:16]:These bits configure the number of minislots in the dynamic segment of a cycle
-                                         // [5:0]: These bits configure the duration of a minislot
-
-       Fr_ConfigPtr->gtu9  = 0x00010204; // gdDynamicSlotIdlePhase = 1, gdMinislotActionPointOffset = 2, gdActionPointOffset = 4h
-       Fr_ConfigPtr->gtu10 = 0x015100CD; // pRateCorrectionOut = 337d = 151h, pOffsetCorrectionOut = 205d = CDh
-       Fr_ConfigPtr->gtu11 = 0x00000000; // pExternRateCorrection = 0, pExternOffsetCorrection = 0, no ext. clk. corr.
-
-
-       Fr_ConfigPtr->succ2 = 0x0F036DA2; // gListenNoise = Fh, pdListenTimeout = 224674d = 36DA2h
-                                                                               //LTN [27:24]: Listen timeout noise. Configures the upper limit for the startup and wakeup listen timeout in the
-                                                                               //presence of noise. Must be identical in all nodes of a cluster.
-                                                                               //The wakeup / startup noise timeout is calculated as follows: LT[20:0] � (LTN[3:0] + 1)
-                                           // LT[20:0]: Listen timeout. Configures the upper limit of the startup and wakeup listen timeout.
-
-       Fr_ConfigPtr->succ3 = 0x000000FF; // gMaxWithoutClockCorrectionFatal = Fh , passive = Fh
-                                                                               //WCF[7:4]: Maximum without clock correction fatal. These bits define the number of consecutive even/odd
-                                                                               //cycle pairs with missing clock correction terms that will cause a transition from
-                                                                               //NORMAL_ACTIVE or NORMAL_PASSIVE state.
-
-                                                                               //WCP[3:0]: Maximum without clock correction passive. These bits define the number of consecutive
-                                                                               //even/odd cycle pairs with missing clock correction terms that will cause a transition from
-                                                                               //NORMAL_ACTIVE to NORMAL_PASSIVE to HALT state.
-
-       Fr_ConfigPtr->prtc1 = 0x084C000A; // pWakeupPattern = 2h, gdWakeupSymbolRxWindow = 76d, BRP = 0, gdTSSTransmitter = Ah
-                                                                               //BRP[15:14]; Baud rate prescaler. These bits configure the baud rate on the FlexRay bus. The baud rates
-                                                                               //listed below are valid with a sample clock of 80 MHz. One bit time always consists of 8 samples
-                                                                               //independent of the configured baud rate.  =0 ->10Mb/s
-
-       Fr_ConfigPtr->prtc2 = 0x3CB41212; // gdWakeupSymbolTxLow = 60d, gdWakeupSymbolTxIdle = 180d, gdWakeupSymbolRxLow = 18d, gdWakeupSymbolRxIdle = 18d
-
-       Fr_ConfigPtr->mhdc  = 0x010D0009; // pLatestTransmit = 269d = 010Dh, gPayloadLengthStatic = 9h
-                                                                               //Start of latest transmit (in minislots). These bits configure the maximum minislot value allowed
-                                                                               //minislots before inhibiting new frame transmissions in the Dynamic Segment of the cycle.
-                                           //[7:0]: Static frame data length.
-
-       Fr_ConfigPtr->mrc   = 0x00174004; // LCB=23d, FFB=64d, FDB=4d (0..3 static, 4..23 dyn., 0 fifo)
-}
+static Fr_TMS570LS_ClusterConfigType Fr_cluster_config = {
+       .gColdStartAttempts = 0x2,
+       .gListenNoise = 0xF,
+       .gMacroPerCycle = 0x15E0,       // (cycle period, 5.6us)
+       .gMaxWithoutClockCorrectionFatal = 0xF,
+       .gMaxWithoutClockCorrectionPassive = 0xF,
+       .gNetworkManagementVectorLength = 12,
+       .gNumberOfMinislots = 0x15A,
+       .gNumberOfStaticSlots = 0x8,
+       .gOffsetCorrectionStart = 0xAE4,
+       .gPayloadLengthStatic = 0x9,
+       .gSyncNodeMax = 0xF,
+       .gdActionPointOffset = 0x4,
+       .gdCASRxLowMax = 0x43,
+       .gdDynamicSlotIdlePhase = 0x1,
+       .gdMinislot = 0x4,
+       .gdMinislotActionPointOffset = 0x2,
+       .gdNIT = 0xAE3,
+       .gdSampleClockPeriod = 0,               // 10mbit/sec
+       .gdStaticSlot = 0x56,
+       .gdTSSTransmitter = 0xA,
+       .gdWakeupSymbolRxIdle = 18,
+       .gdWakeupSymbolRxLow = 18,
+       .gdWakeupSymbolRxWindow = 76,
+       .gdWakeupSymbolTxIdle = 180,
+       .gdWakeupSymbolTxLow = 60
+};
 
 /**
- *     Configure FlexRay as node A.
- *      - Clear message RAMS
- *      - Configure global parameters
- *      - Initialize buffers
- *      - Go to ready state
- *      - Enable interrupts
- *     This function prepares FlexRay to send data in Frames 1 and 9 and to receive data from frames 2 and 10.
- *     Frame 1 is synchronization frame.
- *     @return SUCCESS or FAILURE when error
+ * This structure contains local configuration of the FlexRay node A.
+ * That is the node that transmits messages to the node B.
  */
-int config_init_a() {
-       cfg Fr_Config;
-
-       if (fray_clear_msg_ram() != SUCCESS) {
-               return FAILURE;
-       }
-
-       fray_wait_for_POC_ready();
-       configure_global_parameters(&Fr_Config);
-       fray_init(&Fr_Config);
-       fray_config_buffer(0, FRAY_BUF_MBI_EN|FRAY_BUF_CHB_EN|FRAY_BUF_CHA_EN|FRAY_BUF_TX|FRAY_BUF_SYNC_EN|FRAY_BUF_SFI_EN, 0, 1, 9, 0x80);
-       fray_config_buffer(2, FRAY_BUF_MBI_EN|FRAY_BUF_CHB_EN|FRAY_BUF_CHA_EN|FRAY_BUF_RX, 0, 2, 9, 0x85);
-       fray_config_buffer(9, FRAY_BUF_MBI_EN|FRAY_BUF_CHB_EN|FRAY_BUF_CHA_EN|FRAY_BUF_TX, 0, 9, 127, 0x200);
-       fray_config_buffer(10, FRAY_BUF_MBI_EN|FRAY_BUF_CHB_EN|FRAY_BUF_CHA_EN|FRAY_BUF_RX, 0, 10, 127, 0x240);
-
-       if (fray_controler_init() != SUCCESS) {
-               return FAILURE;
-       }
+static Fr_TMS570LS_NodeConfigType Fr_node_A_config = {
+       .pAllowHaltDueToClock = 0,
+       .pAllowPassiveToActive = FALSE,
+       .pChannels = FR_CHANNEL_AB,
+       .pClusterDriftDamping = 0x1,
+       .pDelayCompensationA = 0x3,
+       .pDelayCompensationB = 0x3,
+       .pExternOffsetCorrection = 0,
+       .pExternRateCorrection = 0,
+       .pKeySlotUsedForStartup = TRUE,
+       .pKeySlotUsedForSync = TRUE,
+       .pLatestTx = 0x10D,
+       .pMacroInitialOffsetA = 0x6,
+       .pMacroInitialOffsetB = 0x6,
+       .pMicroInitialOffsetA = 0x18,
+       .pMicroInitialOffsetB = 0x18,
+       .pMicroPerCycle = 0x36B00,
+       .pRateCorrectionOut = 0xCD,
+       .pOffsetCorrectionOut = 0x151,
+       .pSamplesPerMicrotick = 0,              // 10 mbit/sec
+       .pSingleSlotEnabled = TRUE,
+       .pWakeupChannel = FR_CHANNEL_A,
+       .pWakeupPattern = 2,
+       .pdAcceptedStartupRange = 0x81,
+       .pdListenTimeout = 0x36DA2,
+       .pdMaxDrift = 0x151,
+       .pDecodingCorrection = 0x33
+};
 
-       fray_init_irq();
-       return SUCCESS;
-}
+/**
+ * This structure contains local configuration of the FlexRay node B.
+ * That is the node that receives messages from the node A.
+ */
+static Fr_TMS570LS_NodeConfigType Fr_node_B_config = {
+               .pAllowHaltDueToClock = 0,
+               .pAllowPassiveToActive = FALSE,
+               .pChannels = FR_CHANNEL_AB,
+               .pClusterDriftDamping = 0x1,
+               .pDelayCompensationA = 0x3,
+               .pDelayCompensationB = 0x3,
+               .pExternOffsetCorrection = 0,
+               .pExternRateCorrection = 0,
+               .pKeySlotUsedForStartup = TRUE,
+               .pKeySlotUsedForSync = TRUE,
+               .pLatestTx = 0x10D,
+               .pMacroInitialOffsetA = 0x6,
+               .pMacroInitialOffsetB = 0x6,
+               .pMicroInitialOffsetA = 0x18,
+               .pMicroInitialOffsetB = 0x18,
+               .pMicroPerCycle = 0x36B00,
+               .pRateCorrectionOut = 0xCD,
+               .pOffsetCorrectionOut = 0x151,
+               .pSamplesPerMicrotick = 0,              // 10 mbit/sec
+               .pSingleSlotEnabled = TRUE,
+               .pWakeupChannel = FR_CHANNEL_A,
+               .pWakeupPattern = 2,
+               .pdAcceptedStartupRange = 0x81,
+               .pdListenTimeout = 0x36DA2,
+               .pdMaxDrift = 0x151,
+               .pDecodingCorrection = 0x33
+};
 
 /**
- *     Loads data into TX buffers for FlexRay node A.
+ * FlexRay node A message RAM configuration.
+ * Reconfiguration is disabled, 2 static buffers are configured.
  */
-void start_transmit_node_a() {
-       uint32_t data[6];
-
-       fray_wait_for_new_cycle();
-
-       // write payload for buffers
-       // buffer #1
-       data[0] = 0x00000001;
-       data[1] = 0x000000FF;
-       fray_buffer_set_data(0, data, 2);
-
-       // buffer #9
-       data[0] = 0xFF;                  // Data 1
-       data[1] = 0xFFFF;        // Data 2
-       data[2] = 0xFFFFFF;      // Data 3
-       data[3] = 0xFFFFFFFF;    // Data 4
-       data[4] = 0xFFFFFF00;    // Data 5
-       data[5] = 0xFFFF0000;    // Data 6
-       fray_buffer_set_data(9, data, 6);
-}
+static Fr_TMS570LS_MsgRAMConfig Fr_node_A_msgRAM_config = {
+       .dynSegmentBufferCount = 0,
+       .fifoBufferCount = 0,
+       .secureBuffers = FR_SB_ALL_REC_DISABLED,
+       .statSegmentBufferCount = 2,
+       .syncFramePayloadMultiplexEnabled = 0
+};
 
 /**
- *     Check if some message was received on message buffer 2 of FlexRay node A.
- *     If yes, get the message and check if it fits the pattern
- *     @return -1 if no message was received
- *                     0 if message was received and is correct
- *                     1 if message was received and is incorrect
+ * FlexRay node B message RAM configuration.
+ * Reconfiguration is disabled, 2 static buffers are configured.
  */
-int receive_node_a() {
-       uint32_t data[6];
-       int error = -1; // No message received
-
-       // check if a message is received in buffer 2 from node B
-    if (fray_buffer_message_received(2)) {
-       fray_buffer_get_data(2, data, 2);
-       if (data[1] != 0x87654321)
-               error = 1;
-       else
-               error = 0;
-       }
-       return error;
-}
+static Fr_TMS570LS_MsgRAMConfig Fr_node_B_msgRAM_config = {
+       .dynSegmentBufferCount = 0,
+       .fifoBufferCount = 0,
+       .secureBuffers = FR_SB_ALL_REC_DISABLED,
+       .statSegmentBufferCount = 2,
+       .syncFramePayloadMultiplexEnabled = 0
+};
 
 /**
- *     Configure FlexRay as node B.
- *      - Clear message RAMS
- *      - Configure global parameters
- *      - Initialize buffers
- *      - Go to ready state
- *      - Enable interrupts
- *     This function prepares FlexRay to send data in Frames 2 and 10 and to receive data from frames 1 and 9.
- *     Frame 2 is synchronization frame.
- *     @return SUCCESS or FAILURE when error
+ * The FlexRay node A is a sync node and coldstarter. That is why the first buffer
+ * (buffer 0) is configured as TX. All coldstarters and sync nodes must have the
+ * first buffer configured as TX. The FlexRay network has to contain at least two
+ * sync nodes and coldstarters.
+ * The second buffer is used for messages transmission. It is TX and configured as
+ * single-shot to send only one message after some period.
  */
-int config_init_b() {
-       cfg Fr_Config;
+static Fr_TMS570LS_BufferConfigType Fr_node_A_static_buffers_config[] = {
+               {
+                       .channel = FR_CHANNEL_AB,
+                       .cycleCounterFiltering = 0,
+                       .isTx = TRUE,
+                       .maxPayload = 9,
+                       .msgBufferInterrupt = TRUE,
+                       .payloadPreambleIndicatorTr = FALSE,
+                       .rejectNullFrames = FALSE,
+                       .rejectStaticSegment = FALSE,
+                       .singleTransmit = FALSE,
+                       .slotId = 1
+               },
+               {
+                       .channel = FR_CHANNEL_AB,
+                       .cycleCounterFiltering = 0,
+                       .isTx = TRUE,
+                       .maxPayload = 9,
+                       .msgBufferInterrupt = TRUE,
+                       .payloadPreambleIndicatorTr = FALSE,
+                       .rejectNullFrames = FALSE,
+                       .rejectStaticSegment = FALSE,
+                       .singleTransmit = TRUE,
+                       .slotId = 3
+               }
+};
 
-       if (fray_clear_msg_ram() != SUCCESS) {
-               return FAILURE;
+/**
+ * The FlexRay node B is a sync node and coldstarter. That is why the first buffer
+ * (buffer 0) is configured as TX. All coldstarters and sync nodes must have the
+ * first buffer configured as TX. The FlexRay network has to contain at least two
+ * sync nodes and coldstarters.
+ * The second buffer is used for messages receiving.
+ */
+static Fr_TMS570LS_BufferConfigType Fr_node_B_static_buffers_config[] = {
+       {
+               .channel = FR_CHANNEL_AB,
+               .cycleCounterFiltering = 0,
+               .isTx = TRUE,
+               .maxPayload = 9,
+               .msgBufferInterrupt = TRUE,
+               .payloadPreambleIndicatorTr = FALSE,
+               .rejectNullFrames = FALSE,
+               .rejectStaticSegment = FALSE,
+               .singleTransmit = FALSE,
+               .slotId = 2
+       },
+       {
+               .channel = FR_CHANNEL_AB,
+               .cycleCounterFiltering = 0,
+               .isTx = FALSE,
+               .maxPayload = 9,
+               .msgBufferInterrupt = TRUE,
+               .payloadPreambleIndicatorTr = FALSE,
+               .rejectNullFrames = FALSE,
+               .rejectStaticSegment = FALSE,
+               .singleTransmit = TRUE,
+               .slotId = 3
        }
+};
 
-       fray_wait_for_POC_ready();
-       configure_global_parameters(&Fr_Config);
-       fray_init(&Fr_Config);
-
-       fray_config_buffer(0, FRAY_BUF_MBI_EN|FRAY_BUF_CHB_EN|FRAY_BUF_CHA_EN|FRAY_BUF_TX|FRAY_BUF_SYNC_EN|FRAY_BUF_SFI_EN, 0, 2, 9, 0x85);
-       fray_config_buffer(1, FRAY_BUF_MBI_EN|FRAY_BUF_CHB_EN|FRAY_BUF_CHA_EN|FRAY_BUF_RX, 0, 1, 9, 0x80);
-       fray_config_buffer(10, FRAY_BUF_MBI_EN|FRAY_BUF_CHB_EN|FRAY_BUF_CHA_EN|FRAY_BUF_TX, 0, 10, 127, 0x240);
-       fray_config_buffer(9, FRAY_BUF_MBI_EN|FRAY_BUF_CHB_EN|FRAY_BUF_CHA_EN|FRAY_BUF_RX, 0, 9, 127, 0x200);
-
-       if (fray_controler_init() != SUCCESS) {
-               return FAILURE;
-       }
-       fray_init_irq();
+/**
+ * Unifying configuration structure for the node A.
+ */
+static Fr_ConfigType Fr_config_node_A = {
+       .clusterConfiguration = &Fr_cluster_config,
+       .dynamicBufferConfigs = NULL,
+       .fifoBufferConfigs = NULL,
+       .msgRAMConfig = &Fr_node_A_msgRAM_config,
+       .nodeConfiguration = &Fr_node_A_config,
+       .staticBufferConfigs = Fr_node_A_static_buffers_config
+};
 
-       return SUCCESS;
-}
+/**
+ * Unifying configuration structure for the node B.
+ */
+static Fr_ConfigType Fr_config_node_B = {
+       .clusterConfiguration = &Fr_cluster_config,
+       .dynamicBufferConfigs = NULL,
+       .fifoBufferConfigs = NULL,
+       .msgRAMConfig = &Fr_node_B_msgRAM_config,
+       .nodeConfiguration = &Fr_node_B_config,
+       .staticBufferConfigs = Fr_node_B_static_buffers_config
+};
 
 /**
- *     Loads data into TX buffers for FlexRay node B.
+ *     Loads data into TX buffer for FlexRay node A.
+ *     Set TX Request for the buffer to start the transmission.
  */
-void start_transmit_node_b() {
-       uint32_t data[6];
-
-       fray_wait_for_new_cycle();
-
-       // write payload for buffers
-       // buffer #2
-       data[0] = 0x12345678;
-       data[1] = 0x87654321;
-       fray_buffer_set_data(0, data, 2);
-
-       // buffer #10
-       data[0] = 0xFF;                  // Data 1
-       data[1] = 0xFFFF;        // Data 2
-       data[2] = 0xFFFFFF;      // Data 3
-       data[3] = 0xFFFFFFFF;    // Data 4
-       data[4] = 0xFFFFFF00;    // Data 5
-       data[5] = 0xFFFF0000;    // Data 6
-       fray_buffer_set_data(10, data, 6);
+int8_t transmit_node_a() {
+       uint8_t data[18];
+       int i;
+
+       // Write payload for the buffer
+       for (i = 0; i < 18; i++) {
+               data[i] = i;
+       }
+       return rpp_fr_transmit_lpdu(0, 3, data, 18);
 }
 
 /**
- *     Check if some message was received on message buffer 1 of FlexRay node B.
- *     If yes, get the message and check if it fits the pattern
+ *     Check if some message was received on message buffer 2 of FlexRay node B.
+ *     If yes, retrieve the message and check if it fits the pattern
  *     @return -1 if no message was received
- *                     0 if message was received and is correct
- *                     1 if message was received and is incorrect
+ *                      0 if message was received and is correct
+ *                      1 if message was received and is incorrect
+ *                      2 if error occurred
  */
 int receive_node_b() {
-       uint32_t data[6];
-       int error = -1; // No message received
-
-       // check if a message is received in buffer 2 from node B
-    if (fray_buffer_message_received(1) != 0) {
-       fray_buffer_get_data(1, data, 2);
-       if (data[1] != 0x000000FF)
-               error = 1;
-       else
-               error = 0;
+       uint8_t data[18];
+       Fr_RxLPduStatusType status;
+       uint8_t size;
+       int i;
+
+       if (rpp_fr_receive_lpdu(0, 3, data, &status, &size) == FAILURE) {
+               return 2;
+       }
+       if (status == FR_NOT_RECEIVED) {
+               return -1;
+       }
+       else {
+               for (i = 0; i < 18; i++) {
+                       if (data[i] != i) {
+                               return 1;
+                       }
+               }
+       return 0;
        }
-       return error;
 }
 
+
 /**
  *     @brief  Get FlexRay status in human readable form
  *
@@ -314,7 +351,7 @@ int cmd_do_fray_status(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[
 }
 
 /**
- *     @brief  Start sending and receiving data on as node A
+ *     @brief  Start sending data on the FlexRay as node A
  *
  * @param[in]  cmd_io  Pointer to IO stack
  * @param[in]  des             Pointer to command descriptor
@@ -325,49 +362,64 @@ int cmd_do_test_frayA(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[]
        uint32_t i;
        uint32_t error = 0;
        uint32_t msg_cnt = 0;
-       int ret;
-
-       if (config_init_a() != SUCCESS) {
-               rpp_sci_printf("Fray node A initialization failed.\r\n");
-               return 0;
+       boolean_t irq = FALSE;
+
+    if (rpp_fr_init_driver(&Fr_config_node_A, &error) == FAILURE) {
+               rpp_sci_printf("Fray driver initialization failed: %#x.\n", error);
+               return -CMDERR_BADCFG;
+    }
+       if (rpp_fr_init_controller(0, &error) == FAILURE) {
+               rpp_sci_printf("Fray control node initialization failed: %#x.\n", error);
+               return -CMDERR_BADCFG;
        }
-       rpp_sci_printf("Fray node A initialized.\r\n");
+       rpp_sci_printf("Fray control node initialized.\r\n");
        rpp_sci_printf("Waiting for network connection...\r\n");
 
-       if (fray_startup_procedure(1) != SUCCESS) {
-               rpp_sci_printf("Integration to the network failed.\r\n");
-               return 0;
+       if (rpp_fr_start_communication(0, &error) == FAILURE) {
+               rpp_sci_printf("Integration to the network failed: %#x.\n", error);
+               return -CMDERR_BADCFG;
+       }
+       if (rpp_fr_all_slots(0) == FAILURE) {
+               rpp_sci_printf("All slots mode selection failed.\n");
+               return -CMDERR_BADCFG;
        }
 
        rpp_sci_printf("Connected. Frames transmission is starting. O means OK, X means Error\r\n");
-       start_transmit_node_a();
-
+       if (rpp_fr_clear_timer_irq(0,0) == FAILURE ||
+                       rpp_fr_set_timer(0,0,10,1) == FAILURE
+               ) {
+               rpp_sci_printf("Absolute timer setting failed.\n");
+               return -CMDERR_BADCFG;
+       }
        for (i = 0; i < 100; i++){
-           // wait for cycle start interrupt flag
-               fray_wait_for_new_cycle();
-               ret = receive_node_a();
-               if (ret == 0) {
-                       rpp_sci_printf("O");
-                       msg_cnt++;
+           // wait for 30th cycle
+               while (irq == FALSE) {
+                       rpp_fr_get_timer_irq_status(0,0,&irq);
                }
-               else if (ret == 1) {
+               if (transmit_node_a() == FAILURE) {
                        rpp_sci_printf("X");
                        error++;
-                       msg_cnt++;
+               }
+               else {
+                       rpp_sci_printf("O");
+               }
+               if (rpp_fr_clear_timer_irq(0,0) == FAILURE) {
+                       rpp_sci_printf("Absolute timer IRQ clearing failed.\n");
+                       break;
                }
        }
-       rpp_sci_printf("\r\nReceived %d messages with %d errors.\r\n", msg_cnt, error);
-       if (fray_halt() != SUCCESS) {
+       rpp_sci_printf("\r\nTransmitted %d messages with %d errors.\r\n", msg_cnt, error);
+       if (rpp_fr_halt_communication(0) != SUCCESS) {
                rpp_sci_printf("FlexRay HALT command failed, please reset the board to stop transmission.\r\n");
        }
        else {
-               rpp_sci_printf("FlexRay halted\r\n");
+               rpp_sci_printf("FlexRay halted, reset the board to make FlexRay usable again.\r\n");
        }
        return 0;
 }
 
 /**
- *     @brief  Start sending and receiving data on as node B
+ *     @brief  Start receiving data on the FlexRay as node B
  *
  * @param[in]  cmd_io  Pointer to IO stack
  * @param[in]  des             Pointer to command descriptor
@@ -379,27 +431,34 @@ int cmd_do_test_frayB(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[]
        uint32_t i;
        uint32_t error = 0;
        uint32_t msg_cnt = 0;
-       int ret;
-
-       if (config_init_b() != SUCCESS) {
-               rpp_sci_printf("Fray node B initialization failed.\r\n");
-               return 0;
+       int ret = -1;
+
+    if (rpp_fr_init_driver(&Fr_config_node_B, &error) == FAILURE) {
+               rpp_sci_printf("Fray driver initialization failed: %#x.\n", error);
+               return -CMDERR_BADCFG;
+    }
+       if (rpp_fr_init_controller(0, &error) == FAILURE) {
+               rpp_sci_printf("Fray control node initialization failed: %#x.\n", error);
+               return -CMDERR_BADCFG;
        }
-       rpp_sci_printf("Fray node B initialized.\r\n");
+       rpp_sci_printf("Fray control node initialized.\r\n");
        rpp_sci_printf("Waiting for network connection...\r\n");
 
-       if (fray_startup_procedure(1) != SUCCESS) {
-               rpp_sci_printf("Integration to the network failed.\r\n");
-               return 0;
+       if (rpp_fr_start_communication(0, &error) == FAILURE) {
+               rpp_sci_printf("Integration to the network failed: %#x.\n", error);
+               return -CMDERR_BADCFG;
+       }
+       if (rpp_fr_all_slots(0) == FAILURE) {
+               rpp_sci_printf("All slots mode selection failed.\n");
+               return -CMDERR_BADCFG;
        }
 
        rpp_sci_printf("Connected. Frames transmission is starting. O means OK, X means Error\r\n");
-       start_transmit_node_b();
-
-       for (i = 0; i < 100; i++){
-           // wait for cycle start interrupt flag
-               fray_wait_for_new_cycle();
-               ret = receive_node_b();
+       for (i = 0; i < 100; i++) {
+           // wait for cycle 30 interrupt flag
+               while(ret == -1) {
+                       ret = receive_node_b();
+               }
                if (ret == 0) {
                        rpp_sci_printf("O");
                        msg_cnt++;
@@ -409,6 +468,10 @@ int cmd_do_test_frayB(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[]
                        error++;
                        msg_cnt++;
                }
+               else {
+                       rpp_sci_printf("Message receiving failed.\n");
+                       break;
+               }
        }
        rpp_sci_printf("\r\nReceived %d messages with %d errors.\r\n", msg_cnt, error);
        if (fray_halt() != SUCCESS) {
@@ -454,15 +517,16 @@ cmd_des_t const cmd_des_test_fray_a={
            "\n"
            "=== Description ===\n"
            "\n"
-           "The commands creates FlexRay node A and starts sending and receiving\n"
-           "100 messages. The command should be run with two devices connected by\n"
+           "The commands creates FlexRay node A and starts sending a message each 10th\n"
+           "communication cycle. 100 messages are sent for the test of the connection.\n"
+           "The command should be run with two devices connected by\n"
            "a FlexRay bus and the second device should be running the fraytestB\n"
            "command (it is necessary to run both commands shortly after each\n"
            "other).\n"
            "\n"
-           "When the command receives a message a character is printed. O means\n"
-           "that the message was received correctly, X signal an reception error.\n"
-           "The number of RX errors and successfully received messages is\n"
+           "When the command transmit a message a character is printed. O means\n"
+           "that the message was transmitted correctly, X signal a transmission error.\n"
+           "The number of TX errors and successfully transmitted messages is\n"
            "maintained during the test and printed at the end.\n",
            CMD_HANDLER(cmd_do_test_frayA), (void *)&cmd_list_fray
 };
@@ -477,11 +541,11 @@ cmd_des_t const cmd_des_test_fray_b={
            "\n"
            "=== Description ===\n"
            "\n"
-           "The commands creates FlexRay node B and starts sending and receiving\n"
-           "100 messages. The command should be run with two devices connected by\n"
-           "a FlexRay bus and the second device should be running the fraytestA\n"
-           "command (it is necessary to run both commands shortly after each\n"
-           "other).\n"
+           "The commands creates FlexRay node B and starts receiving a messages.\n"
+           "100 messages should be received. The command should be run with two\n"
+           "devices connected by a FlexRay bus and the second device should be\n"
+           "running the fraytestA command (it is necessary to run both commands\n"
+           "shortly after each other).\n"
            "\n"
            "When the command receives a message a character is printed. O means\n"
            "that the message was received correctly, X signal an reception error.\n"