mirror of
https://gitlab.com/etherlab.org/ethercat.git
synced 2026-08-18 09:07:24 +08:00
Implemented ioctl()s for setting SII caching method.
This commit is contained in:
@@ -820,3 +820,20 @@ int ecrt_master_reset(ec_master_t *master)
|
||||
}
|
||||
|
||||
/****************************************************************************/
|
||||
|
||||
int ecrt_master_sii_caching(ec_master_t *master,
|
||||
ec_sii_caching_fields_t fields)
|
||||
{
|
||||
int ret;
|
||||
|
||||
ret = ioctl(master->fd, EC_IOCTL_SII_CACHING, fields);
|
||||
if (EC_IOCTL_IS_ERROR(ret)) {
|
||||
fprintf(stderr, "Failed to set SII caching method: %s\n",
|
||||
strerror(EC_IOCTL_ERRNO(ret)));
|
||||
return -EC_IOCTL_ERRNO(ret);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/****************************************************************************/
|
||||
|
||||
@@ -143,6 +143,7 @@ static ATTRIBUTES int ec_ioctl_master(
|
||||
io.phase = (uint8_t) master->phase;
|
||||
io.active = (uint8_t) master->active;
|
||||
io.scan_busy = master->scan_busy;
|
||||
io.sii_caching = master->sii_caching;
|
||||
|
||||
up(&master->master_sem);
|
||||
|
||||
@@ -2387,6 +2388,29 @@ static ATTRIBUTES int ec_ioctl_reset(
|
||||
|
||||
/****************************************************************************/
|
||||
|
||||
/** Set SII caching method.
|
||||
*
|
||||
* \return Always zero (success).
|
||||
*/
|
||||
static ATTRIBUTES int ec_ioctl_sii_caching(
|
||||
ec_master_t *master, /**< EtherCAT master. */
|
||||
void *arg, /**< ioctl() argument. */
|
||||
ec_ioctl_context_t *ctx /**< Private data structure of file handle. */
|
||||
)
|
||||
{
|
||||
int ret = 0;
|
||||
if (unlikely(!ctx->requested)) {
|
||||
ret = -EPERM;
|
||||
goto out_return;
|
||||
}
|
||||
|
||||
ret = ecrt_master_sii_caching(master, (unsigned long) arg);
|
||||
out_return:
|
||||
return ret;
|
||||
}
|
||||
|
||||
/****************************************************************************/
|
||||
|
||||
/** Configure a sync manager.
|
||||
*
|
||||
* \return Zero on success, otherwise a negative error code.
|
||||
@@ -5567,6 +5591,13 @@ static long ec_ioctl_nrt
|
||||
}
|
||||
ret = ec_ioctl_set_send_interval(master, arg, ctx);
|
||||
break;
|
||||
case EC_IOCTL_SII_CACHING:
|
||||
if (!ctx->writable) {
|
||||
ret = -EPERM;
|
||||
break;
|
||||
}
|
||||
ret = ec_ioctl_sii_caching(master, arg, ctx);
|
||||
break;
|
||||
default:
|
||||
#ifdef EC_IOCTL_RTDM
|
||||
ret = ec_ioctl_both(master, ctx, cmd, arg);
|
||||
|
||||
+4
-2
@@ -1,6 +1,6 @@
|
||||
/*****************************************************************************
|
||||
*
|
||||
* Copyright (C) 2006-2024 Florian Pose, Ingenieurgemeinschaft IgH
|
||||
* Copyright (C) 2006-2026 Florian Pose, Ingenieurgemeinschaft IgH
|
||||
*
|
||||
* This file is part of the IgH EtherCAT master.
|
||||
*
|
||||
@@ -47,7 +47,7 @@
|
||||
*
|
||||
* Increment this when changing the ioctl interface!
|
||||
*/
|
||||
#define EC_IOCTL_VERSION_MAGIC 37
|
||||
#define EC_IOCTL_VERSION_MAGIC 38
|
||||
|
||||
// Command-line tool
|
||||
#define EC_IOCTL_MODULE EC_IOR(0x00, ec_ioctl_module_t)
|
||||
@@ -161,6 +161,7 @@
|
||||
#define EC_IOCTL_VOE_EXEC EC_IOWR(0x64, ec_ioctl_voe_t)
|
||||
#define EC_IOCTL_VOE_DATA EC_IOWR(0x65, ec_ioctl_voe_t)
|
||||
#define EC_IOCTL_SET_SEND_INTERVAL EC_IOW(0x66, size_t)
|
||||
#define EC_IOCTL_SII_CACHING EC_IOW(0x67, uint32_t)
|
||||
|
||||
/****************************************************************************/
|
||||
|
||||
@@ -211,6 +212,7 @@ typedef struct {
|
||||
uint64_t app_time;
|
||||
uint64_t dc_ref_time;
|
||||
uint16_t ref_clock;
|
||||
uint32_t sii_caching;
|
||||
} ec_ioctl_master_t;
|
||||
|
||||
/****************************************************************************/
|
||||
|
||||
+40
-1
@@ -94,7 +94,46 @@ void CommandMaster::execute(const StringVector &args)
|
||||
cout << endl
|
||||
<< " Active: " << (data.active ? "yes" : "no") << endl
|
||||
<< " Slaves: " << data.slave_count << endl
|
||||
<< " Ethernet devices:" << endl;
|
||||
<< " SII caching: ";
|
||||
|
||||
bool first{true};
|
||||
if (data.sii_caching & EC_SII_VENDOR) {
|
||||
cout << "Vendor";
|
||||
first = false;
|
||||
}
|
||||
if (data.sii_caching & EC_SII_PRODUCT) {
|
||||
if (not first) {
|
||||
cout << " | ";
|
||||
}
|
||||
first = false;
|
||||
cout << "Product";
|
||||
}
|
||||
if (data.sii_caching & EC_SII_REVISION) {
|
||||
if (not first) {
|
||||
cout << " | ";
|
||||
}
|
||||
first = false;
|
||||
cout << "Revision";
|
||||
}
|
||||
if (data.sii_caching & EC_SII_SERIAL) {
|
||||
if (not first) {
|
||||
cout << " | ";
|
||||
}
|
||||
first = false;
|
||||
cout << "Serial";
|
||||
}
|
||||
if (data.sii_caching & EC_SII_ALIAS) {
|
||||
if (not first) {
|
||||
cout << " | ";
|
||||
}
|
||||
first = false;
|
||||
cout << "Alias";
|
||||
}
|
||||
if (first) {
|
||||
cout << "disabled";
|
||||
}
|
||||
|
||||
cout << endl << " Ethernet devices:" << endl;
|
||||
|
||||
for (dev_idx = EC_DEVICE_MAIN; dev_idx < data.num_devices;
|
||||
dev_idx++) {
|
||||
|
||||
Reference in New Issue
Block a user