laforge submitted this change.

View Change

Approvals: Jenkins Builder: Verified laforge: Looks good to me, approved
vty: Add option to disable GPS-DO loop and use manual tuning values

Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
Change-Id: I8668fe42e4c399f08696e497887120e501341f5a
---
M src/e1d.h
M src/usb.c
M src/vty.c
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 {
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 @@
{
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 @@
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 @@
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 @@
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);

To view, visit change 29635. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: osmo-e1d
Gerrit-Branch: master
Gerrit-Change-Id: I8668fe42e4c399f08696e497887120e501341f5a
Gerrit-Change-Number: 29635
Gerrit-PatchSet: 4
Gerrit-Owner: tnt <tnt@246tNt.com>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge <laforge@osmocom.org>
Gerrit-MessageType: merged