mirror of
https://gitlab.com/etherlab.org/ethercat.git
synced 2026-02-07 04:11:50 +08:00
Output reference clock and application time in 'ethercat Master'.
This commit is contained in:
7
TODO
7
TODO
@@ -12,8 +12,13 @@ Version 1.5.0:
|
||||
|
||||
* Distributed clocks:
|
||||
- Delay calculation.
|
||||
- Output reference clock and application time in 'ethercat master'.
|
||||
- User same application time offset when setting start times.
|
||||
- Replace timeval by uint64 EtherCAT time.
|
||||
* Fix arguments of reg_read.
|
||||
* Sign/Abs type for reg_ commands?
|
||||
* Number layout for reg_read.
|
||||
* Show Record / Array / List type of SDOs.
|
||||
* Limit bandwidth of state machine datagram.
|
||||
* Read alias from register 0x0012 instead of SII.
|
||||
* Finish library implementation.
|
||||
* Re-work EoE code.
|
||||
|
||||
@@ -173,6 +173,7 @@ int ec_cdev_ioctl_master(
|
||||
|
||||
if (down_interruptible(&master->device_sem))
|
||||
return -EINTR;
|
||||
|
||||
if (master->main_device.dev) {
|
||||
memcpy(data.devices[0].address,
|
||||
master->main_device.dev->dev_addr, ETH_ALEN);
|
||||
@@ -194,8 +195,16 @@ int ec_cdev_ioctl_master(
|
||||
data.devices[1].link_state = master->backup_device.link_state ? 1 : 0;
|
||||
data.devices[1].tx_count = master->backup_device.tx_count;
|
||||
data.devices[1].rx_count = master->backup_device.rx_count;
|
||||
|
||||
up(&master->device_sem);
|
||||
|
||||
data.app_time = master->app_time;
|
||||
data.ref_clock = EC_READ_U16(master->sync_datagram.address);
|
||||
if (data.ref_clock < 0xffff) {
|
||||
// ref_clock address is station_address, output ring position
|
||||
data.ref_clock--;
|
||||
}
|
||||
|
||||
if (copy_to_user((void __user *) arg, &data, sizeof(data)))
|
||||
return -EFAULT;
|
||||
|
||||
|
||||
@@ -136,6 +136,8 @@ typedef struct {
|
||||
uint32_t tx_count;
|
||||
uint32_t rx_count;
|
||||
} devices[2];
|
||||
uint64_t app_time;
|
||||
uint16_t ref_clock;
|
||||
} ec_ioctl_master_t;
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
@@ -622,6 +622,8 @@ void ec_master_leave_operation_phase(ec_master_t *master
|
||||
}
|
||||
#endif
|
||||
|
||||
master->app_time = 0ULL;
|
||||
|
||||
if (ec_master_thread_start(master, ec_master_idle_thread,
|
||||
"EtherCAT-IDLE"))
|
||||
EC_WARN("Failed to restart master thread!\n");
|
||||
|
||||
@@ -33,6 +33,8 @@ using namespace std;
|
||||
|
||||
#include "CommandMaster.h"
|
||||
|
||||
#define MAX_TIME_STR_SIZE 50
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
CommandMaster::CommandMaster():
|
||||
@@ -65,6 +67,9 @@ void CommandMaster::execute(MasterDevice &m, const StringVector &args)
|
||||
ec_ioctl_master_t data;
|
||||
stringstream err;
|
||||
unsigned int i;
|
||||
time_t epoch;
|
||||
char time_str[MAX_TIME_STR_SIZE + 1];
|
||||
size_t time_str_size;
|
||||
|
||||
if (args.size()) {
|
||||
err << "'" << getName() << "' takes no arguments!";
|
||||
@@ -86,10 +91,11 @@ void CommandMaster::execute(MasterDevice &m, const StringVector &args)
|
||||
}
|
||||
|
||||
cout << endl
|
||||
<< " Slaves: " << data.slave_count << endl;
|
||||
<< " Slaves: " << data.slave_count << endl
|
||||
<< " Ethernet devices:" << endl;
|
||||
|
||||
for (i = 0; i < 2; i++) {
|
||||
cout << " Device" << i << ": ";
|
||||
cout << " " << (i == 0 ? "Main" : "Backup") << ": ";
|
||||
if (data.devices[i].address[0] == 0x00
|
||||
&& data.devices[i].address[1] == 0x00
|
||||
&& data.devices[i].address[2] == 0x00
|
||||
@@ -107,12 +113,29 @@ void CommandMaster::execute(MasterDevice &m, const StringVector &args)
|
||||
<< setw(2) << (unsigned int) data.devices[i].address[5] << " ("
|
||||
<< (data.devices[i].attached ? "attached" : "waiting...")
|
||||
<< ")" << endl << dec
|
||||
<< " Link: " << (data.devices[i].link_state ? "UP" : "DOWN") << endl
|
||||
<< " Tx count: " << data.devices[i].tx_count << endl
|
||||
<< " Rx count: " << data.devices[i].rx_count;
|
||||
<< " Link: " << (data.devices[i].link_state ? "UP" : "DOWN") << endl
|
||||
<< " Tx count: " << data.devices[i].tx_count << endl
|
||||
<< " Rx count: " << data.devices[i].rx_count;
|
||||
}
|
||||
cout << endl;
|
||||
}
|
||||
|
||||
cout << " Distributed clocks:" << endl
|
||||
<< " Reference clock: ";
|
||||
if (data.ref_clock != 0xffff) {
|
||||
cout << "Slave " << dec << data.ref_clock;
|
||||
} else {
|
||||
cout << "None";
|
||||
}
|
||||
cout << endl
|
||||
<< " Application time: " << data.app_time << endl
|
||||
<< " ";
|
||||
|
||||
epoch = data.app_time / 1000000000 + 946684800ULL;
|
||||
time_str_size = strftime(time_str, MAX_TIME_STR_SIZE,
|
||||
"%Y-%m-%d %H:%M:%S", gmtime(&epoch));
|
||||
cout << string(time_str, time_str_size) << "."
|
||||
<< setfill('0') << setw(9) << data.app_time % 1000000000 << endl;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
Reference in New Issue
Block a user