|
OpenLcbCLib 1.0 Alpha
OpenSource C Library to create OpenLcb/Lcc Nodes
|
Common utility functions for OpenLCB message and buffer manipulation. More...
Functions | |
| uint16_t | OpenLcbUtilities_payload_type_to_len (payload_type_enum payload_type) |
| Converts a payload_type_enum to its maximum byte length. | |
| uint32_t | OpenLcbUtilities_calculate_memory_offset_into_node_space (openlcb_node_t *openlcb_node) |
| Returns the byte offset into global config memory where this node's space begins. | |
| void | OpenLcbUtilities_load_openlcb_message (openlcb_msg_t *openlcb_msg, uint16_t source_alias, uint64_t source_id, uint16_t dest_alias, uint64_t dest_id, uint16_t mti) |
| Loads message header fields and clears the payload to zeros. | |
| void | OpenLcbUtilities_clear_openlcb_message_payload (openlcb_msg_t *openlcb_msg) |
| Zeros all payload bytes and resets payload_count. Header preserved. | |
| void | OpenLcbUtilities_clear_openlcb_message (openlcb_msg_t *openlcb_msg) |
| Zeros entire message including header, state flags, and reference count. | |
| void | OpenLcbUtilities_copy_event_id_to_openlcb_payload (openlcb_msg_t *openlcb_msg, event_id_t event_id) |
| Copies an 8-byte event ID to payload at offset 0. | |
| void | OpenLcbUtilities_copy_byte_to_openlcb_payload (openlcb_msg_t *openlcb_msg, uint8_t byte, uint16_t offset) |
| Copies one byte to payload at the given offset. | |
| void | OpenLcbUtilities_copy_word_to_openlcb_payload (openlcb_msg_t *openlcb_msg, uint16_t word, uint16_t offset) |
| Copies a 16-bit word (big-endian) to payload at the given offset. | |
| void | OpenLcbUtilities_copy_dword_to_openlcb_payload (openlcb_msg_t *openlcb_msg, uint32_t doubleword, uint16_t offset) |
| Copies a 32-bit doubleword (big-endian) to payload at the given offset. | |
| uint16_t | OpenLcbUtilities_copy_string_to_openlcb_payload (openlcb_msg_t *openlcb_msg, const char string[], uint16_t offset) |
| Copies a null-terminated string into the payload. | |
| uint16_t | OpenLcbUtilities_copy_byte_array_to_openlcb_payload (openlcb_msg_t *openlcb_msg, const uint8_t byte_array[], uint16_t offset, uint16_t requested_bytes) |
| Copies a byte array into the payload. May copy fewer bytes if payload space is exhausted. | |
| void | OpenLcbUtilities_copy_node_id_to_openlcb_payload (openlcb_msg_t *openlcb_msg, node_id_t node_id, uint16_t offset) |
| Copies a 6-byte node ID (big-endian) to payload at the given offset. | |
| node_id_t | OpenLcbUtilities_extract_node_id_from_openlcb_payload (openlcb_msg_t *openlcb_msg, uint16_t offset) |
| Extracts a 6-byte node ID from payload at the given offset. | |
| event_id_t | OpenLcbUtilities_extract_event_id_from_openlcb_payload (openlcb_msg_t *openlcb_msg) |
| Extracts an 8-byte event ID from payload at offset 0. | |
| uint8_t | OpenLcbUtilities_extract_byte_from_openlcb_payload (openlcb_msg_t *openlcb_msg, uint16_t offset) |
| Extracts one byte from payload at the given offset. | |
| uint16_t | OpenLcbUtilities_extract_word_from_openlcb_payload (openlcb_msg_t *openlcb_msg, uint16_t offset) |
| Extracts a 16-bit word (big-endian) from payload at the given offset. | |
| uint32_t | OpenLcbUtilities_extract_dword_from_openlcb_payload (openlcb_msg_t *openlcb_msg, uint16_t offset) |
| Extracts a 32-bit doubleword (big-endian) from payload at the given offset. | |
| void | OpenLcbUtilities_set_multi_frame_flag (uint8_t *target, uint8_t flag) |
| Sets the multi-frame control flag in the upper nibble of target, preserving the lower nibble. | |
| bool | OpenLcbUtilities_is_addressed_openlcb_message (openlcb_msg_t *openlcb_msg) |
| Returns true if the MTI has the destination-address-present bit set. | |
| uint8_t | OpenLcbUtilities_count_nulls_in_openlcb_payload (openlcb_msg_t *openlcb_msg) |
| Returns the count of null bytes (0x00) in the payload. Used for SNIP validation. | |
| bool | OpenLcbUtilities_is_addressed_message_for_node (openlcb_node_t *openlcb_node, openlcb_msg_t *openlcb_msg) |
| Returns true if the message destination matches this node's alias or ID. | |
| bool | OpenLcbUtilities_is_producer_event_assigned_to_node (openlcb_node_t *openlcb_node, event_id_t event_id, uint16_t *event_index) |
| Searches the node's producer list for a matching event ID. | |
| bool | OpenLcbUtilities_is_consumer_event_assigned_to_node (openlcb_node_t *openlcb_node, event_id_t event_id, uint16_t *event_index) |
| Searches the node's consumer list for a matching event ID. | |
| node_id_t | OpenLcbUtilities_extract_node_id_from_config_mem_buffer (configuration_memory_buffer_t *buffer, uint8_t index) |
| Extracts a 6-byte node ID from a config memory buffer at the given index. | |
| uint16_t | OpenLcbUtilities_extract_word_from_config_mem_buffer (configuration_memory_buffer_t *buffer, uint8_t index) |
| Extracts a 16-bit word from a config memory buffer at the given index. | |
| void | OpenLcbUtilities_copy_node_id_to_config_mem_buffer (configuration_memory_buffer_t *buffer, node_id_t node_id, uint8_t index) |
| Copies a 6-byte node ID into a config memory buffer at the given index. | |
| void | OpenLcbUtilities_copy_event_id_to_config_mem_buffer (configuration_memory_buffer_t *buffer, event_id_t event_id, uint8_t index) |
| Copies an 8-byte event ID into a config memory buffer at the given index. | |
| event_id_t | OpenLcbUtilities_copy_config_mem_buffer_to_event_id (configuration_memory_buffer_t *buffer, uint8_t index) |
| Extracts an 8-byte event ID from a config memory buffer at the given index. | |
| void | OpenLcbUtilities_load_config_mem_reply_write_ok_message_header (openlcb_statemachine_info_t *statemachine_info, config_mem_write_request_info_t *config_mem_write_request_info) |
| Builds a config memory write-success reply datagram header. | |
| void | OpenLcbUtilities_load_config_mem_reply_write_fail_message_header (openlcb_statemachine_info_t *statemachine_info, config_mem_write_request_info_t *config_mem_write_request_info, uint16_t error_code) |
| Builds a config memory write-failure reply datagram header. | |
| void | OpenLcbUtilities_load_config_mem_reply_read_ok_message_header (openlcb_statemachine_info_t *statemachine_info, config_mem_read_request_info_t *config_mem_read_request_info) |
| Builds a config memory read-success reply datagram header only. | |
| void | OpenLcbUtilities_load_config_mem_reply_read_fail_message_header (openlcb_statemachine_info_t *statemachine_info, config_mem_read_request_info_t *config_mem_read_request_info, uint16_t error_code) |
| Builds a config memory read-failure reply datagram header. | |
| bool | OpenLcbUtilities_is_event_id_in_consumer_ranges (openlcb_node_t *openlcb_node, event_id_t event_id) |
| Returns true if the event ID falls within any of the node's consumer ranges. | |
| bool | OpenLcbUtilities_is_event_id_in_producer_ranges (openlcb_node_t *openlcb_node, event_id_t event_id) |
| Returns true if the event ID falls within any of the node's producer ranges. | |
| event_id_t | OpenLcbUtilities_generate_event_range_id (event_id_t base_event_id, event_range_count_enum count) |
| Generates a masked Event ID covering a range of consecutive events. | |
| bool | OpenLcbUtilities_is_broadcast_time_event (event_id_t event_id) |
| Returns true if the event ID belongs to the broadcast time event space. | |
| uint64_t | OpenLcbUtilities_extract_clock_id_from_time_event (event_id_t event_id) |
| Extracts the 48-bit clock ID (upper 6 bytes) from a broadcast time event ID. | |
| broadcast_time_event_type_enum | OpenLcbUtilities_get_broadcast_time_event_type (event_id_t event_id) |
| Returns the broadcast_time_event_type_enum for a broadcast time event ID. | |
| bool | OpenLcbUtilities_extract_time_from_event_id (event_id_t event_id, uint8_t *hour, uint8_t *minute) |
| Extracts hour and minute from a broadcast time event ID. Returns false if out of range. | |
| bool | OpenLcbUtilities_extract_date_from_event_id (event_id_t event_id, uint8_t *month, uint8_t *day) |
| Extracts month and day from a broadcast time event ID. Returns false if out of range. | |
| bool | OpenLcbUtilities_extract_year_from_event_id (event_id_t event_id, uint16_t *year) |
| Extracts year from a broadcast time event ID. Returns false if out of range. | |
| bool | OpenLcbUtilities_extract_rate_from_event_id (event_id_t event_id, int16_t *rate) |
| Extracts the 12-bit signed fixed-point rate from a broadcast time event ID. | |
| event_id_t | OpenLcbUtilities_create_time_event_id (uint64_t clock_id, uint8_t hour, uint8_t minute, bool is_set) |
| Creates a Report/Set Time event ID from clock_id, hour, minute. | |
| event_id_t | OpenLcbUtilities_create_date_event_id (uint64_t clock_id, uint8_t month, uint8_t day, bool is_set) |
| Creates a Report/Set Date event ID from clock_id, month, day. | |
| event_id_t | OpenLcbUtilities_create_year_event_id (uint64_t clock_id, uint16_t year, bool is_set) |
| Creates a Report/Set Year event ID from clock_id, year. | |
| event_id_t | OpenLcbUtilities_create_rate_event_id (uint64_t clock_id, int16_t rate, bool is_set) |
| Creates a Report/Set Rate event ID from clock_id, rate. | |
| event_id_t | OpenLcbUtilities_create_command_event_id (uint64_t clock_id, broadcast_time_event_type_enum command) |
| Creates a command event ID (Query, Start, Stop, Date Rollover) for the given clock. | |
| bool | OpenLcbUtilities_is_train_search_event (event_id_t event_id) |
| Returns true if the event ID belongs to the train search space. | |
| void | OpenLcbUtilities_extract_train_search_digits (event_id_t event_id, uint8_t *digits) |
| Extracts 6 search-query nibbles from a train search event ID into digits[]. | |
| uint8_t | OpenLcbUtilities_extract_train_search_flags (event_id_t event_id) |
| Extracts the flags byte (byte 7) from a train search event ID. | |
| uint16_t | OpenLcbUtilities_train_search_digits_to_address (const uint8_t *digits) |
| Converts a 6-nibble digit array to a numeric DCC address, skipping leading 0xF nibbles. | |
| event_id_t | OpenLcbUtilities_create_train_search_event_id (uint16_t address, uint8_t flags) |
| Creates a train search event ID from a DCC address and flags byte. | |
| bool | OpenLcbUtilities_is_emergency_event (event_id_t event_id) |
| Returns true if the event ID is one of the 4 well-known emergency events. | |
Common utility functions for OpenLCB message and buffer manipulation.
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.
All multi-byte values follow OpenLCB big-endian (network byte order) convention. Payload insert functions increment payload_count; extract functions do not modify it.
| uint16_t OpenLcbUtilities_payload_type_to_len | ( | payload_type_enum | payload_type | ) |
Converts a payload_type_enum to its maximum byte length.
Converts a payload_type_enum to its maximum byte length. Returns 0 for unknown types.
| uint32_t OpenLcbUtilities_calculate_memory_offset_into_node_space | ( | openlcb_node_t * | openlcb_node | ) |
Returns the byte offset into global config memory where this node's space begins.
| openlcb_node | Pointer to the openlcb_node_t to calculate the offset for. |
| void OpenLcbUtilities_load_openlcb_message | ( | openlcb_msg_t * | openlcb_msg, |
| uint16_t | source_alias, | ||
| uint64_t | source_id, | ||
| uint16_t | dest_alias, | ||
| uint64_t | dest_id, | ||
| uint16_t | mti ) |
Loads message header fields and clears the payload to zeros.
| openlcb_msg | Pointer to the openlcb_msg_t to initialize |
| source_alias | 12-bit CAN alias of the source node |
| source_id | 48-bit node_id_t of the source node |
| dest_alias | 12-bit CAN alias of the destination (0 for global) |
| dest_id | 48-bit node_id_t of the destination (0 for global) |
| mti | Message Type Indicator |
| void OpenLcbUtilities_clear_openlcb_message_payload | ( | openlcb_msg_t * | openlcb_msg | ) |
Zeros all payload bytes and resets payload_count. Header preserved.
| openlcb_msg | Pointer to the openlcb_msg_t to clear payload from. |
| void OpenLcbUtilities_clear_openlcb_message | ( | openlcb_msg_t * | openlcb_msg | ) |
Zeros entire message including header, state flags, and reference count.
| openlcb_msg | Pointer to the openlcb_msg_t to fully clear. |
| void OpenLcbUtilities_copy_event_id_to_openlcb_payload | ( | openlcb_msg_t * | openlcb_msg, |
| event_id_t | event_id ) |
Copies an 8-byte event ID to payload at offset 0.
| openlcb_msg | Pointer to the openlcb_msg_t to write into. |
| event_id | 64-bit event_id_t to store in the payload. |
| void OpenLcbUtilities_copy_byte_to_openlcb_payload | ( | openlcb_msg_t * | openlcb_msg, |
| uint8_t | byte, | ||
| uint16_t | offset ) |
Copies one byte to payload at the given offset.
| openlcb_msg | Pointer to the openlcb_msg_t to write into. |
| byte | Byte value to store. |
| offset | Byte offset in the payload. |
| void OpenLcbUtilities_copy_word_to_openlcb_payload | ( | openlcb_msg_t * | openlcb_msg, |
| uint16_t | word, | ||
| uint16_t | offset ) |
Copies a 16-bit word (big-endian) to payload at the given offset.
| openlcb_msg | Pointer to the openlcb_msg_t to write into. |
| word | 16-bit value to store in big-endian order. |
| offset | Starting byte offset in the payload. |
| void OpenLcbUtilities_copy_dword_to_openlcb_payload | ( | openlcb_msg_t * | openlcb_msg, |
| uint32_t | doubleword, | ||
| uint16_t | offset ) |
Copies a 32-bit doubleword (big-endian) to payload at the given offset.
| openlcb_msg | Pointer to the openlcb_msg_t to write into. |
| doubleword | 32-bit value to store in big-endian order. |
| offset | Starting byte offset in the payload. |
| uint16_t OpenLcbUtilities_copy_string_to_openlcb_payload | ( | openlcb_msg_t * | openlcb_msg, |
| const char | string[], | ||
| uint16_t | offset ) |
Copies a null-terminated string into the payload.
Truncates if payload space is insufficient but always adds a null terminator.
| uint16_t OpenLcbUtilities_copy_byte_array_to_openlcb_payload | ( | openlcb_msg_t * | openlcb_msg, |
| const uint8_t | byte_array[], | ||
| uint16_t | offset, | ||
| uint16_t | requested_bytes ) |
Copies a byte array into the payload. May copy fewer bytes if payload space is exhausted.
Copies a byte array into the payload.
| void OpenLcbUtilities_copy_node_id_to_openlcb_payload | ( | openlcb_msg_t * | openlcb_msg, |
| node_id_t | node_id, | ||
| uint16_t | offset ) |
Copies a 6-byte node ID (big-endian) to payload at the given offset.
Copies a 6-byte node ID to payload at the given offset.
| node_id_t OpenLcbUtilities_extract_node_id_from_openlcb_payload | ( | openlcb_msg_t * | openlcb_msg, |
| uint16_t | offset ) |
Extracts a 6-byte node ID from payload at the given offset.
| openlcb_msg | Pointer to the openlcb_msg_t to read from. |
| offset | Starting byte offset in the payload. |
| event_id_t OpenLcbUtilities_extract_event_id_from_openlcb_payload | ( | openlcb_msg_t * | openlcb_msg | ) |
Extracts an 8-byte event ID from payload at offset 0.
| openlcb_msg | Pointer to the openlcb_msg_t to read from. |
| uint8_t OpenLcbUtilities_extract_byte_from_openlcb_payload | ( | openlcb_msg_t * | openlcb_msg, |
| uint16_t | offset ) |
Extracts one byte from payload at the given offset.
| openlcb_msg | Pointer to the openlcb_msg_t to read from. |
| offset | Byte offset in the payload. |
| uint16_t OpenLcbUtilities_extract_word_from_openlcb_payload | ( | openlcb_msg_t * | openlcb_msg, |
| uint16_t | offset ) |
Extracts a 16-bit word (big-endian) from payload at the given offset.
| openlcb_msg | Pointer to the openlcb_msg_t to read from. |
| offset | Starting byte offset in the payload. |
| uint32_t OpenLcbUtilities_extract_dword_from_openlcb_payload | ( | openlcb_msg_t * | openlcb_msg, |
| uint16_t | offset ) |
Extracts a 32-bit doubleword (big-endian) from payload at the given offset.
| openlcb_msg | Pointer to the openlcb_msg_t to read from. |
| offset | Starting byte offset in the payload. |
| void OpenLcbUtilities_set_multi_frame_flag | ( | uint8_t * | target, |
| uint8_t | flag ) |
Sets the multi-frame control flag in the upper nibble of target, preserving the lower nibble.
| target | Pointer to the byte whose upper nibble will be replaced. |
| flag | Flag value to write into the upper nibble. |
| bool OpenLcbUtilities_is_addressed_openlcb_message | ( | openlcb_msg_t * | openlcb_msg | ) |
Returns true if the MTI has the destination-address-present bit set.
| openlcb_msg | Pointer to the openlcb_msg_t to check. |
| uint8_t OpenLcbUtilities_count_nulls_in_openlcb_payload | ( | openlcb_msg_t * | openlcb_msg | ) |
Returns the count of null bytes (0x00) in the payload. Used for SNIP validation.
| openlcb_msg | Pointer to the openlcb_msg_t to scan. |
| bool OpenLcbUtilities_is_addressed_message_for_node | ( | openlcb_node_t * | openlcb_node, |
| openlcb_msg_t * | openlcb_msg ) |
Returns true if the message destination matches this node's alias or ID.
| openlcb_node | Pointer to the openlcb_node_t to match against. |
| openlcb_msg | Pointer to the openlcb_msg_t to check. |
| bool OpenLcbUtilities_is_producer_event_assigned_to_node | ( | openlcb_node_t * | openlcb_node, |
| event_id_t | event_id, | ||
| uint16_t * | event_index ) |
Searches the node's producer list for a matching event ID.
| openlcb_node | Node to search |
| event_id | Event ID to find |
| event_index | Receives the list index if found (undefined on false return) |
| bool OpenLcbUtilities_is_consumer_event_assigned_to_node | ( | openlcb_node_t * | openlcb_node, |
| event_id_t | event_id, | ||
| uint16_t * | event_index ) |
Searches the node's consumer list for a matching event ID.
| openlcb_node | Node to search |
| event_id | Event ID to find |
| event_index | Receives the list index if found (undefined on false return) |
| node_id_t OpenLcbUtilities_extract_node_id_from_config_mem_buffer | ( | configuration_memory_buffer_t * | buffer, |
| uint8_t | index ) |
Extracts a 6-byte node ID from a config memory buffer at the given index.
| buffer | Pointer to the configuration_memory_buffer_t to read from. |
| index | Starting byte index in the buffer. |
| uint16_t OpenLcbUtilities_extract_word_from_config_mem_buffer | ( | configuration_memory_buffer_t * | buffer, |
| uint8_t | index ) |
Extracts a 16-bit word from a config memory buffer at the given index.
| buffer | Pointer to the configuration_memory_buffer_t to read from. |
| index | Starting byte index in the buffer. |
| void OpenLcbUtilities_copy_node_id_to_config_mem_buffer | ( | configuration_memory_buffer_t * | buffer, |
| node_id_t | node_id, | ||
| uint8_t | index ) |
Copies a 6-byte node ID into a config memory buffer at the given index.
| buffer | Pointer to the configuration_memory_buffer_t to write into. |
| node_id | 48-bit node_id_t to store. |
| index | Starting byte index in the buffer. |
| void OpenLcbUtilities_copy_event_id_to_config_mem_buffer | ( | configuration_memory_buffer_t * | buffer, |
| event_id_t | event_id, | ||
| uint8_t | index ) |
Copies an 8-byte event ID into a config memory buffer at the given index.
| buffer | Pointer to the configuration_memory_buffer_t to write into. |
| event_id | 64-bit event_id_t to store. |
| index | Starting byte index in the buffer. |
| event_id_t OpenLcbUtilities_copy_config_mem_buffer_to_event_id | ( | configuration_memory_buffer_t * | buffer, |
| uint8_t | index ) |
Extracts an 8-byte event ID from a config memory buffer at the given index.
| buffer | Pointer to the configuration_memory_buffer_t to read from. |
| index | Starting byte index in the buffer. |
| void OpenLcbUtilities_load_config_mem_reply_write_ok_message_header | ( | openlcb_statemachine_info_t * | statemachine_info, |
| config_mem_write_request_info_t * | config_mem_write_request_info ) |
Builds a config memory write-success reply datagram header.
| statemachine_info | Pointer to the openlcb_statemachine_info_t context. |
| config_mem_write_request_info | Pointer to the config_mem_write_request_info_t from the original request. |
| void OpenLcbUtilities_load_config_mem_reply_write_fail_message_header | ( | openlcb_statemachine_info_t * | statemachine_info, |
| config_mem_write_request_info_t * | config_mem_write_request_info, | ||
| uint16_t | error_code ) |
Builds a config memory write-failure reply datagram header.
Error code placement depends on address encoding: ADDRESS_SPACE_IN_BYTE_6 places it at offset 7, otherwise offset 6.
| void OpenLcbUtilities_load_config_mem_reply_read_ok_message_header | ( | openlcb_statemachine_info_t * | statemachine_info, |
| config_mem_read_request_info_t * | config_mem_read_request_info ) |
Builds a config memory read-success reply datagram header only.
Caller must append actual data bytes separately after this call.
| void OpenLcbUtilities_load_config_mem_reply_read_fail_message_header | ( | openlcb_statemachine_info_t * | statemachine_info, |
| config_mem_read_request_info_t * | config_mem_read_request_info, | ||
| uint16_t | error_code ) |
Builds a config memory read-failure reply datagram header.
Error code is placed at the data_start offset where actual data would have been.
| bool OpenLcbUtilities_is_event_id_in_consumer_ranges | ( | openlcb_node_t * | openlcb_node, |
| event_id_t | event_id ) |
Returns true if the event ID falls within any of the node's consumer ranges.
| openlcb_node | Pointer to the openlcb_node_t whose consumer ranges are checked. |
| event_id | 64-bit event_id_t to test. |
| bool OpenLcbUtilities_is_event_id_in_producer_ranges | ( | openlcb_node_t * | openlcb_node, |
| event_id_t | event_id ) |
Returns true if the event ID falls within any of the node's producer ranges.
| openlcb_node | Pointer to the openlcb_node_t whose producer ranges are checked. |
| event_id | 64-bit event_id_t to test. |
| event_id_t OpenLcbUtilities_generate_event_range_id | ( | event_id_t | base_event_id, |
| event_range_count_enum | count ) |
Generates a masked Event ID covering a range of consecutive events.
| base_event_id | Starting event_id_t of the range |
| count | Number of events in the range (event_range_count_enum) |
| bool OpenLcbUtilities_is_broadcast_time_event | ( | event_id_t | event_id | ) |
Returns true if the event ID belongs to the broadcast time event space.
| event_id | 64-bit event_id_t to test. |
| uint64_t OpenLcbUtilities_extract_clock_id_from_time_event | ( | event_id_t | event_id | ) |
Extracts the 48-bit clock ID (upper 6 bytes) from a broadcast time event ID.
| event_id | Broadcast time event_id_t to extract from. |
| broadcast_time_event_type_enum OpenLcbUtilities_get_broadcast_time_event_type | ( | event_id_t | event_id | ) |
Returns the broadcast_time_event_type_enum for a broadcast time event ID.
| event_id | Broadcast time event_id_t to classify. |
| bool OpenLcbUtilities_extract_time_from_event_id | ( | event_id_t | event_id, |
| uint8_t * | hour, | ||
| uint8_t * | minute ) |
Extracts hour and minute from a broadcast time event ID. Returns false if out of range.
Extracts hour and minute from a broadcast time event ID.
| bool OpenLcbUtilities_extract_date_from_event_id | ( | event_id_t | event_id, |
| uint8_t * | month, | ||
| uint8_t * | day ) |
Extracts month and day from a broadcast time event ID. Returns false if out of range.
Extracts month and day from a broadcast time event ID.
| bool OpenLcbUtilities_extract_year_from_event_id | ( | event_id_t | event_id, |
| uint16_t * | year ) |
Extracts year from a broadcast time event ID. Returns false if out of range.
Extracts year from a broadcast time event ID.
| bool OpenLcbUtilities_extract_rate_from_event_id | ( | event_id_t | event_id, |
| int16_t * | rate ) |
Extracts the 12-bit signed fixed-point rate from a broadcast time event ID.
Rate format is 10.2 fixed point. Sign-extends bit 11 for negative rates.
| event_id_t OpenLcbUtilities_create_time_event_id | ( | uint64_t | clock_id, |
| uint8_t | hour, | ||
| uint8_t | minute, | ||
| bool | is_set ) |
Creates a Report/Set Time event ID from clock_id, hour, minute.
| clock_id | 48-bit clock identifier. |
| hour | Hour value (0-23). |
| minute | Minute value (0-59). |
| is_set | true for a Set command, false for a Report. |
| event_id_t OpenLcbUtilities_create_date_event_id | ( | uint64_t | clock_id, |
| uint8_t | month, | ||
| uint8_t | day, | ||
| bool | is_set ) |
Creates a Report/Set Date event ID from clock_id, month, day.
| clock_id | 48-bit clock identifier. |
| month | Month value (1-12). |
| day | Day value (1-31). |
| is_set | true for a Set command, false for a Report. |
| event_id_t OpenLcbUtilities_create_year_event_id | ( | uint64_t | clock_id, |
| uint16_t | year, | ||
| bool | is_set ) |
Creates a Report/Set Year event ID from clock_id, year.
| clock_id | 48-bit clock identifier. |
| year | Year value (0-4095). |
| is_set | true for a Set command, false for a Report. |
| event_id_t OpenLcbUtilities_create_rate_event_id | ( | uint64_t | clock_id, |
| int16_t | rate, | ||
| bool | is_set ) |
Creates a Report/Set Rate event ID from clock_id, rate.
| clock_id | 48-bit clock identifier. |
| rate | 12-bit signed fixed-point rate (10.2 format). |
| is_set | true for a Set command, false for a Report. |
| event_id_t OpenLcbUtilities_create_command_event_id | ( | uint64_t | clock_id, |
| broadcast_time_event_type_enum | command ) |
Creates a command event ID (Query, Start, Stop, Date Rollover) for the given clock.
| clock_id | 48-bit clock identifier. |
| command | broadcast_time_event_type_enum specifying the command type. |
| bool OpenLcbUtilities_is_train_search_event | ( | event_id_t | event_id | ) |
Returns true if the event ID belongs to the train search space.
Returns true if the event ID belongs to the train search space (upper 4 bytes = 0x090099FF).
| void OpenLcbUtilities_extract_train_search_digits | ( | event_id_t | event_id, |
| uint8_t * | digits ) |
Extracts 6 search-query nibbles from a train search event ID into digits[].
| event_id | Train search event_id_t to decode. |
| digits | Pointer to a 6-element uint8_t array that receives the nibble values. |
| uint8_t OpenLcbUtilities_extract_train_search_flags | ( | event_id_t | event_id | ) |
Extracts the flags byte (byte 7) from a train search event ID.
| event_id | Train search event_id_t to decode. |
| uint16_t OpenLcbUtilities_train_search_digits_to_address | ( | const uint8_t * | digits | ) |
Converts a 6-nibble digit array to a numeric DCC address, skipping leading 0xF nibbles.
| digits | Pointer to a 6-element uint8_t array of nibble values. |
| event_id_t OpenLcbUtilities_create_train_search_event_id | ( | uint16_t | address, |
| uint8_t | flags ) |
Creates a train search event ID from a DCC address and flags byte.
| address | DCC address to encode into the search event. |
| flags | Flags byte placed in the lowest byte of the event ID. |
| bool OpenLcbUtilities_is_emergency_event | ( | event_id_t | event_id | ) |
Returns true if the event ID is one of the 4 well-known emergency events.
| event_id | 64-bit event_id_t to test. |
Copyright (c) 2026 Jim Kueneman all rights reserved. See the License