mirror of
https://gitlab.com/etherlab.org/ethercat.git
synced 2026-09-20 17:17:41 +08:00
Merged
This commit is contained in:
+52
-8
@@ -264,10 +264,8 @@ int ecrt_master_sdo_download(ec_master_t *master, uint16_t slave_position,
|
||||
download.data = data;
|
||||
|
||||
if (ioctl(master->fd, EC_IOCTL_SLAVE_SDO_DOWNLOAD, &download) == -1) {
|
||||
if (errno == -EIO) {
|
||||
if (abort_code) {
|
||||
*abort_code = download.abort_code;
|
||||
}
|
||||
if (errno == EIO && abort_code) {
|
||||
*abort_code = download.abort_code;
|
||||
}
|
||||
fprintf(stderr, "Failed to execute SDO download: %s\n",
|
||||
strerror(errno));
|
||||
@@ -292,10 +290,8 @@ int ecrt_master_sdo_upload(ec_master_t *master, uint16_t slave_position,
|
||||
upload.target = target;
|
||||
|
||||
if (ioctl(master->fd, EC_IOCTL_SLAVE_SDO_UPLOAD, &upload) == -1) {
|
||||
if (errno == -EIO) {
|
||||
if (abort_code) {
|
||||
*abort_code = upload.abort_code;
|
||||
}
|
||||
if (errno == EIO && abort_code) {
|
||||
*abort_code = upload.abort_code;
|
||||
}
|
||||
fprintf(stderr, "Failed to execute SDO upload: %s\n",
|
||||
strerror(errno));
|
||||
@@ -308,6 +304,54 @@ int ecrt_master_sdo_upload(ec_master_t *master, uint16_t slave_position,
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
int ecrt_master_write_idn(ec_master_t *master, uint16_t slave_position,
|
||||
uint16_t idn, uint8_t *data, size_t data_size, uint32_t *error_code)
|
||||
{
|
||||
ec_ioctl_slave_soe_write_t io;
|
||||
|
||||
io.slave_position = slave_position;
|
||||
io.idn = idn;
|
||||
io.data_size = data_size;
|
||||
io.data = data;
|
||||
|
||||
if (ioctl(master->fd, EC_IOCTL_SLAVE_SOE_WRITE, &io) == -1) {
|
||||
if (errno == EIO && error_code) {
|
||||
*error_code = io.error_code;
|
||||
}
|
||||
fprintf(stderr, "Failed to write IDN: %s\n", strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
int ecrt_master_read_idn(ec_master_t *master, uint16_t slave_position,
|
||||
uint16_t idn, uint8_t *target, size_t target_size,
|
||||
size_t *result_size, uint32_t *error_code)
|
||||
{
|
||||
ec_ioctl_slave_soe_read_t io;
|
||||
|
||||
io.slave_position = slave_position;
|
||||
io.idn = idn;
|
||||
io.mem_size = target_size;
|
||||
io.data = target;
|
||||
|
||||
if (ioctl(master->fd, EC_IOCTL_SLAVE_SOE_READ, &io) == -1) {
|
||||
if (errno == EIO && error_code) {
|
||||
*error_code = io.error_code;
|
||||
}
|
||||
fprintf(stderr, "Failed to read IDN: %s\n", strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
|
||||
*result_size = io.data_size;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
int ecrt_master_activate(ec_master_t *master)
|
||||
{
|
||||
if (ioctl(master->fd, EC_IOCTL_ACTIVATE,
|
||||
|
||||
Reference in New Issue
Block a user