vty: Add option to disable GPS-DO loop and use manual tuning values
Signed-off-by: Sylvain Munaut <tnt@246tNt.com> Change-Id: I8668fe42e4c399f08696e497887120e501341f5a
This commit is contained in:
parent
a810249f9a
commit
9d45233337
|
@ -174,6 +174,11 @@ struct e1_intf {
|
|||
|
||||
struct {
|
||||
char *serial_str;
|
||||
struct {
|
||||
bool manual;
|
||||
uint16_t coarse;
|
||||
uint16_t fine;
|
||||
} gpsdo;
|
||||
} usb;
|
||||
|
||||
bool vty_created;
|
||||
|
|
11
src/usb.c
11
src/usb.c
|
@ -789,6 +789,17 @@ _e1_usb_gpsdo_init(struct e1_intf *intf)
|
|||
{
|
||||
struct e1_usb_intf_data *id = intf->drv_data;
|
||||
|
||||
if (intf->usb.gpsdo.manual) {
|
||||
struct e1usb_gpsdo_tune tune = {
|
||||
.coarse = intf->usb.gpsdo.coarse,
|
||||
.fine = intf->usb.gpsdo.fine,
|
||||
};
|
||||
e1_usb_ctrl_set_gpsdo_mode(intf, ICE1USB_GPSDO_MODE_DISABLED);
|
||||
e1_usb_ctrl_set_gpsdo_tune(intf, &tune);
|
||||
} else {
|
||||
e1_usb_ctrl_set_gpsdo_mode(intf, ICE1USB_GPSDO_MODE_AUTO);
|
||||
}
|
||||
|
||||
osmo_timer_setup(&id->gpsdo.poll_timer, &_e1_usb_gpsdo_poll_cb, intf);
|
||||
osmo_timer_schedule(&id->gpsdo.poll_timer, 1, 0);
|
||||
}
|
||||
|
|
36
src/vty.c
36
src/vty.c
|
@ -302,6 +302,38 @@ DEFUN(cfg_e1d_if_usb_serial, cfg_e1d_if_usb_serial_cmd,
|
|||
return CMD_SUCCESS;
|
||||
}
|
||||
|
||||
DEFUN(cfg_e1d_if_gpsdo_manual, cfg_e1d_if_gpsdo_manual_cmd,
|
||||
"gpsdo-manual <0-4095> <0-4095>",
|
||||
"Set the GPS-DO to manual mode with the provided tune values\n"
|
||||
"Coarse tune value\n"
|
||||
"Fine tune value\n")
|
||||
{
|
||||
struct e1_intf *intf = vty->index;
|
||||
|
||||
if (intf->drv != E1_DRIVER_USB)
|
||||
return CMD_WARNING;
|
||||
|
||||
intf->usb.gpsdo.manual = true;
|
||||
intf->usb.gpsdo.coarse = atoi(argv[0]);
|
||||
intf->usb.gpsdo.fine = atoi(argv[1]);
|
||||
|
||||
return CMD_SUCCESS;
|
||||
}
|
||||
|
||||
DEFUN(cfg_e1d_if_no_gpsdo_manual, cfg_e1d_if_no_gpsdo_manual_cmd,
|
||||
"no gpsdo-manual",
|
||||
NO_STR "Set the GPS-DO back to automatic mode\n")
|
||||
{
|
||||
struct e1_intf *intf = vty->index;
|
||||
|
||||
if (intf->drv != E1_DRIVER_USB)
|
||||
return CMD_WARNING;
|
||||
|
||||
intf->usb.gpsdo.manual = false;
|
||||
|
||||
return CMD_SUCCESS;
|
||||
}
|
||||
|
||||
DEFUN(cfg_e1d_if_line, cfg_e1d_if_line_cmd, "line <0-255>",
|
||||
"Configure an E1 line\n"
|
||||
"E1 Interface Number\n")
|
||||
|
@ -387,6 +419,8 @@ static int config_write_e1d(struct vty *vty)
|
|||
vty_out(vty, " interface %u icE1usb%s", intf->id, VTY_NEWLINE);
|
||||
if (intf->usb.serial_str && strlen(intf->usb.serial_str))
|
||||
vty_out(vty, " usb-serial %s%s", intf->usb.serial_str, VTY_NEWLINE);
|
||||
if (intf->usb.gpsdo.manual)
|
||||
vty_out(vty, " gpsdo-manual %d %d%s", intf->usb.gpsdo.coarse, intf->usb.gpsdo.fine, VTY_NEWLINE);
|
||||
break;
|
||||
case E1_DRIVER_VPAIR:
|
||||
vty_out(vty, " interface %u vpair%s", intf->id, VTY_NEWLINE);
|
||||
|
@ -417,6 +451,8 @@ void e1d_vty_init(struct e1_daemon *e1d)
|
|||
install_element(E1D_NODE, &cfg_e1d_if_vpair_cmd);
|
||||
install_element(INTF_NODE, &cfg_e1d_if_line_cmd);
|
||||
install_element(INTF_NODE, &cfg_e1d_if_usb_serial_cmd);
|
||||
install_element(INTF_NODE, &cfg_e1d_if_gpsdo_manual_cmd);
|
||||
install_element(INTF_NODE, &cfg_e1d_if_no_gpsdo_manual_cmd);
|
||||
|
||||
install_node(&line_node, NULL);
|
||||
install_element(LINE_NODE, &cfg_e1d_if_line_mode_cmd);
|
||||
|
|
Loading…
Reference in New Issue