3 #ifndef __EMCY_CONSUMER_HPP__
4 #define __EMCY_CONSUMER_HPP__
35 using code_t = std::pair<std::uint16_t, std::string>;
43 {
delete codeRegistry; }
46 bool accept(
const std::uint8_t * data);
51 {
delete codeRegistry;
52 codeRegistry =
new T; }
61 { callback = HandlerFn(); }
64 using HandlerFn = std::function<void(
code_t, std::uint8_t,
const std::uint8_t *)>;
Generic EMCY message parser.
Definition: EmcyConsumer.hpp:19
virtual std::string codeToMessage(std::uint16_t code)
Obtain string representation of an EMCY code.
Definition: EmcyConsumer.cpp:9
virtual ~EmcyCodeRegistry()=default
Virtual destructor.
Representation of CAN EMCY protocol.
Definition: EmcyConsumer.hpp:33
EmcyConsumer()
Constructor.
Definition: EmcyConsumer.hpp:38
void registerHandler(Fn &&fn)
Register callback.
Definition: EmcyConsumer.hpp:56
void unregisterHandler()
Unregister callback.
Definition: EmcyConsumer.hpp:60
bool accept(const std::uint8_t *data)
Invoke callback on parsed CAN message data.
Definition: EmcyConsumer.cpp:88
~EmcyConsumer()
Destructor.
Definition: EmcyConsumer.hpp:42
std::pair< std::uint16_t, std::string > code_t
Emergency error code.
Definition: EmcyConsumer.hpp:35
void setErrorCodeRegistry()
Instantiate a non-default EMCY message parser.
Definition: EmcyConsumer.hpp:50
The main, catch-all namespace for Robotics Lab UC3M.
Definition: groups.dox:6