Renamed app_start_time to dc_ref_time; output via command-line tool.

This commit is contained in:
Florian Pose 2018-11-26 17:17:18 +01:00
parent 0257660396
commit 083bd419b8
7 changed files with 21 additions and 24 deletions

View File

@ -960,7 +960,7 @@ void ec_fsm_master_enter_write_system_times(
{
ec_master_t *master = fsm->master;
if (master->has_app_time) {
if (master->dc_ref_time) {
while (fsm->slave < master->slaves + master->slave_count) {
if (!fsm->slave->base_dc_supported
@ -984,7 +984,7 @@ void ec_fsm_master_enter_write_system_times(
} else {
if (master->active) {
EC_MASTER_WARN(master, "No app_time received up to now,"
EC_MASTER_WARN(master, "No application time received up to now,"
" but master already active.\n");
} else {
EC_MASTER_DBG(master, 1, "No app_time received up to now.\n");

View File

@ -1413,24 +1413,22 @@ void ec_fsm_slave_config_state_dc_sync_check(
abs_sync_diff, diff_ms);
}
// set DC start time
// set DC start time (roughly in the future, not in-phase)
start_time = master->app_time + EC_DC_START_OFFSET; // now + X ns
// FIXME use slave's local system time here?
if (sync0->cycle_time) {
// find correct phase
if (master->has_app_time) {
if (master->dc_ref_time) {
u64 diff, start;
u32 remainder, cycle;
diff = start_time - master->app_start_time;
diff = start_time - master->dc_ref_time;
cycle = sync0->cycle_time + sync1->cycle_time;
remainder = do_div(diff, cycle);
start = start_time + cycle - remainder + sync0->shift_time;
EC_SLAVE_DBG(slave, 1, "app_start_time=%llu\n",
master->app_start_time);
EC_SLAVE_DBG(slave, 1, " ref_time=%llu\n", master->dc_ref_time);
EC_SLAVE_DBG(slave, 1, " app_time=%llu\n", master->app_time);
EC_SLAVE_DBG(slave, 1, " start_time=%llu\n", start_time);
EC_SLAVE_DBG(slave, 1, " cycle=%u\n", cycle);

View File

@ -180,6 +180,7 @@ static ATTRIBUTES int ec_ioctl_master(
up(&master->device_sem);
io.app_time = master->app_time;
io.dc_ref_time = master->dc_ref_time;
io.ref_clock =
master->dc_ref_clock ? master->dc_ref_clock->ring_position : 0xffff;

View File

@ -56,7 +56,7 @@
*
* Increment this when changing the ioctl interface!
*/
#define EC_IOCTL_VERSION_MAGIC 28
#define EC_IOCTL_VERSION_MAGIC 29
// Command-line tool
#define EC_IOCTL_MODULE EC_IOR(0x00, ec_ioctl_module_t)
@ -201,6 +201,7 @@ typedef struct {
int32_t rx_byte_rates[EC_RATE_COUNT];
int32_t loss_rates[EC_RATE_COUNT];
uint64_t app_time;
uint64_t dc_ref_time;
uint16_t ref_clock;
} ec_ioctl_master_t;

View File

@ -184,8 +184,7 @@ int ec_master_init(ec_master_t *master, /**< EtherCAT master */
INIT_LIST_HEAD(&master->domains);
master->app_time = 0ULL;
master->app_start_time = 0ULL;
master->has_app_time = 0;
master->dc_ref_time = 0ULL;
master->scan_busy = 0;
master->allow_scan = 1;
@ -2417,8 +2416,7 @@ void ecrt_master_deactivate(ec_master_t *master)
#endif
master->app_time = 0ULL;
master->app_start_time = 0ULL;
master->has_app_time = 0;
master->dc_ref_time = 0ULL;
#ifdef EC_EOE
if (eoe_was_running) {
@ -2774,9 +2772,8 @@ void ecrt_master_application_time(ec_master_t *master, uint64_t app_time)
{
master->app_time = app_time;
if (unlikely(!master->has_app_time)) {
master->app_start_time = app_time;
master->has_app_time = 1;
if (unlikely(!master->dc_ref_time)) {
master->dc_ref_time = app_time;
}
}

View File

@ -236,8 +236,7 @@ struct ec_master {
struct list_head domains; /**< List of domains. */
u64 app_time; /**< Time of the last ecrt_master_sync() call. */
u64 app_start_time; /**< Application start time. */
u8 has_app_time; /**< Application time is valid. */
u64 dc_ref_time; /**< Common reference timestamp for DC start times. */
ec_datagram_t ref_sync_datagram; /**< Datagram used for synchronizing the
reference clock to the master clock. */
ec_datagram_t sync_datagram; /**< Datagram used for DC drift

View File

@ -264,6 +264,7 @@ void CommandMaster::execute(const StringVector &args)
cout << "None";
}
cout << endl
<< " DC reference time: " << data.dc_ref_time << endl
<< " Application time: " << data.app_time << endl
<< " ";