- Main Page
- Related Pages
- Classes
- Files

- Class List
- Class Hierarchy
- Class Members

Public Member Functions | Protected Member Functions | Friends

# SCS::Receiver Class Reference

The main class and entry point to the CAN Aerospace world. It manages network access and handles all protocol requirements. More...

`#include <receiver.h>`

Inheritance diagram for SCS::Receiver:
[legend]

List of all members.

## Public Member Functions
| Receiver (uint8_t required_software_revision, uint8_t own_node_id=255, const std::string &host_addr="239.40.41.42")
| Receiver (uint8_t required_software_revision, NetworkConnector< can_t > *connector, uint8_t own_node_id=255)
virtual | ~Receiver ()
void | requestData (can_Id_t can_id, TypelessDataReference *dataref)
void | requestData (can_Id_t can_id, int32_t *t)
void | requestData (can_Id_t can_id, float *t)
void | requestData (can_Id_t can_id, double *t)
void | requestData (can_Id_t can_id, bool *t)
void | requestData (can_Id_t can_id, char4 *t)
void | requestData (can_Id_t can_id, std::string *t)
void | requestData (can_Id_t can_id, std::vector< float > *t)
void | requestData (can_Id_t can_id, boost::function< void(int32_t)> f, int32_t *t)
void | requestData (can_Id_t can_id, boost::function< void(float)> f, float *t)
void | requestData (can_Id_t can_id, boost::function< void(double)> f, double *t)
void | requestData (can_Id_t can_id, boost::function< void(bool)> f, bool *t)
void | requestData (can_Id_t can_id, boost::function< void(char4)> f, char4 *t)
void | requestData (can_Id_t can_id, boost::function< void(const std::string &)> f, std::string *t)
void | requestData (can_Id_t can_id, boost::function< void(const std::vector< float > &)> f, std::vector< float > *t)
void | requestData (can_Id_t can_id, boost::function< void(int32_t)> f)
void | requestData (can_Id_t can_id, boost::function< void(float)> f)
void | requestData (can_Id_t can_id, boost::function< void(double)> f)
void | requestData (can_Id_t can_id, boost::function< void(bool)> f)
void | requestData (can_Id_t can_id, boost::function< void(char4)> f)
void | requestData (can_Id_t can_id, boost::function< void(const std::string &)> f)
void | requestData (can_Id_t can_id, boost::function< void(const std::vector< float > &)> f)
void | sendData (can_Id_t can_id, int32_t t)
void | sendData (can_Id_t can_id, float t)
void | sendData (can_Id_t can_id, double t)
void | sendData (can_Id_t can_id, bool t)
void | sendData (can_Id_t can_id, char4 t)
void | sendData (can_Id_t can_id, const std::string &t)
void | sendData (can_Id_t can_id, const std::vector< float > &t)
void | sendData (can_Id_t can_id)
void | run (bool do_log_output=true)
void | requestModule (uint8_t node_id, uint16_t module, uint16_t mode=1)
TypelessDataReference * | get (can_Id_t can_id)
## Protected Member Functions
virtual void | handleSTS ()
virtual void | handleMCS (uint16_t module, uint16_t mode)
virtual uint32_t | handleMIS ()
virtual bool | handleDRS (uint32_t)
## Friends
class | CanAeroBusConnector

## Detailed Description

The main class and entry point to the CAN Aerospace world. It manages network access and handles all protocol requirements.

The receiver maintains a list of CAN ids the application subscribed to. Notification on data changes is available either via callback functions or through pointers to variables that shall be updated.

Calling Receiver::requestData enables you to communicate with all participants on the bus. It is the sole thing to do for interaction with the simulator.

For more advanced use cases, like custom node services and publishing own data, inherit from Receiver and reimplement handleSTS, handleMCS and handleDRS functions.

For even more customization, you can implement the CanAeroDataManager interface. Also take a look at the TypelessDataReference interface, which is implemented by several templates for strongly-typed data access.

Note:
  Thread safety: This class is reentrant.
  callbacks are guaranteed to be invoked from the same thread the Receiver::run() function is called.

Author:
  (c) 2009, 2010 by Philipp Münzel

Version:
  1.3

## Constructor & Destructor Documentation

SCS::Receiver::Receiver | ( | uint8_t | required_software_revision,
|  | uint8_t | own_node_id = `255`,
|  | const std::string & | host_addr = `"239.40.41.42"`
| ) |  |

Open the network interfaces and announce yourself to other participants on the bus.

Parameters:

  required_software_revision | revision of the CAN Aerospace distribution your application requires
  own_node_id | your assigned node id or 255 for auto-configuration
  host_addr | can be used to assign different SCS subnets to different multicast groups. If you don't need this, leave it unchanged!!!

SCS::Receiver::Receiver | ( | uint8_t | required_software_revision,
|  | NetworkConnector< can_t > * | connector,
|  | uint8_t | own_node_id = `255`
| ) |  |

Open the network interfaces and announce yourself to other participants on the bus.

Parameters:

  required_software_revision | revision of the CAN Aerospace distribution your application requires
  connector | pointer to a compliant network connector, ownership is taken by Receiver
  own_node_id | your assigned node id or 255 for auto-configuration

virtual SCS::Receiver::~Receiver | ( |  | ) | `[virtual]`

Close all connections

## Member Function Documentation

TypelessDataReference* SCS::Receiver::get | ( | can_Id_t | can_id | ) |

Parameters:

  can_id | CAN id of simulation data, specified in identifier distribution

Note:
  This function comes in handy when you need own DataRef implementations.

Returns:
  pointer to instance of (custom) DataReference implementation

Deprecated:
  Only for internal use. To be discontinued without further notice.

virtual bool SCS::Receiver::handleDRS | ( | uint32_t |  | ) | `[protected, virtual]`

Handle incoming data request services. You may override this function if you inherit from Receiver. The data request service must only answer requests for CAN ids published exclusively by your application.

Implements SCS::CanAeroDataManager.

virtual void SCS::Receiver::handleMCS | ( | uint16_t | module,
|  | uint16_t | mode
| ) |  | `[protected, virtual]`

Handle incoming module configuration services. You may override this function if you inherit from Receiver.

Parameters:

  module | Module affected
  mode | Mode parameter that shall be passed to this module

Implements SCS::CanAeroDataManager.

virtual uint32_t SCS::Receiver::handleMIS | ( |  | ) | `[protected, virtual]`

Handle incoming module information services. You may override this function if you inherit from Receiver.

Implements SCS::CanAeroDataManager.

virtual void SCS::Receiver::handleSTS | ( |  | ) | `[protected, virtual]`

Handle incoming state transmission services. You may override this function if you inherit from Receiver. The state transmission service must transmit all CAN ids published exclusively by your application once.

Implements SCS::CanAeroDataManager.

void SCS::Receiver::requestData | ( | can_Id_t | can_id,
|  | boost::function< void(int32_t)> | f
| ) |  |

Request to receive updates on the given CAN Id from the bus. The identifier distribution defines which data format is used.

Parameters:

  can_id | CAN id of simulation data, specified in identifier distribution
  f | Callback function to be called when value changes on the bus

void SCS::Receiver::requestData | ( | can_Id_t | can_id,
|  | boost::function< void(float)> | f
| ) |  |

Request to receive updates on the given CAN Id from the bus. The identifier distribution defines which data format is used.

Parameters:

  can_id | CAN id of simulation data, specified in identifier distribution
  f | Callback function to be called when value changes on the bus

void SCS::Receiver::requestData | ( | can_Id_t | can_id,
|  | double * | t
| ) |  |

Request to receive updates on the given CAN Id from the bus. The identifier distribution defines which data format is used.

Parameters:

  can_id | CAN id of simulation data, specified in identifier distribution
  t | Pointer to variable to be updated when value changes on the bus

void SCS::Receiver::requestData | ( | can_Id_t | can_id,
|  | TypelessDataReference * | dataref
| ) |  |

Request to receive updates on the given CAN Id from the bus. The identifier distribution defines which data format is used.

Note:
  This function comes in handy when you need own DataRef implementations.

Parameters:

  can_id | CAN id of simulation data, specified in identifier distribution
  dataref | pointer to some ready-to-use DataReference implementation

Deprecated:
  Only for internal use. To be discontinued without further notice.

void SCS::Receiver::requestData | ( | can_Id_t | can_id,
|  | std::vector< float > * | t
| ) |  |

Request to receive updates on the given CAN Id from the bus. The identifier distribution defines which data format is used.

Parameters:

  can_id | CAN id of simulation data, specified in identifier distribution
  t | Pointer to variable to be updated when value changes on the bus

void SCS::Receiver::requestData | ( | can_Id_t | can_id,
|  | int32_t * | t
| ) |  |

Request to receive updates on the given CAN Id from the bus. The identifier distribution defines which data format is used.

Parameters:

  can_id | CAN id of simulation data, specified in identifier distribution
  t | Pointer to variable to be updated when value changes on the bus

void SCS::Receiver::requestData | ( | can_Id_t | can_id,
|  | boost::function< void(double)> | f
| ) |  |

Request to receive updates on the given CAN Id from the bus. The identifier distribution defines which data format is used.

Parameters:

  can_id | CAN id of simulation data, specified in identifier distribution
  f | Callback function to be called when value changes on the bus

void SCS::Receiver::requestData | ( | can_Id_t | can_id,
|  | boost::function< void(int32_t)> | f,
|  | int32_t * | t
| ) |  |

Request to receive updates on the given CAN Id from the bus. The identifier distribution defines which data format is used.

Parameters:

  can_id | CAN id of simulation data, specified in identifier distribution
  f | Callback function to be called when value changes on the bus
  t | Pointer to variable to be updated when value changes on the bus

void SCS::Receiver::requestData | ( | can_Id_t | can_id,
|  | boost::function< void(bool)> | f
| ) |  |

Request to receive updates on the given CAN Id from the bus. The identifier distribution defines which data format is used.

Parameters:

  can_id | CAN id of simulation data, specified in identifier distribution
  f | Callback function to be called when value changes on the bus

void SCS::Receiver::requestData | ( | can_Id_t | can_id,
|  | bool * | t
| ) |  |

Request to receive updates on the given CAN Id from the bus. The identifier distribution defines which data format is used.

Parameters:

  can_id | CAN id of simulation data, specified in identifier distribution
  t | Pointer to variable to be updated when value changes on the bus

void SCS::Receiver::requestData | ( | can_Id_t | can_id,
|  | boost::function< void(float)> | f,
|  | float * | t
| ) |  |

Request to receive updates on the given CAN Id from the bus. The identifier distribution defines which data format is used.

Parameters:

  can_id | CAN id of simulation data, specified in identifier distribution
  f | Callback function to be called when value changes on the bus
  t | Pointer to variable to be updated when value changes on the bus

void SCS::Receiver::requestData | ( | can_Id_t | can_id,
|  | boost::function< void(const std::vector< float > &)> | f
| ) |  |

Request to receive updates on the given CAN Id from the bus. The identifier distribution defines which data format is used.

Parameters:

  can_id | CAN id of simulation data, specified in identifier distribution
  f | Callback function to be called when value changes on the bus

void SCS::Receiver::requestData | ( | can_Id_t | can_id,
|  | boost::function< void(char4)> | f
| ) |  |

Request to receive updates on the given CAN Id from the bus. The identifier distribution defines which data format is used.

Parameters:

  can_id | CAN id of simulation data, specified in identifier distribution
  f | Callback function to be called when value changes on the bus

void SCS::Receiver::requestData | ( | can_Id_t | can_id,
|  | boost::function< void(const std::string &)> | f
| ) |  |

Request to receive updates on the given CAN Id from the bus. The identifier distribution defines which data format is used.

Parameters:

  can_id | CAN id of simulation data, specified in identifier distribution
  f | Callback function to be called when value changes on the bus

void SCS::Receiver::requestData | ( | can_Id_t | can_id,
|  | boost::function< void(double)> | f,
|  | double * | t
| ) |  |

Request to receive updates on the given CAN Id from the bus. The identifier distribution defines which data format is used.

Parameters:

  can_id | CAN id of simulation data, specified in identifier distribution
  f | Callback function to be called when value changes on the bus
  t | Pointer to variable to be updated when value changes on the bus

void SCS::Receiver::requestData | ( | can_Id_t | can_id,
|  | float * | t
| ) |  |

Request to receive updates on the given CAN Id from the bus. The identifier distribution defines which data format is used.

Parameters:

  can_id | CAN id of simulation data, specified in identifier distribution
  t | Pointer to variable to be updated when value changes on the bus

void SCS::Receiver::requestData | ( | can_Id_t | can_id,
|  | char4 * | t
| ) |  |

Request to receive updates on the given CAN Id from the bus. The identifier distribution defines which data format is used.

Parameters:

  can_id | CAN id of simulation data, specified in identifier distribution
  t | Pointer to variable to be updated when value changes on the bus

void SCS::Receiver::requestData | ( | can_Id_t | can_id,
|  | boost::function< void(bool)> | f,
|  | bool * | t
| ) |  |

Request to receive updates on the given CAN Id from the bus. The identifier distribution defines which data format is used.

Parameters:

  can_id | CAN id of simulation data, specified in identifier distribution
  f | Callback function to be called when value changes on the bus
  t | Pointer to variable to be updated when value changes on the bus

void SCS::Receiver::requestData | ( | can_Id_t | can_id,
|  | boost::function< void(const std::vector< float > &)> | f,
|  | std::vector< float > * | t
| ) |  |

Request to receive updates on the given CAN Id from the bus. The identifier distribution defines which data format is used.

Parameters:

  can_id | CAN id of simulation data, specified in identifier distribution
  f | Callback function to be called when value changes on the bus
  t | Pointer to variable to be updated when value changes on the bus

void SCS::Receiver::requestData | ( | can_Id_t | can_id,
|  | boost::function< void(const std::string &)> | f,
|  | std::string * | t
| ) |  |

Request to receive updates on the given CAN Id from the bus. The identifier distribution defines which data format is used.

Parameters:

  can_id | CAN id of simulation data, specified in identifier distribution
  f | Callback function to be called when value changes on the bus
  t | Pointer to variable to be updated when value changes on the bus

void SCS::Receiver::requestData | ( | can_Id_t | can_id,
|  | boost::function< void(char4)> | f,
|  | char4 * | t
| ) |  |

Request to receive updates on the given CAN Id from the bus. The identifier distribution defines which data format is used.

Parameters:

  can_id | CAN id of simulation data, specified in identifier distribution
  f | Callback function to be called when value changes on the bus
  t | Pointer to variable to be updated when value changes on the bus

void SCS::Receiver::requestData | ( | can_Id_t | can_id,
|  | std::string * | t
| ) |  |

Request to receive updates on the given CAN Id from the bus. The identifier distribution defines which data format is used.

Parameters:

  can_id | CAN id of simulation data, specified in identifier distribution
  t | Pointer to variable to be updated when value changes on the bus

void SCS::Receiver::requestModule | ( | uint8_t | node_id,
|  | uint16_t | module,
|  | uint16_t | mode = `1`
| ) |  |

Request another bus participant to en- or disable one of its modules.

Causes the node to be asked via MIS aboutits capabilities and enables the requested capability via MCS.

Parameters:

  node_id | node which owns the requested module
  module | number of the module to be enabled
  mode | the mode command to set

void SCS::Receiver::run | ( | bool | do_log_output = `true` | ) |

Offer data to be requested by other participants on the bus.

Parameters:

  can_id_29bit | the CAN id in 29bit adress range which others have to request to get this data
  t | pointer where data should be read if someone requests it and is written if someone sends it Call this repeatedly, either from the application's main loop or a separate application thread.

Will update pointers and invoke callbacks with new data. Big black magic box that makes all work as you expect, ensuring the protocol is handled following the CAN Aerospace and SCS specifications.

Note:
  It is guaranteed that all callbacks are called from the very same thread this function is called from.

Parameters:

  do_log_output | log all messages to the defaultlogger. Disable this if you call the LogWriter::writeEntries() of your own logger somewhere else

void SCS::Receiver::sendData | ( | can_Id_t | can_id,
|  | char4 | t
| ) |  |

Send value of given CAN id to the bus, so other participants are informed and can synchronize themselves to the new value.

Parameters:

  can_id | CAN id of simulation data, specified in identifier distribution
  t | value to be send

void SCS::Receiver::sendData | ( | can_Id_t | can_id,
|  | const std::string & | t
| ) |  |

Send value of given CAN id to the bus, so other participants are informed and can synchronize themselves to the new value.

Parameters:

  can_id | CAN id of simulation data, specified in identifier distribution
  t | value to be send

void SCS::Receiver::sendData | ( | can_Id_t | can_id,
|  | bool | t
| ) |  |

Send value of given CAN id to the bus, so other participants are informed and can synchronize themselves to the new value.

Parameters:

  can_id | CAN id of simulation data, specified in identifier distribution
  t | value to be send

void SCS::Receiver::sendData | ( | can_Id_t | can_id | ) |

Send value of given CAN id to the bus, so other participants are informed and can synchronize themselves to the new value.

Note:
  The value sent is read from the pointer you specified when requesting the data

Parameters:

  can_id | CAN id of simulation data, specified in identifier distribution

void SCS::Receiver::sendData | ( | can_Id_t | can_id,
|  | double | t
| ) |  |

Send value of given CAN id to the bus, so other participants are informed and can synchronize themselves to the new value.

Parameters:

  can_id | CAN id of simulation data, specified in identifier distribution
  t | value to be send

void SCS::Receiver::sendData | ( | can_Id_t | can_id,
|  | float | t
| ) |  |

Send value of given CAN id to the bus, so other participants are informed and can synchronize themselves to the new value.

Parameters:

  can_id | CAN id of simulation data, specified in identifier distribution
  t | value to be send

void SCS::Receiver::sendData | ( | can_Id_t | can_id,
|  | const std::vector< float > & | t
| ) |  |

Send value of given CAN id to the bus, so other participants are informed and can synchronize themselves to the new value.

Parameters:

  can_id | CAN id of simulation data, specified in identifier distribution
  t | value to be send

void SCS::Receiver::sendData | ( | can_Id_t | can_id,
|  | int32_t | t
| ) |  |

Send value of given CAN id to the bus, so other participants are informed and can synchronize themselves to the new value.

Parameters:

  can_id | CAN id of simulation data, specified in identifier distribution
  t | value to be send

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

- receiver.h