22 #ifndef LELY_COCPP_MASTER_HPP_
23 #define LELY_COCPP_MASTER_HPP_
82 return Write(::std::forward<T>(value));
112 return id_ ? master_->
TpdoRead<T>(id_, idx_, subidx_)
113 : master_->
Read<T>(idx_, subidx_);
129 Read(::std::error_code& ec)
const {
130 return id_ ? master_->
TpdoRead<T>(id_, idx_, subidx_, ec)
131 : master_->
Read<T>(idx_, subidx_, ec);
151 master_->
TpdoWrite(id_, idx_, subidx_, ::std::forward<T>(value));
153 master_->
Write(idx_, subidx_, ::std::forward<T>(value));
174 Write(T&& value, ::std::error_code& ec) {
176 master_->
TpdoWrite(id_, idx_, subidx_, ::std::forward<T>(value), ec);
178 master_->
Write(idx_, subidx_, ::std::forward<T>(value), ec);
196 Write(
const void* p, ::std::size_t n) {
197 if (!id_) master_->
Write(idx_, subidx_, p, n);
214 Write(
const void* p, ::std::size_t n, ::std::error_code& ec) {
215 if (!id_) master_->
Write(idx_, subidx_, p, n, ec);
259 SubObject(
BasicMaster* master, uint8_t
id, uint16_t idx,
260 uint8_t subidx) noexcept
261 : master_(master), idx_(idx), subidx_(subidx), id_(
id) {}
306 return id_ ? (is_rpdo_ ? master_->
RpdoRead<T>(id_, idx_, subidx_)
307 : master_->
TpdoRead<T>(id_, idx_, subidx_))
308 : master_->
Read<T>(idx_, subidx_);
325 Read(::std::error_code& ec)
const {
326 return id_ ? (is_rpdo_ ? master_->
RpdoRead<T>(id_, idx_, subidx_, ec)
327 : master_->
TpdoRead<T>(id_, idx_, subidx_, ec))
328 : master_->
Read<T>(idx_, subidx_, ec);
333 uint8_t subidx) noexcept
336 ConstSubObject(
const BasicMaster* master, uint8_t
id, uint16_t idx,
337 uint8_t subidx,
bool is_rpdo) noexcept
348 uint8_t is_rpdo_ : 1;
376 return SubObject(master_, id_, idx_, subidx);
397 :
Object(master, 0, idx) {}
399 Object(
BasicMaster* master, uint8_t
id, uint16_t idx) noexcept
400 : master_(master), idx_(idx), id_(
id) {}
402 BasicMaster* master_;
437 ConstObject(
const BasicMaster* master, uint8_t
id, uint16_t idx,
438 bool is_rpdo) noexcept
439 : master_(master), idx_(idx), id_(
id), is_rpdo_(is_rpdo) {}
441 const BasicMaster* master_;
444 uint8_t is_rpdo_ : 1;
472 : master_(master), id_(
id) {}
498 return Object(master_, id_, idx);
518 : master_(master), id_(
id) {}
529 void lock()
override;
533 using Node::TpdoEventMutex::TpdoEventMutex;
551 ::std::error_code ec, T value);
566 ::std::error_code ec);
590 const ::std::string& dcf_bin =
"", uint8_t
id = 0xff);
594 const ::std::string& dcf_txt,
595 const ::std::string& dcf_bin =
"", uint8_t
id = 0xff)
664 bool Boot(uint8_t
id);
677 bool IsReady(uint8_t
id)
const;
710 void Error(uint8_t
id);
721 void Error(uint16_t eec, uint8_t er,
722 const uint8_t msef[5] =
nullptr) noexcept;
733 void RpdoRtr(
int num = 0) noexcept;
741 DamMpdoEvent(
int num, uint8_t
id, uint16_t idx, uint8_t subidx, T value) {
742 ::std::lock_guard<BasicLockable>
lock(*
this);
744 Node::DamMpdoEvent(num,
id, idx, subidx, value);
753 ::std::chrono::milliseconds
GetTimeout()
const;
761 void SetTimeout(const ::std::chrono::milliseconds& timeout);
771 ::std::error_code ec;
787 ::std::lock_guard<BasicLockable>
lock(*
this);
793 sdo->SubmitUpload(req);
804 template <
class T,
class F>
808 SubmitRead<T>(exec,
id, idx, subidx, ::std::forward<F>(con),
GetTimeout());
816 template <
class T,
class F>
819 ::std::error_code& ec) {
820 SubmitRead<T>(exec,
id, idx, subidx, ::std::forward<F>(con),
GetTimeout(),
829 template <
class T,
class F>
832 const ::std::chrono::milliseconds& timeout) {
833 ::std::error_code ec;
834 SubmitRead<T>(exec,
id, idx, subidx, ::std::forward<F>(con), timeout, ec);
835 if (ec)
throw SdoError(
id, idx, subidx, ec,
"SubmitRead");
855 template <
class T,
class F>
858 const ::std::chrono::milliseconds& timeout,
859 ::std::error_code& ec) {
860 SubmitUpload<T>(exec,
id, idx, subidx, ::std::forward<F>(con),
false,
869 template <
class T,
class F>
873 SubmitBlockRead<T>(exec,
id, idx, subidx, ::std::forward<F>(con),
882 template <
class T,
class F>
885 F&& con, ::std::error_code& ec) {
886 SubmitBlockRead<T>(exec,
id, idx, subidx, ::std::forward<F>(con),
895 template <
class T,
class F>
898 F&& con, const ::std::chrono::milliseconds& timeout) {
899 ::std::error_code ec;
900 SubmitBlockRead<T>(exec,
id, idx, subidx, ::std::forward<F>(con), timeout,
902 if (ec)
throw SdoError(
id, idx, subidx, ec,
"SubmitBlockRead");
926 template <
class T,
class F>
929 F&& con, const ::std::chrono::milliseconds& timeout,
930 ::std::error_code& ec) {
931 SubmitUpload<T>(exec,
id, idx, subidx, ::std::forward<F>(con),
true,
953 template <
class T,
class F>
956 F&& con,
bool block, const ::std::chrono::milliseconds& timeout,
957 ::std::error_code& ec) {
958 ::std::lock_guard<BasicLockable>
lock(*
this);
964 sdo->SubmitUpload<T>(exec, idx, subidx, ::std::forward<F>(con), block,
979 ::std::error_code ec;
995 ::std::lock_guard<BasicLockable>
lock(*
this);
1001 sdo->SubmitDownload(req);
1012 template <
class T,
class F>
1015 T&& value, F&& con) {
1016 SubmitWrite(exec,
id, idx, subidx, ::std::forward<T>(value),
1025 template <
class T,
class F>
1028 T&& value, F&& con, ::std::error_code& ec) {
1029 SubmitWrite(exec,
id, idx, subidx, ::std::forward<T>(value),
1038 template <
class T,
class F>
1041 T&& value, F&& con, const ::std::chrono::milliseconds& timeout) {
1042 ::std::error_code ec;
1043 SubmitWrite(exec,
id, idx, subidx, ::std::forward<T>(value),
1044 ::std::forward<F>(con), timeout, ec);
1045 if (ec)
throw SdoError(
id, idx, subidx, ec,
"SubmitWrite");
1066 template <
class T,
class F>
1069 T&& value, F&& con, const ::std::chrono::milliseconds& timeout,
1070 ::std::error_code& ec) {
1072 ::std::forward<F>(con),
false, timeout, ec);
1080 template <
class T,
class F>
1083 T&& value, F&& con) {
1093 template <
class T,
class F>
1096 T&& value, F&& con, ::std::error_code& ec) {
1106 template <
class T,
class F>
1110 const ::std::chrono::milliseconds& timeout) {
1111 ::std::error_code ec;
1113 ::std::forward<F>(con), timeout, ec);
1114 if (ec)
throw SdoError(
id, idx, subidx, ec,
"SubmitBlockWrite");
1139 template <
class T,
class F>
1143 const ::std::chrono::milliseconds& timeout,
1144 ::std::error_code& ec) {
1146 ::std::forward<F>(con),
true, timeout, ec);
1168 template <
class T,
class F>
1171 T&& value, F&& con,
bool block,
1172 const ::std::chrono::milliseconds& timeout,
1173 ::std::error_code& ec) {
1174 ::std::lock_guard<BasicLockable>
lock(*
this);
1180 sdo->SubmitDownload(exec, idx, subidx, ::std::forward<T>(value),
1181 ::std::forward<F>(con), block, timeout);
1203 ::std::error_code& ec);
1213 const uint8_t* end, F&& con) {
1225 const uint8_t* end, F&& con, ::std::error_code& ec) {
1238 const uint8_t* end, F&& con,
1239 const ::std::chrono::milliseconds& timeout) {
1240 ::std::error_code ec;
1241 SubmitWriteDcf(exec,
id, begin, end, ::std::forward<F>(con), timeout, ec);
1242 if (ec)
throw SdoError(
id, 0, 0, ec,
"SubmitWriteDcf");
1269 const uint8_t* end, F&& con,
1270 const ::std::chrono::milliseconds& timeout,
1271 ::std::error_code& ec) {
1272 ::std::lock_guard<BasicLockable>
lock(*
this);
1278 sdo->SubmitDownloadDcf(exec, begin, end, ::std::forward<F>(con), timeout);
1303 ::std::error_code& ec) {
1315 const ::std::chrono::milliseconds& timeout) {
1316 ::std::error_code ec;
1317 SubmitWriteDcf(exec,
id, path, ::std::forward<F>(con), timeout, ec);
1318 if (ec)
throw SdoError(
id, 0, 0, ec,
"SubmitWriteDcf");
1342 const ::std::chrono::milliseconds& timeout,
1343 ::std::error_code& ec) {
1344 ::std::lock_guard<BasicLockable>
lock(*
this);
1350 sdo->SubmitDownloadDcf(exec, path, ::std::forward<F>(con), timeout);
1364 return AsyncRead<T>(exec,
id, idx, subidx,
GetTimeout());
1386 const ::std::chrono::milliseconds& timeout) {
1387 return AsyncUpload<T>(exec,
id, idx, subidx,
false, timeout);
1398 return AsyncBlockRead<T>(exec,
id, idx, subidx,
GetTimeout());
1424 const ::std::chrono::milliseconds& timeout) {
1425 return AsyncUpload<T>(exec,
id, idx, subidx,
true, timeout);
1449 bool block, const ::std::chrono::milliseconds& timeout) {
1452 ::std::lock_guard<BasicLockable>
lock(*
this);
1457 return sdo->AsyncUpload<T>(exec, idx, subidx, block, timeout);
1473 return AsyncWrite(exec,
id, idx, subidx, ::std::forward<T>(value),
1496 T&& value, const ::std::chrono::milliseconds& timeout) {
1497 return AsyncDownload(exec,
id, idx, subidx, ::std::forward<T>(value),
false,
1510 return AsyncBlockWrite(exec,
id, idx, subidx, ::std::forward<T>(value),
1537 T&& value, const ::std::chrono::milliseconds& timeout) {
1538 return AsyncDownload(exec,
id, idx, subidx, ::std::forward<T>(value),
true,
1563 T&& value,
bool block,
1564 const ::std::chrono::milliseconds& timeout) {
1567 ::std::lock_guard<BasicLockable>
lock(*
this);
1572 return sdo->AsyncDownload<T>(exec, idx, subidx, ::std::forward<T>(value),
1587 const uint8_t* end) {
1610 const uint8_t* begin,
const uint8_t* end,
1611 const ::std::chrono::milliseconds& timeout);
1639 const ::std::chrono::milliseconds& timeout);
1673 OnRpdoWrite(::std::function<
void(uint8_t, uint16_t, uint8_t)> on_rpdo_write) {
1674 Node::OnRpdoWrite(on_rpdo_write);
1697 OnSync(::std::function<
void(uint8_t,
const time_point&)> on_sync) {
1709 OnTime(::std::function<
void(const ::std::chrono::system_clock::time_point&)>
1717 ::std::function<
void(uint8_t, uint16_t, uint8_t, uint8_t[5])> on_emcy) {
1727 void OnNodeGuarding(::std::function<
void(uint8_t,
bool)> on_node_guarding);
1736 ::std::function<
void(uint8_t,
NmtState,
char, const ::std::string&)>
1743 using MapType = ::std::map<uint8_t, DriverBase*>;
1767 void OnRpdoWrite(uint8_t
id, uint16_t idx, uint8_t subidx) noexcept
override;
1784 void OnHeartbeat(uint8_t
id,
bool occurred) noexcept
override;
1802 void OnSync(uint8_t cnt,
const time_point& t) noexcept
override;
1809 void OnSyncError(uint16_t eec, uint8_t er) noexcept
override;
1816 void OnTime(const ::std::chrono::system_clock::time_point& abs_time) noexcept
1825 void OnEmcy(uint8_t
id, uint16_t eec, uint8_t er,
1826 uint8_t msef[5]) noexcept
override;
1890 const ::std::string& what) noexcept;
1897 void IsReady(uint8_t
id,
bool ready) noexcept;
1911 virtual void OnConfig(uint8_t
id) noexcept;
1919 void ConfigResult(uint8_t
id, ::std::error_code ec) noexcept;
1949 ::std::unique_ptr<Impl_> impl_;
1975 OnRpdoWrite(::std::function<
void(uint8_t, uint16_t, uint8_t)> on_rpdo_write) {
1999 OnSync(::std::function<
void(uint8_t,
const time_point&)> on_sync) {
2011 OnTime(::std::function<
void(const ::std::chrono::system_clock::time_point&)>
2019 ::std::function<
void(uint8_t, uint16_t, uint8_t, uint8_t[5])> on_emcy) {
2060 void OnRpdoWrite(uint8_t
id, uint16_t idx, uint8_t subidx) noexcept
override;
2077 void OnHeartbeat(uint8_t
id,
bool occurred) noexcept
override;
2094 void OnSync(uint8_t cnt,
const time_point& t) noexcept
override;
2102 void OnSyncError(uint16_t eec, uint8_t er) noexcept
override;
2110 void OnTime(const ::std::chrono::system_clock::time_point& abs_time) noexcept
2119 void OnEmcy(uint8_t
id, uint16_t eec, uint8_t er,
2120 uint8_t msef[5]) noexcept
override;
2128 void OnNodeGuarding(uint8_t
id,
bool occurred) noexcept
override;
2137 const ::std::string& what) noexcept
override;
2145 void OnConfig(uint8_t
id) noexcept
override;
An asynchronous CANopen master.
void OnCanState(::std::function< void(io::CanState, io::CanState)> on_can_state)
void OnTime(::std::function< void(const ::std::chrono::system_clock::time_point &)> on_time)
void OnCanError(::std::function< void(io::CanError)> on_can_error)
void OnNodeGuarding(::std::function< void(uint8_t, bool)> on_node_guarding)
void OnEmcy(::std::function< void(uint8_t, uint16_t, uint8_t, uint8_t[5])> on_emcy)
void OnConfig(uint8_t id) noexcept override
The default implementation queues a notification for the driver registered for node id.
void OnBoot(::std::function< void(uint8_t, NmtState, char, const ::std::string &)> on_boot)
void OnState(::std::function< void(uint8_t, NmtState)> on_state)
void OnSyncError(::std::function< void(uint16_t, uint8_t)> on_sync_error)
void OnRpdoWrite(::std::function< void(uint8_t, uint16_t, uint8_t)> on_rpdo_write)
void OnCommand(::std::function< void(NmtCommand)> on_command)
void OnSync(::std::function< void(uint8_t, const time_point &)> on_sync)
void OnHeartbeat(::std::function< void(uint8_t, bool)> on_heartbeat)
An accessor providing read-only access to a CANopen object in a local object dictionary.
ConstSubObject operator[](uint8_t subidx) const noexcept
Returns an accessor object that provides read-only access to the specified CANopen sub-object in the ...
An accessor providing read-only access to a CANopen sub-object in a local object dictionary.
T Read(::std::error_code &ec) const
Reads the value of the sub-object by submitting an SDO upload request to the local object dictionary.
T Read() const
Reads the value of the sub-object by submitting an SDO upload request to the local object dictionary.
A mutator providing read/write access to a CANopen object in a local object dictionary.
SubObject operator[](uint8_t subidx) noexcept
Returns a mutator object that provides read/write access to the specified CANopen sub-object in the l...
ConstSubObject operator[](uint8_t subidx) const noexcept
Returns an accessor object that provides read-only access to the specified CANopen sub-object in the ...
An accessor providing read-only access to TPDO-mapped objects in a remote object dictionary.
ConstObject operator[](uint16_t idx) const noexcept
Returns an accessor object that provides read-only access to the specified RPDO-mapped object in the ...
A mutator providing read/write access to a CANopen sub-object in a local object dictionary.
SubObject & Write(T &&value, ::std::error_code &ec)
Writes a value to the sub-object by submitting an SDO download request to the local object dictionary...
SubObject & Write(const void *p, ::std::size_t n)
Writes an OCTET_STRING or DOMAIN value to the sub-object by submitting an SDO download request to the...
SubObject & Write(T &&value)
Writes a value to the sub-object by submitting an SDO download request to the local object dictionary...
void WriteEvent()
Checks if the sub-object can be mapped into a PDO and, if so, triggers the transmission of every acyc...
void WriteEvent(::std::error_code &ec) noexcept
Checks if the sub-object can be mapped into a PDO and, if so, triggers the transmission of every acyc...
T Read() const
Reads the value of the sub-object by submitting an SDO upload request to the local object dictionary.
SubObject & Write(const void *p, ::std::size_t n, ::std::error_code &ec)
Writes an OCTET_STRING or DOMAIN value to the sub-object by submitting an SDO download request to the...
SubObject & operator=(T &&value)
Sets the value of the sub-object.
T Read(::std::error_code &ec) const
Reads the value of the sub-object by submitting an SDO upload request to the local object dictionary.
void lock() override
Blocks until a lock can be obtained for the current execution agent (thread, process,...
void unlock() override
Releases the lock held by the execution agent. Throws no exceptions.
A mutator providing read/write access to TPDO-mapped objects in a remote object dictionary.
ConstObject operator[](uint16_t idx) const noexcept
Returns an accessor object that provides read-only access to the specified TPDO-mapped object in the ...
Object operator[](uint16_t idx) noexcept
Returns a mutator object that provides read/write access to the specified PDO-mapped object in the re...
void OnState(::std::function< void(uint8_t, NmtState)> on_state)
void SubmitBlockRead(ev_exec_t *exec, uint8_t id, uint16_t idx, uint8_t subidx, F &&con)
Equivalent to SubmitBlockRead(ev_exec_t* exec, uint8_t id, uint16_t idx, uint8_t subidx,...
SdoFuture< T > AsyncRead(ev_exec_t *exec, uint8_t id, uint16_t idx, uint8_t subidx, const ::std::chrono::milliseconds &timeout)
Queues an asynchronous read (SDO upload) operation and creates a future which becomes ready once the ...
bool IsConfig(uint8_t id) const
Returns true if the remote node is configuring (i.e., the 'update configuration' step of the NMT 'boo...
void SubmitBlockWrite(ev_exec_t *exec, uint8_t id, uint16_t idx, uint8_t subidx, T &&value, F &&con)
Equivalent to SubmitBlockWrite(ev_exec_t* exec, uint8_t id, uint16_t idx, uint8_t subidx,...
SdoFuture< void > AsyncBlockWrite(ev_exec_t *exec, uint8_t id, uint16_t idx, uint8_t subidx, T &&value)
Equivalent to AsyncBlockWrite(ev_exec_t* exec, uint8_t id, uint16_t idx, uint8_t subidx,...
void SubmitWriteDcf(ev_exec_t *exec, uint8_t id, const uint8_t *begin, const uint8_t *end, F &&con)
Equivalent to SubmitWriteDcf(ev_exec_t* exec, uint8_t id, const uint8_t *begin, const uint8_t *end,...
void TpdoEvent(int num=0) noexcept
void SubmitWriteDcf(ev_exec_t *exec, uint8_t id, const char *path, F &&con)
Equivalent to SubmitWriteDcf(ev_exec_t* exec, uint8_t id, const char* path, F&& con,...
void(uint8_t id, uint16_t idx, uint8_t subidx, ::std::error_code ec) WriteSignature
The signature of the callback function invoked on completion of an asynchronous write (SDO download) ...
void SubmitWrite(ev_exec_t *exec, uint8_t id, uint16_t idx, uint8_t subidx, T &&value, F &&con, const ::std::chrono::milliseconds &timeout)
Equivalent to SubmitWrite(ev_exec_t* exec, uint8_t id, uint16_t idx, uint8_t subidx,...
void SubmitWriteDcf(uint8_t id, SdoDownloadDcfRequest &req)
Equivalent to SubmitWriteDcf(uint8_t id, SdoDownloadDcfRequest& req, ::std::error_code& ec),...
ev::Future<::std::size_t, void > AsyncDeconfig()
Queues the DriverBase::OnDeconfig() method for all registered drivers and creates a future which beco...
void SubmitUpload(ev_exec_t *exec, uint8_t id, uint16_t idx, uint8_t subidx, F &&con, bool block, const ::std::chrono::milliseconds &timeout, ::std::error_code &ec)
Queues an asynchronous SDO upload operation.
void SubmitRead(ev_exec_t *exec, uint8_t id, uint16_t idx, uint8_t subidx, F &&con, const ::std::chrono::milliseconds &timeout)
Equivalent to SubmitRead(ev_exec_t* exec, uint8_t id, uint16_t idx, uint8_t subidx,...
virtual void OnConfig(uint8_t id) noexcept
The function invoked when the 'update configuration' step is reached during the NMT 'boot slave' proc...
void(uint8_t id, uint16_t idx, uint8_t subidx, ::std::error_code ec, T value) ReadSignature
The signature of the callback function invoked on completion of an asynchronous read (SDO upload) ope...
Object operator[](::std::ptrdiff_t idx) noexcept
Returns a mutator object that provides read/write access to the specified CANopen object in the local...
void OnTime(::std::function< void(const ::std::chrono::system_clock::time_point &)> on_time)
void SubmitRead(ev_exec_t *exec, uint8_t id, uint16_t idx, uint8_t subidx, F &&con, const ::std::chrono::milliseconds &timeout, ::std::error_code &ec)
Queues an asynchronous read (SDO upload) operation.
void SubmitWriteDcf(ev_exec_t *exec, uint8_t id, const char *path, F &&con, ::std::error_code &ec)
Equivalent to SubmitWriteDcf(ev_exec_t* exec, uint8_t id, const char* path, F&& con,...
SdoFuture< void > AsyncWriteDcf(ev_exec_t *exec, uint8_t id, const char *path)
Equivalent to AsyncWriteDcf(ev_exec_t* exec, uint8_t id, const char* path, const ::std::chrono::milli...
RpdoMapped RpdoMapped(uint8_t id) const noexcept
Returns an accessor object that provides read-only access to RPDO-mapped objects in the remote object...
void RpdoRtr(int num=0) noexcept
void OnHeartbeat(::std::function< void(uint8_t, bool)> on_heartbeat)
void Command(NmtCommand cs, uint8_t id=0)
Issues an NMT command to a slave.
BasicMaster(io::TimerBase &timer, io::CanChannelBase &chan, const ::std::string &dcf_txt, const ::std::string &dcf_bin="", uint8_t id=0xff)
Creates a new CANopen master.
BasicMaster(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 master.
void OnCanState(::std::function< void(io::CanState, io::CanState)> on_can_state)
void Erase(DriverBase &driver)
Unregisters a driver for a remote CANopen node.
void SubmitWriteDcf(ev_exec_t *exec, uint8_t id, const char *path, F &&con, const ::std::chrono::milliseconds &timeout, ::std::error_code &ec)
Queues a series of asynchronous write (SDO download) operations.
SdoFuture< void > AsyncBlockWrite(ev_exec_t *exec, uint8_t id, uint16_t idx, uint8_t subidx, T &&value, const ::std::chrono::milliseconds &timeout)
Queues an asynchronous write (SDO block download) operation and creates a future which becomes ready ...
SdoFuture< void > AsyncWrite(ev_exec_t *exec, uint8_t id, uint16_t idx, uint8_t subidx, T &&value)
Equivalent to AsyncWrite(ev_exec_t* exec, uint8_t id, uint16_t idx, uint8_t subidx,...
void SubmitBlockRead(ev_exec_t *exec, uint8_t id, uint16_t idx, uint8_t subidx, F &&con, const ::std::chrono::milliseconds &timeout)
Equivalent to SubmitBlockRead(ev_exec_t* exec, uint8_t id, uint16_t idx, uint8_t subidx,...
void SubmitWriteDcf(ev_exec_t *exec, uint8_t id, const char *path, F &&con, const ::std::chrono::milliseconds &timeout)
Equivalent to SubmitWriteDcf(ev_exec_t* exec, uint8_t id, const char* path, F&& con,...
SdoFuture< T > AsyncUpload(ev_exec_t *exec, uint8_t id, uint16_t idx, uint8_t subidx, bool block, const ::std::chrono::milliseconds &timeout)
Queues an asynchronous SDO upload operation and creates a future which becomes ready once the request...
void OnBoot(::std::function< void(uint8_t, NmtState, char, const ::std::string &)> on_boot)
Registers the function invoked when the NMT 'boot slave' process completes.
SdoFuture< T > AsyncBlockRead(ev_exec_t *exec, uint8_t id, uint16_t idx, uint8_t subidx, const ::std::chrono::milliseconds &timeout)
Queues an asynchronous read (SDO block upload) operation and creates a future which becomes ready onc...
void SubmitWrite(ev_exec_t *exec, uint8_t id, uint16_t idx, uint8_t subidx, T &&value, F &&con)
Equivalent to SubmitWrite(ev_exec_t* exec, uint8_t id, uint16_t idx, uint8_t subidx,...
SdoFuture< T > AsyncRead(ev_exec_t *exec, uint8_t id, uint16_t idx, uint8_t subidx)
Equivalent to AsyncRead(ev_exec_t* exec, uint8_t id, uint16_t idx, uint8_t subidx,...
void Insert(DriverBase &driver)
Registers a driver for a remote CANopen node.
void SubmitBlockWrite(ev_exec_t *exec, uint8_t id, uint16_t idx, uint8_t subidx, T &&value, F &&con, ::std::error_code &ec)
Equivalent to SubmitBlockWrite(ev_exec_t* exec, uint8_t id, uint16_t idx, uint8_t subidx,...
void Error(uint8_t id)
Indicates the occurrence of an error event on a remote node and triggers the error handling process (...
bool Boot(uint8_t id)
Requests the NMT 'boot slave' process for the specified node.
void SubmitWriteDcf(ev_exec_t *exec, uint8_t id, const uint8_t *begin, const uint8_t *end, F &&con, ::std::error_code &ec)
Equivalent to SubmitWriteDcf(ev_exec_t* exec, uint8_t id, const uint8_t *begin, const uint8_t *end,...
void SubmitWrite(ev_exec_t *exec, uint8_t id, uint16_t idx, uint8_t subidx, T &&value, F &&con, ::std::error_code &ec)
Equivalent to SubmitWrite(ev_exec_t* exec, uint8_t id, uint16_t idx, uint8_t subidx,...
void OnNodeGuarding(::std::function< void(uint8_t, bool)> on_node_guarding)
Registers the function invoked when a node guarding timeout event occurs or is resolved.
void SubmitDownload(ev_exec_t *exec, uint8_t id, uint16_t idx, uint8_t subidx, T &&value, F &&con, bool block, const ::std::chrono::milliseconds &timeout, ::std::error_code &ec)
Queues an asynchronous SDO download operation.
void SubmitWrite(ev_exec_t *exec, uint8_t id, uint16_t idx, uint8_t subidx, T &&value, F &&con, const ::std::chrono::milliseconds &timeout, ::std::error_code &ec)
Queues an asynchronous write (SDO download) operation.
SdoFuture< void > AsyncWriteDcf(ev_exec_t *exec, uint8_t id, const uint8_t *begin, const uint8_t *end)
Equivalent to AsyncWriteDcf(ev_exec_t* exec, uint8_t id, const uint8_t* begin, const uint8_t* end,...
void SubmitWriteDcf(ev_exec_t *exec, uint8_t id, const uint8_t *begin, const uint8_t *end, F &&con, const ::std::chrono::milliseconds &timeout, ::std::error_code &ec)
Queues a series of asynchronous write (SDO download) operations.
void SubmitRead(ev_exec_t *exec, uint8_t id, uint16_t idx, uint8_t subidx, F &&con, ::std::error_code &ec)
Equivalent to SubmitRead(ev_exec_t* exec, uint8_t id, uint16_t idx, uint8_t subidx,...
bool IsReady(uint8_t id) const
Returns true if the remote node is ready (i.e., the NMT 'boot slave' process has successfully complet...
::std::chrono::milliseconds GetTimeout() const
Returns the SDO timeout used during the NMT 'boot slave' and 'check configuration' processes.
TpdoMapped TpdoMapped(uint8_t id) noexcept
Returns a mutator object that provides read/write access to TPDO-mapped objects in the remote object ...
void SubmitBlockRead(ev_exec_t *exec, uint8_t id, uint16_t idx, uint8_t subidx, F &&con, ::std::error_code &ec)
Equivalent to SubmitBlockRead(ev_exec_t* exec, uint8_t id, uint16_t idx, uint8_t subidx,...
SdoFuture< void > AsyncDownload(ev_exec_t *exec, uint8_t id, uint16_t idx, uint8_t subidx, T &&value, bool block, const ::std::chrono::milliseconds &timeout)
Queues an asynchronous SDO download operation and creates a future which becomes ready once the reque...
void OnEmcy(::std::function< void(uint8_t, uint16_t, uint8_t, uint8_t[5])> on_emcy)
void SubmitRead(uint8_t id, SdoUploadRequest< T > &req)
Equivalent to SubmitRead(uint8_t id, SdoUploadRequest<T>& req, ::std::error_code& ec),...
void SubmitRead(ev_exec_t *exec, uint8_t id, uint16_t idx, uint8_t subidx, F &&con)
Equivalent to SubmitRead(ev_exec_t* exec, uint8_t id, uint16_t idx, uint8_t subidx,...
void SetTimeout(const ::std::chrono::milliseconds &timeout)
Sets the SDO timeout used during the NMT 'boot slave' and 'check configuration' processes.
void OnCanError(::std::function< void(io::CanError)> on_can_error)
TpdoEventMutex tpdo_event_mutex
void ConfigResult(uint8_t id, ::std::error_code ec) noexcept
Reports the result of the 'update configuration' step to the NMT service.
void SubmitWrite(uint8_t id, SdoDownloadRequest< T > &req)
Equivalent to SubmitWrite(uint8_t id, SdoDownloadRequest<T>& req, ::std::error_code& ec),...
void CancelSdo(uint8_t id=0)
Aborts any ongoing or pending SDO requests for the specified slave.
void SubmitBlockRead(ev_exec_t *exec, uint8_t id, uint16_t idx, uint8_t subidx, F &&con, const ::std::chrono::milliseconds &timeout, ::std::error_code &ec)
Queues an asynchronous read (SDO block upload) operation.
void OnSync(::std::function< void(uint8_t, const time_point &)> on_sync)
void SubmitRead(uint8_t id, SdoUploadRequest< T > &req, ::std::error_code &ec)
Queues an asynchronous read (SDO upload) operation.
void OnRpdoWrite(::std::function< void(uint8_t, uint16_t, uint8_t)> on_rpdo_write)
ConstObject operator[](::std::ptrdiff_t idx) const noexcept
Returns an accessor object that provides read-only access to the specified CANopen object in the loca...
SdoFuture< T > AsyncBlockRead(ev_exec_t *exec, uint8_t id, uint16_t idx, uint8_t subidx)
Equivalent to AsyncBlockRead(ev_exec_t* exec, uint8_t id, uint16_t idx, uint8_t subidx,...
void DamMpdoEvent(int num, uint8_t id, uint16_t idx, uint8_t subidx, T value)
void SubmitWrite(uint8_t id, SdoDownloadRequest< T > &req, ::std::error_code &ec)
Queues an asynchronous write (SDO download) operation.
void SubmitWriteDcf(ev_exec_t *exec, uint8_t id, const uint8_t *begin, const uint8_t *end, F &&con, const ::std::chrono::milliseconds &timeout)
Equivalent to SubmitWriteDcf(ev_exec_t* exec, uint8_t id, const uint8_t *begin, const uint8_t *end,...
void OnCommand(::std::function< void(NmtCommand)> on_command)
Sdo * GetSdo(uint8_t id)
Returns a pointer to the default client-SDO service for the given node.
void OnSyncError(::std::function< void(uint16_t, uint8_t)> on_sync_error)
void SubmitBlockWrite(ev_exec_t *exec, uint8_t id, uint16_t idx, uint8_t subidx, T &&value, F &&con, const ::std::chrono::milliseconds &timeout, ::std::error_code &ec)
Queues an asynchronous write (SDO block download) operation.
SdoFuture< void > AsyncWrite(ev_exec_t *exec, uint8_t id, uint16_t idx, uint8_t subidx, T &&value, const ::std::chrono::milliseconds &timeout)
Queues an asynchronous write (SDO download) operation and creates a future which becomes ready once t...
void SubmitBlockWrite(ev_exec_t *exec, uint8_t id, uint16_t idx, uint8_t subidx, T &&value, F &&con, const ::std::chrono::milliseconds &timeout)
Equivalent to SubmitBlockWrite(ev_exec_t* exec, uint8_t id, uint16_t idx, uint8_t subidx,...
void TpdoWriteEvent(uint8_t id, uint16_t idx, uint8_t subidx)
Triggers the transmission of every event-driven, asynchronous Transmit-PDO which is mapped into the s...
typename ::std::enable_if< is_canopen_basic< T >::value, T >::type TpdoRead(uint8_t id, uint16_t idx, uint8_t subidx) const
Submits an SDO upload request to a TPDO-mapped sub-object in the local object dictionary,...
typename ::std::enable_if< is_canopen< T >::value, T >::type Read(uint16_t idx, uint8_t subidx) const
Submits an SDO upload request to the local object dictionary.
typename ::std::enable_if< is_canopen_basic< T >::value >::type TpdoWrite(uint8_t id, uint16_t idx, uint8_t subidx, T value)
Writes a value to a sub-object in a remote object dictionary by submitting an SDO download request to...
void WriteEvent(uint16_t idx, uint8_t subidx)
Checks if the specified sub-object in the local object dictionary can be mapped into a PDO and,...
typename ::std::enable_if< is_canopen< T >::value >::type Write(uint16_t idx, uint8_t subidx, const T &value)
Submits an SDO download request to the local object dictionary.
uint8_t id() const noexcept
Returns the node-ID.
typename ::std::enable_if< is_canopen_basic< T >::value, T >::type RpdoRead(uint8_t id, uint16_t idx, uint8_t subidx) const
Reads the value of a sub-object in a remote object dictionary by submitting an SDO upload request to ...
The abstract driver interface for a remote CANopen node.
A recursive mutex-like object that can be used to postpone the transmission of acyclic and event-driv...
The base class for CANopen nodes.
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.
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 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...
void SetTime()
Updates the CAN network time.
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.
void OnCommand(::std::function< void(NmtCommand)> on_command)
Registers the function to be invoked when an NMT command is received from the master.
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 GetExecutor() const noexcept
Returns the executor used to process I/O and CANopen events.
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.
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.
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.
A series of SDO download (i.e., write) requests corresponding to the entries in a concise DCF.
An SDO download (i.e., write) request.
The type of exception thrown when an SDO abort code is received.
An SDO upload (i.e., read) request.
uint16_t idx
The object index.
uint8_t subidx
The object sub-index.
The type of objects thrown as exceptions to report a system error with an associated error code.
A reference to an abstract CAN channel.
void lock() final
Blocks until a lock can be obtained for the current execution agent (thread, process,...
virtual void on_can_error(CanError error) noexcept
The function invoked when an error is detected on the CAN bus.
virtual void on_can_state(CanState new_state, CanState old_state) noexcept
The function invoked when a CAN bus state change is detected.
A reference to an abstract timer.
CanError
The error flags of a CAN bus, which are not mutually exclusive.
CanState
The states of a CAN node, depending on the TX/RX error count.
const struct ev_exec_vtbl *const ev_exec_t
An abstract task executor.
@ NO_SDO
Resource not available: SDO connection.
NmtCommand
The NMT command specifiers.
This header file is part of the C++ CANopen application library; it contains the CANopen node declara...
This header file is part of the C++ CANopen master library; it contains the Client-SDO queue declarat...
The internal implementation of the CANopen master.