Lely core libraries
2.3.4
|
Go to the documentation of this file.
47 #endif // !LELY_NO_CO_TPDO
49 #if !LELY_NO_CO_RPDO && !LELY_NO_CO_MPDO
66 operator()(
co_nmt_t* nmt)
const noexcept {
73 void OnCsInd(
co_nmt_t* nmt, uint8_t cs) noexcept;
74 void OnHbInd(
co_nmt_t* nmt, uint8_t
id,
int state,
int reason) noexcept;
75 void OnStInd(
co_nmt_t* nmt, uint8_t
id, uint8_t st) noexcept;
78 void OnRpdoInd(
co_rpdo_t* pdo, uint32_t ac,
const void* ptr,
80 void OnRpdoErr(
co_rpdo_t* pdo, uint16_t eec, uint8_t er) noexcept;
84 void OnTpdoInd(
co_tpdo_t* pdo, uint32_t ac,
const void* ptr,
89 void OnSyncInd(
co_nmt_t* nmt, uint8_t cnt) noexcept;
90 void OnSyncErr(
co_sync_t* sync, uint16_t eec, uint8_t er) noexcept;
94 void OnTimeInd(
co_time_t* time,
const timespec* tp) noexcept;
98 void OnEmcyInd(
co_emcy_t* emcy, uint8_t
id, uint16_t ec, uint8_t er,
99 uint8_t msef[5]) noexcept;
103 void OnRateInd(
co_lss_t*, uint16_t rate,
int delay) noexcept;
104 int OnStoreInd(
co_lss_t*, uint8_t
id, uint16_t rate) noexcept;
108 void RpdoRtr(
int num) noexcept;
116 ::std::unique_ptr<co_nmt_t, NmtDeleter> nmt;
119 ::std::function<void(uint8_t,
bool)> on_heartbeat;
120 ::std::function<void(uint8_t,
NmtState)> on_state;
122 ::std::function<void(
int, ::std::error_code,
const void*, ::std::size_t)>
124 ::std::function<void(
int, uint16_t, uint8_t)> on_rpdo_error;
127 ::std::function<void(
int, ::std::error_code,
const void*, ::std::size_t)>
131 ::std::function<void(uint8_t,
const time_point&)> on_sync;
132 ::std::function<void(uint16_t, uint8_t)> on_sync_error;
135 ::std::function<void(const ::std::chrono::system_clock::time_point&)> on_time;
138 ::std::function<void(uint8_t, uint16_t, uint8_t, uint8_t[5])> on_emcy;
141 ::std::function<void(
int, ::std::chrono::milliseconds)> on_switch_bitrate;
146 const ::std::string& dcf_txt, const ::std::string& dcf_bin,
148 : io::CanNet(exec, timer, chan, 0, 0),
149 Device(dcf_txt, dcf_bin, id, this),
150 tpdo_event_mutex(*this),
156 Node::~Node() =
default;
175 wait.
value = util::to_timespec(t);
187 auto value = util::to_timespec(t);
189 if (!f) util::throw_errc(
"AsyncWait");
192 int errc = f.get().
error();
193 if (errc) util::throw_errc(
"AsyncWait", errc);
214 ::std::chrono::milliseconds delay) {
226 [
this, &ctrl, bitrate,
247 ::std::lock_guard<util::BasicLockable>
lock(*
this);
253 ::std::lock_guard<util::BasicLockable>
lock(*
this);
259 ::std::lock_guard<util::BasicLockable>
lock(*
this);
266 util::throw_errc(
"Reset");
271 ::std::error_code& ec) {
272 ::std::lock_guard<util::BasicLockable>
lock(*
this);
284 ::std::error_code ec;
291 ::std::lock_guard<util::BasicLockable>
lock(*
this);
292 impl_->on_command = on_command;
297 ::std::lock_guard<util::BasicLockable>
lock(*
this);
298 impl_->on_heartbeat = on_heartbeat;
303 ::std::lock_guard<util::BasicLockable>
lock(*
this);
304 impl_->on_state = on_state;
309 ::std::function<
void(
int, ::std::error_code,
const void*, ::std::size_t)>
314 ::std::lock_guard<util::BasicLockable>
lock(*
this);
315 impl_->on_rpdo = on_rpdo;
324 ::std::lock_guard<util::BasicLockable>
lock(*
this);
325 impl_->on_rpdo_error = on_rpdo_error;
331 ::std::function<
void(
int, ::std::error_code,
const void*, ::std::size_t)>
336 ::std::lock_guard<util::BasicLockable>
lock(*
this);
337 impl_->on_tpdo = on_tpdo;
342 Node::OnSync(::std::function<
void(uint8_t,
const time_point&)> on_sync) {
346 ::std::lock_guard<util::BasicLockable>
lock(*
this);
347 impl_->on_sync = on_sync;
356 ::std::lock_guard<util::BasicLockable>
lock(*
this);
357 impl_->on_sync_error = on_sync_error;
363 ::std::function<
void(const ::std::chrono::system_clock::time_point&)>
368 ::std::lock_guard<util::BasicLockable>
lock(*
this);
369 impl_->on_time = on_time;
375 ::std::function<
void(uint8_t, uint16_t, uint8_t, uint8_t[5])> on_emcy) {
379 ::std::lock_guard<util::BasicLockable>
lock(*
this);
380 impl_->on_emcy = on_emcy;
386 ::std::function<
void(
int, ::std::chrono::milliseconds)> on_switch_bitrate) {
388 (void)on_switch_bitrate;
390 ::std::lock_guard<util::BasicLockable>
lock(*
this);
391 impl_->on_switch_bitrate = on_switch_bitrate;
421 assert(new_state != old_state);
424 if (new_state == io::CanState::PASSIVE) {
427 }
else if (old_state == io::CanState::BUSOFF) {
435 return impl_->nmt.get();
439 Node::Error(uint16_t eec, uint8_t er,
const uint8_t msef[5]) noexcept {
451 for (num = 1; num <= 512; num++) impl_->RpdoRtr(num);
466 typename ::std::enable_if<is_canopen_basic<T>::value &&
sizeof(T) <= 4,
468 Node::DamMpdoEvent(
int num, uint8_t
id, uint16_t idx, uint8_t subidx, T value) {
478 uint8_t buf[4] = {0};
479 co_val_write(canopen_traits<T>::index, &value, buf, buf + 4);
485 #ifndef DOXYGEN_SHOULD_SKIP_THIS
488 template void Node::DamMpdoEvent<bool>(
int, uint8_t, uint16_t, uint8_t,
bool);
491 template void Node::DamMpdoEvent<int8_t>(
int, uint8_t, uint16_t, uint8_t,
495 template void Node::DamMpdoEvent<int16_t>(
int, uint8_t, uint16_t, uint8_t,
499 template void Node::DamMpdoEvent<int32_t>(
int, uint8_t, uint16_t, uint8_t,
503 template void Node::DamMpdoEvent<uint8_t>(
int, uint8_t, uint16_t, uint8_t,
507 template void Node::DamMpdoEvent<uint16_t>(
int, uint8_t, uint16_t, uint8_t,
511 template void Node::DamMpdoEvent<uint32_t>(
int, uint8_t, uint16_t, uint8_t,
515 template void Node::DamMpdoEvent<float>(
int, uint8_t, uint16_t, uint8_t,
float);
535 #endif // !DOXYGEN_SHOULD_SKIP_THIS
540 if (impl_->on_can_state) {
541 auto f = impl_->on_can_state;
542 util::UnlockGuard<util::BasicLockable>
unlock(*
this);
543 f(new_state, old_state);
550 if (impl_->on_can_error) {
551 auto f = impl_->on_can_error;
552 util::UnlockGuard<util::BasicLockable>
unlock(*
this);
558 Node::OnStore(uint8_t,
int) {
559 util::throw_error_code(
"OnStore", ::std::errc::operation_not_supported);
566 [](
co_nmt_t*
nmt, uint8_t cs,
void* data) noexcept {
567 static_cast<Impl_*>(data)->OnCsInd(nmt, cs);
573 [](
co_nmt_t*
nmt, uint8_t
id,
int state,
int reason,
574 void* data) noexcept {
575 static_cast<Impl_*>(data)->OnHbInd(nmt, id, state, reason);
581 [](
co_nmt_t*
nmt, uint8_t
id, uint8_t st,
void* data) noexcept {
582 static_cast<Impl_*>(data)->OnStInd(nmt, id, st);
589 [](
co_nmt_t*
nmt, uint8_t cnt,
void* data) noexcept {
590 static_cast<Impl_*>(data)->OnSyncInd(nmt, cnt);
597 Node::Impl_::OnCsInd(
co_nmt_t* nmt, uint8_t cs) noexcept {
606 [](
co_lss_t* lss, uint16_t rate,
int delay,
void* data) noexcept {
607 static_cast<Impl_*
>(data)->OnRateInd(lss, rate, delay);
613 [](
co_lss_t* lss, uint8_t
id, uint16_t rate,
void* data) noexcept {
614 return static_cast<Impl_*
>(data)->OnStoreInd(lss,
id, rate);
627 [](
co_sync_t* sync, uint16_t eec, uint8_t er,
void* data) noexcept {
628 static_cast<Impl_*
>(data)->OnSyncErr(sync, eec, er);
639 [](
co_time_t* time,
const timespec* tp,
void* data) noexcept {
640 static_cast<Impl_*
>(data)->OnTimeInd(time, tp);
651 [](
co_emcy_t* emcy, uint8_t
id, uint16_t eec, uint8_t er,
652 uint8_t msef[5],
void* data) noexcept {
653 static_cast<Impl_*
>(data)->OnEmcyInd(emcy,
id, eec, er, msef);
662 for (
int i = 1; i <= 512; i++) {
667 [](
co_rpdo_t* pdo, uint32_t ac,
const void* ptr,
size_t n,
668 void* data) noexcept {
669 static_cast<Impl_*
>(data)->OnRpdoInd(pdo, ac, ptr, n);
675 [](
co_rpdo_t* pdo, uint16_t eec, uint8_t er,
void* data) noexcept {
676 static_cast<Impl_*
>(data)->OnRpdoErr(pdo, eec, er);
683 for (
int i = 1; i <= 512; i++) {
688 [](
co_tpdo_t* pdo, uint32_t ac,
const void* ptr,
size_t n,
689 void* data) noexcept {
690 static_cast<Impl_*
>(data)->OnTpdoInd(pdo, ac, ptr, n);
700 self->UpdateRpdoMapping();
703 self->UpdateTpdoMapping();
711 util::UnlockGuard<util::BasicLockable> unlock(*
self);
717 Node::Impl_::OnHbInd(
co_nmt_t* nmt, uint8_t
id,
int state,
718 int reason) noexcept {
725 self->OnHeartbeat(
id, occurred);
728 auto f = on_heartbeat;
729 util::UnlockGuard<util::BasicLockable> unlock(*
self);
735 Node::Impl_::OnStInd(
co_nmt_t* nmt, uint8_t
id, uint8_t st) noexcept {
741 self->OnState(
id,
static_cast<NmtState>(st));
745 util::UnlockGuard<util::BasicLockable> unlock(*
self);
753 Node::Impl_::OnRpdoInd(
co_rpdo_t* pdo, uint32_t ac,
const void* ptr,
762 auto buf =
static_cast<const uint8_t*
>(ptr);
764 self->RpdoWrite(buf[0],
ldle_u16(buf + 1), buf[3]);
769 self->OnRpdo(num,
static_cast<SdoErrc>(ac), ptr, n);
773 util::UnlockGuard<util::BasicLockable> unlock(*
self);
774 f(num,
static_cast<SdoErrc>(ac), ptr, n);
779 Node::Impl_::OnRpdoErr(
co_rpdo_t* pdo, uint16_t eec, uint8_t er) noexcept {
781 self->OnRpdoError(num, eec, er);
784 auto f = on_rpdo_error;
785 util::UnlockGuard<util::BasicLockable> unlock(*
self);
790 #endif // !LELY_NO_CO_RPDO
794 Node::Impl_::OnTpdoInd(
co_tpdo_t* pdo, uint32_t ac,
const void* ptr,
797 self->OnTpdo(num,
static_cast<SdoErrc>(ac), ptr, n);
801 util::UnlockGuard<util::BasicLockable> unlock(*
self);
802 f(num,
static_cast<SdoErrc>(ac), ptr, n);
810 Node::Impl_::OnSyncInd(
co_nmt_t*, uint8_t cnt) noexcept {
811 auto t =
self->GetClock().gettime();
812 self->OnSync(cnt, t);
816 util::UnlockGuard<util::BasicLockable> unlock(*
self);
822 Node::Impl_::OnSyncErr(
co_sync_t*, uint16_t eec, uint8_t er) noexcept {
823 self->OnSyncError(eec, er);
826 auto f = on_sync_error;
827 util::UnlockGuard<util::BasicLockable> unlock(*
self);
832 #endif // !LELY_NO_CO_SYNC
836 Node::Impl_::OnTimeInd(
co_time_t*,
const timespec* tp) noexcept {
838 ::std::chrono::system_clock::time_point abs_time(util::from_timespec(*tp));
839 self->OnTime(abs_time);
843 util::UnlockGuard<util::BasicLockable> unlock(*
self);
851 Node::Impl_::OnEmcyInd(
co_emcy_t*, uint8_t
id, uint16_t ec, uint8_t er,
852 uint8_t msef[5]) noexcept {
853 self->OnEmcy(
id, ec, er, msef);
857 util::UnlockGuard<util::BasicLockable> unlock(*
self);
866 Node::Impl_::OnRateInd(
co_lss_t*, uint16_t rate,
int delay) noexcept {
867 self->OnSwitchBitrate(rate * 1000, ::std::chrono::milliseconds(delay));
869 if (on_switch_bitrate) {
870 auto f = on_switch_bitrate;
871 util::UnlockGuard<util::BasicLockable> unlock(*
self);
872 f(rate * 1000, ::std::chrono::milliseconds(delay));
877 Node::Impl_::OnStoreInd(
co_lss_t*, uint8_t
id, uint16_t rate) noexcept {
879 self->OnStore(
id, rate * 1000);
886 #endif // !LELY_NO_CO_LSS
890 Node::Impl_::RpdoRtr(
int num) noexcept {
void OnRpdo(::std::function< void(int, ::std::error_code, const void *, ::std::size_t)> on_rpdo)
Registers the function to be invoked when a Receive-PDO is processed.
void co_lss_set_rate_ind(co_lss_t *lss, co_lss_rate_ind_t *ind, void *data)
Sets the indication function invoked when an LSS 'activate bit timing' request is received.
struct timespec value
The absolute expiration time.
void co_sync_set_err(co_sync_t *sync, co_sync_err_t *err, void *data)
Sets the error handling function of a SYNC consumer service.
void io_tqueue_submit_wait(io_tqueue_t *tq, struct io_tqueue_wait *wait)
Submits a wait operation to a timer queue.
void OnCanError(::std::function< void(io::CanError)> on_can_error)
Registers the function to be invoked when an error is detected on the CAN bus.
NmtCommand
The NMT command specifiers.
const struct ev_exec_vtbl *const ev_exec_t
An abstract task executor.
void co_nmt_set_hb_ind(co_nmt_t *nmt, co_nmt_hb_ind_t *ind, void *data)
Sets the indication function invoked when a heartbeat event occurs.
bool AbortWait(io_tqueue_wait &wait) noexcept
Aborts the specified wait operation if it is pending.
void set_time()
Updates the CAN network time.
void OnState(::std::function< void(uint8_t, NmtState)> on_state)
Registers the function to be invoked when an NMT state change or boot-up event is detected for a remo...
ev::Future< void, ::std::exception_ptr > AsyncWait(ev_exec_t *exec, const time_point &t, io_tqueue_wait **pwait=nullptr)
Submits an asynchronous wait operation and creates a future which becomes ready once the wait operati...
A reference to an abstract timer.
void co_nmt_on_hb(co_nmt_t *nmt, co_unsigned8_t id, int state, int reason)
Implements the default behavior when a heartbeat event occurs (see sections 7.2.8....
The internal implementation of the CANopen node.
#define CO_PDO_MAP_SAM_MPDO
The value of sub-index 0 of the PDO mapping parameter record indicating a a source address mode multi...
A CANopen TIME producer/consumer service.
void RpdoRtr(int num=0) noexcept
Requests the transmission of a PDO by sending a CAN frame with the RTR (Remote Transmission Request) ...
void co_time_set_ind(co_time_t *time, co_time_ind_t *ind, void *data)
Sets the indication function invoked when a CANopen time stamp is received.
A refence to an I/O context. This class is a wrapper around #io_ctx_t*.
void Reset()
(Re)starts the node.
co_sync_t * co_nmt_get_sync(const co_nmt_t *nmt)
Returns a pointer to the SYNC producer/consumer service.
co_unsigned8_t co_dev_get_id(const co_dev_t *dev)
Returns the node-ID of a CANopen device.
int get_errc(void)
Returns the last (thread-specific) native error code set by a system call or library function.
The type of objects thrown as exceptions to report a system error with an associated error code.
virtual void on_can_state(CanState new_state, CanState old_state) noexcept
The function invoked when a CAN bus state change is detected.
void co_nmt_on_err(co_nmt_t *nmt, co_unsigned16_t eec, co_unsigned8_t er, const co_unsigned8_t msef[5])
Implements the default error handling behavior by generating an EMCY message with co_emcy_push() and ...
A reference to an abstract CAN channel.
void OnCanState(::std::function< void(io::CanState, io::CanState)> on_can_state)
Registers the function to be invoked when a CAN bus state change is detected.
@ CO_NMT_EC_TIMEOUT
An NMT error control timeout event.
co_unsigned32_t co_dev_cfg_hb(co_dev_t *dev, co_unsigned8_t id, co_unsigned16_t ms)
Configures heartbeat consumption for the specified node by updating CANopen object 1016 (Consumer hea...
void OnHeartbeat(::std::function< void(uint8_t, bool)> on_heartbeat)
Registers the function to be invoked when a heartbeat timeout event occurs or is resolved.
ev::Executor get_executor() const noexcept
void OnTime(::std::function< void(const ::std::chrono::system_clock::time_point &)> on_time)
Registers the function to be invoked when a TIME message is received.
CanError
The error flags of a CAN bus, which are not mutually exclusive.
#define CO_NMT_CS_START
The NMT command specifier 'start'.
CanState
The states of a CAN node, depending on the TX/RX error count.
void unlock() override
Releases the lock held by the execution agent. Throws no exceptions.
co_unsigned16_t co_tpdo_get_num(const co_tpdo_t *pdo)
Returns the PDO number of a Transmit-PDO.
void stop(::std::error_code &ec) noexcept
void TpdoEvent(int num=0) noexcept
Triggers the transmission of an acyclic or event-driven PDO.
A wait operation suitable for use with a timer queue.
ev_future_t * io_tqueue_async_wait(io_tqueue_t *tq, ev_exec_t *exec, const struct timespec *value, struct io_tqueue_wait **pwait)
Submits an asynchronous wait operation to a timer queue and creates a future which becomes ready once...
Clock get_clock() const noexcept
#define CAN_MAX_LEN
The maximum number of bytes in the payload of a CAN format frame.
void co_nmt_on_tpdo_event_lock(co_nmt_t *nmt)
Postpones the transmission of PDOs triggered by co_nmt_on_tpdo_event() until a matching call to co_nm...
co_tpdo_t * co_nmt_get_tpdo(const co_nmt_t *nmt, co_unsigned16_t n)
Returns a pointer to a Transmit-PDO service.
void lock() final
Blocks until a lock can be obtained for the current execution agent (thread, process,...
__co_dev * dev() const noexcept
Returns a pointer to the internal CANopen device from <lely/co/dev.hpp>.
uint8_t id() const noexcept
Returns the node-ID.
int co_dam_mpdo_event(co_tpdo_t *pdo, co_unsigned8_t id, co_unsigned16_t idx, co_unsigned8_t subidx, const co_unsigned8_t data[4])
Triggers the transmission of a DAM-MPDO.
void set_errc(int errc)
Sets the current (thread-specific) native error code to errc.
An abstract task executor. This class is a wrapper around #ev_exec_t*.
void restart(::std::error_code &ec) noexcept
__can_net * net() const noexcept
Returns a pointer to the internal CAN network interface from <lely/can/net.h>.
void co_lss_set_store_ind(co_lss_t *lss, co_lss_store_ind_t *ind, void *data)
Sets the indication function invoked when an LSS 'store configuration' request is received.
void OnCommand(::std::function< void(NmtCommand)> on_command)
Registers the function to be invoked when an NMT command is received from the master.
virtual void on_can_error(CanError error) noexcept
The function invoked when an error is detected on the CAN bus.
void set_bitrate(int nominal, int data, ::std::error_code &ec) noexcept
A CANopen EMCY producer/consumer service.
A CANopen LSS master/slave service.
bool CancelWait(io_tqueue_wait &wait) noexcept
Cancels the specified wait operation if it is pending.
The CANopen device description.
#define CO_NMT_CS_ENTER_PREOP
The NMT command specifier 'enter pre-operational'.
void OnSyncError(::std::function< void(uint16_t, uint8_t)> on_sync_error)
Registers the function to be invoked when the data length of a received SYNC message does not match.
ContextBase get_ctx() const noexcept
void co_nmt_on_tpdo_event_unlock(co_nmt_t *nmt)
Undoes the effect of a single call to co_nmt_on_tpdo_event_lock() and possibly triggers the transmiss...
void co_nmt_set_cs_ind(co_nmt_t *nmt, co_nmt_cs_ind_t *ind, void *data)
Sets the indication function invoked when an NMT command is received.
void OnTpdo(::std::function< void(int, ::std::error_code, const void *, ::std::size_t)> on_tpdo)
Registers the function to be invoked after a Transmit-PDO is sent or an error occurs.
void OnEmcy(::std::function< void(uint8_t, uint16_t, uint8_t, uint8_t[5])> on_emcy)
Registers the function to be invoked when an EMCY message is received.
const struct co_pdo_map_par * co_rpdo_get_map_par(const co_rpdo_t *pdo)
Returns a pointer to the PDO mapping parameter record of a Receive-PDO.
size_t io_tqueue_abort_wait(io_tqueue_t *tq, struct io_tqueue_wait *wait)
Aborts the specified timer queue wait operation if it is pending.
int co_nmt_cs_ind(co_nmt_t *nmt, co_unsigned8_t cs)
Processes an NMT command from the master or the application.
A CANopen NMT master/slave service.
SdoErrc
The SDO abort codes.
io::ContextBase GetContext() const noexcept
Returns the underlying I/O context with which this context is registered.
co_rpdo_t * co_nmt_get_rpdo(const co_nmt_t *nmt, co_unsigned16_t n)
Returns a pointer to a Receive-PDO service.
@ CO_NMT_EC_OCCURRED
An NMT error control event occurred.
io::Clock GetClock() const noexcept
Returns the clock used by the timer.
void ConfigHeartbeat(uint8_t id, const ::std::chrono::milliseconds &ms, ::std::error_code &ec)
Configures heartbeat consumption for the specified node by updating CANopen object 1016 (Consumer hea...
The base class for CANopen nodes.
ev::Executor GetExecutor() const noexcept
Returns the executor used to process I/O and CANopen events.
#define CO_NMT_CS_RESET_NODE
The NMT command specifier 'reset node'.
co_unsigned16_t co_rpdo_get_num(const co_rpdo_t *pdo)
Returns the PDO number of a Receive-PDO.
void co_nmt_set_st_ind(co_nmt_t *nmt, co_nmt_st_ind_t *ind, void *data)
Sets the indication function invoked when a state change is detected.
void co_nmt_destroy(co_nmt_t *nmt)
Destroys a CANopen NMT master/slave service.
co_nmt_t * co_nmt_create(can_net_t *net, co_dev_t *dev)
Creates a new CANopen NMT master/slave service.
The type of exception thrown when an SDO abort code is received.
An abstract clock. This class is a wrapper around #io_clock_t*.
void OnSync(::std::function< void(uint8_t, const time_point &)> on_sync)
Registers the function to be invoked when a SYNC message is sent/received.
void unlock() final
Releases the lock held by the execution agent. Throws no exceptions.
co_dev_t * co_nmt_get_dev(const co_nmt_t *nmt)
Returns a pointer to the CANopen device of an NMT master/slave service.
Node(ev_exec_t *exec, io::TimerBase &timer, io::CanChannelBase &chan, const ::std::string &dcf_txt, const ::std::string &dcf_bin="", uint8_t id=0xff)
Creates a new CANopen node.
int co_rpdo_rtr(co_rpdo_t *pdo)
Requests the transmission of a PDO.
void co_nmt_set_sync_ind(co_nmt_t *nmt, co_nmt_sync_ind_t *ind, void *data)
Sets the indication function invoked by co_nmt_on_sync() after all PDOs have been transmitted/process...
void co_rpdo_set_ind(co_rpdo_t *pdo, co_rpdo_ind_t *ind, void *data)
Sets the indication function invoked when a Receive-PDO error occurs.
A reference to an abstract CAN controller.
co_time_t * co_nmt_get_time(const co_nmt_t *nmt)
Returns a pointer to the TIME producer/consumer service.
void co_rpdo_set_err(co_rpdo_t *pdo, co_rpdo_err_t *err, void *data)
Sets the error handling function of a Receive-PDO service.
void SubmitWait(const time_point &t, io_tqueue_wait &wait)
Submits a wait operation.
void co_emcy_set_ind(co_emcy_t *emcy, co_emcy_ind_t *ind, void *data)
Sets the indication function invoked when a CANopen EMCY message is received.
size_t io_tqueue_cancel_wait(io_tqueue_t *tq, struct io_tqueue_wait *wait)
Cancels the specified timer queue wait operation if it is pending.
void SetTime()
Updates the CAN network time.
void lock() override
Blocks until a lock can be obtained for the current execution agent (thread, process,...
#define CO_NMT_CS_RESET_COMM
The NMT command specifier 'reset communication'.
void OnRpdoError(::std::function< void(int, uint16_t, uint8_t)> on_rpdo_error)
Registers the function to be invoked when a Receive-PDO length mismatch or timeout error occurs.
uint_least16_t ldle_u16(const uint_least8_t src[2])
Loads a 16-bit unsigned integer in little-endian byte order.
void co_nmt_on_tpdo_event(co_nmt_t *nmt, co_unsigned16_t n)
Implements the default behavior when an event is indicated for an event-driven (asynchronous) Transmi...
__co_nmt * nmt() const noexcept
Returns a pointer to the internal CANopen NMT master/slave service from <lely/co/nmt....
co_lss_t * co_nmt_get_lss(const co_nmt_t *nmt)
Returns a pointer to the LSS master/slave service.
co_emcy_t * co_nmt_get_emcy(const co_nmt_t *nmt)
Returns a pointer to the EMCY producer/consumer service.
void OnSwitchBitrate(::std::function< void(int, ::std::chrono::milliseconds)> on_switch_bitrate)
Registers the function to be invoked when the LSS master activates the bit rate of all CANopen device...
A CANopen SYNC producer/consumer service.
void co_tpdo_set_ind(co_tpdo_t *pdo, co_tpdo_ind_t *ind, void *data)
Sets the indication function invoked when a Transmit-PDO is sent or an error occurs.
size_t co_val_write(co_unsigned16_t type, const void *val, uint_least8_t *begin, uint_least8_t *end)
Writes a value of the specified data type to a memory buffer.
void co_nmt_on_st(co_nmt_t *nmt, co_unsigned8_t id, co_unsigned8_t st)
Implements the default behavior when a state change is detected by the node guarding or heartbeat pro...
ev::Future< void, ::std::exception_ptr > AsyncSwitchBitrate(io::CanControllerBase &ctrl, int bitrate, ::std::chrono::milliseconds delay)
Stops the specified CAN controller and submits asynchronous operations to wait for the delay period,...