Skip to content

Commit 8b9e325

Browse files
committed
update: remove ununsed system time diff monitor
Signed-off-by: sakumisu <1203593632@qq.com>
1 parent e6421b8 commit 8b9e325

File tree

3 files changed

+4
-79
lines changed

3 files changed

+4
-79
lines changed

include/ec_master.h

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -77,14 +77,6 @@ typedef struct ec_master {
7777
ec_datagram_t dc_ref_sync_datagram; /**< Datagram used for synchronizing the reference clock to the master clock. */
7878
ec_datagram_t dc_all_sync_datagram; /**< Datagram used for synchronizing all slaves to the dc ref clock. */
7979

80-
ec_datagram_t systime_diff_mon_datagram; /**< Datagram used for reading the system time difference between master and reference clock. */
81-
bool systime_diff_enable;
82-
uint32_t min_systime_diff;
83-
uint32_t max_systime_diff;
84-
uint32_t curr_systime_diff;
85-
uint32_t systime_diff_count;
86-
uint64_t total_systime_diff;
87-
8880
bool dc_sync_with_dc_ref_enable; /**< true: Sync the reference clock by dc ref clock, false: by master */
8981
uint32_t cycle_time; /**< Cycle time [ns]. */
9082
int32_t shift_time; /**< Shift time [ns]. */

src/ec_cmd.c

Lines changed: 3 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,6 @@ static void ec_master_cmd_show_help(void)
5959
EC_LOG_RAW(" perf -s Start performance test\n");
6060
EC_LOG_RAW(" perf -d Stop performance test\n");
6161
EC_LOG_RAW(" perf -v Show performance statistics\n");
62-
EC_LOG_RAW(" timediff -s Enable system time diff monitor\n");
63-
EC_LOG_RAW(" timediff -d Disable system time diff monitor\n");
64-
EC_LOG_RAW(" timediff -v Show system time diff statistics\n");
6562
EC_LOG_RAW(" help Show this help\n\n");
6663
}
6764

@@ -804,37 +801,7 @@ int ethercat(int argc, const char **argv)
804801
return 0;
805802
}
806803
#endif
807-
else if (argc >= 3 && strcmp(argv[1], "timediff") == 0) {
808-
if (strcmp(argv[2], "-s") == 0) {
809-
uintptr_t flags;
810-
811-
flags = ec_osal_enter_critical_section();
812-
global_cmd_master->systime_diff_enable = true;
813-
global_cmd_master->curr_systime_diff = 0;
814-
global_cmd_master->min_systime_diff = 0xffffffff;
815-
global_cmd_master->max_systime_diff = 0;
816-
global_cmd_master->systime_diff_count = 0;
817-
global_cmd_master->total_systime_diff = 0;
818-
ec_osal_leave_critical_section(flags);
819-
820-
} else if (strcmp(argv[2], "-d") == 0) {
821-
uintptr_t flags;
822-
823-
flags = ec_osal_enter_critical_section();
824-
global_cmd_master->systime_diff_enable = false;
825-
ec_osal_leave_critical_section(flags);
826-
} else if (strcmp(argv[2], "-v") == 0) {
827-
for (uint32_t i = 0; i < 10; i++) {
828-
EC_LOG_RAW("System Time Diff curr = %u, min = %u, max = %u, avg = %u ns\n",
829-
global_cmd_master->curr_systime_diff,
830-
global_cmd_master->min_systime_diff,
831-
global_cmd_master->max_systime_diff,
832-
(unsigned int)(global_cmd_master->total_systime_diff / global_cmd_master->systime_diff_count));
833-
ec_osal_msleep(1000);
834-
}
835-
}
836-
return 0;
837-
} else if (strcmp(argv[1], "perf") == 0) {
804+
else if (strcmp(argv[1], "perf") == 0) {
838805
if (strcmp(argv[2], "-s") == 0) {
839806
uintptr_t flags;
840807

@@ -850,8 +817,8 @@ int ethercat(int argc, const char **argv)
850817
global_cmd_master->total_exec_ns = 0;
851818
global_cmd_master->exec_count = 0;
852819

853-
global_cmd_master->min_offset_ns = 0xffffffff;
854-
global_cmd_master->max_offset_ns = 0;
820+
global_cmd_master->min_offset_ns = INT32_MAX;
821+
global_cmd_master->max_offset_ns = INT32_MIN;
855822
ec_osal_leave_critical_section(flags);
856823
return 0;
857824
} else if (strcmp(argv[2], "-d") == 0) {

src/ec_master.c

Lines changed: 1 addition & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -372,9 +372,6 @@ int ec_master_init(ec_master_t *master, uint8_t master_index)
372372
ec_datagram_init(&master->main_datagram, EC_MAX_DATA_SIZE);
373373
ec_datagram_init(&master->dc_ref_sync_datagram, 8);
374374
ec_datagram_init(&master->dc_all_sync_datagram, 8);
375-
ec_datagram_init(&master->systime_diff_mon_datagram, 4);
376-
377-
ec_datagram_brd(&master->systime_diff_mon_datagram, ESCREG_OF(ESCREG->SYS_TIME_DIFF), 4);
378375

379376
master->scan_lock = ec_osal_mutex_create();
380377
if (!master->scan_lock) {
@@ -439,7 +436,6 @@ int ec_master_start(ec_master_t *master)
439436
master->phase = EC_OPERATION;
440437
master->nonperiod_suspend = true;
441438
master->interval = 0;
442-
master->systime_diff_enable = false;
443439
master->dc_sync_integral = 0;
444440

445441
// wait for non-periodic thread to suspend
@@ -759,7 +755,6 @@ EC_FAST_CODE_SECTION static void ec_master_period_process(void *arg)
759755
uint8_t netdev_idx;
760756
uint64_t dc_ref_systime = 0;
761757
int32_t offsettime = 0;
762-
uint32_t delta = 0;
763758
uint64_t start_time;
764759
uint32_t period_ns;
765760
uint32_t exec_ns;
@@ -777,15 +772,7 @@ EC_FAST_CODE_SECTION static void ec_master_period_process(void *arg)
777772

778773
ec_master_dc_sync_with_pi(master, dc_ref_systime, &offsettime);
779774

780-
if (offsettime > 0) {
781-
delta = offsettime;
782-
} else {
783-
delta = -offsettime;
784-
}
785-
786-
if (delta > 0) {
787-
ec_htimer_update((master->cycle_time / 1000 + offsettime / 1000));
788-
}
775+
ec_htimer_update(master->cycle_time / 1000 + offsettime / 1000);
789776
}
790777
} else {
791778
EC_WRITE_U32(master->dc_ref_sync_datagram.data, ec_timestamp_get_time_ns() & 0xffffffff);
@@ -824,27 +811,6 @@ EC_FAST_CODE_SECTION static void ec_master_period_process(void *arg)
824811
ec_master_queue_datagram(master, &pdo_datagram->datagrams[EC_NETDEV_MAIN]);
825812
}
826813

827-
if (master->systime_diff_enable) {
828-
if (master->systime_diff_mon_datagram.state == EC_DATAGRAM_RECEIVED) {
829-
master->curr_systime_diff = EC_READ_U32(master->systime_diff_mon_datagram.data) & 0x7fffffff;
830-
831-
if (master->curr_systime_diff < master->min_systime_diff) {
832-
master->min_systime_diff = master->curr_systime_diff;
833-
}
834-
835-
if (master->curr_systime_diff > master->max_systime_diff) {
836-
master->max_systime_diff = master->curr_systime_diff;
837-
}
838-
master->systime_diff_count++;
839-
master->total_systime_diff += master->curr_systime_diff;
840-
}
841-
842-
if ((master->interval % 10) == 0) {
843-
ec_datagram_zero(&master->systime_diff_mon_datagram);
844-
ec_master_queue_datagram(master, &master->systime_diff_mon_datagram);
845-
}
846-
}
847-
848814
ec_master_send(master);
849815

850816
period_ns = start_time - master->last_start_time;

0 commit comments

Comments
 (0)