KaCanOpen
 All Classes Functions Variables Typedefs Enumerations Pages
Public Member Functions | Public Attributes | List of all members
kaco::Master Class Reference

This class represents a master node. It listens for new slaves and provides access to them via get_slaves(). More...

#include <master.h>

Collaboration diagram for kaco::Master:
Collaboration graph
[legend]

Public Member Functions

 Master ()
 Constructor. Creates Core instance and adds NMT listener for new devices.
 
 Master (const Master &)=delete
 Copy constructor deleted because of callbacks with self-references.
 
 Master (Master &&)=delete
 Move constructor deleted because of callbacks with self-references.
 
 ~Master ()
 Destructor.
 
bool start (const std::string busname, const std::string &baudrate)
 Starts master and creates Core. More...
 
bool start (const std::string busname, const unsigned baudrate)
 Starts master and creates Core. More...
 
void stop ()
 Stops master and core.
 
size_t num_devices () const
 Returns the number of slave devices in the network. More...
 
Deviceget_device (size_t index) const
 Returns a reference to a slave device object. More...
 

Public Attributes

Core core
 Core instance.
 

Detailed Description

This class represents a master node. It listens for new slaves and provides access to them via get_slaves().

Examples:
examples/listdevices.cpp, examples/master.cpp, examples/pdo.cpp, examples/ros/motor_and_io_bridge.cpp, and examples/ros/ros.cpp.

Definition at line 47 of file master.h.

Member Function Documentation

Device & kaco::Master::get_device ( size_t  index) const

Returns a reference to a slave device object.

Parameters
indexIndex of the device. Must be smaller than num_devices().
Remarks
thread-safe
Examples:
examples/listdevices.cpp, examples/master.cpp, examples/pdo.cpp, examples/ros/motor_and_io_bridge.cpp, and examples/ros/ros.cpp.

Definition at line 84 of file master.cpp.

size_t kaco::Master::num_devices ( ) const

Returns the number of slave devices in the network.

Remarks
thread-safe
Examples:
examples/listdevices.cpp, examples/master.cpp, examples/pdo.cpp, examples/ros/motor_and_io_bridge.cpp, and examples/ros/ros.cpp.

Definition at line 80 of file master.cpp.

bool kaco::Master::start ( const std::string  busname,
const std::string &  baudrate 
)

Starts master and creates Core.

Parameters
busnameName of the bus which will be passed to the CAN driver, e.g. slcan0
baudrateBaudrate as a string which will be passed to the CAN driver. Most drivers from the CanFestival project accept the following values: "1M", "500K", "125K", "100K", "50K", "20K", "10K" and "5K".
Returns
true if successful
Remarks
Master must not run yet.
Examples:
examples/listdevices.cpp, examples/master.cpp, examples/pdo.cpp, examples/ros/motor_and_io_bridge.cpp, and examples/ros/ros.cpp.

Definition at line 51 of file master.cpp.

bool kaco::Master::start ( const std::string  busname,
const unsigned  baudrate 
)

Starts master and creates Core.

Parameters
busnameName of the bus which will be passed to the CAN driver, e.g. slcan0
baudrateBaudrate in 1/s. The value will be passed to the CAN driver in string representation. Attention: For full compatibility with CanFestival drivers, values > 1000000 are postfixed with "M" and values > 1000 are postfixed with "K". E.g. 1000000->"1M", 500000->"500K" and 5000->"5K".
Returns
true if successful
Remarks
Master must not run yet.

Definition at line 63 of file master.cpp.


The documentation for this class was generated from the following files: