*/
#include "protocol.h"
+#include <libserialport.h>
#define SERIALCOMM "115200/8n1"
SR_CONF_PATTERN_MODE,
SR_CONF_SWAP,
SR_CONF_RLE,
+ SR_CONF_MAX_UNCOMPRESSED_SAMPLES,
};
#define STR_PATTERN_EXTERNAL "external"
/* Wait 10ms for a response. */
g_usleep(10000);
- probefd.fd = serial->fd;
+ sp_get_port_handle(serial->data, &probefd.fd);
probefd.events = G_IO_IN;
g_poll(&probefd, 1, 1);
if (probefd.revents != G_IO_IN)
return NULL;
- if (serial_read(serial, buf, 4) != 4)
+ if (serial_read_blocking(serial, buf, 4) != 4)
return NULL;
if (strncmp(buf, "1SLO", 4) && strncmp(buf, "1ALS", 4))
return NULL;
return ((struct drv_context *)(di->priv))->instances;
}
-static int dev_open(struct sr_dev_inst *sdi)
-{
- struct sr_serial_dev_inst *serial;
-
- serial = sdi->conn;
- if (serial_open(serial, SERIAL_RDWR | SERIAL_NONBLOCK) != SR_OK)
- return SR_ERR;
-
- sdi->status = SR_ST_ACTIVE;
-
- return SR_OK;
-}
-
-static int dev_close(struct sr_dev_inst *sdi)
-{
- struct sr_serial_dev_inst *serial;
-
- serial = sdi->conn;
- if (serial && serial->fd != -1) {
- serial_close(serial);
- sdi->status = SR_ST_INACTIVE;
- }
-
- return SR_OK;
-}
-
static int cleanup(void)
{
return dev_clear();
const struct sr_probe_group *probe_group)
{
struct dev_context *devc;
+ int num_channels, i;
(void)probe_group;
case SR_CONF_RLE:
*data = g_variant_new_boolean(devc->flag_reg & FLAG_RLE ? TRUE : FALSE);
break;
+ case SR_CONF_MAX_UNCOMPRESSED_SAMPLES:
+ if (devc->flag_reg & FLAG_RLE)
+ return SR_ERR_NA;
+ if (devc->max_samples == 0)
+ /* Device didn't specify sample memory size in metadata. */
+ return SR_ERR_NA;
+ /*
+ * Channel groups are turned off if no probes in that group are
+ * enabled, making more room for samples for the enabled group.
+ */
+ ols_configure_probes(sdi);
+ num_channels = 0;
+ for (i = 0; i < 4; i++) {
+ if (devc->probe_mask & (0xff << (i * 8)))
+ num_channels++;
+ }
+ *data = g_variant_new_uint64(devc->max_samples / num_channels);
+ break;
default:
return SR_ERR_NA;
}
/* Send header packet to the session bus. */
std_session_send_df_header(cb_data, LOG_PREFIX);
- sr_source_add(serial->fd, G_IO_IN, -1, ols_receive_data, cb_data);
+ serial_source_add(serial, G_IO_IN, -1, ols_receive_data, cb_data);
return SR_OK;
}
.config_get = config_get,
.config_set = config_set,
.config_list = config_list,
- .dev_open = dev_open,
- .dev_close = dev_close,
+ .dev_open = std_serial_dev_open,
+ .dev_close = std_serial_dev_close,
.dev_acquisition_start = dev_acquisition_start,
.dev_acquisition_stop = dev_acquisition_stop,
.priv = NULL,