Commit 81adcc8c authored by Alessandro Rubini's avatar Alessandro Rubini

userspace/tools: add '-w' option to wr_mon

Signed-off-by: Alessandro Rubini's avatarAlessandro Rubini <rubini@gnudd.com>
parent 9c2217cf
......@@ -141,6 +141,44 @@ void show_ports(void)
}
}
/*
* This is almost a copy of the above, used by web interface.
* Code duplication is bad, but this is better than a separate tool
* which is almost identical but even broken
*/
static void show_unadorned_ports(void)
{
int i, j;
for(i=0; i<18;i++)
{
char if_name[10], found = 0;
hexp_port_state_t state;
snprintf(if_name, 10, "wr%d", i);
for(j=0;j<port_list.num_ports;j++)
if(!strcmp(port_list.port_names[j], if_name)) {
found = 1;
break;
}
if(!found)
continue;
halexp_get_port_state(&state, if_name);
printf("%s %s %s %s \n", /* trailing space needed? */
state.up
? "up" : "down",
state.mode == HEXP_PORT_MODE_WR_MASTER
? "Master" : "Slave", /* FIXME: other options? */
state.is_locked
? "Locked" : "NoLock",
state.rx_calibrated && state.tx_calibrated
? "Calibrated" : "Uncalibrated");
}
}
void show_servo(void)
{
ptpdexp_sync_state_t ss;
......@@ -260,7 +298,7 @@ int main(int argc, char *argv[])
int opt;
int usecolor = 1;
while((opt=getopt(argc, argv, "sbgp")) != -1)
while((opt=getopt(argc, argv, "sbgpw")) != -1)
{
switch(opt)
{
......@@ -280,6 +318,10 @@ int main(int argc, char *argv[])
init(0);
show_all();
exit(0);
case 'w': /* for the web interface */
init(0);
show_unadorned_ports();
exit(0);
default:
fprintf(stderr, "Unrecognized option.\n");
break;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment