]> sigrok.org Git - libsigrok.git/blobdiff - src/hardware/atten-pps3xxx/api.c
Fix similar broken error handling on several serial calls.
[libsigrok.git] / src / hardware / atten-pps3xxx / api.c
index 0df8bcf0fe2d877e9edb67de5450a1761e84047d..a0f84152405f6725c2af1dc2a7ed48fc818c9e61 100644 (file)
@@ -39,16 +39,16 @@ static const uint32_t scanopts[] = {
 static const uint32_t devopts[] = {
        SR_CONF_POWER_SUPPLY,
        SR_CONF_CONTINUOUS,
-       SR_CONF_OUTPUT_CHANNEL_CONFIG,
-       SR_CONF_OVER_CURRENT_PROTECTION_ENABLED,
+       SR_CONF_OUTPUT_CHANNEL_CONFIG | SR_CONF_GET | SR_CONF_SET | SR_CONF_LIST,
+       SR_CONF_OVER_CURRENT_PROTECTION_ENABLED | SR_CONF_GET | SR_CONF_SET,
 };
 
 static const uint32_t devopts_cg[] = {
-       SR_CONF_OUTPUT_VOLTAGE,
-       SR_CONF_OUTPUT_VOLTAGE_MAX,
-       SR_CONF_OUTPUT_CURRENT,
-       SR_CONF_OUTPUT_CURRENT_MAX,
-       SR_CONF_OUTPUT_ENABLED,
+       SR_CONF_OUTPUT_VOLTAGE | SR_CONF_GET,
+       SR_CONF_OUTPUT_VOLTAGE_MAX | SR_CONF_GET | SR_CONF_SET | SR_CONF_LIST,
+       SR_CONF_OUTPUT_CURRENT | SR_CONF_GET,
+       SR_CONF_OUTPUT_CURRENT_MAX | SR_CONF_GET | SR_CONF_SET | SR_CONF_LIST,
+       SR_CONF_OUTPUT_ENABLED | SR_CONF_GET | SR_CONF_SET,
 };
 
 static const char *channel_modes[] = {
@@ -122,7 +122,7 @@ static GSList *scan(GSList *options, int modelid)
        if (!(serial = sr_serial_dev_inst_new(conn, serialcomm)))
                return NULL;
 
-       if (serial_open(serial, SERIAL_RDWR | SERIAL_NONBLOCK) != SR_OK)
+       if (serial_open(serial, SERIAL_RDWR) != SR_OK)
                return NULL;
        serial_flush(serial);
 
@@ -130,9 +130,8 @@ static GSList *scan(GSList *options, int modelid)
        memset(packet, 0, PACKET_SIZE);
        packet[0] = 0xaa;
        packet[1] = 0xaa;
-       if (serial_write(serial, packet, PACKET_SIZE) == -1) {
-               sr_err("Unable to write while probing for hardware: %s",
-                               strerror(errno));
+       if (serial_write_blocking(serial, packet, PACKET_SIZE) < PACKET_SIZE) {
+               sr_err("Unable to write while probing for hardware.");
                return NULL;
        }
        /* The device responds with a 24-byte packet when it receives a packet.
@@ -161,7 +160,7 @@ static GSList *scan(GSList *options, int modelid)
                return NULL;
        }
 
-       sdi = sr_dev_inst_new(0, SR_ST_INACTIVE, "Atten", model->name, NULL);
+       sdi = sr_dev_inst_new(SR_ST_INACTIVE, "Atten", model->name, NULL);
        sdi->driver = di;
        sdi->inst_type = SR_INST_SERIAL;
        sdi->conn = serial;