Lely core libraries 2.3.4
lss_master.hpp
Go to the documentation of this file.
1
24#ifndef LELY_COAPP_LSS_MASTER_HPP_
25#define LELY_COAPP_LSS_MASTER_HPP_
26
27#include <lely/coapp/node.hpp>
30
31#include <chrono>
32#include <memory>
33#include <utility>
34
35namespace lely {
36
37namespace canopen {
38
45template <class T>
47
54template <class T>
56
78
80enum class LssState {
82 WAITING = 0,
87 CONFIG = 1
88};
89
90class LssMaster;
91
92namespace detail {
93
94class LssRequestBase : public ev_task {
95 friend class canopen::LssMaster;
96
97 public:
99 : ev_task EV_TASK_INIT(exec, [](ev_task* task) noexcept {
100 (*static_cast<LssRequestBase*>(task))();
101 }) {}
102
103 LssRequestBase(const LssRequestBase&) = delete;
104 LssRequestBase& operator=(const LssRequestBase&) = delete;
105
106 virtual ~LssRequestBase() = default;
107
113
115 ::std::error_code ec{};
116
117 private:
118 virtual void operator()() noexcept = 0;
119
120 virtual void OnRequest(void* data) noexcept = 0;
121};
122
124 public:
125 using LssRequestBase::LssRequestBase;
126
129
130 private:
131 void OnRequest(void* data) noexcept final;
132};
133
135 public:
136 using LssRequestBase::LssRequestBase;
137
142 LssAddress address{0, 0, 0, 0};
143
144 private:
145 void OnRequest(void* data) noexcept final;
146};
147
149 public:
150 using LssRequestBase::LssRequestBase;
151
153 uint8_t id{0};
154
155 private:
156 void OnRequest(void* data) noexcept final;
157};
158
160 public:
161 using LssRequestBase::LssRequestBase;
162
164 int bitrate{0};
165
166 private:
167 void OnRequest(void* data) noexcept final;
168};
169
171 public:
172 using LssRequestBase::LssRequestBase;
173
178 int delay{0};
179
180 private:
181 void OnRequest(void* data) noexcept final;
182};
183
185 public:
186 using LssRequestBase::LssRequestBase;
187
188 private:
189 void OnRequest(void* data) noexcept final;
190};
191
193 public:
194 using LssRequestBase::LssRequestBase;
195
197 uint32_t number{0};
198};
199
201 public:
202 using LssGetNumberRequestBase::LssGetNumberRequestBase;
203
204 private:
205 void OnRequest(void* data) noexcept final;
206};
207
209 public:
210 using LssGetNumberRequestBase::LssGetNumberRequestBase;
211
212 private:
213 void OnRequest(void* data) noexcept final;
214};
215
217 public:
218 using LssGetNumberRequestBase::LssGetNumberRequestBase;
219
220 private:
221 void OnRequest(void* data) noexcept final;
222};
223
225 public:
226 using LssGetNumberRequestBase::LssGetNumberRequestBase;
227
228 private:
229 void OnRequest(void* data) noexcept final;
230};
231
233 public:
234 using LssRequestBase::LssRequestBase;
235
237 uint8_t id{0};
238
239 private:
240 void OnRequest(void* data) noexcept final;
241};
242
244 public:
245 using LssRequestBase::LssRequestBase;
246
247 private:
248 void OnRequest(void* data) noexcept final;
249};
250
252 public:
253 using LssRequestBase::LssRequestBase;
254
259 LssAddress address{0, 0, 0, 0};
260};
261
263 public:
264 using LssScanRequestBase::LssScanRequestBase;
265
267 LssAddress lo{0, 0, 0, 0};
272 LssAddress hi{0, 0, 0, 0};
273
274 private:
275 void OnRequest(void* data) noexcept final;
276};
277
279 public:
280 using LssScanRequestBase::LssScanRequestBase;
281
287 LssAddress mask{0, 0, 0, 0};
288
289 private:
290 void OnRequest(void* data) noexcept final;
291};
292
293} // namespace detail
294
297 public:
306 using Signature = void(::std::error_code ec);
307
313 template <class F>
314 explicit LssSwitchRequest(ev_exec_t* exec, F&& con)
315 : detail::LssSwitchRequestBase(exec), con_(::std::forward<F>(con)) {}
316
318 template <class F>
319 explicit LssSwitchRequest(F&& con)
320 : LssSwitchRequest(nullptr, ::std::forward<F>(con)) {}
321
322 private:
323 void
324 operator()() noexcept final {
325 if (con_) con_(ec);
326 }
327
328 ::std::function<Signature> con_;
329};
330
333 public:
342 using Signature = void(::std::error_code ec);
343
349 template <class F>
350 explicit LssSwitchSelectiveRequest(ev_exec_t* exec, F&& con)
351 : detail::LssSwitchSelectiveRequestBase(exec),
352 con_(::std::forward<F>(con)) {}
353
355 template <class F>
358
359 private:
360 void
361 operator()() noexcept final {
362 if (con_) con_(ec);
363 }
364
365 ::std::function<Signature> con_;
366};
367
370 public:
379 using Signature = void(::std::error_code ec);
380
386 template <class F>
387 explicit LssSetIdRequest(ev_exec_t* exec, F&& con)
388 : detail::LssSetIdRequestBase(exec), con_(::std::forward<F>(con)) {}
389
391 template <class F>
392 explicit LssSetIdRequest(F&& con)
393 : LssSetIdRequest(nullptr, ::std::forward<F>(con)) {}
394
395 private:
396 void
397 operator()() noexcept final {
398 if (con_) con_(ec);
399 }
400
401 ::std::function<Signature> con_;
402};
403
406 public:
415 using Signature = void(::std::error_code ec);
416
422 template <class F>
423 explicit LssSetBitrateRequest(ev_exec_t* exec, F&& con)
424 : detail::LssSetBitrateRequestBase(exec), con_(::std::forward<F>(con)) {}
425
427 template <class F>
428 explicit LssSetBitrateRequest(F&& con)
430
431 private:
432 void
433 operator()() noexcept final {
434 if (con_) con_(ec);
435 }
436
437 ::std::function<Signature> con_;
438};
439
442 public:
451 using Signature = void(::std::error_code ec);
452
458 template <class F>
459 explicit LssSwitchBitrateRequest(ev_exec_t* exec, F&& con)
460 : detail::LssSwitchBitrateRequestBase(exec),
461 con_(::std::forward<F>(con)) {}
462
464 template <class F>
467
468 private:
469 void
470 operator()() noexcept final {
471 if (con_) con_(ec);
472 }
473
474 ::std::function<Signature> con_;
475};
476
479 public:
488 using Signature = void(::std::error_code ec);
489
494 template <class F>
495 explicit LssStoreRequest(ev_exec_t* exec, F&& con)
496 : detail::LssStoreRequestBase(exec), con_(::std::forward<F>(con)) {}
497
499 template <class F>
500 explicit LssStoreRequest(F&& con)
501 : LssStoreRequest(nullptr, ::std::forward<F>(con)) {}
502
503 private:
504 void
505 operator()() noexcept final {
506 if (con_) con_(ec);
507 }
508
509 ::std::function<Signature> con_;
510};
511
514 public:
525 using Signature = void(::std::error_code ec, uint32_t number);
526
531 template <class F>
532 explicit LssGetVendorIdRequest(ev_exec_t* exec, F&& con)
533 : detail::LssGetVendorIdRequestBase(exec), con_(::std::forward<F>(con)) {}
534
536 template <class F>
537 explicit LssGetVendorIdRequest(F&& con)
539
540 private:
541 void
542 operator()() noexcept final {
543 if (con_) con_(ec, number);
544 }
545
546 ::std::function<Signature> con_;
547};
548
551 public:
562 using Signature = void(::std::error_code ec, uint32_t number);
563
568 template <class F>
569 explicit LssGetProductCodeRequest(ev_exec_t* exec, F&& con)
570 : detail::LssGetProductCodeRequestBase(exec),
571 con_(::std::forward<F>(con)) {}
572
574 template <class F>
577
578 private:
579 void
580 operator()() noexcept final {
581 if (con_) con_(ec, number);
582 }
583
584 ::std::function<Signature> con_;
585};
586
589 public:
600 using Signature = void(::std::error_code ec, uint32_t number);
601
606 template <class F>
607 explicit LssGetRevisionRequest(ev_exec_t* exec, F&& con)
608 : detail::LssGetRevisionRequestBase(exec), con_(::std::forward<F>(con)) {}
609
611 template <class F>
612 explicit LssGetRevisionRequest(F&& con)
614
615 private:
616 void
617 operator()() noexcept final {
618 if (con_) con_(ec, number);
619 }
620
621 ::std::function<Signature> con_;
622};
623
626 public:
637 using Signature = void(::std::error_code ec, uint32_t number);
638
643 template <class F>
644 explicit LssGetSerialNrRequest(ev_exec_t* exec, F&& con)
645 : detail::LssGetSerialNrRequestBase(exec), con_(::std::forward<F>(con)) {}
646
648 template <class F>
649 explicit LssGetSerialNrRequest(F&& con)
651
652 private:
653 void
654 operator()() noexcept final {
655 if (con_) con_(ec, number);
656 }
657
658 ::std::function<Signature> con_;
659};
660
663 public:
673 using Signature = void(::std::error_code ec, uint8_t id);
674
679 template <class F>
680 explicit LssGetIdRequest(ev_exec_t* exec, F&& con)
681 : detail::LssGetIdRequestBase(exec), con_(::std::forward<F>(con)) {}
682
684 template <class F>
685 explicit LssGetIdRequest(F&& con)
686 : LssGetIdRequest(nullptr, ::std::forward<F>(con)) {}
687
688 private:
689 void
690 operator()() noexcept final {
691 if (con_) con_(ec, id);
692 }
693
694 ::std::function<Signature> con_;
695};
696
699 public:
710 using Signature = void(::std::error_code ec, bool found);
711
716 template <class F>
717 explicit LssIdNonConfigRequest(ev_exec_t* exec, F&& con)
718 : detail::LssStoreRequestBase(exec), con_(::std::forward<F>(con)) {}
719
721 template <class F>
722 explicit LssIdNonConfigRequest(F&& con)
724
725 private:
726 void
727 operator()() noexcept final {
728 bool found = !ec;
729 // A timeout means no slave was found, but is otherwise not an error.
730 if (ec == ::std::errc::timed_out) ec.clear();
731 if (con_) con_(ec, found);
732 }
733
734 ::std::function<Signature> con_;
735};
736
739 public:
749 using Signature = void(::std::error_code ec, LssAddress address);
750
756 template <class F>
757 explicit LssSlowscanRequest(ev_exec_t* exec, F&& con)
758 : detail::LssSlowscanRequestBase(exec), con_(::std::forward<F>(con)) {}
759
761 template <class F>
762 explicit LssSlowscanRequest(F&& con)
763 : LssSlowscanRequest(nullptr, ::std::forward<F>(con)) {}
764
765 private:
766 void
767 operator()() noexcept final {
768 if (con_) con_(ec, address);
769 }
770
771 ::std::function<Signature> con_;
772};
773
776 public:
786 using Signature = void(::std::error_code ec, LssAddress address);
787
794 template <class F>
795 explicit LssFastscanRequest(ev_exec_t* exec, F&& con)
796 : detail::LssFastscanRequestBase(exec), con_(::std::forward<F>(con)) {}
797
799 template <class F>
800 explicit LssFastscanRequest(F&& con)
801 : LssFastscanRequest(nullptr, ::std::forward<F>(con)) {}
802
803 private:
804 void
805 operator()() noexcept final {
806 if (con_) con_(ec, address);
807 }
808
809 ::std::function<Signature> con_;
810};
811
812namespace detail {
813
814template <class F>
815class LssSwitchRequestWrapper : public LssSwitchRequestBase {
816 public:
817 explicit LssSwitchRequestWrapper(ev_exec_t* exec, LssState state, F&& con)
818 : LssSwitchRequestBase(exec), con_(::std::forward<F>(con)) {
819 this->state = state;
820 }
821
822 private:
823 void
824 operator()() noexcept final {
825 compat::invoke(::std::move(con_), ec);
826 delete this;
827 }
828
829 typename ::std::decay<F>::type con_;
830};
831
832template <class F>
833class LssSwitchSelectiveRequestWrapper : public LssSwitchSelectiveRequestBase {
834 public:
835 explicit LssSwitchSelectiveRequestWrapper(ev_exec_t* exec,
836 const LssAddress& address, F&& con)
837 : LssSwitchSelectiveRequestBase(exec), con_(::std::forward<F>(con)) {
838 this->address = address;
839 }
840
841 private:
842 void
843 operator()() noexcept final {
844 compat::invoke(::std::move(con_), ec);
845 delete this;
846 }
847
848 typename ::std::decay<F>::type con_;
849};
850
851template <class F>
852class LssSetIdRequestWrapper : public LssSetIdRequestBase {
853 public:
854 explicit LssSetIdRequestWrapper(ev_exec_t* exec, uint8_t id, F&& con)
855 : LssSetIdRequestBase(exec), con_(::std::forward<F>(con)) {
856 this->id = id;
857 }
858
859 private:
860 void
861 operator()() noexcept final {
862 compat::invoke(::std::move(con_), ec);
863 delete this;
864 }
865
866 typename ::std::decay<F>::type con_;
867};
868
869template <class F>
870class LssSetBitrateRequestWrapper : public LssSetBitrateRequestBase {
871 public:
872 explicit LssSetBitrateRequestWrapper(ev_exec_t* exec, int bitrate, F&& con)
873 : LssSetBitrateRequestBase(exec), con_(::std::forward<F>(con)) {
874 this->bitrate = bitrate;
875 }
876
877 private:
878 void
879 operator()() noexcept final {
880 compat::invoke(::std::move(con_), ec);
881 delete this;
882 }
883
884 typename ::std::decay<F>::type con_;
885};
886
887template <class F>
888class LssSwitchBitrateRequestWrapper : public LssSwitchBitrateRequestBase {
889 public:
890 explicit LssSwitchBitrateRequestWrapper(ev_exec_t* exec, int delay, F&& con)
891 : LssSwitchBitrateRequestBase(exec), con_(::std::forward<F>(con)) {
892 this->delay = delay;
893 }
894
895 private:
896 void
897 operator()() noexcept final {
898 compat::invoke(::std::move(con_), ec);
899 delete this;
900 }
901
902 typename ::std::decay<F>::type con_;
903};
904
905template <class F>
906class LssStoreRequestWrapper : public LssStoreRequestBase {
907 public:
908 explicit LssStoreRequestWrapper(ev_exec_t* exec, F&& con)
909 : LssStoreRequestBase(exec), con_(::std::forward<F>(con)) {}
910
911 private:
912 void
913 operator()() noexcept final {
914 compat::invoke(::std::move(con_), ec);
915 delete this;
916 }
917
918 typename ::std::decay<F>::type con_;
919};
920
921template <class F>
922class LssGetVendorIdRequestWrapper : public LssGetVendorIdRequestBase {
923 public:
924 explicit LssGetVendorIdRequestWrapper(ev_exec_t* exec, F&& con)
925 : LssGetVendorIdRequestBase(exec), con_(::std::forward<F>(con)) {}
926
927 private:
928 void
929 operator()() noexcept final {
930 compat::invoke(::std::move(con_), ec, number);
931 delete this;
932 }
933
934 typename ::std::decay<F>::type con_;
935};
936
937template <class F>
938class LssGetProductCodeRequestWrapper : public LssGetProductCodeRequestBase {
939 public:
940 explicit LssGetProductCodeRequestWrapper(ev_exec_t* exec, F&& con)
941 : LssGetProductCodeRequestBase(exec), con_(::std::forward<F>(con)) {}
942
943 private:
944 void
945 operator()() noexcept final {
946 compat::invoke(::std::move(con_), ec, number);
947 delete this;
948 }
949
950 typename ::std::decay<F>::type con_;
951};
952
953template <class F>
954class LssGetRevisionRequestWrapper : public LssGetRevisionRequestBase {
955 public:
956 explicit LssGetRevisionRequestWrapper(ev_exec_t* exec, F&& con)
957 : LssGetRevisionRequestBase(exec), con_(::std::forward<F>(con)) {}
958
959 private:
960 void
961 operator()() noexcept final {
962 compat::invoke(::std::move(con_), ec, number);
963 delete this;
964 }
965
966 typename ::std::decay<F>::type con_;
967};
968
969template <class F>
970class LssGetSerialNrRequestWrapper : public LssGetSerialNrRequestBase {
971 public:
972 explicit LssGetSerialNrRequestWrapper(ev_exec_t* exec, F&& con)
973 : LssGetSerialNrRequestBase(exec), con_(::std::forward<F>(con)) {}
974
975 private:
976 void
977 operator()() noexcept final {
978 compat::invoke(::std::move(con_), ec, number);
979 delete this;
980 }
981
982 typename ::std::decay<F>::type con_;
983};
984
985template <class F>
986class LssGetIdRequestWrapper : public LssGetIdRequestBase {
987 public:
988 explicit LssGetIdRequestWrapper(ev_exec_t* exec, F&& con)
989 : LssGetIdRequestBase(exec), con_(::std::forward<F>(con)) {}
990
991 private:
992 void
993 operator()() noexcept final {
994 compat::invoke(::std::move(con_), ec, id);
995 delete this;
996 }
997
998 typename ::std::decay<F>::type con_;
999};
1000
1001template <class F>
1002class LssIdNonConfigRequestWrapper : public LssIdNonConfigRequestBase {
1003 public:
1004 explicit LssIdNonConfigRequestWrapper(ev_exec_t* exec, F&& con)
1005 : LssIdNonConfigRequestBase(exec), con_(::std::forward<F>(con)) {}
1006
1007 private:
1008 void
1009 operator()() noexcept final {
1010 bool found = !ec;
1011 // A timeout means no slave was found, but is otherwise not an error.
1012 if (ec == ::std::errc::timed_out) ec.clear();
1013 compat::invoke(::std::move(con_), ec, found);
1014 delete this;
1015 }
1016
1017 typename ::std::decay<F>::type con_;
1018};
1019
1020template <class F>
1021class LssSlowscanRequestWrapper : public LssSlowscanRequestBase {
1022 public:
1023 explicit LssSlowscanRequestWrapper(ev_exec_t* exec, const LssAddress& lo,
1024 const LssAddress& hi, F&& con)
1025 : LssSlowscanRequestBase(exec), con_(::std::forward<F>(con)) {
1026 this->lo = lo;
1027 this->hi = hi;
1028 }
1029
1030 private:
1031 void
1032 operator()() noexcept final {
1033 compat::invoke(::std::move(con_), ec, address);
1034 delete this;
1035 }
1036
1037 typename ::std::decay<F>::type con_;
1038};
1039
1040template <class F>
1041class LssFastscanRequestWrapper : public LssFastscanRequestBase {
1042 public:
1043 explicit LssFastscanRequestWrapper(ev_exec_t* exec, const LssAddress& address,
1044 const LssAddress& mask, F&& con)
1045 : LssFastscanRequestBase(exec), con_(::std::forward<F>(con)) {
1046 this->address = address;
1047 this->mask = mask;
1048 }
1049
1050 private:
1051 void
1052 operator()() noexcept final {
1053 compat::invoke(::std::move(con_), ec, address);
1054 delete this;
1055 }
1056
1057 typename ::std::decay<F>::type con_;
1058};
1059
1060} // namespace detail
1061
1072template <class F>
1073// clang-format off
1074inline typename ::std::enable_if<
1075 compat::is_invocable<F, ::std::error_code>::value,
1076 detail::LssSwitchRequestWrapper<F>*>::type
1078 // clang-format on
1079 return new detail::LssSwitchRequestWrapper<F>(exec, state,
1080 ::std::forward<F>(con));
1081}
1082
1094template <class F>
1095inline typename ::std::enable_if<
1097 detail::LssSwitchSelectiveRequestWrapper<F>*>::type
1099 F&& con) {
1100 return new detail::LssSwitchSelectiveRequestWrapper<F>(
1101 exec, address, ::std::forward<F>(con));
1102}
1103
1114template <class F>
1115// clang-format off
1116inline typename ::std::enable_if<
1118 detail::LssSetIdRequestWrapper<F>*>::type
1120 // clang-format on
1121 return new detail::LssSetIdRequestWrapper<F>(exec, id,
1122 ::std::forward<F>(con));
1123}
1124
1136template <class F>
1137// clang-format off
1138inline typename ::std::enable_if<
1140 detail::LssSetBitrateRequestWrapper<F>*>::type
1141make_lss_set_bitrate_request(ev_exec_t* exec, int bitrate, F&& con) {
1142 // clang-format on
1143 return new detail::LssSetBitrateRequestWrapper<F>(exec, bitrate,
1144 ::std::forward<F>(con));
1145}
1146
1158template <class F>
1159// clang-format off
1160inline typename ::std::enable_if<
1162 detail::LssSwitchBitrateRequestWrapper<F>*>::type
1164 // clang-format on
1165 return new detail::LssSwitchBitrateRequestWrapper<F>(exec, delay,
1166 ::std::forward<F>(con));
1167}
1168
1178template <class F>
1179// clang-format off
1180inline typename ::std::enable_if<
1182 detail::LssStoreRequestWrapper<F>*>::type
1184 // clang-format on
1185 return new detail::LssStoreRequestWrapper<F>(exec, ::std::forward<F>(con));
1186}
1187
1197template <class F>
1198inline typename ::std::enable_if<
1200 detail::LssGetVendorIdRequestWrapper<F>*>::type
1202 return new detail::LssGetVendorIdRequestWrapper<F>(exec,
1203 ::std::forward<F>(con));
1204}
1205
1215template <class F>
1216inline typename ::std::enable_if<
1218 detail::LssGetProductCodeRequestWrapper<F>*>::type
1220 return new detail::LssGetProductCodeRequestWrapper<F>(exec,
1221 ::std::forward<F>(con));
1222}
1223
1233template <class F>
1234inline typename ::std::enable_if<
1236 detail::LssGetRevisionRequestWrapper<F>*>::type
1238 return new detail::LssGetRevisionRequestWrapper<F>(exec,
1239 ::std::forward<F>(con));
1240}
1241
1251template <class F>
1252inline typename ::std::enable_if<
1254 detail::LssGetSerialNrRequestWrapper<F>*>::type
1256 return new detail::LssGetSerialNrRequestWrapper<F>(exec,
1257 ::std::forward<F>(con));
1258}
1259
1269template <class F>
1270inline typename ::std::enable_if<
1272 detail::LssGetIdRequestWrapper<F>*>::type
1274 return new detail::LssGetIdRequestWrapper<F>(exec, ::std::forward<F>(con));
1275}
1276
1286template <class F>
1287// clang-format off
1288inline typename ::std::enable_if<
1290 detail::LssIdNonConfigRequestWrapper<F>*>::type
1292 // clang-format on
1293 return new detail::LssIdNonConfigRequestWrapper<F>(exec,
1294 ::std::forward<F>(con));
1295}
1296
1309template <class F>
1310inline typename ::std::enable_if<
1312 detail::LssSlowscanRequestWrapper<F>*>::type
1314 const LssAddress& hi, F&& con) {
1315 return new detail::LssSlowscanRequestWrapper<F>(exec, lo, hi,
1316 ::std::forward<F>(con));
1317}
1318
1334template <class F>
1335inline typename ::std::enable_if<
1337 detail::LssFastscanRequestWrapper<F>*>::type
1339 const LssAddress& mask, F&& con) {
1340 return new detail::LssFastscanRequestWrapper<F>(exec, address, mask,
1341 ::std::forward<F>(con));
1342}
1343
1351 friend class detail::LssSwitchRequestBase;
1353 friend class detail::LssSetIdRequestBase;
1356 friend class detail::LssStoreRequestBase;
1361 friend class detail::LssGetIdRequestBase;
1363 friend class detail::LssSlowscanRequestBase;
1364 friend class detail::LssFastscanRequestBase;
1365
1366 public:
1376 explicit LssMaster(ev_exec_t* exec, Node& node,
1377 io::CanControllerBase* ctrl = nullptr);
1378
1380 explicit LssMaster(Node& node, io::CanControllerBase* ctrl = nullptr)
1381 : LssMaster(nullptr, node, ctrl) {}
1382
1383 LssMaster(const LssMaster&) = delete;
1384 LssMaster& operator=(const LssMaster&) = delete;
1385
1386 virtual ~LssMaster();
1387
1392 ev::Executor GetExecutor() const noexcept;
1393
1395 Node& GetNode() const noexcept;
1396
1401 io::CanControllerBase* GetController() const noexcept;
1402
1404 ::std::chrono::microseconds GetInhibit() const;
1405
1407 void SetInhibit(const ::std::chrono::microseconds& inhibit);
1408
1414 ::std::chrono::milliseconds GetTimeout() const;
1415
1421 void SetTimeout(const ::std::chrono::milliseconds& timeout);
1422
1430 void
1431 SubmitSwitch(detail::LssSwitchRequestBase& req,
1432 LssState state = LssState::WAITING) {
1433 req.state = state;
1434 Submit(req);
1435 }
1436
1446 template <class F>
1447 void
1448 SubmitSwitch(ev_exec_t* exec, LssState state, F&& con) {
1449 Submit(*make_lss_switch_request(exec, state, ::std::forward<F>(con)));
1450 }
1451
1453 template <class F>
1454 void
1455 SubmitSwitch(LssState state, F&& con) {
1456 SubmitSwitch(nullptr, state, ::std::forward<F>(con));
1457 }
1458
1460 bool
1462 return Cancel(req);
1463 }
1464
1466 bool
1468 return Abort(req);
1469 }
1470
1483 LssFuture<void> AsyncSwitch(ev_exec_t* exec,
1484 LssState state = LssState::WAITING,
1486
1489 AsyncSwitch(LssState state = LssState::WAITING,
1490 detail::LssSwitchRequestBase** preq = nullptr) {
1491 return AsyncSwitch(nullptr, state, preq);
1492 }
1493
1502 void
1504 const LssAddress& address) {
1505 req.address = address;
1506 Submit(req);
1507 }
1508
1520 template <class F>
1521 void
1522 SubmitSwitchSelective(ev_exec_t* exec, const LssAddress& address, F&& con) {
1523 Submit(*make_lss_switch_selective_request(exec, address,
1524 ::std::forward<F>(con)));
1525 }
1526
1528 template <class F>
1529 void
1530 SubmitSwitchSelective(const LssAddress& address, F&& con) {
1531 SubmitSwitchSelective(nullptr, address, ::std::forward<F>(con));
1532 }
1533
1535 bool
1537 return Cancel(req);
1538 }
1539
1541 bool
1543 return Abort(req);
1544 }
1545
1559 LssFuture<void> AsyncSwitchSelective(
1560 ev_exec_t* exec, const LssAddress& address,
1562
1567 return AsyncSwitchSelective(nullptr, address, preq);
1568 }
1569
1579 void
1581 req.id = id;
1582 Submit(req);
1583 }
1584
1596 template <class F>
1597 void
1598 SubmitSetId(ev_exec_t* exec, uint8_t id, F&& con) {
1599 Submit(*make_lss_set_id_request(exec, id, ::std::forward<F>(con)));
1600 }
1601
1603 template <class F>
1604 void
1605 SubmitSetId(uint8_t id, F&& con) {
1606 SubmitSetId(nullptr, id, ::std::forward<F>(con));
1607 }
1608
1610 bool
1612 return Cancel(req);
1613 }
1614
1616 bool
1618 return Abort(req);
1619 }
1620
1635 LssFuture<void> AsyncSetId(ev_exec_t* exec, uint8_t id,
1636 detail::LssSetIdRequestBase** preq = nullptr);
1637
1641 return AsyncSetId(nullptr, id, preq);
1642 }
1643
1654 void
1656 req.bitrate = bitrate;
1657 Submit(req);
1658 }
1659
1672 template <class F>
1673 void
1674 SubmitSetBitrate(ev_exec_t* exec, int bitrate, F&& con) {
1675 Submit(
1676 *make_lss_set_bitrate_request(exec, bitrate, ::std::forward<F>(con)));
1677 }
1678
1680 template <class F>
1681 void
1682 SubmitSetBitrate(int bitrate, F&& con) {
1683 SubmitSetBitrate(nullptr, bitrate, ::std::forward<F>(con));
1684 }
1685
1687 bool
1689 return Cancel(req);
1690 }
1691
1693 bool
1695 return Abort(req);
1696 }
1697
1713 LssFuture<void> AsyncSetBitrate(
1714 ev_exec_t* exec, int bitrate,
1716
1719 AsyncSetBitrate(int bitrate,
1721 return AsyncSetBitrate(nullptr, bitrate, preq);
1722 }
1723
1734 void
1736 req.delay = delay;
1737 Submit(req);
1738 }
1739
1752 template <class F>
1753 void
1754 SubmitSwitchBitrate(ev_exec_t* exec, int delay, F&& con) {
1755 Submit(
1756 *make_lss_switch_bitrate_request(exec, delay, ::std::forward<F>(con)));
1757 }
1758
1760 template <class F>
1761 void
1762 SubmitSwitchBitrate(int delay, F&& con) {
1763 SubmitSwitchBitrate(nullptr, delay, ::std::forward<F>(con));
1764 }
1765
1767 bool
1769 return Cancel(req);
1770 }
1771
1773 bool
1775 return Abort(req);
1776 }
1777
1794 ev_exec_t* exec, int delay,
1796
1801 return AsyncSwitchBitrate(nullptr, delay, preq);
1802 }
1803
1810 void
1812 Submit(req);
1813 }
1814
1825 template <class F>
1826 void
1827 SubmitStore(ev_exec_t* exec, F&& con) {
1828 Submit(*make_lss_store_request(exec, ::std::forward<F>(con)));
1829 }
1830
1832 template <class F>
1833 void
1835 SubmitStore(nullptr, ::std::forward<F>(con));
1836 }
1837
1839 bool
1841 return Cancel(req);
1842 }
1843
1845 bool
1847 return Abort(req);
1848 }
1849
1863 LssFuture<void> AsyncStore(ev_exec_t* exec,
1864 detail::LssStoreRequestBase** preq = nullptr);
1865
1869 return AsyncStore(nullptr, preq);
1870 }
1871
1878 void
1882
1893 template <class F>
1894 void
1896 Submit(*make_lss_get_vendor_id_request(exec, ::std::forward<F>(con)));
1897 }
1898
1900 template <class F>
1901 void
1903 SubmitGetVendorId(nullptr, ::std::forward<F>(con));
1904 }
1905
1907 bool
1909 return Cancel(req);
1910 }
1911
1913 bool
1915 return Abort(req);
1916 }
1917
1931 LssFuture<uint32_t> AsyncGetVendorId(
1933
1937 return AsyncGetVendorId(nullptr, preq);
1938 }
1939
1946 void
1950
1961 template <class F>
1962 void
1964 Submit(*make_lss_get_product_code_request(exec, ::std::forward<F>(con)));
1965 }
1966
1968 template <class F>
1969 void
1971 SubmitGetProductCode(nullptr, ::std::forward<F>(con));
1972 }
1973
1975 bool
1977 return Cancel(req);
1978 }
1979
1981 bool
1983 return Abort(req);
1984 }
1985
1999 LssFuture<uint32_t> AsyncGetProductCode(
2001
2005 return AsyncGetProductCode(nullptr, preq);
2006 }
2007
2014 void
2018
2029 template <class F>
2030 void
2032 Submit(*make_lss_get_revision_request(exec, ::std::forward<F>(con)));
2033 }
2034
2036 template <class F>
2037 void
2039 SubmitGetRevision(nullptr, ::std::forward<F>(con));
2040 }
2041
2043 bool
2045 return Cancel(req);
2046 }
2047
2049 bool
2051 return Abort(req);
2052 }
2053
2067 LssFuture<uint32_t> AsyncGetRevision(
2069
2073 return AsyncGetRevision(nullptr, preq);
2074 }
2075
2082 void
2086
2097 template <class F>
2098 void
2100 Submit(*make_lss_get_serial_nr_request(exec, ::std::forward<F>(con)));
2101 }
2102
2104 template <class F>
2105 void
2107 SubmitGetSerialNr(nullptr, ::std::forward<F>(con));
2108 }
2109
2111 bool
2113 return Cancel(req);
2114 }
2115
2117 bool
2119 return Abort(req);
2120 }
2121
2135 LssFuture<uint32_t> AsyncGetSerialNr(
2137
2141 return AsyncGetSerialNr(nullptr, preq);
2142 }
2143
2149 void
2151 Submit(req);
2152 }
2153
2164 template <class F>
2165 void
2166 SubmitGetId(ev_exec_t* exec, F&& con) {
2167 Submit(*make_lss_get_id_request(exec, ::std::forward<F>(con)));
2168 }
2169
2171 template <class F>
2172 void
2174 SubmitGetId(nullptr, ::std::forward<F>(con));
2175 }
2176
2178 bool
2180 return Cancel(req);
2181 }
2182
2184 bool
2186 return Abort(req);
2187 }
2188
2202 LssFuture<uint8_t> AsyncGetId(ev_exec_t* exec,
2203 detail::LssGetIdRequestBase** preq = nullptr);
2204
2208 return AsyncGetId(nullptr, preq);
2209 }
2210
2216 void
2220
2230 template <class F>
2231 void
2233 Submit(*make_lss_id_non_config_request(exec, ::std::forward<F>(con)));
2234 }
2235
2237 template <class F>
2238 void
2240 SubmitIdNonConfig(nullptr, ::std::forward<F>(con));
2241 }
2242
2248 bool
2250 return Cancel(req);
2251 }
2252
2254 bool
2256 return Abort(req);
2257 }
2258
2271 LssFuture<bool> AsyncIdNonConfig(
2273
2277 return AsyncIdNonConfig(nullptr, preq);
2278 }
2279
2290 void
2292 const LssAddress& hi) {
2293 req.lo = lo;
2294 req.hi = hi;
2295 Submit(req);
2296 }
2297
2311 template <class F>
2312 void
2313 SubmitSlowscan(ev_exec_t* exec, const LssAddress& lo, const LssAddress& hi,
2314 F&& con) {
2315 Submit(*make_lss_slowscan_request(exec, lo, hi, ::std::forward<F>(con)));
2316 }
2317
2319 template <class F>
2320 void
2322 SubmitSlowscan(nullptr, ::std::forward<F>(con));
2323 }
2324
2326 bool
2328 return Cancel(req);
2329 }
2330
2332 bool
2334 return Abort(req);
2335 }
2336
2352 LssFuture<LssAddress> AsyncSlowscan(
2353 ev_exec_t* exec, const LssAddress& lo, const LssAddress& hi,
2355
2360 return AsyncSlowscan(nullptr, lo, hi, preq);
2361 }
2362
2376 void
2378 const LssAddress& mask) {
2379 req.address = address;
2380 req.mask = mask;
2381 Submit(req);
2382 }
2383
2399 template <class F>
2400 void
2401 SubmitFastscan(ev_exec_t* exec, const LssAddress& address,
2402 const LssAddress& mask, F&& con) {
2403 Submit(*make_lss_fastscan_request(exec, address, mask,
2404 ::std::forward<F>(con)));
2405 }
2406
2408 template <class F>
2409 void
2411 SubmitFastscan(nullptr, ::std::forward<F>(con));
2412 }
2413
2415 bool
2417 return Cancel(req);
2418 }
2419
2421 bool
2423 return Abort(req);
2424 }
2425
2444 LssFuture<LssAddress> AsyncFastscan(
2445 ev_exec_t* exec, const LssAddress& address = {0, 0, 0, 0},
2446 const LssAddress& mask = {0, 0, 0, 0},
2447 detail::LssFastscanRequestBase** preq = nullptr);
2448
2450 LssFuture<LssAddress>
2451 AsyncFastscan(const LssAddress& address = {0, 0, 0, 0},
2452 const LssAddress& mask = {0, 0, 0, 0},
2453 detail::LssFastscanRequestBase** preq = nullptr) {
2454 return AsyncFastscan(nullptr, address, mask, preq);
2455 }
2456
2458 void Submit(detail::LssRequestBase& req);
2459
2467 bool Cancel(detail::LssRequestBase& req);
2468
2476 ::std::size_t CancelAll();
2477
2485 bool Abort(detail::LssRequestBase& req);
2486
2493 ::std::size_t AbortAll();
2494
2506 virtual void
2507 OnStart(::std::function<void(::std::error_code ec)> res) noexcept {
2508 res(::std::error_code{});
2509 }
2510
2529 virtual void OnSwitchBitrate(
2530 int bitrate, ::std::chrono::milliseconds delay,
2531 ::std::function<void(::std::error_code ec)> res) noexcept;
2532
2533 protected:
2534 void lock() final;
2535 void unlock() final;
2536
2541 void SetTime();
2542
2543 private:
2544 struct Impl_;
2545 ::std::unique_ptr<Impl_> impl_;
2546};
2547
2548} // namespace canopen
2549
2550} // namespace lely
2551
2552#endif // LELY_COAPP_LSS_MASTER_HPP_
A CANopen value.
Definition val.hpp:42
An 'LSS Fastscan' request.
void(::std::error_code ec, LssAddress address) Signature
The signature of the callback function invoked on completion of an 'LSS Fastscan' request.
LssFastscanRequest(ev_exec_t *exec, F &&con)
Constructs an empty 'LSS Fastscan' request with a completion task.
LssFastscanRequest(F &&con)
Equivalent to LssSlowscanRequest(nullptr, con).
An LSS 'inquire node-ID' request.
LssGetIdRequest(F &&con)
Equivalent to LssGetIdRequest(nullptr, con).
void(::std::error_code ec, uint8_t id) Signature
The signature of the callback function invoked on completion of an LSS 'inquire node-ID' request.
LssGetIdRequest(ev_exec_t *exec, F &&con)
Constructs an empty LSS 'store configuration' request with a completion task.
An LSS 'inquire identity product-code' request.
void(::std::error_code ec, uint32_t number) Signature
The signature of the callback function invoked on completion of an LSS 'inquire identity product-code...
LssGetProductCodeRequest(F &&con)
Equivalent to LssGetProductCodeRequest(nullptr, con).
LssGetProductCodeRequest(ev_exec_t *exec, F &&con)
Constructs an empty LSS 'store configuration' request with a completion task.
An LSS 'inquire identity revision-number' request.
void(::std::error_code ec, uint32_t number) Signature
The signature of the callback function invoked on completion of an LSS 'inquire identity revision-num...
LssGetRevisionRequest(ev_exec_t *exec, F &&con)
Constructs an empty LSS 'store configuration' request with a completion task.
LssGetRevisionRequest(F &&con)
Equivalent to LssGetRevisionRequest(nullptr, con).
An LSS 'inquire identity serial-number' request.
LssGetSerialNrRequest(ev_exec_t *exec, F &&con)
Constructs an empty LSS 'store configuration' request with a completion task.
void(::std::error_code ec, uint32_t number) Signature
The signature of the callback function invoked on completion of an LSS 'inquire identity serial-numbe...
LssGetSerialNrRequest(F &&con)
Equivalent to LssGetSerialNrRequest(nullptr, con).
An LSS 'inquire identity vendor-ID' request.
LssGetVendorIdRequest(ev_exec_t *exec, F &&con)
Constructs an empty LSS 'store configuration' request with a completion task.
LssGetVendorIdRequest(F &&con)
Equivalent to LssGetVendorIdRequest(nullptr, con).
void(::std::error_code ec, uint32_t number) Signature
The signature of the callback function invoked on completion of an LSS 'inquire identity vendor-ID' r...
An LSS 'identify non-configured remote slave' request.
LssIdNonConfigRequest(ev_exec_t *exec, F &&con)
Constructs an empty LSS 'identify non-configured remote slave' request with a completion task.
LssIdNonConfigRequest(F &&con)
Equivalent to LssIdNonConfigRequest(nullptr, con).
void(::std::error_code ec, bool found) Signature
The signature of the callback function invoked on completion of an LSS 'identify non-configured remot...
The base class for CANopen LSS masters.
void SubmitIdNonConfig(F &&con)
Equivalent to SubmitIdNonConfig(nullptr, con).
void SubmitSlowscan(ev_exec_t *exec, const LssAddress &lo, const LssAddress &hi, F &&con)
Creates and queues an 'LSS Slowscan' request.
void SubmitGetProductCode(detail::LssGetProductCodeRequestBase &req)
Queues an LSS 'inquire identity product-code' request.
void SubmitSetBitrate(int bitrate, F &&con)
Equivalent to SubmitSetBitrate(nullptr, id, con).
void SubmitSwitch(ev_exec_t *exec, LssState state, F &&con)
Creates and queues an LSS 'switch state global' request.
void SubmitStore(F &&con)
Equivalent to SubmitStore(nullptr, con).
LssFuture< LssAddress > AsyncFastscan(const LssAddress &address={0, 0, 0, 0}, const LssAddress &mask={0, 0, 0, 0}, detail::LssFastscanRequestBase **preq=nullptr)
Equivalent to AsyncFastscan(nullptr, address, mask, preq).
bool AbortSwitchBitrate(detail::LssSwitchBitrateRequestBase &req)
Aborts an LSS 'activate bit timing parameters' request.
LssFuture< uint8_t > AsyncGetId(detail::LssGetIdRequestBase **preq=nullptr)
Equivalent to AsyncGetId(nullptr, preq).
void SubmitFastscan(detail::LssFastscanRequestBase &req, const LssAddress &address, const LssAddress &mask)
Queues an 'LSS Fastscan' request.
void SubmitStore(detail::LssStoreRequestBase &req)
Queues an LSS 'store configuration' request.
bool AbortStore(detail::LssStoreRequestBase &req)
Aborts an LSS 'store configuration' request.
void SubmitSlowscan(F &&con)
Equivalent to SubmitSlowscan(nullptr, con).
bool AbortSetId(detail::LssSetIdRequestBase &req)
Aborts an LSS 'configure node-ID' request.
void SubmitGetId(detail::LssGetIdRequestBase &req)
Queues an LSS 'inquire node-ID' request.
bool CancelGetProductCode(detail::LssGetProductCodeRequestBase &req)
Cancels an LSS 'inquire identity product-code' request.
bool CancelGetSerialNr(detail::LssGetSerialNrRequestBase &req)
Cancels an LSS 'inquire identity serial-number' request.
bool CancelSetId(detail::LssSetIdRequestBase &req)
Cancels an LSS 'configure node-ID' request.
void SubmitSwitchSelective(detail::LssSwitchSelectiveRequestBase &req, const LssAddress &address)
Queues an LSS 'switch state selective' request.
LssFuture< LssAddress > AsyncSlowscan(const LssAddress &lo, const LssAddress &hi, detail::LssSlowscanRequestBase **preq=nullptr)
Equivalent to AsyncSlowscan(nullptr, lo, hi, preq).
bool CancelIdNonConfig(detail::LssIdNonConfigRequestBase &req)
Cancels an LSS 'identify non-configured remote slave' request.
bool CancelFastscan(detail::LssFastscanRequestBase &req)
Cancels an 'LSS Fastscan' request.
void SubmitIdNonConfig(detail::LssIdNonConfigRequestBase &req)
Queues an LSS 'identify non-configured remote slave' request.
LssFuture< uint32_t > AsyncGetVendorId(detail::LssGetVendorIdRequestBase **preq=nullptr)
Equivalent to AsyncGetVendorId(nullptr, preq).
void SubmitGetRevision(detail::LssGetRevisionRequestBase &req)
Queues an LSS 'inquire identity revision-number' request.
void SubmitIdNonConfig(ev_exec_t *exec, F &&con)
Creates and queues an LSS 'identify non-configured remote slave' request.
bool AbortGetSerialNr(detail::LssGetSerialNrRequestBase &req)
Aborts an LSS 'inquire identity serial-number' request.
void SubmitSwitch(LssState state, F &&con)
Equivalent to SubmitSwitch(nullptr, state, con).
LssFuture< void > AsyncSetId(uint8_t id, detail::LssSetIdRequestBase **preq=nullptr)
Equivalent to AsyncSetId(nullptr, id, preq).
void SubmitSwitchSelective(const LssAddress &address, F &&con)
Equivalent to SubmitSwitchSelective(nullptr, state, con).
LssFuture< bool > AsyncIdNonConfig(detail::LssIdNonConfigRequestBase **preq=nullptr)
Equivalent to AsyncIdNonConfig(nullptr, preq).
LssFuture< void > AsyncStore(detail::LssStoreRequestBase **preq=nullptr)
Equivalent to AsyncStore(nullptr, preq).
bool CancelSetBitrate(detail::LssSetBitrateRequestBase &req)
Cancels an LSS 'configure bit timing parameters' request.
bool CancelSwitch(detail::LssSwitchRequestBase &req)
Cancels an LSS 'switch state global' request.
void SubmitGetId(ev_exec_t *exec, F &&con)
Creates and queues an LSS 'inquire node-ID' request.
void SubmitGetId(F &&con)
Equivalent to SubmitGetId(nullptr, con).
bool AbortSetBitrate(detail::LssSetBitrateRequestBase &req)
Aborts an LSS 'configure bit timing parameters' request.
void SubmitSetId(uint8_t id, F &&con)
Equivalent to SubmitSetId(nullptr, id, con).
bool AbortGetRevision(detail::LssGetRevisionRequestBase &req)
Aborts an LSS 'inquire identity revision-number' request.
LssFuture< uint32_t > AsyncGetRevision(detail::LssGetRevisionRequestBase **preq=nullptr)
Equivalent to AsyncGetRevision(nullptr, preq).
void SubmitGetVendorId(detail::LssGetVendorIdRequestBase &req)
Queues an LSS 'inquire identity vendor-ID' request.
void SubmitGetSerialNr(ev_exec_t *exec, F &&con)
Creates and queues an LSS 'inquire identity serial-number' request.
void SubmitSwitchBitrate(detail::LssSwitchBitrateRequestBase &req, int delay)
Queues an LSS 'activate bit timing parameters' request.
LssFuture< void > AsyncSwitchBitrate(ev_exec_t *exec, int delay, detail::LssSwitchBitrateRequestBase **preq=nullptr)
Queues an asynchronous LSS 'activate bit timing parameters' request and creates a future which become...
void SubmitGetVendorId(ev_exec_t *exec, F &&con)
Creates and queues an LSS 'inquire identity vendor-ID' request.
void SubmitFastscan(ev_exec_t *exec, const LssAddress &address, const LssAddress &mask, F &&con)
Creates and queues an 'LSS Fastscan' request.
bool CancelSwitchSelective(detail::LssSwitchSelectiveRequestBase &req)
Cancels an LSS 'switch state selective' request.
LssFuture< void > AsyncSwitch(LssState state=LssState::WAITING, detail::LssSwitchRequestBase **preq=nullptr)
Equivalent to AsyncSwitch(nullptr, state, preq).
bool CancelGetId(detail::LssGetIdRequestBase &req)
Cancels an LSS 'inquire node-ID' request.
void SubmitGetVendorId(F &&con)
Equivalent to SubmitGetVendorId(nullptr, con).
LssFuture< void > AsyncSwitchBitrate(int delay, detail::LssSwitchBitrateRequestBase **preq=nullptr)
Equivalent to AsyncSwitchBitrate(nullptr, id, preq).
void SubmitSetBitrate(ev_exec_t *exec, int bitrate, F &&con)
Creates and queues an LSS 'configure bit timing parameters' request.
bool AbortGetVendorId(detail::LssGetVendorIdRequestBase &req)
Aborts an LSS 'inquire identity vendor-ID' request.
void SubmitSetId(detail::LssSetIdRequestBase &req, uint8_t id)
Queues an LSS 'configure node-ID' request.
bool AbortSwitchSelective(detail::LssSwitchSelectiveRequestBase &req)
Aborts an LSS 'switch state selective' request.
void SubmitStore(ev_exec_t *exec, F &&con)
Creates and queues an LSS 'store configuration' request.
void SubmitGetSerialNr(F &&con)
Equivalent to SubmitGetSerialNr(nullptr, con).
bool CancelGetRevision(detail::LssGetRevisionRequestBase &req)
Cancels an LSS 'inquire identity revision-number' request.
void SubmitSetId(ev_exec_t *exec, uint8_t id, F &&con)
Creates and queues an LSS 'configure node-ID' request.
void SubmitGetRevision(F &&con)
Equivalent to SubmitGetRevision(nullptr, con).
void SubmitSwitchBitrate(int delay, F &&con)
Equivalent to SubmitSwitchBitrate(nullptr, id, con).
LssFuture< void > AsyncSwitchSelective(const LssAddress &address, detail::LssSwitchSelectiveRequestBase **preq=nullptr)
Equivalent to AsyncSwitchSelective(nullptr, address, preq).
void SubmitSwitchBitrate(ev_exec_t *exec, int delay, F &&con)
Creates and queues an LSS 'activate bit timing parameters' request.
bool CancelStore(detail::LssStoreRequestBase &req)
Cancels an LSS 'store configuration' request.
bool AbortSlowscan(detail::LssSlowscanRequestBase &req)
Aborts an 'LSS Slowscan' request.
virtual void OnStart(::std::function< void(::std::error_code ec)> res) noexcept
The function invoked when the LSS master services are executed during the NMT startup process.
void SubmitFastscan(F &&con)
Equivalent to SubmitFastscan(nullptr, con).
void SubmitGetProductCode(ev_exec_t *exec, F &&con)
Creates and queues an LSS 'inquire identity product-code' request.
bool CancelSlowscan(detail::LssSlowscanRequestBase &req)
Cancels an 'LSS Slowscan' request.
bool AbortGetProductCode(detail::LssGetProductCodeRequestBase &req)
Aborts an LSS 'inquire identity product-code' request.
bool CancelGetVendorId(detail::LssGetVendorIdRequestBase &req)
Cancels an LSS 'inquire identity vendor-ID' request.
void SubmitGetRevision(ev_exec_t *exec, F &&con)
Creates and queues an LSS 'inquire identity revision-number' request.
bool CancelSwitchBitrate(detail::LssSwitchBitrateRequestBase &req)
Cancels an LSS 'activate bit timing parameters' request.
bool AbortFastscan(detail::LssFastscanRequestBase &req)
Aborts an 'LSS Fastscan' request.
void SubmitGetSerialNr(detail::LssGetSerialNrRequestBase &req)
Queues an LSS 'inquire identity serial-number' request.
LssFuture< uint32_t > AsyncGetProductCode(detail::LssGetProductCodeRequestBase **preq=nullptr)
Equivalent to AsyncGetProductCode(nullptr, preq).
bool AbortIdNonConfig(detail::LssIdNonConfigRequestBase &req)
Aborts an LSS 'identify non-configured remote slave' request.
void SubmitSlowscan(detail::LssSlowscanRequestBase &req, const LssAddress &lo, const LssAddress &hi)
Queues an 'LSS Slowscan' request.
LssFuture< uint32_t > AsyncGetSerialNr(detail::LssGetSerialNrRequestBase **preq=nullptr)
Equivalent to AsyncGetSerialNr(nullptr, preq).
LssFuture< void > AsyncSetBitrate(int bitrate, detail::LssSetBitrateRequestBase **preq=nullptr)
Equivalent to AsyncSetBitrate(nullptr, id, preq).
void SubmitSetBitrate(detail::LssSetBitrateRequestBase &req, int bitrate)
Queues an LSS 'configure bit timing parameters' request.
void SubmitGetProductCode(F &&con)
Equivalent to SubmitGetProductCode(nullptr, con).
bool AbortSwitch(detail::LssSwitchRequestBase &req)
Aborts an LSS 'switch state global' request.
bool AbortGetId(detail::LssGetIdRequestBase &req)
Aborts an LSS 'inquire node-ID' request.
void SubmitSwitchSelective(ev_exec_t *exec, const LssAddress &address, F &&con)
Creates and queues an LSS 'switch state selective' request.
LssMaster(Node &node, io::CanControllerBase *ctrl=nullptr)
Creates a new CANopen LSS master.
An LSS 'configure bit timing parameters' request.
void(::std::error_code ec) Signature
The signature of the callback function invoked on completion of an LSS 'configure bit timing paramete...
LssSetBitrateRequest(ev_exec_t *exec, F &&con)
Constructs an empty LSS 'configure bit timing parameters' request with a completion task.
LssSetBitrateRequest(F &&con)
Equivalent to LssSetBitrateRequest(nullptr, con).
An LSS 'configure node-ID' request.
void(::std::error_code ec) Signature
The signature of the callback function invoked on completion of an LSS 'configure node-ID' request.
LssSetIdRequest(ev_exec_t *exec, F &&con)
Constructs an empty LSS 'configure node-ID' request with a completion task.
LssSetIdRequest(F &&con)
Equivalent to LssSetIdRequest(nullptr, con).
An 'LSS Slowscan' request.
LssSlowscanRequest(F &&con)
Equivalent to LssSlowscanRequest(nullptr, con).
void(::std::error_code ec, LssAddress address) Signature
The signature of the callback function invoked on completion of an 'LSS Slowscan' request.
LssSlowscanRequest(ev_exec_t *exec, F &&con)
Constructs an empty 'LSS Slowscan' request with a completion task.
An LSS 'store configuration' request.
void(::std::error_code ec) Signature
The signature of the callback function invoked on completion of an LSS 'store configuration' request.
LssStoreRequest(F &&con)
Equivalent to LssStoreRequest(nullptr, con).
LssStoreRequest(ev_exec_t *exec, F &&con)
Constructs an empty LSS 'store configuration' request with a completion task.
An LSS 'activate bit timing parameters' request.
LssSwitchBitrateRequest(ev_exec_t *exec, F &&con)
Constructs an empty LSS 'activate bit timing parameters' request with a completion task.
LssSwitchBitrateRequest(F &&con)
Equivalent to LssSwitchBitrateRequest(nullptr, con).
void(::std::error_code ec) Signature
The signature of the callback function invoked on completion of an LSS 'activate bit timing parameter...
An LSS 'switch state global' request.
LssSwitchRequest(ev_exec_t *exec, F &&con)
Constructs an empty LSS 'switch state global' request with a completion task.
void(::std::error_code ec) Signature
The signature of the callback function invoked on completion of an LSS 'switch state global' request.
LssSwitchRequest(F &&con)
Equivalent to LssSwitchRequest(nullptr, con).
An LSS 'switch state selective' request.
LssSwitchSelectiveRequest(F &&con)
Equivalent to LssSwitchSelectiveRequest(nullptr, con).
LssSwitchSelectiveRequest(ev_exec_t *exec, F &&con)
Constructs an empty LSS 'switch state selective' request with a completion task.
void(::std::error_code ec) Signature
The signature of the callback function invoked on completion of an LSS 'switch state selective' reque...
The base class for CANopen nodes.
Definition node.hpp:116
LssAddress mask
A mask specifying which bits in the LSS address of the slave device are already known and can be skip...
::std::error_code ec
The error code (0 on success).
ev::Executor GetExecutor() const noexcept
Returns the executor to which the completion task is (to be) submitted.
LssAddress address
On success, the LSS address of the detected slave device.
int bitrate
The requested pending bit rate (in bit/s) of the LSS slave device.
uint8_t id
The requested pending node-ID of the LSS slave device.
LssAddress hi
The upper bound of the LSS address of the slave device.
LssAddress lo
The lower bound of the LSS address of the slave device.
int delay
The delay (in milliseconds) before and after the switch, during which CAN frames MUST NOT be sent.
LssAddress address
The address of the LSS slave device to be switched into the configuration state.
An abstract task executor. This class is a wrapper around #ev_exec_t*.
Definition exec.hpp:38
A future.
Definition future.hpp:384
A promise.
Definition future.hpp:60
A reference to an abstract CAN controller.
Definition can.hpp:286
An abstract interface conforming to the BasicLockable concept.
Definition mutex.hpp:34
This header file is part of the compatibility library; it includes <functional> and defines any missi...
const struct ev_exec_vtbl *const ev_exec_t
An abstract task executor.
Definition ev.h:29
This header file is part of the compatibility library; it includes <type_traits> and defines any miss...
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.
@ WAITING
The state in which a slave may be identified.
@ CONFIG
The state in which the node-ID and bit timing parameters of a slave may be configured.
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::LssSwitchBitrateRequestWrapper< F > * >::type make_lss_switch_bitrate_request(ev_exec_t *exec, int delay, F &&con)
Creates an LSS 'activate bit timing parameters' 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.
STL namespace.
This header file is part of the C++ CANopen application library; it contains the CANopen node declara...
An executable task.
Definition task.h:41
ev_exec_t * exec
A pointer to the executor to which the task is (to be) submitted.
Definition task.h:43
The 128-bit number uniquely identifying each CANopen node.
uint32_t revision
The revision number.
uint32_t product_code
THe product code.
uint32_t serial_nr
THe serial number.
uint32_t vendor_id
The vendor-ID.
Determines whether F can be invoked with the arguments Args....
#define EV_TASK_INIT(exec, func)
The static initializer for ev_task.
Definition task.h:53