41 m_device_alive_callback_functional = std::bind(&Master::device_alive_callback,
this, std::placeholders::_1);
51 bool Master::start(
const std::string busname,
const std::string& baudrate) {
52 bool success =
core.
start(busname, baudrate);
63 bool Master::start(
const std::string busname,
const unsigned baudrate) {
64 bool success =
core.
start(busname, baudrate);
81 return m_devices.size();
85 assert(m_devices.size()>index);
86 return *(m_devices.at(index).get());
89 void Master::device_alive_callback(
const uint8_t node_id) {
90 if (!m_device_alive.test(node_id)) {
91 m_device_alive.set(node_id);
92 m_devices.emplace_back(
new Device(
core, node_id));
94 WARN(
"Device with node ID "<<node_id<<
" already exists. Ignoring...");
Device & get_device(size_t index) const
Returns a reference to a slave device object.
NMT nmt
The NMT sub-protocol.
void register_device_alive_callback(const DeviceAliveCallback &callback)
Registers a callback which will be called when a slave sends it's state via NMT and the state indicat...
size_t num_devices() const
Returns the number of slave devices in the network.
void stop()
Stops master and core.
bool start(const std::string busname, const std::string &baudrate)
Starts master and creates Core.
Master()
Constructor. Creates Core instance and adds NMT listener for new devices.
void discover_nodes()
Discovers nodes in the network via node guard protocol.
void stop()
Stops the receive loop and closes the driver.
This class represents a CanOpen slave device in the network.
bool start(const std::string busname, const std::string &baudrate)
Opens CAN driver and starts CAN message receive loop.