|
Open Model Railroad Network (OpenMRN)
|
Go to the source code of this file.
Functions | |
| static char | nibble_to_ascii (int nibble) |
| Build an ASCII character representation of a nibble value (uppercase hex). | |
| static int | ascii_to_nibble (const char c) |
| Tries to parse a hex character to a nibble. | |
| int | gc_format_parse (const char *buf, struct can_frame *can_frame) |
| Parses a GridConnect packet. | |
| static void | output_single (char *&dst, char value) |
| Helper function for appending to a buffer ONCE. | |
| static void | output_double (char *&dst, char value) |
| Helper function for appending to a buffer TWICE. | |
| char * | gc_format_generate (const struct can_frame *can_frame, char *buf, int double_format) |
| Formats a can frame in the GridConnect protocol. | |
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
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.
Implementations of GridConnect packet parser and formatter routines.
Definition in file gc_format.cxx.
|
static |
Tries to parse a hex character to a nibble.
Understands both upper and lowercase hex.
| c | is the character to convert. |
Definition at line 64 of file gc_format.cxx.
| char * gc_format_generate | ( | const struct can_frame * | can_frame, |
| char * | buf, | ||
| int | double_format | ||
| ) |
Formats a can frame in the GridConnect protocol.
If requested, it can create the double protocol with leading !!, trailing ;; and all the characters doubled.
If the input frame is an error frame, then does not output anything and returns the input pointer.
| can_frame | is the input frame. |
| buf | is the output buffer. The caller must ensure this is big enough to hold the resulting frame (28 or 56 bytes). |
| double_format | if non-zero, the doubling format will be generated. |
Definition at line 199 of file gc_format.cxx.
| int gc_format_parse | ( | const char * | buf, |
| struct can_frame * | can_frame | ||
| ) |
Parses a GridConnect packet.
| buf | points to a character buffer that contains the packet. The leading ":" must be already removed, the tailing ';' must be replaced by a \0 char. |
| can_frame | is the CAN frame that will be filled based on the source packet. |
Definition at line 82 of file gc_format.cxx.
|
static |
Build an ASCII character representation of a nibble value (uppercase hex).
| nibble | to convert |
Definition at line 47 of file gc_format.cxx.
|
static |
Helper function for appending to a buffer TWICE.
Used in the implementation of the double-byte gridconnect output protocol.
| dst | buffer to append data to |
| value | one character to append to. |
Definition at line 176 of file gc_format.cxx.
|
static |
Helper function for appending to a buffer ONCE.
| dst | buffer to append data to |
| value | one character to append to. |
Definition at line 165 of file gc_format.cxx.