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[] = {
struct sr_serial_dev_inst *serial;
GSList *l, *devices;
struct pps_model *model;
+ float byte_delay_ms;
uint8_t packet[PACKET_SIZE];
unsigned int i;
int ret;
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);
- /* This is how the vendor software channels for hardware. */
+ /* How long it takes for a byte to transfer over the serial port. */
+ if (sp_get_port_transport(serial->data) == SP_TRANSPORT_NATIVE)
+ /* 11 bits at 9600 bps. */
+ byte_delay_ms = 1.15;
+ else
+ /* Emulated serial over USB or bluetooth is just enqueueing. */
+ byte_delay_ms = 0;
+
+ /* This is how the vendor software scans for hardware. */
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,
+ byte_delay_ms * PACKET_SIZE + 1) < 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.
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;
devc = g_malloc0(sizeof(struct dev_context));
devc->model = model;
devc->config = g_malloc0(sizeof(struct per_channel_config) * model->num_channels);
+ devc->byte_delay_ms = byte_delay_ms;
sdi->priv = devc;
drvc->instances = g_slist_append(drvc->instances, sdi);
devices = g_slist_append(devices, sdi);