Open Model Railroad Network (OpenMRN)
Loading...
Searching...
No Matches
Convert.hxx File Reference
#include <endian.h>
#include <string.h>
#include "openlcb/Defs.hxx"

Go to the source code of this file.

Namespaces

namespace  openlcb
 

Functions

string openlcb::node_id_to_buffer (NodeID id)
 Convenience function to render a 48-bit NMRAnet node ID into a new buffer.
 
void openlcb::node_id_to_data (NodeID id, void *data)
 Convenience function to render a 48-bit NMRAnet node ID into an existing buffer.
 
NodeID openlcb::buffer_to_node_id (const string &buf)
 Converts a 6-byte-long buffer to a node ID.
 
NodeID openlcb::data_to_node_id (const void *d)
 Converts 6 bytes of big-endian data to a node ID.
 
Payload openlcb::eventid_to_buffer (uint64_t eventid)
 Converts an Event ID to a Payload suitable to be sent as an event report.
 
uint64_t openlcb::data_to_eventid (const void *data)
 Takes 8 bytes (big-endian) from *data, and returns the event id they represent.
 
string openlcb::error_to_buffer (uint16_t error_code, uint16_t mti)
 Formats a payload for response of error response messages such as OPtioanl Interaction Rejected or Terminate Due To Error.
 
string openlcb::error_to_buffer (uint16_t error_code)
 Formats a payload for response of error response messages such as Datagram Rejected.
 
void openlcb::error_to_data (uint16_t error_code, void *data)
 Writes an error code into a payload object at a given pointer.
 
uint16_t openlcb::data_to_error (const void *data)
 Parses an error code from a payload object at a given pointer.
 
void openlcb::append_error_to_buffer (uint16_t error_code, Payload *p)
 Appends an error to the end of an existing buffer.
 
void openlcb::buffer_to_error (const Payload &payload, uint16_t *error_code, uint16_t *mti, string *error_message)
 Parses the payload of an Optional Interaction Rejected or Terminate Due To Error message.
 
Payload openlcb::error_payload (uint16_t error_code, Defs::MTI incoming_mti)
 Generates the payload for an OIR or TDE message.
 
unsigned openlcb::node_high (NodeID id)
 
unsigned openlcb::node_low (NodeID id)
 

Variables

string openlcb::EMPTY_PAYLOAD
 A global class / variable for empty or not-yet-initialized payloads.
 

Detailed Description

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

  • Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  • Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Conversion routines for OpenLCB types.

Author
Balazs Racz
Date
17 Aug 2021

Definition in file Convert.hxx.