Lely core libraries
2.3.4
|
Go to the documentation of this file.
84 void OnCsInd(
co_lss_t*, uint8_t cs) noexcept;
85 void OnErrInd(
co_lss_t*, uint8_t cs, uint8_t err, uint8_t spec) noexcept;
86 void OnLssIdInd(
co_lss_t*, uint8_t cs, co_unsigned32_t
id) noexcept;
87 void OnNidInd(
co_lss_t*, uint8_t cs, uint8_t
id) noexcept;
88 void OnScanInd(
co_lss_t*, uint8_t cs,
const co_id*
id) noexcept;
90 void OnWait(::std::error_code) noexcept;
106 void* lss_data{
nullptr};
112 co_id id1{4, 0, 0, 0, 0};
113 co_id id2{4, 0, 0, 0, 0};
119 LssSwitchRequestBase::OnRequest(
void* data) noexcept {
120 static_cast<LssMaster::Impl_*
>(data)->OnSwitch(*
this);
124 LssSwitchSelectiveRequestBase::OnRequest(
void* data) noexcept {
125 static_cast<LssMaster::Impl_*
>(data)->OnSwitchSelective(*
this);
129 LssSetIdRequestBase::OnRequest(
void* data) noexcept {
130 static_cast<LssMaster::Impl_*
>(data)->OnSetId(*
this);
134 LssSetBitrateRequestBase::OnRequest(
void* data) noexcept {
135 static_cast<LssMaster::Impl_*
>(data)->OnSetBitrate(*
this);
139 LssSwitchBitrateRequestBase::OnRequest(
void* data) noexcept {
140 static_cast<LssMaster::Impl_*
>(data)->OnSwitchBitrate(*
this);
144 LssStoreRequestBase::OnRequest(
void* data) noexcept {
145 static_cast<LssMaster::Impl_*
>(data)->OnStore(*
this);
149 LssGetVendorIdRequestBase::OnRequest(
void* data) noexcept {
150 static_cast<LssMaster::Impl_*
>(data)->OnGetVendorId(*
this);
154 LssGetProductCodeRequestBase::OnRequest(
void* data) noexcept {
155 static_cast<LssMaster::Impl_*
>(data)->OnGetProductCode(*
this);
159 LssGetRevisionRequestBase::OnRequest(
void* data) noexcept {
160 static_cast<LssMaster::Impl_*
>(data)->OnGetRevision(*
this);
164 LssGetSerialNrRequestBase::OnRequest(
void* data) noexcept {
165 static_cast<LssMaster::Impl_*
>(data)->OnGetSerialNr(*
this);
169 LssGetIdRequestBase::OnRequest(
void* data) noexcept {
170 static_cast<LssMaster::Impl_*
>(data)->OnGetId(*
this);
174 LssIdNonConfigRequestBase::OnRequest(
void* data) noexcept {
175 static_cast<LssMaster::Impl_*
>(data)->OnIdNonConfig(*
this);
179 LssSlowscanRequestBase::OnRequest(
void* data) noexcept {
180 static_cast<LssMaster::Impl_*
>(data)->OnSlowscan(*
this);
184 LssFastscanRequestBase::OnRequest(
void* data) noexcept {
185 static_cast<LssMaster::Impl_*
>(data)->OnFastscan(*
this);
191 : impl_(new
Impl_(this, exec, node, ctrl, node.nmt())) {}
193 LssMaster::~LssMaster() =
default;
210 ::std::chrono::microseconds
212 ::std::lock_guard<Impl_>
lock(*impl_);
213 ::std::chrono::microseconds::rep value = impl_->inhibit;
214 return ::std::chrono::microseconds(value * 100);
219 auto value = inhibit.count();
221 if (value > ::std::numeric_limits<uint16_t>::max() * 100)
222 value = ::std::numeric_limits<uint16_t>::max() * 100;
224 ::std::lock_guard<Impl_>
lock(*impl_);
226 impl_->inhibit = (value + 99) / 100;
231 ::std::chrono::milliseconds
233 ::std::lock_guard<Impl_>
lock(*impl_);
234 return ::std::chrono::milliseconds(impl_->timeout);
239 auto value = timeout.count();
241 if (value > ::std::numeric_limits<int>::max())
242 value = ::std::numeric_limits<int>::max();
244 ::std::lock_guard<Impl_>
lock(*impl_);
245 impl_->timeout = value;
256 p.
set(ec ? ::std::make_exception_ptr(
257 ::std::system_error(ec,
"AsyncSwitch"))
260 if (preq) *preq = req;
270 exec, address, [p](::std::error_code ec)
mutable {
271 p.
set(ec ? ::std::make_exception_ptr(
272 ::std::system_error(ec,
"AsyncSwitchSelective"))
275 if (preq) *preq = req;
286 p.
set(ec ? ::std::make_exception_ptr(
287 ::std::system_error(ec,
"AsyncSetId"))
290 if (preq) *preq = req;
300 exec, bitrate, [p](::std::error_code ec)
mutable {
301 p.
set(ec ? ::std::make_exception_ptr(
302 ::std::system_error(ec,
"AsyncSetBitrate"))
305 if (preq) *preq = req;
314 p.
set(ec ? ::std::make_exception_ptr(::std::system_error(ec,
"AsyncStore"))
317 if (preq) *preq = req;
327 exec, [p](::std::error_code ec, uint32_t number)
mutable {
329 p.
set(util::failure(::std::make_exception_ptr(
330 ::std::system_error(ec,
"AsyncGetVendorId"))));
332 p.
set(util::success(number));
334 if (preq) *preq = req;
344 exec, [p](::std::error_code ec, uint32_t number)
mutable {
346 p.
set(util::failure(::std::make_exception_ptr(
347 ::std::system_error(ec,
"AsyncGetProductCode"))));
349 p.
set(util::success(number));
351 if (preq) *preq = req;
361 exec, [p](::std::error_code ec, uint32_t number)
mutable {
363 p.
set(util::failure(::std::make_exception_ptr(
364 ::std::system_error(ec,
"AsyncGetRevision"))));
366 p.
set(util::success(number));
368 if (preq) *preq = req;
378 exec, [p](::std::error_code ec, uint32_t number)
mutable {
380 p.
set(util::failure(::std::make_exception_ptr(
381 ::std::system_error(ec,
"AsyncGetSerialNr"))));
383 p.
set(util::success(number));
385 if (preq) *preq = req;
394 exec, [p](::std::error_code ec, uint8_t
id)
mutable {
396 p.
set(util::failure(::std::make_exception_ptr(
397 ::std::system_error(ec,
"AsyncGetId"))));
399 p.
set(util::success(
id));
401 if (preq) *preq = req;
411 exec, [p](::std::error_code ec,
bool found)
mutable {
413 p.
set(util::failure(::std::make_exception_ptr(
414 ::std::system_error(ec,
"AsyncIdNonConfig"))));
416 p.
set(util::success(found));
418 if (preq) *preq = req;
430 [p](::std::error_code ec,
const LssAddress& address)
mutable {
432 p.
set(util::failure(::std::make_exception_ptr(
433 ::std::system_error(ec,
"AsyncSlowscan"))));
435 p.
set(util::success(address));
437 if (preq) *preq = req;
449 [p](::std::error_code ec,
const LssAddress& address)
mutable {
451 p.
set(util::failure(::std::make_exception_ptr(
452 ::std::system_error(ec,
"AsyncFastscan"))));
454 p.
set(util::success(address));
456 if (preq) *preq = req;
463 ::std::lock_guard<util::BasicLockable>
lock(*
this);
470 ::std::lock_guard<Impl_>
lock(*impl_);
471 return impl_->Cancel(&req, ec) != 0;
477 ::std::lock_guard<Impl_>
lock(*impl_);
478 return impl_->Cancel(
nullptr, ec);
483 ::std::lock_guard<Impl_>
lock(*impl_);
484 return impl_->Abort(&req) != 0;
489 ::std::lock_guard<Impl_>
lock(*impl_);
490 return impl_->Abort(
nullptr);
495 int bitrate, ::std::chrono::milliseconds delay,
496 ::std::function<
void(::std::error_code ec)> res) noexcept {
497 if (GetController()) {
501 .AsyncWait(GetExecutor(), delay / 2)
507 GetController()->stop();
510 return GetNode().AsyncWait(GetExecutor(), delay / 2);
517 GetController()->set_bitrate(bitrate);
520 return GetNode().AsyncWait(GetExecutor(), delay);
523 ::std::error_code ec;
528 GetController()->restart();
529 }
catch (::std::system_error& e) {
559 exec(exec_ ? exec_ : static_cast<
ev_exec_t*>(node_.GetExecutor())),
568 static_cast<Impl_*
>(data)->OnLssReq(nmt, lss);
581 ::std::error_code ec;
582 ctrl->get_bitrate(&bitrate,
nullptr, ec);
597 self->GetExecutor().post([
this]() noexcept {
598 self->OnStart([
this](::std::error_code) noexcept {
599 ::std::lock_guard<Impl_>
lock(*
this);
607 LssMaster::Impl_::Submit(detail::LssRequestBase& req) {
608 if (!req.exec) req.exec =
self->GetExecutor();
609 auto exec = req.GetExecutor();
614 if (first) OnRequest(req);
618 LssMaster::Impl_::Cancel(detail::LssRequestBase* req, ::std::error_code ec) {
633 auto exec = req->GetExecutor();
637 n += n < ::std::numeric_limits<::std::size_t>::max();
643 LssMaster::Impl_::Abort(detail::LssRequestBase* req) {
654 LssMaster::Impl_::Pop(detail::LssRequestBase* req,
sllist& queue) {
671 return req !=
nullptr;
675 LssMaster::Impl_::OnSwitch(detail::LssSwitchRequestBase& req) noexcept {
681 ::std::error_code ec;
692 LssMaster::Impl_::OnSwitchSelective(
693 detail::LssSwitchSelectiveRequestBase& req) noexcept {
697 id1 = {4, req.address.vendor_id, req.address.product_code,
698 req.address.revision, req.address.serial_nr};
707 [](
co_lss_t* lss, uint8_t cs,
void* data) noexcept {
708 static_cast<Impl_*
>(data)->OnCsInd(lss, cs);
719 LssMaster::Impl_::OnSetId(detail::LssSetIdRequestBase& req) noexcept {
730 [](
co_lss_t* lss, uint8_t cs, uint8_t err, uint8_t spec,
731 void* data) noexcept {
732 static_cast<Impl_*>(data)->OnErrInd(lss, cs, err, spec);
743 LssMaster::Impl_::OnSetBitrate(detail::LssSetBitrateRequestBase& req) noexcept {
752 switch (req.bitrate) {
762 lss, req.bitrate / 1000,
763 [](
co_lss_t* lss, uint8_t cs, uint8_t err, uint8_t spec,
764 void* data) noexcept {
765 static_cast<Impl_*>(data)->OnErrInd(lss, cs, err, spec);
771 bitrate = req.bitrate;
783 LssMaster::Impl_::OnSwitchBitrate(
784 detail::LssSwitchBitrateRequestBase& req) noexcept {
793 if (!bitrate || req.delay < 0 ||
794 req.delay > ::std::numeric_limits<uint16_t>::max()) {
804 ::std::chrono::milliseconds delay(req.delay);
806 self->GetExecutor().post([
this, delay]() noexcept {
807 self->OnSwitchBitrate(bitrate, delay, [
this](::std::error_code ec) {
809 ::std::lock_guard<Impl_>
lock(*
this);
812 auto req =
static_cast<detail::LssSwitchBitrateRequestBase*
>(task);
823 LssMaster::Impl_::OnStore(detail::LssStoreRequestBase& req) noexcept {
834 [](
co_lss_t* lss, uint8_t cs, uint8_t err, uint8_t spec,
835 void* data) noexcept {
836 static_cast<Impl_*
>(data)->OnErrInd(lss, cs, err, spec);
847 LssMaster::Impl_::OnGetVendorId(
848 detail::LssGetVendorIdRequestBase& req) noexcept {
860 [](
co_lss_t* lss, uint8_t cs, uint32_t
id,
void* data) noexcept {
861 static_cast<Impl_*
>(data)->OnLssIdInd(lss, cs,
id);
872 LssMaster::Impl_::OnGetProductCode(
873 detail::LssGetProductCodeRequestBase& req) noexcept {
885 [](
co_lss_t* lss, uint8_t cs, uint32_t
id,
void* data) noexcept {
886 static_cast<Impl_*
>(data)->OnLssIdInd(lss, cs,
id);
897 LssMaster::Impl_::OnGetRevision(
898 detail::LssGetRevisionRequestBase& req) noexcept {
910 [](
co_lss_t* lss, uint8_t cs, uint32_t
id,
void* data) noexcept {
911 static_cast<Impl_*
>(data)->OnLssIdInd(lss, cs,
id);
922 LssMaster::Impl_::OnGetSerialNr(
923 detail::LssGetSerialNrRequestBase& req) noexcept {
935 [](
co_lss_t* lss, uint8_t cs, uint32_t
id,
void* data) noexcept {
936 static_cast<Impl_*
>(data)->OnLssIdInd(lss, cs,
id);
947 LssMaster::Impl_::OnGetId(detail::LssGetIdRequestBase& req) noexcept {
959 [](
co_lss_t* lss, uint8_t cs, uint8_t
id,
void* data) noexcept {
960 static_cast<Impl_*
>(data)->OnNidInd(lss, cs,
id);
971 LssMaster::Impl_::OnIdNonConfig(
972 detail::LssIdNonConfigRequestBase& req) noexcept {
983 [](
co_lss_t* lss, uint8_t cs,
void* data) noexcept {
984 static_cast<Impl_*
>(data)->OnCsInd(lss, cs);
995 LssMaster::Impl_::OnSlowscan(detail::LssSlowscanRequestBase& req) noexcept {
999 id1 = {4, req.lo.vendor_id, req.lo.product_code, req.lo.revision,
1001 id2 = {4, req.hi.vendor_id, req.hi.product_code, req.hi.revision,
1009 req.address = {0, 0, 0, 0};
1012 [](
co_lss_t* lss, uint8_t cs,
const co_id*
id,
void* data) noexcept {
1013 static_cast<Impl_*
>(data)->OnScanInd(lss, cs,
id);
1024 LssMaster::Impl_::OnFastscan(detail::LssFastscanRequestBase& req) noexcept {
1028 id1 = {4, req.address.vendor_id, req.address.product_code,
1029 req.address.revision, req.address.serial_nr};
1030 id2 = {4, req.mask.vendor_id, req.mask.product_code, req.mask.revision,
1031 req.mask.serial_nr};
1040 [](
co_lss_t* lss, uint8_t cs,
const co_id*
id,
void* data) noexcept {
1041 static_cast<Impl_*
>(data)->OnScanInd(lss, cs,
id);
1052 LssMaster::Impl_::OnCsInd(
co_lss_t*, uint8_t cs) noexcept {
1055 auto req =
static_cast<detail::LssSwitchRequestBase*
>(task);
1066 LssMaster::Impl_::OnErrInd(
co_lss_t*, uint8_t cs, uint8_t err,
1070 auto req =
static_cast<detail::LssRequestBase*
>(task);
1117 LssMaster::Impl_::OnLssIdInd(
co_lss_t*, uint8_t cs,
1118 co_unsigned32_t
id) noexcept {
1121 auto req =
static_cast<detail::LssGetNumberRequestBase*
>(task);
1134 LssMaster::Impl_::OnNidInd(
co_lss_t*, uint8_t cs, uint8_t
id) noexcept {
1137 auto req =
static_cast<detail::LssGetIdRequestBase*
>(task);
1150 LssMaster::Impl_::OnScanInd(
co_lss_t*, uint8_t cs,
const co_id*
id) noexcept {
1154 auto req =
static_cast<detail::LssScanRequestBase*
>(task);
1158 req->address.vendor_id =
id->vendor_id;
1159 req->address.product_code =
id->product_code;
1160 req->address.revision =
id->revision;
1161 req->address.serial_nr =
id->serial_nr;
1170 LssMaster::Impl_::OnRequest(detail::LssRequestBase& req) noexcept {
1172 req.OnRequest(
this);
1180 LssMaster::Impl_::OnCompletion(detail::LssRequestBase& req) noexcept {
1184 auto exec = req.GetExecutor();
1186 exec.on_task_fini();
1189 if (task) OnRequest(*
static_cast<detail::LssRequestBase*
>(task));
1196 #endif // !LELY_NO_CO_LSS
void lock() final
Blocks until a lock can be obtained for the current execution agent (thread, process,...
int co_lss_switch_req(co_lss_t *lss, co_unsigned8_t mode)
Requests the 'switch state global' service.
An abstract interface conforming to the BasicLockable concept.
struct ev_task * ev_task_from_node(struct slnode *node)
Converts a pointer to a node in a queue to the address of the task containing the node.
::std::chrono::microseconds GetInhibit() const
Returns the inhibit time between successive CAN frames.
const struct ev_exec_vtbl *const ev_exec_t
An abstract task executor.
LssFuture< uint32_t > AsyncGetVendorId(ev_exec_t *exec, detail::LssGetVendorIdRequestBase **preq=nullptr)
Queues an asynchronous LSS 'inquire identity vendor-ID' request and creates a future which becomes re...
struct slnode * sllist_remove(struct sllist *list, struct slnode *node)
Removes a node from a singly-linked list.
ev::Executor GetExecutor() const noexcept
Returns the default executor used to execute completion tasks of LSS requests.
void co_nmt_get_lss_req(const co_nmt_t *nmt, co_nmt_lss_req_t **pind, void **pdata)
Retrieves the request function invoked to perform LSS when booting an NMT master.
struct slnode * sllist_first(const struct sllist *list)
Returns a pointer to the first node in a singly-linked list.
LssFuture< bool > AsyncIdNonConfig(ev_exec_t *exec, detail::LssIdNonConfigRequestBase **preq=nullptr)
Queues an asynchronous LSS 'identify non-configured remote slave' request and creates a future which ...
LssFuture< void > AsyncSetId(ev_exec_t *exec, uint8_t id, detail::LssSetIdRequestBase **preq=nullptr)
Queues an asynchronous LSS 'configure node-ID' request and creates a future which becomes ready once ...
int co_lss_set_rate_req(co_lss_t *lss, co_unsigned16_t rate, co_lss_err_ind_t *ind, void *data)
Requests the 'configure bit timing parameters' service.
int co_lss_store_req(co_lss_t *lss, co_lss_err_ind_t *ind, void *data)
Requests the 'store configuration' service.
LssMaster(ev_exec_t *exec, Node &node, io::CanControllerBase *ctrl=nullptr)
Creates a new CANopen LSS master.
typename ::std::enable_if< compat::is_invocable< F, ::std::error_code, uint32_t >::value, detail::LssGetSerialNrRequestWrapper< F > * >::type make_lss_get_serial_nr_request(ev_exec_t *exec, F &&con)
Creates an LSS 'inquire identity serial-number' request with a completion task.
void Submit(detail::LssRequestBase &req)
Queues an LSS request.
LssFuture< uint8_t > AsyncGetId(ev_exec_t *exec, detail::LssGetIdRequestBase **preq=nullptr)
Queues an asynchronous LSS 'inquire node-ID' request and creates a future which becomes ready once th...
io::CanControllerBase * GetController() const noexcept
Returns the pointer to the CAN controller for this node passed to the constructor (may be a null poin...
typename ::std::enable_if< compat::is_invocable< F, ::std::error_code >::value, detail::LssSetIdRequestWrapper< F > * >::type make_lss_set_id_request(ev_exec_t *exec, uint8_t id, F &&con)
Creates an LSS 'configure node-ID' request with a completion task.
typename ::std::enable_if< compat::is_invocable< F, ::std::error_code, uint32_t >::value, detail::LssGetRevisionRequestWrapper< F > * >::type make_lss_get_revision_request(ev_exec_t *exec, F &&con)
Creates an LSS 'inquire identity revision-number' request with a completion task.
LssFuture< void > AsyncSetBitrate(ev_exec_t *exec, int bitrate, detail::LssSetBitrateRequestBase **preq=nullptr)
Queues an asynchronous LSS 'configure bit timing parameters' request and creates a future which becom...
void sllist_push_front(struct sllist *list, struct slnode *node)
Pushes a node to the front of a singly-linked list.
::std::chrono::milliseconds GetTimeout() const
Returns the timeout when waiting for a slave to respond to an LSS request.
int co_lss_get_timeout(const co_lss_t *lss)
Returns the timeout (in milliseconds) of an LSS master service.
int get_errc(void)
Returns the last (thread-specific) native error code set by a system call or library function.
typename ::std::enable_if< compat::is_invocable< F, ::std::error_code, uint8_t >::value, detail::LssGetIdRequestWrapper< F > * >::type make_lss_get_id_request(ev_exec_t *exec, F &&con)
Creates an LSS 'inquire node-ID' request with a completion task.
void SetTimeout(const ::std::chrono::milliseconds &timeout)
Sets the timeout when waiting for a slave to respond to an LSS request.
::std::size_t AbortAll()
Aborts all pending LSS requests.
Node & GetNode() const noexcept
Returns the CANopen master node.
Future< T, E > get_future() const noexcept
Returns a lely::ev::Future with (a reference to) the same shared state as *this.
virtual void OnSwitchBitrate(int bitrate, ::std::chrono::milliseconds delay, ::std::function< void(::std::error_code ec)> res) noexcept
The function invoked when the master activates the bit rate of all CANopen devices in the network.
struct sllist * sllist_append(struct sllist *dst, struct sllist *src)
Appends the singly-linked list at src to the one at dst.
void co_nmt_lss_req_t(co_nmt_t *nmt, co_lss_t *lss, void *data)
The type of a CANopen LSS request function, invoked by an NMT master before booting the slaves (see F...
typename ::std::enable_if< compat::is_invocable< F, ::std::error_code, LssAddress >::value, detail::LssSlowscanRequestWrapper< F > * >::type make_lss_slowscan_request(ev_exec_t *exec, const LssAddress &lo, const LssAddress &hi, F &&con)
Creates an 'LSS Slowscan' request with a completion task.
int co_lss_id_non_cfg_slave_req(co_lss_t *lss, co_lss_cs_ind_t *ind, void *data)
Requests the 'LSS identify non-configured remote slave' service.
int co_lss_is_idle(const co_lss_t *lss)
Returns 1 if the specified LSS master is idle, and 0 if a request is ongoing.
void unlock() final
Releases the lock held by the execution agent. Throws no exceptions.
int co_lss_get_serial_nr_req(co_lss_t *lss, co_lss_lssid_ind_t *ind, void *data)
Requests the 'inquire identity serial-number' service.
LssFuture< uint32_t > AsyncGetRevision(ev_exec_t *exec, detail::LssGetRevisionRequestBase **preq=nullptr)
Queues an asynchronous LSS 'inquire identity revision-number' request and creates a future which beco...
int co_lss_slowscan_req(co_lss_t *lss, const struct co_id *lo, const struct co_id *hi, co_lss_scan_ind_t *ind, void *data)
Requests the 'LSS Slowscan' service.
typename ::std::enable_if< compat::is_invocable< F, ::std::error_code, uint32_t >::value, detail::LssGetProductCodeRequestWrapper< F > * >::type make_lss_get_product_code_request(ev_exec_t *exec, F &&con)
Creates an LSS 'inquire identity product-code' request with a completion task.
void lock() final
Blocks until a lock can be obtained for the current execution agent (thread, process,...
LssFuture< uint32_t > AsyncGetProductCode(ev_exec_t *exec, detail::LssGetProductCodeRequestBase **preq=nullptr)
Queues an asynchronous LSS 'inquire identity product-code' request and creates a future which becomes...
void set_errc(int errc)
Sets the current (thread-specific) native error code to errc.
int sllist_empty(const struct sllist *list)
Returns 1 if the singly-linked list is empty, and 0 if not.
#define LELY_CO_LSS_TIMEOUT
The default LSS timeout (in milliseconds).
An abstract task executor. This class is a wrapper around #ev_exec_t*.
void unlock() final
Releases the lock held by the execution agent. Throws no exceptions.
size_t ev_task_queue_abort(struct sllist *queue)
Aborts the tasks in queue by invoking ev_exec_on_task_fini() for each of them.
LssFuture< LssAddress > AsyncFastscan(ev_exec_t *exec, const LssAddress &address={0, 0, 0, 0}, const LssAddress &mask={0, 0, 0, 0}, detail::LssFastscanRequestBase **preq=nullptr)
Queues an asynchronous 'LSS Fastscan' request and creates a future which becomes ready once the reque...
A CANopen LSS master/slave service.
co_unsigned16_t co_lss_get_inhibit(const co_lss_t *lss)
Returns the inhibit time (in multiples of 100 microseconds) of an LSS master service.
LssFuture< void > AsyncStore(ev_exec_t *exec, detail::LssStoreRequestBase **preq=nullptr)
Queues an asynchronous LSS 'store configuration' request and creates a future which becomes ready onc...
#define LELY_CO_LSS_INHIBIT
The default LSS inhibit time (in multiples of 100 microseconds).
typename ::std::enable_if< compat::is_invocable< F, ::std::error_code >::value, detail::LssSetBitrateRequestWrapper< F > * >::type make_lss_set_bitrate_request(ev_exec_t *exec, int bitrate, F &&con)
Creates an LSS 'configure bit timing parameters' request with a completion task.
void co_lss_set_timeout(co_lss_t *lss, int timeout)
Sets the timeout of an LSS master service.
void sllist_init(struct sllist *list)
Initializes a singly-linked list.
A CANopen NMT master/slave service.
struct slnode * sllist_pop_front(struct sllist *list)
Pops a node from the front of a singly-linked list.
void SetTime()
Update the CAN network time.
typename ::std::enable_if< compat::is_invocable< F, ::std::error_code, uint32_t >::value, detail::LssGetVendorIdRequestWrapper< F > * >::type make_lss_get_vendor_id_request(ev_exec_t *exec, F &&con)
Creates an LSS 'inquire identity vendor-ID' request with a completion task.
typename ::std::enable_if< compat::is_invocable< F, ::std::error_code, LssAddress >::value, detail::LssFastscanRequestWrapper< F > * >::type make_lss_fastscan_request(ev_exec_t *exec, const LssAddress &address, const LssAddress &mask, F &&con)
Creates an 'LSS Fastscan' request with a completion task.
void co_lss_abort_req(co_lss_t *lss)
Aborts the current LSS master request.
typename ::std::enable_if< compat::is_invocable< F, ::std::error_code >::value, detail::LssStoreRequestWrapper< F > * >::type make_lss_store_request(ev_exec_t *exec, F &&con)
Creates an LSS 'store configuration' request with a completion task.
The base class for CANopen nodes.
LssFuture< uint32_t > AsyncGetSerialNr(ev_exec_t *exec, detail::LssGetSerialNrRequestBase **preq=nullptr)
Queues an asynchronous LSS 'inquire identity serial-number' request and creates a future which become...
LssFuture< void > AsyncSwitchSelective(ev_exec_t *exec, const LssAddress &address, detail::LssSwitchSelectiveRequestBase **preq=nullptr)
Queues an asynchronous LSS 'switch state selective' request and creates a future which becomes ready ...
typename ::std::enable_if< compat::is_invocable< F, ::std::error_code >::value, detail::LssSwitchRequestWrapper< F > * >::type make_lss_switch_request(ev_exec_t *exec, LssState state, F &&con)
Creates an LSS 'switch state global' request with a completion task.
void unlock() final
Releases the lock held by the execution agent. Throws no exceptions.
LssFuture< void > AsyncSwitch(ev_exec_t *exec, LssState state=LssState::WAITING, detail::LssSwitchRequestBase **preq=nullptr)
Queues an asynchronous LSS 'switch state global' request and creates a future which becomes ready onc...
bool Abort(detail::LssRequestBase &req)
Aborts a pending LSS request.
void SetInhibit(const ::std::chrono::microseconds &inhibit)
Sets the inhibit time between successive CAN frames.
LssState
The states of the LSS finite state automaton (FSA) of a slave device.
void co_lss_set_inhibit(co_lss_t *lss, co_unsigned16_t inhibit)
Sets the inhibit time between successive LSS messages of an LSS master service.
A reference to an abstract CAN controller.
::std::size_t CancelAll()
Cancels all pending LSS requests and stops the ongoing request, if any.
typename ::std::enable_if< compat::is_invocable< F, ::std::error_code, bool >::value, detail::LssIdNonConfigRequestWrapper< F > * >::type make_lss_id_non_config_request(ev_exec_t *exec, F &&con)
Creates an LSS 'identify non-configured remote slave' request with a completion task.
int co_lss_set_id_req(co_lss_t *lss, co_unsigned8_t id, co_lss_err_ind_t *ind, void *data)
Requests the 'configure node-ID' service.
void SetTime()
Updates the CAN network time.
void co_nmt_set_lss_req(co_nmt_t *nmt, co_nmt_lss_req_t *ind, void *data)
Sets the request function invoked to perform LSS when booting an NMT master.
int co_lss_switch_sel_req(co_lss_t *lss, const struct co_id *id, co_lss_cs_ind_t *ind, void *data)
Requests the 'switch state selective' service.
int co_lss_get_product_code_req(co_lss_t *lss, co_lss_lssid_ind_t *ind, void *data)
Requests the 'inquire identity product-code' service.
The base class for CANopen LSS masters.
LssFuture< LssAddress > AsyncSlowscan(ev_exec_t *exec, const LssAddress &lo, const LssAddress &hi, detail::LssSlowscanRequestBase **preq=nullptr)
Queues an asynchronous 'LSS Slowscan' request and creates a future which becomes ready once the reque...
A node in a singly-linked list.
::std::error_code make_error_code(SdoErrc e) noexcept
Creates an error code corresponding to an SDO abort code.
int co_lss_get_id_req(co_lss_t *lss, co_lss_nid_ind_t *ind, void *data)
Requests the 'inquire node-ID' service.
int co_lss_fastscan_req(co_lss_t *lss, const struct co_id *id, const struct co_id *mask, co_lss_scan_ind_t *ind, void *data)
Requests the 'LSS Fastscan' service.
void lock() final
Blocks until a lock can be obtained for the current execution agent (thread, process,...
void sllist_push_back(struct sllist *list, struct slnode *node)
Pushes a node to the back of a singly-linked list.
co_lss_t * co_nmt_get_lss(const co_nmt_t *nmt)
Returns a pointer to the LSS master/slave service.
bool set(U &&u)
Satisfies a promise, if it was not aready satisfied, and stores the specified value as the result in ...
int co_lss_get_revision_req(co_lss_t *lss, co_lss_lssid_ind_t *ind, void *data)
Requests the 'inquire identity revision-number' service.
int co_lss_switch_rate_req(co_lss_t *lss, int delay)
Requests the 'activate bit timing parameters' service.
bool Cancel(detail::LssRequestBase &req)
Cancels a pending LSS request.
The 128-bit number uniquely identifying each CANopen node.
int co_lss_get_vendor_id_req(co_lss_t *lss, co_lss_lssid_ind_t *ind, void *data)
Requests the 'inquire identity vendor-ID' service.
int co_nmt_lss_con(co_nmt_t *nmt)
Confirms the completion of the process when booting an NMT master.
typename ::std::enable_if< compat::is_invocable< F, ::std::error_code >::value, detail::LssSwitchSelectiveRequestWrapper< F > * >::type make_lss_switch_selective_request(ev_exec_t *exec, const LssAddress &address, F &&con)
Creates an LSS 'switch state selective' request with a completion task.