]> sigrok.org Git - libsigrok.git/blobdiff - hardware/link-mso19/protocol.c
mso-19: Initial analog probe support (unfinished).
[libsigrok.git] / hardware / link-mso19 / protocol.c
index 350cc7d148602136ebdef14fbcf0079407f9b19b..ab77a5a15eb26e05f7c5b8353d9948e9a9281164 100644 (file)
@@ -20,7 +20,6 @@
  */
 
 #include "protocol.h"
-#include <arpa/inet.h>
 
 /* serial protocol */
 #define mso_trans(a, v) \
@@ -55,7 +54,7 @@ SR_PRIV int mso_send_control_message(struct sr_serial_dev_inst *serial,
        p += sizeof(mso_head);
 
        for (i = 0; i < n; i++) {
-               *(uint16_t *) p = htons(payload[i]);
+               *(uint16_t *) p = g_htons(payload[i]);
                p += 2;
        }
        memcpy(p, mso_foot, sizeof(mso_foot));
@@ -122,7 +121,7 @@ SR_PRIV int mso_configure_trigger(const struct sr_dev_inst *sdi)
        uint16_t ops[18];
        ops[0] = mso_trans(3, threshold_value & 0xff);
        //The trigger_config also holds the 2 MSB bits from the threshold value
-       ops[1] = mso_trans(4, trigger_config | (threshold_value >> 8) & 0x03);
+       ops[1] = mso_trans(4, trigger_config | ((threshold_value >> 8) & 0x03));
        ops[2] = mso_trans(5, devc->la_trigger);
        ops[3] = mso_trans(6, devc->la_trigger_mask);
        ops[4] = mso_trans(7, devc->trigger_holdoff[0]);
@@ -334,7 +333,7 @@ SR_PRIV int mso_configure_rate(const struct sr_dev_inst *sdi, uint32_t rate)
        return ret;
 }
 
-SR_PRIV int mso_check_trigger(struct sr_serial_dev_inst *serial, uint8_t * info)
+SR_PRIV int mso_check_trigger(struct sr_serial_dev_inst *serial, uint8_t *info)
 {
        uint16_t ops[] = { mso_trans(REG_TRIGGER, 0) };
        int ret;
@@ -347,7 +346,8 @@ SR_PRIV int mso_check_trigger(struct sr_serial_dev_inst *serial, uint8_t * info)
        uint8_t buf = 0;
        if (serial_read(serial, &buf, 1) != 1)  /* FIXME: Need timeout */
                ret = SR_ERR;
-       *info = buf;
+       if (!info)
+               *info = buf;
 
        sr_dbg("Trigger state is: 0x%x.", *info);
        return ret;