class SR_API InputFileDevice;
class SR_API Output;
class SR_API DataType;
+class SR_API Option;
/** Exception thrown when an error code is returned by any libsigrok call. */
class SR_API Error: public exception
/** Set configuration for the given key to a specified value. */
void config_set(const ConfigKey *key, Glib::VariantBase value);
/** Enumerate available values for the given configuration key. */
- Glib::VariantBase config_list(const ConfigKey *key);
+ Glib::VariantContainerBase config_list(const ConfigKey *key);
protected:
Configurable(
struct sr_dev_driver *driver,
public StructureWrapper<Context, struct sr_dev_inst>
{
public:
+ /** Description identifying this device. */
+ string get_description();
/** Vendor name for this device. */
string get_vendor();
/** Model name for this device. */
string get_version();
/** List of the channels available on this device. */
vector<shared_ptr<Channel> > get_channels();
+ /** Channel groups available on this device, indexed by name. */
+ map<string, shared_ptr<ChannelGroup> > get_channel_groups();
/** Open device. */
void open();
/** Close device. */
protected:
Device(struct sr_dev_inst *structure);
~Device();
- vector<Channel *> channels;
+ shared_ptr<Channel> get_channel(struct sr_channel *ptr);
+ map<struct sr_channel *, Channel *> channels;
+ map<string, ChannelGroup *> channel_groups;
/** Deleter needed to allow shared_ptr use with protected destructor. */
class Deleter
{
friend class Channel;
friend class ChannelGroup;
friend class Output;
+ friend class Analog;
};
/** A real hardware device, connected via a driver */
public:
/** Driver providing this device. */
shared_ptr<Driver> get_driver();
- /** Channel groups available on this device, indexed by name. */
- map<string, shared_ptr<ChannelGroup> > get_channel_groups();
protected:
HardwareDevice(Driver *driver, struct sr_dev_inst *structure);
~HardwareDevice();
Driver *driver;
- map<string, ChannelGroup *> channel_groups;
friend class Driver;
friend class ChannelGroup;
};
bool get_enabled();
/** Set the enabled status of this channel. */
void set_enabled(bool value);
+ /** Get the index number of this channel. */
+ unsigned int get_index();
protected:
Channel(struct sr_channel *structure);
~Channel();
/** A group of channels on a device, which share some configuration */
class SR_API ChannelGroup :
- public StructureWrapper<HardwareDevice, struct sr_channel_group>,
+ public StructureWrapper<Device, struct sr_channel_group>,
public Configurable
{
public:
/** List of the channels in this group. */
vector<shared_ptr<Channel> > get_channels();
protected:
- ChannelGroup(HardwareDevice *device, struct sr_channel_group *structure);
+ ChannelGroup(Device *device, struct sr_channel_group *structure);
~ChannelGroup();
vector<Channel *> channels;
- friend class HardwareDevice;
+ friend class Device;
};
/** A trigger configuration */
/** Begin saving session to a file. */
void begin_save(string filename);
/** Append a packet to the session file being saved. */
- void append(shared_ptr<Device> device, shared_ptr<Packet> packet);
+ void append(shared_ptr<Packet> packet);
+ /** Append raw logic data to the session file being saved. */
+ void append(void *data, size_t length, unsigned int unit_size);
/** Get current trigger setting. */
shared_ptr<Trigger> get_trigger();
/** Set trigger setting. */
};
/** A packet on the session datafeed */
-class SR_API Packet
+class SR_API Packet : public enable_shared_from_this<Packet>
{
public:
/** Type of this packet. */
const PacketType *get_type();
/** Payload of this packet. */
- PacketPayload *get_payload();
+ shared_ptr<PacketPayload> get_payload();
protected:
- Packet(const struct sr_datafeed_packet *structure);
+ Packet(shared_ptr<Device> device,
+ const struct sr_datafeed_packet *structure);
~Packet();
const struct sr_datafeed_packet *structure;
+ shared_ptr<Device> device;
PacketPayload *payload;
/** Deleter needed to allow shared_ptr use with protected destructor. */
class Deleter
friend class Session;
friend class Output;
friend class DatafeedCallbackData;
+ friend class Header;
+ friend class Meta;
+ friend class Logic;
+ friend class Analog;
};
/** Abstract base class for datafeed packet payloads */
protected:
PacketPayload();
virtual ~PacketPayload() = 0;
- virtual void *get_data() = 0;
- virtual size_t get_data_size() = 0;
+ shared_ptr<PacketPayload> get_shared_pointer(Packet *parent) {
+ return static_pointer_cast<PacketPayload>(get_shared_pointer(parent));
+ }
+ /** Deleter needed to allow shared_ptr use with protected destructor. */
+ class Deleter
+ {
+ public:
+ void operator()(PacketPayload *payload) { delete payload; }
+ };
+ friend class Deleter;
friend class Packet;
friend class Output;
};
+/** Payload of a datafeed header packet */
+class SR_API Header : public PacketPayload,
+ public StructureWrapper<Packet, const struct sr_datafeed_header>
+{
+public:
+ int get_feed_version();
+ Glib::TimeVal get_start_time();
+protected:
+ Header(const struct sr_datafeed_header *structure);
+ ~Header();
+ const struct sr_datafeed_header *structure;
+ friend class Packet;
+};
+
+/** Payload of a datafeed metadata packet */
+class SR_API Meta : public PacketPayload,
+ public StructureWrapper<Packet, const struct sr_datafeed_meta>
+{
+public:
+ map<const ConfigKey *, Glib::VariantBase> get_config();
+protected:
+ Meta(const struct sr_datafeed_meta *structure);
+ ~Meta();
+ const struct sr_datafeed_meta *structure;
+ map<const ConfigKey *, Glib::VariantBase> config;
+ friend class Packet;
+};
+
/** Payload of a datafeed packet with logic data */
-class SR_API Logic : public PacketPayload
+class SR_API Logic : public PacketPayload,
+ public StructureWrapper<Packet, const struct sr_datafeed_logic>
{
+public:
+ /* Pointer to data. */
+ void *get_data_pointer();
+ /* Data length in bytes. */
+ size_t get_data_length();
+ /* Size of each sample in bytes. */
+ unsigned int get_unit_size();
protected:
Logic(const struct sr_datafeed_logic *structure);
~Logic();
const struct sr_datafeed_logic *structure;
- vector<uint8_t> data;
- void *get_data();
- size_t get_data_size();
friend class Packet;
};
/** Payload of a datafeed packet with analog data */
-class SR_API Analog : public PacketPayload
+class SR_API Analog : public PacketPayload,
+ public StructureWrapper<Packet, const struct sr_datafeed_analog>
{
public:
+ /** Pointer to data. */
+ float *get_data_pointer();
/** Number of samples in this packet. */
unsigned int get_num_samples();
+ /** Channels for which this packet contains data. */
+ vector<shared_ptr<Channel> > get_channels();
/** Measured quantity of the samples in this packet. */
const Quantity *get_mq();
/** Unit of the samples in this packet. */
Analog(const struct sr_datafeed_analog *structure);
~Analog();
const struct sr_datafeed_analog *structure;
- void *get_data();
- size_t get_data_size();
friend class Packet;
};
friend class InputFormat;
};
+/** An option used by an output format */
+class SR_API Option
+{
+public:
+ /** Short name of this option suitable for command line usage. */
+ string get_id();
+ /** Short name of this option suitable for GUI usage. */
+ string get_name();
+ /** Description of this option in a sentence. */
+ string get_description();
+ /** Default value for this option. */
+ Glib::VariantBase get_default_value();
+ /** Possible values for this option, if a limited set. */
+ vector<Glib::VariantBase> get_values();
+protected:
+ Option(const struct sr_option *structure,
+ shared_ptr<const struct sr_option> structure_array);
+ ~Option();
+ const struct sr_option *structure;
+ shared_ptr<const struct sr_option> structure_array;
+ /** Deleter needed to allow shared_ptr use with protected destructor. */
+ class Deleter
+ {
+ public:
+ void operator()(Option *option) { delete option; }
+ };
+ friend class Deleter;
+ friend class OutputFormat;
+};
+
/** An output format supported by the library */
class SR_API OutputFormat :
- public StructureWrapper<Context, struct sr_output_format>
+ public StructureWrapper<Context, const struct sr_output_module>
{
public:
/** Name of this output format. */
string get_name();
/** Description of this output format. */
string get_description();
+ /** Options supported by this output format. */
+ map<string, shared_ptr<Option> > get_options();
/** Create an output using this format. */
- shared_ptr<Output> create_output(shared_ptr<Device> device, map<string, string> options = {});
+ shared_ptr<Output> create_output(shared_ptr<Device> device,
+ map<string, Glib::VariantBase> options = {});
protected:
- OutputFormat(struct sr_output_format *structure);
+ OutputFormat(const struct sr_output_module *structure);
~OutputFormat();
friend class Context;
friend class Output;
protected:
Output(shared_ptr<OutputFormat> format, shared_ptr<Device> device);
Output(shared_ptr<OutputFormat> format,
- shared_ptr<Device> device, map<string, string> options);
+ shared_ptr<Device> device, map<string, Glib::VariantBase> options);
~Output();
- struct sr_output *structure;
+ const struct sr_output *structure;
const shared_ptr<OutputFormat> format;
const shared_ptr<Device> device;
- const map<string, string> options;
+ const map<string, Glib::VariantBase> options;
/** Deleter needed to allow shared_ptr use with protected destructor. */
class Deleter
{