|
| class | PhysicalIf |
| | Polymorphic class that can be implemented by CAN and TCP interfaces separately for appropriate construction order. More...
|
| |
|
| | SimpleStackBase (std::function< std::unique_ptr< PhysicalIf >()> create_if_helper) |
| |
| Executor< EXECUTOR_PRIORITIES > * | executor () |
| |
| Service * | service () |
| |
| If * | iface () |
| |
| DatagramService * | dg_service () |
| |
| SimpleInfoFlow * | info_flow () |
| | Accessor for clients that have their custom SNIP-like handler.
|
| |
| virtual Node * | node ()=0 |
| |
| MemoryConfigHandler * | memory_config_handler () |
| |
| ConfigUpdateService * | config_service () |
| |
| void | set_tx_activity_led (const Gpio *led, long long period=MSEC_TO_NSEC(33)) |
| | Adds an activiy LED which will be flashed every time a message is sent from this node to the network.
|
| |
| void | restart_stack () |
| | Reinitializes the node.
|
| |
| void | loop_executor (bool delay_start=false) |
| | Donates the current thread to the executor.
|
| |
| void | start_after_delay () |
| | Call this function when you used delay_start upon starting the executor.
|
| |
| void | start_executor_thread (const char *name, int priority, size_t stack_size, bool delay_start=false) |
| | Instructs the executor to create a new thread and run in there.
|
| |
| int | create_config_file_if_needed (const InternalConfigData &ofs, uint16_t expected_version, unsigned file_size) |
| | Tries to open the config file; if not existant, the size too small, or the version number is mismatched, then creates a new file of the given size with all 0xFF bytes inside.
|
| |
| int | check_version_and_factory_reset (const InternalConfigData &ofs, uint16_t expected_version, bool force=false) |
| | Checks the version information in the EEPROM and performs a factory reset if incorrect or if force is set.
|
| |
| void | send_event (uint64_t event_id) |
| | Helper function to send an event report to the bus.
|
| |
| void | send_message_to (Defs::MTI mti, NodeHandle dst, const string &payload=EMPTY_PAYLOAD) |
| | Sends an addressed message to the bus.
|
| |
| virtual uint64_t | get_pip () |
| | Get the PIP response value.
|
| |
|
| void | start_stack (bool delay_start) |
| | Call this function once after the actual IO ports are set up.
|
| |
| virtual void | start_iface (bool restart)=0 |
| | Hook for descendant classes to start the interface.
|
| |
| virtual void | start_node ()=0 |
| | Hook for clients to initialize the node-specific components.
|
| |
| void | default_start_node () |
| | Exports the memory config spaces that are typically used for a complex node.
|
| |
Definition at line 85 of file SimpleStack.hxx.
◆ SimpleStackBase()
| openlcb::SimpleStackBase::SimpleStackBase |
( |
std::function< std::unique_ptr< PhysicalIf >()> |
create_if_helper | ) |
|
◆ check_version_and_factory_reset()
| int openlcb::SimpleStackBase::check_version_and_factory_reset |
( |
const InternalConfigData & |
ofs, |
|
|
uint16_t |
expected_version, |
|
|
bool |
force = false |
|
) |
| |
Checks the version information in the EEPROM and performs a factory reset if incorrect or if force is set.
- Returns
- file descriptor for config file.
- Todo:
- (balazs.racz): We need to clear the eeprom. Best would be if there was an ioctl to return the eeprom to factory default state by just erasing the segments.
Definition at line 349 of file SimpleStack.cxx.
◆ config_service()
◆ create_config_file_if_needed()
| int openlcb::SimpleStackBase::create_config_file_if_needed |
( |
const InternalConfigData & |
ofs, |
|
|
uint16_t |
expected_version, |
|
|
unsigned |
file_size |
|
) |
| |
Tries to open the config file; if not existant, the size too small, or the version number is mismatched, then creates a new file of the given size with all 0xFF bytes inside.
This will internally do everything done by the check_version_and_factory_reset call.
- Parameters
-
| ofs | tells where in the file the versioninfo structure lies. |
| expected_verison | is the correct version of the config file. |
| file_size | is the minimum required size of the config file. |
- Returns
- file descriptor for config file.
Definition at line 250 of file SimpleStack.cxx.
◆ default_start_node()
| void openlcb::SimpleStackBase::default_start_node |
( |
| ) |
|
|
protected |
Exports the memory config spaces that are typically used for a complex node.
Expected to be called from start_node().
Definition at line 146 of file SimpleStack.cxx.
◆ dg_service()
- Returns
- the datagram service for registering new datagram handlers or acquiring datagram client objects.
Definition at line 131 of file SimpleStack.hxx.
◆ executor()
| Executor< EXECUTOR_PRIORITIES > * openlcb::SimpleStackBase::executor |
( |
| ) |
|
|
inline |
- Returns
- the executor that's controlling the main thread of the OpenLCB stack.
Definition at line 112 of file SimpleStack.hxx.
◆ factory_reset_all_events()
| void openlcb::SimpleStackBase::factory_reset_all_events |
( |
const InternalConfigData & |
ofs, |
|
|
uint64_t |
node_id, |
|
|
int |
fd |
|
) |
| |
|
static |
Overwrites all events in the eeprom with a brand new event ID.
Definition at line 394 of file SimpleStack.cxx.
◆ get_pip()
| virtual uint64_t openlcb::SimpleStackBase::get_pip |
( |
| ) |
|
|
inlinevirtual |
◆ iface()
| If * openlcb::SimpleStackBase::iface |
( |
| ) |
|
|
inline |
◆ info_flow()
Accessor for clients that have their custom SNIP-like handler.
Definition at line 137 of file SimpleStack.hxx.
◆ loop_executor()
| void openlcb::SimpleStackBase::loop_executor |
( |
bool |
delay_start = false | ) |
|
|
inline |
Donates the current thread to the executor.
Never returns.
- Parameters
-
| delay_start | if true, then prevents sending traffic to the bus |
Definition at line 177 of file SimpleStack.hxx.
◆ memory_config_handler()
- Returns
- the handler for the memory configuration protocol. This is needed for registering additional memory spaces.
Definition at line 148 of file SimpleStack.hxx.
◆ node()
| virtual Node * openlcb::SimpleStackBase::node |
( |
| ) |
|
|
pure virtual |
◆ restart_stack()
| void openlcb::SimpleStackBase::restart_stack |
( |
| ) |
|
Reinitializes the node.
Useful to call after the connection has flapped (gone down and up).
Definition at line 239 of file SimpleStack.cxx.
◆ send_event()
| void openlcb::SimpleStackBase::send_event |
( |
uint64_t |
event_id | ) |
|
|
inline |
Helper function to send an event report to the bus.
Performs synchronous (dynamic) memory allocation so use it sparingly and when there is sufficient amount of RAM available.
- Parameters
-
| event_id | is the event to send off. |
Definition at line 237 of file SimpleStack.hxx.
◆ send_message_to()
Sends an addressed message to the bus.
Performs synchronous (dynamic) memory allocation so use it sparingly and when there is sufficient amount of RAM available.
- Parameters
-
| mti | is the message to send |
| dst | is the node to send message to. |
| payload | is the contents of the message |
Definition at line 251 of file SimpleStack.hxx.
◆ service()
| Service * openlcb::SimpleStackBase::service |
( |
| ) |
|
|
inline |
- Returns
- a plain service bound to the main thread's executor.
Definition at line 118 of file SimpleStack.hxx.
◆ set_event_offsets()
| void openlcb::SimpleStackBase::set_event_offsets |
( |
const vector< uint16_t > * |
offsets | ) |
|
|
static |
◆ set_tx_activity_led()
| void openlcb::SimpleStackBase::set_tx_activity_led |
( |
const Gpio * |
led, |
|
|
long long |
period = MSEC_TO_NSEC(33) |
|
) |
| |
|
inline |
Adds an activiy LED which will be flashed every time a message is sent from this node to the network.
- Parameters
-
| gpio | LED that will be flashed on for each packet. |
| period | defines in nanosecond the time to spend between updates. |
Definition at line 162 of file SimpleStack.hxx.
◆ start_after_delay()
| void openlcb::SimpleStackBase::start_after_delay |
( |
| ) |
|
Call this function when you used delay_start upon starting the executor.
Definition at line 211 of file SimpleStack.cxx.
◆ start_executor_thread()
| void openlcb::SimpleStackBase::start_executor_thread |
( |
const char * |
name, |
|
|
int |
priority, |
|
|
size_t |
stack_size, |
|
|
bool |
delay_start = false |
|
) |
| |
|
inline |
Instructs the executor to create a new thread and run in there.
- Parameters
-
| name | is the thread name for the executor thread |
| priority | is the executor thread priority (used only for freertos) |
| stack_size | is the executor stack in bytes (used only for freertos) |
| delay_start | if true, then prevents sending traffic to the bus |
Definition at line 193 of file SimpleStack.hxx.
◆ start_iface()
| virtual void openlcb::SimpleStackBase::start_iface |
( |
bool |
restart | ) |
|
|
protectedpure virtual |
◆ start_node()
| virtual void openlcb::SimpleStackBase::start_node |
( |
| ) |
|
|
protectedpure virtual |
◆ start_stack()
| void openlcb::SimpleStackBase::start_stack |
( |
bool |
delay_start | ) |
|
|
protected |
Call this function once after the actual IO ports are set up.
Calling before the executor starts looping is okay.
Definition at line 114 of file SimpleStack.cxx.
◆ ::openmrn_arduino::OpenMRN
| friend class ::openmrn_arduino::OpenMRN |
|
friend |
◆ additionalComponents_
| std::vector<std::unique_ptr<Destructable> > openlcb::SimpleStackBase::additionalComponents_ |
|
protected |
Stores and keeps ownership of optional components.
Definition at line 311 of file SimpleStack.hxx.
◆ configUpdateFlow_
Calls the config listeners with the configuration FD.
Definition at line 294 of file SimpleStack.hxx.
◆ datagramService_
The datagram service bound to the interface object.
Owned by ifaceHolder_;
Definition at line 292 of file SimpleStack.hxx.
◆ eventService_
Dispatches event protocol requests to the event handlers.
Definition at line 298 of file SimpleStack.hxx.
◆ executor_
◆ EXECUTOR_PRIORITIES
| const unsigned openlcb::SimpleStackBase::EXECUTOR_PRIORITIES = 5 |
|
static |
◆ gcAdapter_
| std::unique_ptr<GCAdapterBase> openlcb::SimpleStackBase::gcAdapter_ |
|
protected |
Bridge between canHub_ and gcHub_. Lazily initialized.
Definition at line 309 of file SimpleStack.hxx.
◆ gcHub_
| std::unique_ptr<HubFlow> openlcb::SimpleStackBase::gcHub_ |
|
protected |
All packets are forwarded to this hub in gridconnect format, if needed.
Will be initialized upon first use.
Definition at line 307 of file SimpleStack.hxx.
◆ iface_
The OpenLCB interface object. Owned by ifaceHolder_;.
Definition at line 289 of file SimpleStack.hxx.
◆ ifaceHolder_
| std::unique_ptr<PhysicalIf> openlcb::SimpleStackBase::ifaceHolder_ |
|
protected |
Pointer to the polymorphic implementation of the OpenLCB If.
Definition at line 287 of file SimpleStack.hxx.
◆ infoFlow_
◆ initFlow_
The initialization flow takes care for node startup duties.
Definition at line 296 of file SimpleStack.hxx.
◆ memoryConfigHandler_
Initial value:{
DatagramService * datagramService_
The datagram service bound to the interface object.
Definition at line 302 of file SimpleStack.hxx.
◆ service_
Default service on the particular executor.
Definition at line 285 of file SimpleStack.hxx.
The documentation for this class was generated from the following files: