return SR_OK;
}
-SR_PRIV ssize_t ResourceReader::read_callback(const struct sr_resource *res,
+SR_PRIV gssize ResourceReader::read_callback(const struct sr_resource *res,
void *buf, size_t count, void *cb_data) noexcept
{
try {
if (struct sr_dev_driver **driver_list = sr_driver_list(_structure))
for (int i = 0; driver_list[i]; i++) {
unique_ptr<Driver> driver {new Driver{driver_list[i]}};
- _drivers.emplace(driver->name(), move(driver));
+ _drivers.insert(make_pair(driver->name(), move(driver)));
}
if (const struct sr_input_module **input_list = sr_input_list())
for (int i = 0; input_list[i]; i++) {
unique_ptr<InputFormat> input {new InputFormat{input_list[i]}};
- _input_formats.emplace(input->name(), move(input));
+ _input_formats.insert(make_pair(input->name(), move(input)));
}
if (const struct sr_output_module **output_list = sr_output_list())
for (int i = 0; output_list[i]; i++) {
unique_ptr<OutputFormat> output {new OutputFormat{output_list[i]}};
- _output_formats.emplace(output->name(), move(output));
+ _output_formats.insert(make_pair(output->name(), move(output)));
}
}
{
const auto &name = entry.first;
const auto &driver = entry.second;
- result.emplace(name, driver->share_owned_by(shared_from_this()));
+ result.insert({name, driver->share_owned_by(shared_from_this())});
}
return result;
}
{
const auto &name = entry.first;
const auto &input_format = entry.second;
- result.emplace(name, input_format->share_owned_by(shared_from_this()));
+ result.insert({name, input_format->share_owned_by(shared_from_this())});
}
return result;
}
{
const auto &name = entry.first;
const auto &output_format = entry.second;
- result.emplace(name, output_format->share_owned_by(shared_from_this()));
+ result.insert({name, output_format->share_owned_by(shared_from_this())});
}
return result;
}
{
auto analog = g_new0(struct sr_datafeed_analog, 1);
auto meaning = g_new0(struct sr_analog_meaning, 1);
+ auto encoding = g_new0(struct sr_analog_encoding, 1);
+ auto spec = g_new0(struct sr_analog_spec, 1);
analog->meaning = meaning;
for (const auto &channel : channels)
meaning->channels = g_slist_append(meaning->channels, channel->_structure);
- analog->num_samples = num_samples;
meaning->mq = static_cast<sr_mq>(mq->id());
meaning->unit = static_cast<sr_unit>(unit->id());
meaning->mqflags = static_cast<sr_mqflag>(QuantityFlag::mask_from_flags(move(mqflags)));
+
+ analog->encoding = encoding;
+
+ encoding->unitsize = sizeof(float);
+ encoding->is_signed = TRUE;
+ encoding->is_float = TRUE;
+#ifdef WORDS_BIGENDIAN
+ encoding->is_bigendian = TRUE;
+#else
+ encoding->is_bigendian = FALSE;
+#endif
+ encoding->digits = 0;
+ encoding->is_digits_decimal = FALSE;
+ encoding->scale.p = 1;
+ encoding->scale.q = 1;
+ encoding->offset.p = 0;
+ encoding->offset.q = 1;
+
+ analog->spec = spec;
+
+ spec->spec_digits = 0;
+
+ analog->num_samples = num_samples;
analog->data = data_pointer;
auto packet = g_new(struct sr_datafeed_packet, 1);
packet->type = SR_DF_ANALOG;
set<const ConfigKey *> Driver::scan_options() const
{
- GArray *opts = sr_driver_scan_options(_structure);
+ GArray *opts = sr_driver_scan_options_list(_structure);
set<const ConfigKey *> result;
- for (guint i = 0; i < opts->len; i++)
- result.insert(ConfigKey::get(g_array_index(opts, uint32_t, i)));
- g_array_free(opts, TRUE);
+ if (opts) {
+ for (guint i = 0; i < opts->len; i++)
+ result.insert(ConfigKey::get(g_array_index(opts, uint32_t, i)));
+ g_array_free(opts, TRUE);
+ }
return result;
}
opts = sr_dev_options(config_driver, config_sdi, config_channel_group);
- for (guint i = 0; i < opts->len; i++)
- result.insert(ConfigKey::get(g_array_index(opts, uint32_t, i)));
-
- g_array_free(opts, TRUE);
+ if (opts) {
+ for (guint i = 0; i < opts->len; i++)
+ result.insert(ConfigKey::get(g_array_index(opts, uint32_t, i)));
+ g_array_free(opts, TRUE);
+ }
return result;
}
{
auto *const ch = static_cast<struct sr_channel *>(entry->data);
unique_ptr<Channel> channel {new Channel{ch}};
- _channels.emplace(ch, move(channel));
+ _channels.insert(make_pair(ch, move(channel)));
}
for (GSList *entry = sr_dev_inst_channel_groups_get(structure); entry; entry = entry->next)
{
auto *const cg = static_cast<struct sr_channel_group *>(entry->data);
unique_ptr<ChannelGroup> group {new ChannelGroup{this, cg}};
- _channel_groups.emplace(group->name(), move(group));
+ _channel_groups.insert(make_pair(group->name(), move(group)));
}
}
{
const auto &name = entry.first;
const auto &channel_group = entry.second;
- result.emplace(name, channel_group->share_owned_by(get_shared_from_this()));
+ result.insert({name, channel_group->share_owned_by(get_shared_from_this())});
}
return result;
}
GSList *const last = g_slist_last(sr_dev_inst_channels_get(Device::_structure));
auto *const ch = static_cast<struct sr_channel *>(last->data);
unique_ptr<Channel> channel {new Channel{ch}};
- _channels.emplace(ch, move(channel));
+ _channels.insert(make_pair(ch, move(channel)));
return get_channel(ch);
}
for (GSList *dev = dev_list; dev; dev = dev->next) {
auto *const sdi = static_cast<struct sr_dev_inst *>(dev->data);
unique_ptr<SessionDevice> device {new SessionDevice{sdi}};
- _owned_devices.emplace(sdi, move(device));
+ _owned_devices.insert(make_pair(sdi, move(device)));
}
_context->_session = this;
}
shared_ptr<Option> opt {
new Option{options[i], option_array},
default_delete<Option>{}};
- result.emplace(opt->id(), move(opt));
+ result.insert({opt->id(), move(opt)});
}
}
return result;
check(sr_input_end(_structure));
}
+void Input::reset()
+{
+ check(sr_input_reset(_structure));
+}
+
Input::~Input()
{
sr_input_free(_structure);
shared_ptr<Option> opt {
new Option{options[i], option_array},
default_delete<Option>{}};
- result.emplace(opt->id(), move(opt));
+ result.insert({opt->id(), move(opt)});
}
}
return result;