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};
119LssSwitchRequestBase::OnRequest(
void* data)
noexcept {
120 static_cast<LssMaster::Impl_*
>(data)->OnSwitch(*
this);
124LssSwitchSelectiveRequestBase::OnRequest(
void* data)
noexcept {
125 static_cast<LssMaster::Impl_*
>(data)->OnSwitchSelective(*
this);
129LssSetIdRequestBase::OnRequest(
void* data)
noexcept {
130 static_cast<LssMaster::Impl_*
>(data)->OnSetId(*
this);
134LssSetBitrateRequestBase::OnRequest(
void* data)
noexcept {
135 static_cast<LssMaster::Impl_*
>(data)->OnSetBitrate(*
this);
139LssSwitchBitrateRequestBase::OnRequest(
void* data)
noexcept {
140 static_cast<LssMaster::Impl_*
>(data)->OnSwitchBitrate(*
this);
144LssStoreRequestBase::OnRequest(
void* data)
noexcept {
145 static_cast<LssMaster::Impl_*
>(data)->OnStore(*
this);
149LssGetVendorIdRequestBase::OnRequest(
void* data)
noexcept {
150 static_cast<LssMaster::Impl_*
>(data)->OnGetVendorId(*
this);
154LssGetProductCodeRequestBase::OnRequest(
void* data)
noexcept {
155 static_cast<LssMaster::Impl_*
>(data)->OnGetProductCode(*
this);
159LssGetRevisionRequestBase::OnRequest(
void* data)
noexcept {
160 static_cast<LssMaster::Impl_*
>(data)->OnGetRevision(*
this);
164LssGetSerialNrRequestBase::OnRequest(
void* data)
noexcept {
165 static_cast<LssMaster::Impl_*
>(data)->OnGetSerialNr(*
this);
169LssGetIdRequestBase::OnRequest(
void* data)
noexcept {
170 static_cast<LssMaster::Impl_*
>(data)->OnGetId(*
this);
174LssIdNonConfigRequestBase::OnRequest(
void* data)
noexcept {
175 static_cast<LssMaster::Impl_*
>(data)->OnIdNonConfig(*
this);
179LssSlowscanRequestBase::OnRequest(
void* data)
noexcept {
180 static_cast<LssMaster::Impl_*
>(data)->OnSlowscan(*
this);
184LssFastscanRequestBase::OnRequest(
void* data)
noexcept {
185 static_cast<LssMaster::Impl_*
>(data)->OnFastscan(*
this);
191 : impl_(
new Impl_(this, exec, node, ctrl, node.nmt())) {}
193LssMaster::~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"))
262 return p.get_future();
270 exec, address, [p](::std::error_code ec)
mutable {
271 p.set(ec ? ::std::make_exception_ptr(
272 ::std::system_error(ec,
"AsyncSwitchSelective"))
277 return p.get_future();
286 p.set(ec ? ::std::make_exception_ptr(
287 ::std::system_error(ec,
"AsyncSetId"))
292 return p.get_future();
300 exec, bitrate, [p](::std::error_code ec)
mutable {
301 p.set(ec ? ::std::make_exception_ptr(
302 ::std::system_error(ec,
"AsyncSetBitrate"))
307 return p.get_future();
314 p.set(ec ? ::std::make_exception_ptr(::std::system_error(ec,
"AsyncStore"))
319 return p.get_future();
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));
336 return p.get_future();
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));
353 return p.get_future();
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));
370 return p.get_future();
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));
387 return p.get_future();
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));
403 return p.get_future();
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));
420 return p.get_future();
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));
439 return p.get_future();
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));
458 return p.get_future();
463 ::std::lock_guard<util::BasicLockable>
lock(*
this);
469 auto ec = ::std::make_error_code(::std::errc::operation_canceled);
470 ::std::lock_guard<Impl_>
lock(*impl_);
471 return impl_->Cancel(&req, ec) != 0;
476 auto ec = ::std::make_error_code(::std::errc::operation_canceled);
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) {
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);
607LssMaster::Impl_::Submit(detail::LssRequestBase& req) {
608 if (!req.exec) req.exec = self->GetExecutor();
609 auto exec = req.GetExecutor();
614 if (first) OnRequest(req);
618LssMaster::Impl_::Cancel(detail::LssRequestBase* req, ::std::error_code ec) {
633 auto exec = req->GetExecutor();
637 n += n < ::std::numeric_limits<::std::size_t>::max();
643LssMaster::Impl_::Abort(detail::LssRequestBase* req) {
654LssMaster::Impl_::Pop(detail::LssRequestBase* req,
sllist& queue) {
671 return req !=
nullptr;
675LssMaster::Impl_::OnSwitch(detail::LssSwitchRequestBase& req)
noexcept {
681 ::std::error_code ec;
685 req.ec = util::make_error_code();
692LssMaster::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);
711 req.ec = util::make_error_code();
719LssMaster::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);
735 req.ec = util::make_error_code();
743LssMaster::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);
768 req.ec = util::make_error_code();
771 bitrate = req.bitrate;
774 req.ec = ::std::make_error_code(::std::errc::invalid_argument);
783LssMaster::Impl_::OnSwitchBitrate(
784 detail::LssSwitchBitrateRequestBase& req)
noexcept {
793 if (!bitrate || req.delay < 0 ||
794 req.delay > ::std::numeric_limits<uint16_t>::max()) {
795 req.ec = ::std::make_error_code(::std::errc::invalid_argument);
798 req.ec = util::make_error_code();
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);
823LssMaster::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);
839 req.ec = util::make_error_code();
847LssMaster::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);
864 req.ec = util::make_error_code();
872LssMaster::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);
889 req.ec = util::make_error_code();
897LssMaster::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);
914 req.ec = util::make_error_code();
922LssMaster::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);
939 req.ec = util::make_error_code();
947LssMaster::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);
963 req.ec = util::make_error_code();
971LssMaster::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);
987 req.ec = util::make_error_code();
995LssMaster::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);
1016 req.ec = util::make_error_code();
1024LssMaster::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);
1044 req.ec = util::make_error_code();
1052LssMaster::Impl_::OnCsInd(
co_lss_t*, uint8_t cs)
noexcept {
1055 auto req =
static_cast<detail::LssSwitchRequestBase*
>(task);
1060 req->ec = ::std::make_error_code(::std::errc::timed_out);
1066LssMaster::Impl_::OnErrInd(
co_lss_t*, uint8_t cs, uint8_t err,
1070 auto req =
static_cast<detail::LssRequestBase*
>(task);
1072 req->ec = ::std::make_error_code(::std::errc::protocol_error);
1075 req->ec = ::std::make_error_code(::std::errc::timed_out);
1083 req->ec = ::std::make_error_code(::std::errc::result_out_of_range);
1093 req->ec = ::std::make_error_code(::std::errc::invalid_argument);
1104 ::std::make_error_code(::std::errc::operation_not_supported);
1107 req->ec = ::std::make_error_code(::std::errc::io_error);
1117LssMaster::Impl_::OnLssIdInd(
co_lss_t*, uint8_t cs,
1118 co_unsigned32_t
id)
noexcept {
1121 auto req =
static_cast<detail::LssGetNumberRequestBase*
>(task);
1127 req->ec = ::std::make_error_code(::std::errc::timed_out);
1134LssMaster::Impl_::OnNidInd(
co_lss_t*, uint8_t cs, uint8_t
id)
noexcept {
1137 auto req =
static_cast<detail::LssGetIdRequestBase*
>(task);
1143 req->ec = ::std::make_error_code(::std::errc::timed_out);
1150LssMaster::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;
1163 req->ec = ::std::make_error_code(::std::errc::timed_out);
1170LssMaster::Impl_::OnRequest(detail::LssRequestBase& req)
noexcept {
1172 req.OnRequest(
this);
1174 req.ec = ::std::make_error_code(::std::errc::operation_not_permitted);
1180LssMaster::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));
The base class for CANopen LSS masters.
bool Abort(detail::LssRequestBase &req)
Aborts a pending LSS request.
ev::Executor GetExecutor() const noexcept
Returns the default executor used to execute completion tasks of LSS requests.
LssMaster(ev_exec_t *exec, Node &node, io::CanControllerBase *ctrl=nullptr)
Creates a new CANopen LSS master.
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...
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...
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...
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...
Node & GetNode() const noexcept
Returns the CANopen master node.
void SetTime()
Update the CAN network time.
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 ...
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...
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...
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...
bool Cancel(detail::LssRequestBase &req)
Cancels a pending LSS request.
::std::size_t AbortAll()
Aborts all pending LSS requests.
void Submit(detail::LssRequestBase &req)
Queues an LSS request.
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...
void lock() final
Blocks until a lock can be obtained for the current execution agent (thread, process,...
void SetTimeout(const ::std::chrono::milliseconds &timeout)
Sets the timeout when waiting for a slave to respond to an LSS request.
::std::chrono::microseconds GetInhibit() const
Returns the inhibit time between successive CAN frames.
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.
void unlock() final
Releases the lock held by the execution agent. Throws no exceptions.
void SetInhibit(const ::std::chrono::microseconds &inhibit)
Sets the inhibit time between successive CAN frames.
::std::chrono::milliseconds GetTimeout() const
Returns the timeout when waiting for a slave to respond to an LSS request.
io::CanControllerBase * GetController() const noexcept
Returns the pointer to the CAN controller for this node passed to the constructor (may be a null poin...
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...
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 ...
::std::size_t CancelAll()
Cancels all pending LSS requests and stops the ongoing request, if any.
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...
The base class for CANopen nodes.
void SetTime()
Updates the CAN network time.
An abstract task executor. This class is a wrapper around #ev_exec_t*.
A reference to an abstract CAN controller.
void unlock() final
Releases the lock held by the execution agent. Throws no exceptions.
void lock() final
Blocks until a lock can be obtained for the current execution agent (thread, process,...
An abstract interface conforming to the BasicLockable concept.
This is the internal header file of the C++ CANopen application library.
int get_errc(void)
Returns the last (thread-specific) native error code set by a system call or library function.
void set_errc(int errc)
Sets the current (thread-specific) native error code to errc.
const struct ev_exec_vtbl *const ev_exec_t
An abstract task executor.
This header file is part of the CANopen library; it contains the Layer Setting Services (LSS) and pro...
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_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 co_lss_set_timeout(co_lss_t *lss, int timeout)
Sets the timeout of an LSS master 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.
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.
int co_lss_switch_rate_req(co_lss_t *lss, int delay)
Requests the 'activate bit timing parameters' service.
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_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_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_switch_req(co_lss_t *lss, co_unsigned8_t mode)
Requests the 'switch state global' service.
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_is_idle(const co_lss_t *lss)
Returns 1 if the specified LSS master is idle, and 0 if a request is ongoing.
int co_lss_get_timeout(const co_lss_t *lss)
Returns the timeout (in milliseconds) of an LSS master service.
#define LELY_CO_LSS_INHIBIT
The default LSS inhibit time (in multiples of 100 microseconds).
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.
int co_lss_store_req(co_lss_t *lss, co_lss_err_ind_t *ind, void *data)
Requests the 'store configuration' service.
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.
#define LELY_CO_LSS_TIMEOUT
The default LSS timeout (in milliseconds).
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.
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.
void co_lss_abort_req(co_lss_t *lss)
Aborts the current LSS master request.
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.
This header file is part of the C++ CANopen application library; it contains the CANopen Layer Settin...
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.
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.
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.
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.
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.
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.
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.
LssState
The states of the LSS finite state automaton (FSA) of a slave device.
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.
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.
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, 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.
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.
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.
This header file is part of the CANopen library; it contains the network management (NMT) declaration...
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...
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.
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.
co_lss_t * co_nmt_get_lss(const co_nmt_t *nmt)
Returns a pointer to the LSS master/slave service.
int co_nmt_lss_con(co_nmt_t *nmt)
Confirms the completion of the process when booting an NMT master.
void sllist_init(struct sllist *list)
Initializes a singly-linked list.
struct sllist * sllist_append(struct sllist *dst, struct sllist *src)
Appends the singly-linked list at src to the one at dst.
void sllist_push_front(struct sllist *list, struct slnode *node)
Pushes a node to the front of a singly-linked list.
struct slnode * sllist_remove(struct sllist *list, struct slnode *node)
Removes a node from a singly-linked list.
void sllist_push_back(struct sllist *list, struct slnode *node)
Pushes a node to the back of a singly-linked list.
int sllist_empty(const struct sllist *list)
Returns 1 if the singly-linked list is empty, and 0 if not.
struct slnode * sllist_pop_front(struct sllist *list)
Pops a node from the front of a singly-linked list.
struct slnode * sllist_first(const struct sllist *list)
Returns a pointer to the first node in a singly-linked list.
A CANopen LSS master/slave service.
A CANopen NMT master/slave service.
The 128-bit number uniquely identifying each CANopen node.
void lock() final
Blocks until a lock can be obtained for the current execution agent (thread, process,...
void unlock() final
Releases the lock held by the execution agent. Throws no exceptions.
A node in a singly-linked list.
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.
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.