Skip to content

Commit

Permalink
Adds the send functions to the railcom driver.
Browse files Browse the repository at this point in the history
  • Loading branch information
balazsracz committed Jul 10, 2021
1 parent 83885ef commit a31291a
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 2 deletions.
21 changes: 21 additions & 0 deletions src/freertos_drivers/common/RailcomDriver.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
#include <inttypes.h>

#include "utils/macros.h"
#include "dcc/railcom.h"

/// Abstract base class for railcom drivers. This interface is used to
/// communicate when the railcom cutout happens. The railcom cutout is produced
Expand Down Expand Up @@ -71,6 +72,26 @@ public:
* shall be called before start_cutout. The feedback key set here is used
* until this method is called again. @param key is the new feedback key. */
virtual void set_feedback_key(uint32_t key) = 0;

/** Specifies what packet should be sent for the channel1 cutout. It is
* okay to specify the same packet pointer for ch1 and ch2 cutout.
* @param ch1_pkt the RailCom packet. Only the ch1 data will be read from
* this packet. This pointer must stay alive until the next DCC packet
* comes. The FeedbackKey in this packet must be correct for the current
* DCC packet or else the data will not be sent. */
virtual void send_ch1(const DCCFeedback *ch1_pkt)
{
}

/** Specifies what packet should be sent for the channel2 cutout. It is
* okay to specify the same packet pointer for ch1 and ch2 cutout.
* @param ch2_pkt the RailCom packet. Only the ch2 data will be read from
* this packet. This pointer must stay alive until the next DCC packet
* comes. The FeedbackKey in this packet must be correct for the current
* DCC packet or else the data will not be sent. */
virtual void send_ch2(const DCCFeedback *ch2_pkt)
{
}
};


Expand Down
10 changes: 8 additions & 2 deletions src/freertos_drivers/st/Stm32RailcomSender.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -54,15 +54,21 @@ public:
/// this packet. This pointer must stay alive until the next DCC packet
/// comes. The FeedbackKey in this packet must be correct for the current
/// DCC packet or else the data will not be sent.
void send_ch1(const DCCFeedback *ch1_pkt);
void send_ch1(const DCCFeedback *ch1_pkt) override
{
ch1Pkt_ = ch1_pkt;
}

/// Specifies what packet should be sent for the channel2 cutout. It is
/// okay to specify the same packet pointer for ch1 and ch2 cutout.
/// @param ch2_pkt the RailCom packet. Only the ch2 data will be read from
/// this packet. This pointer must stay alive until the next DCC packet
/// comes. The FeedbackKey in this packet must be correct for the current
/// DCC packet or else the data will not be sent.
void send_ch2(const DCCFeedback *ch2_pkt);
void send_ch2(const DCCFeedback *ch2_pkt) override
{
ch2Pkt_ = ch2_pkt;
}

ssize_t write(File *file, const void *buf, size_t count) override
{
Expand Down

0 comments on commit a31291a

Please sign in to comment.