38 #define PROC_DIR "/proc" 39 #define COMM_FILE "comm" 40 #define PMC_CMD "pmc -u -b 0 'GET PORT_DATA_SET'" 41 #define PTP4L_PROC_NAME "ptp4l" 42 #define PHC2SYS_PROC_NAME "phc2sys" 44 static int find_substr(
const char *str,
const unsigned int str_len,
45 const char *substr,
const unsigned int substr_len)
51 while (ind + substr_len <= str_len) {
52 if (0 == strncmp(&str[ind], substr, substr_len))
59 static int is_process_running(
char *pname)
62 char read_proc_name[
BUF_LEN] = {0};
69 struct dirent *entry = NULL;
70 while (entry = readdir(dir)) {
71 long pid = atol(entry->d_name);
75 FILE *proc_name_file = fopen(full_path,
"r");
76 if (NULL == proc_name_file)
78 fgets( read_proc_name,
BUF_LEN, proc_name_file);
79 if (0 == strncmp(read_proc_name, pname, strlen(pname))) {
90 static int check_ptp_status()
93 const char *keywords[2] = {
"portState",
"SLAVE"};
95 FILE *pmc_pipe = popen(
PMC_CMD,
"r");
99 while(fgets(pmc_out_line,
BUF_LEN, pmc_pipe)) {
100 if (0 == find_substr(pmc_out_line, strlen(pmc_out_line), keywords[0],
101 strlen(keywords[0]))) {
102 if (0 == find_substr(pmc_out_line, strlen(pmc_out_line),
103 keywords[1], strlen(keywords[1]))) {
119 print_dbg(
"PHC2SYS_PROC_NAME %d\n", res);
120 res |= check_ptp_status();
#define print_dbg(fmt, args...)
+
+
#define PHC2SYS_PROC_NAME
+
This file provides interface to synchronization related APIs (PTP/1588) for XRAN. ...
+
+
+
+
Modules provide debug prints and utility functions.
+
+
int xran_is_synchronized()
Function checks if machine is synchronized using PTP for Linux software.
+
+
+