X-Git-Url: https://sigrok.org/gitweb/?a=blobdiff_plain;f=src%2Fhardware%2Fcenter-3xx%2Fprotocol.c;h=ca1ae3b59821f14d8622ada038acaca0fbae846f;hb=176d785d33a28a1bb24f2ee483595ec54f7b52b6;hp=ca11449f4f751eec86c1ca92afbf43823261dd65;hpb=d4f59ce86d23e41da3f94e3d6cab4b4bc3239359;p=libsigrok.git diff --git a/src/hardware/center-3xx/protocol.c b/src/hardware/center-3xx/protocol.c index ca11449f..ca1ae3b5 100644 --- a/src/hardware/center-3xx/protocol.c +++ b/src/hardware/center-3xx/protocol.c @@ -14,8 +14,7 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * along with this program; if not, see . */ #include @@ -25,6 +24,7 @@ struct center_info { float temp[NUM_CHANNELS]; + int digits[NUM_CHANNELS]; gboolean rec, std, max, min, maxmin, t1t2, rel, hold, lowbat, celsius; gboolean memfull, autooff; gboolean mode_std, mode_rel, mode_max, mode_min, mode_maxmin; @@ -97,8 +97,12 @@ static int packet_parse(const uint8_t *buf, int idx, struct center_info *info) /* Byte 43: Specifies whether we need to divide the value(s) by 10. */ for (i = 0; i < NUM_CHANNELS; i++) { /* Bit = 0: Divide by 10. Bit = 1: Don't divide by 10. */ - if ((buf[43] & (1 << i)) == 0) + if ((buf[43] & (1 << i)) == 0) { info->temp[i] /= 10; + info->digits[i] = 1; + } else { + info->digits[i] = 0; + } } /* Bytes 39-42: Overflow/overlimit bits, depending on mode. */ @@ -134,6 +138,7 @@ static int handle_packet(const uint8_t *buf, struct sr_dev_inst *sdi, int idx) devc = sdi->priv; + /* Note: digits/spec_digits will be overridden later. */ sr_analog_init(&analog, &encoding, &meaning, &spec, 0); memset(&info, 0, sizeof(struct center_info)); @@ -155,6 +160,8 @@ static int handle_packet(const uint8_t *buf, struct sr_dev_inst *sdi, int idx) l = NULL; l = g_slist_append(l, g_slist_nth_data(sdi->channels, i)); analog.meaning->channels = l; + analog.encoding->digits = info.digits[i]; + analog.spec->spec_digits = info.digits[i]; analog.data = &(info.temp[i]); sr_session_send(sdi, &packet); g_slist_free(l);