Open Model Railroad Network (OpenMRN)
Loading...
Searching...
No Matches
traction_modem::CvSpace Class Reference
Inheritance diagram for traction_modem::CvSpace:
openlcb::MemorySpace FlowInterface< MessageType > Destructable

Public Member Functions

 CvSpace (PacketFlowInterface *tx)
 
address_t max_address () override
 
bool read_only () override
 
size_t write (address_t destination, const uint8_t *data, size_t len, errorcode_t *error, Notifiable *again) override
 
size_t read (address_t source, uint8_t *dst, size_t len, errorcode_t *error, Notifiable *again) override
 
void send (Buffer< TxMessage > *buf, unsigned prio) override
 Handles messages coming back from the decoder via the traction modem protocol.
 
void handle_read_response (TxMessage &txm)
 
void handle_write_response (TxMessage &txm)
 
- Public Member Functions inherited from openlcb::MemorySpace
virtual bool set_node (Node *node)
 Specifies which node the next operation pertains.
 
virtual address_t min_address ()
 
virtual errorcode_t freeze ()
 Handles space freeze command.
 
virtual errorcode_t unfreeze ()
 Handles space unfreeze command.
 
- Public Member Functions inherited from FlowInterface< MessageType >
virtual Poolpool ()
 
virtual void send (MessageType *message, unsigned priority=UINT_MAX)=0
 Entry point to the flow.
 
virtual MessageType * type_helper ()
 This function is never user in the code, but GDB can use it to infer the correct message types.
 
MessageType * alloc ()
 Synchronously allocates a message buffer from the pool of this flow.
 
void alloc_async (Executable *target)
 Asynchronously allocates a message buffer from the pool of this flow.
 

Public Attributes

bool pendingRead_: 1
 true if we are waiting for a read response
 
bool doneRead_: 1
 true if we the read response arrived
 
bool pendingWrite_: 1
 true if we are waiting for a write response
 
bool doneWrite_: 1
 true if we the write response arrived
 
uint16_t errorCode_ = 0
 Returned error code from the backend.
 
uint8_t * readBuf_ = nullptr
 Where to put the bytes read.
 
unsigned actualLen_ = 0
 How many bytes to put there.
 
Notifiabledone_ = nullptr
 Notifiable to mark when the pending read/write completes.
 
PacketFlowInterfacetxFlow_
 We send outgoing packets to the decoder using this interface.
 

Static Public Attributes

static constexpr uint8_t proxySpace_ = openlcb::MemoryConfigDefs::SPACE_DCC_CV
 This is the memory space we will be using on the decoder.
 
- Static Public Attributes inherited from openlcb::MemorySpace
static const errorcode_t ERROR_AGAIN = 0x3FFF
 This error code signals that the operation was only partially completed, the again notify was used and will be notified when the operation can be re-tried).
 

Additional Inherited Members

- Public Types inherited from openlcb::MemorySpace
typedef uint32_t address_t
 
typedef uint16_t errorcode_t
 
- Public Types inherited from FlowInterface< MessageType >
typedef MessageType message_type
 Stores the message template type for external reference.
 
- Static Public Member Functions inherited from FlowInterface< MessageType >
static MessageType * cast_alloc (QMember *entry)
 Down casts and initializes an asynchronous allocation result to the appropriate flow's buffer type.
 

Detailed Description

Definition at line 421 of file TractionModem.hxx.

Constructor & Destructor Documentation

◆ CvSpace()

traction_modem::CvSpace::CvSpace ( PacketFlowInterface tx)
inline

Definition at line 424 of file TractionModem.hxx.

Member Function Documentation

◆ handle_read_response()

void traction_modem::CvSpace::handle_read_response ( TxMessage txm)
inline

Definition at line 518 of file TractionModem.hxx.

◆ handle_write_response()

void traction_modem::CvSpace::handle_write_response ( TxMessage txm)
inline

Definition at line 535 of file TractionModem.hxx.

◆ max_address()

address_t traction_modem::CvSpace::max_address ( )
inlineoverridevirtual
Returns
the largest valid address for this block. A read of 1 from this address should succeed in returning the last byte.

Implements openlcb::MemorySpace.

Definition at line 432 of file TractionModem.hxx.

◆ read()

size_t traction_modem::CvSpace::read ( address_t  source,
uint8_t *  dst,
size_t  len,
errorcode_t *  error,
Notifiable again 
)
inlineoverridevirtual
Returns
the number of bytes successfully read (before hitting end of space). If *error is set to non-null, then the operation has failed. If the operation needs to be continued, then sets error to ERROR_AGAIN, and calls the Notifiable
Parameters
againwhen a re-try makes sense. The caller should call read once more, with the offset adjusted with the previously returned bytes.

Implements openlcb::MemorySpace.

Definition at line 466 of file TractionModem.hxx.

◆ read_only()

bool traction_modem::CvSpace::read_only ( )
inlineoverridevirtual
Returns
whether the memory space does not accept writes.

Reimplemented from openlcb::MemorySpace.

Definition at line 438 of file TractionModem.hxx.

◆ send()

void traction_modem::CvSpace::send ( Buffer< TxMessage > *  buf,
unsigned  prio 
)
inlineoverride

Handles messages coming back from the decoder via the traction modem protocol.

Definition at line 491 of file TractionModem.hxx.

◆ write()

size_t traction_modem::CvSpace::write ( address_t  destination,
const uint8_t *  data,
size_t  len,
errorcode_t *  error,
Notifiable again 
)
inlineoverridevirtual
Returns
the number of bytes successfully written (before hitting end of space). If *error is set to non-null, then the operation has failed. If the operation needs to be continued, then sets error to MemorySpace::ERROR_AGAIN, and calls the Notifiable
Parameters
againwhen a re-try makes sense. The caller should call write once more, with the offset adjusted with the previously returned bytes.

Reimplemented from openlcb::MemorySpace.

Definition at line 443 of file TractionModem.hxx.

Member Data Documentation

◆ actualLen_

unsigned traction_modem::CvSpace::actualLen_ = 0

How many bytes to put there.

When doneRead_, then the number of bytes actually read.

Definition at line 565 of file TractionModem.hxx.

◆ done_

Notifiable* traction_modem::CvSpace::done_ = nullptr

Notifiable to mark when the pending read/write completes.

Definition at line 568 of file TractionModem.hxx.

◆ doneRead_

bool traction_modem::CvSpace::doneRead_

true if we the read response arrived

Definition at line 552 of file TractionModem.hxx.

◆ doneWrite_

bool traction_modem::CvSpace::doneWrite_

true if we the write response arrived

Definition at line 556 of file TractionModem.hxx.

◆ errorCode_

uint16_t traction_modem::CvSpace::errorCode_ = 0

Returned error code from the backend.

Definition at line 559 of file TractionModem.hxx.

◆ pendingRead_

bool traction_modem::CvSpace::pendingRead_

true if we are waiting for a read response

Definition at line 550 of file TractionModem.hxx.

◆ pendingWrite_

bool traction_modem::CvSpace::pendingWrite_

true if we are waiting for a write response

Definition at line 554 of file TractionModem.hxx.

◆ proxySpace_

constexpr uint8_t traction_modem::CvSpace::proxySpace_ = openlcb::MemoryConfigDefs::SPACE_DCC_CV
staticconstexpr

This is the memory space we will be using on the decoder.

Definition at line 547 of file TractionModem.hxx.

◆ readBuf_

uint8_t* traction_modem::CvSpace::readBuf_ = nullptr

Where to put the bytes read.

Definition at line 562 of file TractionModem.hxx.

◆ txFlow_

PacketFlowInterface* traction_modem::CvSpace::txFlow_

We send outgoing packets to the decoder using this interface.

Definition at line 571 of file TractionModem.hxx.


The documentation for this class was generated from the following file: