1 Notes regaring API Usage {#apiusage}
2 ========================
4 There are some restrictions on the
5 [Application Interface](@ref ApplicationInterface) with respect to the state of
6 the master instance and the calling context, which are explained in the
11 All configuration (`ecrt_slave_config_*()`) has to be done in Linux process
12 context. They can be blocking, so take care when holding locks. After
13 ecrt_master_activate() ing the master, your application must not alter the
14 slave configuration. Instead, update process data using ecrt_domain_queue()
15 and ecrt_domain_process() or use the asynchronous interface like
16 ecrt_sdo_request_read(). Don't forget to ecrt_master_receive() and
17 ecrt_master_send(). These functions can be called from non-process context
18 too, like Xenomai/RTAI applications or custom kernel modules.
22 The first distinction of cases is whether ecrt_master_activate() has been
23 called or not. Before ecrt_master_activate() (or after
24 ecrt_master_deactivate()), the master is in idle phase. Sending and receiving
25 EtherCAT frames will be done by the master itself, the application (e. g. you)
26 can store slave configurations for later use. After ecrt_master_activate(),
27 the master switches into operation mode. The application is now in charge of
28 steering the communication. Process data can be exchanged under real time
29 constraints. Altering the slave configuration is not possible anymore.
32 |---------------|---------------------------------------------------------------------------------------|
33 | `master_op` | Master must be in operation phase, so after `ecrt_master_activate()` has been called. |
34 | `master_idle` | Master must be in idle phase, so before `ecrt_master_activate()` has been called. |
35 | `master_any` | Master can be in idle or operation phase. |
39 The second distinction of cases is the calling context, which means how the
40 application is run. Most of the functions of the
41 [Application Interface](@ref ApplicationInterface) have to acquire locks or
42 allocate memory, so they are potentially sleeping. They are tagged as
43 `blocking`. Sleeping is not allowed in all contexts, for instance when using
44 Xenomai/RTAI or a kernel timer. Only a very limited set of functions can be
45 called from any context, marked as `rt_safe`. They do not allocate memory and
49 |------------|-----------------------------------------------------------------------------------------------|
50 | `rt_safe` | Realtime context (RT userspace, atomic/softirq context in kernel, Xenomai/RTAI RT task) safe. |
51 | `blocking` | Linux process context only (userspace or kernel), might block. |