aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSylvain Munaut <tnt@246tNt.com>2022-10-05 22:34:26 +0200
committerSylvain Munaut <tnt@246tNt.com>2022-10-06 10:44:18 +0200
commit9d452333379b989f07109aec3a7dfb21b84ced5a (patch)
treefdd931350f9f5fb51fc344e563f5681073280559 /src
parenta810249f9aeb5e49cb60576aa1726e3e66319ebf (diff)
vty: Add option to disable GPS-DO loop and use manual tuning values
Signed-off-by: Sylvain Munaut <tnt@246tNt.com> Change-Id: I8668fe42e4c399f08696e497887120e501341f5a
Diffstat (limited to 'src')
-rw-r--r--src/e1d.h5
-rw-r--r--src/usb.c11
-rw-r--r--src/vty.c36
3 files changed, 52 insertions, 0 deletions
diff --git a/src/e1d.h b/src/e1d.h
index ff34800..82c9bb6 100644
--- a/src/e1d.h
+++ b/src/e1d.h
@@ -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;
diff --git a/src/usb.c b/src/usb.c
index b511adb..47fff14 100644
--- a/src/usb.c
+++ b/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);
}
diff --git a/src/vty.c b/src/vty.c
index 65eb334..d3433da 100644
--- a/src/vty.c
+++ b/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);