tnt has uploaded this change for review. ( 
https://gerrit.osmocom.org/c/osmo-e1d/+/29618 )


Change subject: usb: Add support for new GPSDO status field "Accumulated error"
......................................................................

usb: Add support for new GPSDO status field "Accumulated error"

Because we want to handle older firmwares too, we need to excepect
we might get a smaller structure !

(We can't get a larger one since the wLength we send is limited to
the structure we know)

Signed-off-by: Sylvain Munaut <[email protected]>
Change-Id: I4222bf22267f8343abf1e97546111ceb1c299846
---
M src/e1d.h
M src/ice1usb_proto.h
M src/intf_line.c
M src/usb.c
4 files changed, 12 insertions(+), 4 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/osmo-e1d refs/changes/18/29618/1

diff --git a/src/e1d.h b/src/e1d.h
index 42be1b4..ff34800 100644
--- a/src/e1d.h
+++ b/src/e1d.h
@@ -67,6 +67,7 @@
        LINE_GPSDO_TUNE_COARSE,
        LINE_GPSDO_TUNE_FINE,
        LINE_GPSDO_FREQ_EST,
+       LINE_GPSDO_ERR_ACC,
 };

 enum e1_ts_mode {
diff --git a/src/ice1usb_proto.h b/src/ice1usb_proto.h
index 3170d55..38cb23b 100644
--- a/src/ice1usb_proto.h
+++ b/src/ice1usb_proto.h
@@ -65,6 +65,7 @@
        uint8_t mode;                   /*!< Current configured operating mode 
*/
        struct e1usb_gpsdo_tune tune;   /*!< Current VCXO tuning values */
        uint32_t freq_est;              /*!< Latest frequency estimate 
measurement */
+       int16_t  err_acc;               /*!< Accumulated error */
 } __attribute__((packed));


diff --git a/src/intf_line.c b/src/intf_line.c
index a645cd3..c6cb686 100644
--- a/src/intf_line.c
+++ b/src/intf_line.c
@@ -75,6 +75,7 @@
        [LINE_GPSDO_TUNE_COARSE]= { "gpsdo:tune:coarse", "GSPDO Coarse Tuning" 
},
        [LINE_GPSDO_TUNE_FINE]  = { "gpsdo:tune:fine", "GSPDO Fine Tuning" },
        [LINE_GPSDO_FREQ_EST]   = { "gpsdo:freq_est", "GSPDO Frequency 
Estimate" },
+       [LINE_GPSDO_ERR_ACC]    = { "gpsdo:acc_err", "GPSDO Accumulated Error" 
},
 };

 static const struct osmo_stat_item_group_desc line_stats_desc = {
diff --git a/src/usb.c b/src/usb.c
index fa6ddee..49e8dbe 100644
--- a/src/usb.c
+++ b/src/usb.c
@@ -706,14 +706,18 @@
 {
        struct e1_usb_intf_data *id = intf->drv_data;
        struct e1usb_gpsdo_status *last_st = &id->gpsdo.last_status;
-       const struct e1usb_gpsdo_status *st;
+       const struct e1usb_gpsdo_status _st, *st = &_st;
        struct e1_line *line;

        if (len < sizeof(*st)) {
-               LOGPIF(intf, DE1D, LOGL_ERROR, "GPSDO status %zu < %zu!\n", 
len, sizeof(*st));
-               return;
+               LOGPIF(intf, DE1D, LOGL_NOTICE,
+                       "GPSDO status %zu < %zu ! Firmware probably outdated. "
+                       "Some values will be zeroed\n",
+                       len, sizeof(*st));
        }
-       st = (const struct e1usb_gpsdo_status *) data;
+
+       memset(st, 0x00, sizeof(*st));
+       memcpy(st, data, len);

        if (st->state != last_st->state) {
                LOGPIF(intf, DE1D, LOGL_NOTICE, "GPSDO state change: %s -> 
%s\n",
@@ -750,6 +754,7 @@
                line_stat_set(line, LINE_GPSDO_TUNE_COARSE, 
libusb_le16_to_cpu(st->tune.coarse));
                line_stat_set(line, LINE_GPSDO_TUNE_FINE, 
libusb_le16_to_cpu(st->tune.fine));
                line_stat_set(line, LINE_GPSDO_FREQ_EST, 
osmo_load32le(&st->freq_est));
+               line_stat_set(line, LINE_GPSDO_ERR_ACC, 
(int16_t)libusb_le16_to_cpu(st->err_acc));
        }

        /* update our state */

--
To view, visit https://gerrit.osmocom.org/c/osmo-e1d/+/29618
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-e1d
Gerrit-Branch: master
Gerrit-Change-Id: I4222bf22267f8343abf1e97546111ceb1c299846
Gerrit-Change-Number: 29618
Gerrit-PatchSet: 1
Gerrit-Owner: tnt <[email protected]>
Gerrit-MessageType: newchange

Reply via email to