Hi, Gavin: Thanks for your guide, now it can upload SDO packet (seen with Wireshark). But I got an error message on console: * "Failed to execute SDO upload: Bad Address"*
------------------------------- my code --------------------------------------------------------------------- ... size_t *result_size; uint8_t *target; const uint8_t *data; uint32_t *abort_code; ecrt_master_sdo_upload(master, 5, 0xf880, 1, target, 4, result_size, abort_code ); ... if (ecrt_master_activate(master)) return -1; cycle_task(); ... --------------------------------------------------------------------------------------------------------------------- What could be wrong? Thanks again! Jerry On Mon, Jun 18, 2018 at 7:25 PM, Gavin Lambert <gavin.lamb...@tomra.com> wrote: > There are a few different kinds of API to do SDO transfers, depending on > how and when you want to do them. (But in short: no, that code is probably > not correct.) > > > > ecrt_master_sdo_download/upload are blocking APIs; they are intended to > be called before activating the master. It is still possible to call them *on > a separate thread* while the master is active (though be aware that this > will cause lock contention so is not recommended if you have a fast cycle > time). You *must not* call it from your realtime thread. These are > intended for network discovery or other one-off or infrequent actions. > > > > ecrt_slave_config_create_sdo_request and the companion ecrt_sdo_request_* > methods are intended for the case where you want to do transfers (either > one-off or periodically) from the realtime thread while the master is > active. You create the request first (before activating the master) and > then use the other methods to kick off a specific action and then poll it > for completion from inside your realtime loop. These are non-blocking. > > > > ecrt_slave_config_sdo* is for slave configuration settings that need to be > written to the slave each time it reboots. You call these once before > activating the master and then the master itself takes care of sending > these on first configuration and also if the slave needs to be reconfigured > for any reason (eg. network disruption, rebooting). > > > > It's all explained in the documentation, the examples, and the header > files themselves. > > > > *From:* jerry itnet > *Sent:* Tuesday, 19 June 2018 04:15 > *Subject:* [etherlab-users] How to "upload/download" SDOs in > application(*.c file)? > > > > I am confused on how to "upload/download" SDOs in an application. > > For example, am I correct by writing codes like: > > > > ------------- application.c ------------------------------ > --------------------------------------------------------------------- > > .... > > uint16_t sdo_index = 0xf880; uint8_t sdo_subindex = 1; > uint32_t value = 0; > ecrt_slave_config_sdo32( sc, sdo_index, sdo_subindex, value); > > > > if (ecrt_master_activate(master)) return -1; > > size_t *result_size; uint8_t *target; const uint8_t *data; > uint32_t *abort_code; > ecrt_master_sdo_upload(master, 5, 0xf880, 1, target, 4, result_size, > abort_code ); > > ... > > cycle_task(); > > ... > > ------------------------------------------------------------ > ---------------------------------------------------------------------- > > > > Thank in advance for any hint! > > Jerry >
_______________________________________________ etherlab-users mailing list etherlab-users@etherlab.org http://lists.etherlab.org/mailman/listinfo/etherlab-users