val = -val;
*floatval = val;
- analog->encoding->digits = -exponent;
+ analog->encoding->digits = -exponent;
analog->spec->spec_digits = -exponent;
return SR_OK;
parse_flags(buf, info_local);
handle_flags(analog, floatval, &exponent, info_local);
- analog->encoding->digits = -exponent;
+ analog->encoding->digits = -exponent;
analog->spec->spec_digits = -exponent;
return SR_OK;
parse_flags(buf, info_local);
handle_flags(analog, floatval, &exponent, info_local);
- analog->encoding->digits = -exponent;
+ analog->encoding->digits = -exponent;
analog->spec->spec_digits = -exponent;
return SR_OK;
parse_flags(buf, info_local);
handle_flags(analog, floatval, &exponent, info_local);
- analog->encoding->digits = -exponent;
+ analog->encoding->digits = -exponent;
analog->spec->spec_digits = -exponent;
return SR_OK;
info->is_unitless = TRUE;
/* Bytes 0-1: Measurement mode, except AC/DC */
- info->is_resistance = !strncmp(buf, "OH", 2) ||
+ info->is_resistance = !strncmp(buf, "OH", 2) ||
(!strncmp(buf, " ", 2) && info->is_ohm);
- info->is_capacity = !strncmp(buf, "CA", 2) ||
+ info->is_capacity = !strncmp(buf, "CA", 2) ||
(!strncmp(buf, " ", 2) && info->is_farad);
info->is_temperature = !strncmp(buf, "TE", 2);
- info->is_diode = !strncmp(buf, "DI", 2) ||
+ info->is_diode = !strncmp(buf, "DI", 2) ||
(!strncmp(buf, " ", 2) && info->is_volt && info->is_milli);
- info->is_frequency = !strncmp(buf, "FR", 2) ||
+ info->is_frequency = !strncmp(buf, "FR", 2) ||
(!strncmp(buf, " ", 2) && info->is_hertz);
- info->is_gain = !strncmp(buf, "DB", 2);
- info->is_hfe = !strncmp(buf, "HF", 2) ||
+ info->is_gain = !strncmp(buf, "DB", 2);
+ info->is_hfe = !strncmp(buf, "HF", 2) ||
(!strncmp(buf, " ", 2) && !info->is_volt && !info->is_ohm &&
!info->is_logic && !info->is_farad && !info->is_hertz);
/*
parse_flags((const char *)buf, info_local);
handle_flags(analog, floatval, &exponent, info_local);
- analog->encoding->digits = -exponent;
+ analog->encoding->digits = -exponent;
analog->spec->spec_digits = -exponent;
return SR_OK;
*floatval = rawval;
- analog->encoding->digits = -exponent;
+ analog->encoding->digits = -exponent;
analog->spec->spec_digits = -exponent;
return SR_OK;
handle_flags(analog, floatval, info);
- analog->encoding->digits = -exponent;
+ analog->encoding->digits = -exponent;
analog->spec->spec_digits = -exponent;
return SR_OK;
static void parse_flags(const uint8_t *buf, struct vc870_info *info)
{
- /* Bytes 0/1: Function / function select */
+ /* Bytes 0/1: Function / function select */
/* Note: Some of these mappings are fixed up later. */
switch (buf[0]) {
case 0x30: /* DCV / ACV */
handle_flags(analog, floatval, info_local);
- analog->encoding->digits = -exponent;
+ analog->encoding->digits = -exponent;
analog->spec->spec_digits = -exponent;
return SR_OK;
* sr_driver_list is a special section contains pointers to all the hardware
* drivers built into the library. The __start and __stop symbols are
* auto-generated by the linker (OSX needs a little help) and point to the start
- * and end of the section. They are used to iterate over the list of all
+ * and end of the section. They are used to iterate over the list of all
* drivers.
*/
#ifdef __APPLE__
#define LOG_PREFIX "agilent-dmm"
-#define AGDMM_BUFSIZE 256
+#define AGDMM_BUFSIZE 256
/* Always USB-serial, 1ms is plenty. */
#define SERIAL_WRITE_TIMEOUT_MS 1
devc->mode_squarewave = 0;
- rstr = g_match_info_fetch(match, 4);
+ rstr = g_match_info_fetch(match, 4);
if (rstr && sr_atoi(rstr, &resolution) == SR_OK) {
devc->cur_digits = -resolution;
devc->cur_encoding = -resolution + 1;
}
g_free(rstr);
- mstr = g_match_info_fetch(match, 1);
+ mstr = g_match_info_fetch(match, 1);
if (!strncmp(mstr, "VOLT", 4)) {
devc->cur_mq = SR_MQ_VOLTAGE;
devc->cur_unit = SR_UNIT_VOLT;
devc->cur_digits = 4;
devc->cur_encoding = 5;
} else if (!strncmp(mstr, "T1", 2) || !strncmp(mstr, "T2", 2) ||
- !strncmp(mstr, "TEMP", 2)) {
+ !strncmp(mstr, "TEMP", 2)) {
devc->cur_mq = SR_MQ_TEMPERATURE;
m2 = g_match_info_fetch(match, 2);
if (!strcmp(m2, "FAR"))
#include "protocol.h"
typedef enum {
- LIVE_DATA = 0x00,
- LOG_METADATA = 0x11,
- LOG_DATA = 0x14,
- LOG_START = 0x18,
- LOG_END = 0x19,
+ LIVE_DATA = 0x00,
+ LOG_METADATA = 0x11,
+ LOG_DATA = 0x14,
+ LOG_START = 0x18,
+ LOG_END = 0x19,
} packet_type;
static gboolean appa_55ii_checksum(const uint8_t *buf)
#define LOG_PREFIX "appa-55ii"
-#define APPA_55II_NUM_CHANNELS 2
-#define APPA_55II_BUF_SIZE (4 + 32 + 1)
-#define DEFAULT_DATA_SOURCE DATA_SOURCE_LIVE
+#define APPA_55II_NUM_CHANNELS 2
+#define APPA_55II_BUF_SIZE (4 + 32 + 1)
+#define DEFAULT_DATA_SOURCE DATA_SOURCE_LIVE
enum {
DATA_SOURCE_LIVE,
struct dev_context {
/* Acquisition settings */
struct sr_sw_limits limits;
- gboolean data_source; /**< Whether to read live samples or memory */
+ gboolean data_source; /**< Whether to read live samples or memory */
/* Temporary state across callbacks */
uint8_t buf[APPA_55II_BUF_SIZE];
buf[15] &= ~0x04;
/* SI prefix */
- if (buf[14] & 0x40) { floatval[0] *= 1e-9; digits[0] += 9; } /* n */
- if (buf[15] & 0x08) { floatval[0] *= 1e-6; digits[0] += 6; } /* µ */
- if (buf[15] & 0x04) { floatval[0] *= 1e-3; digits[0] += 3; } /* m */
- if (buf[15] & 0x40) { floatval[0] *= 1e3; digits[0] -= 3; } /* k */
- if (buf[15] & 0x20) { floatval[0] *= 1e6; digits[0] -= 6; } /* M */
+ if (buf[14] & 0x40) { floatval[0] *= 1e-9; digits[0] += 9; } /* n */
+ if (buf[15] & 0x08) { floatval[0] *= 1e-6; digits[0] += 6; } /* µ */
+ if (buf[15] & 0x04) { floatval[0] *= 1e-3; digits[0] += 3; } /* m */
+ if (buf[15] & 0x40) { floatval[0] *= 1e3; digits[0] -= 3; } /* k */
+ if (buf[15] & 0x20) { floatval[0] *= 1e6; digits[0] -= 6; } /* M */
if (over_limit) floatval[0] = INFINITY;
if (buf[9] & 0x20) analog[1].meaning->mqflags |= SR_MQFLAG_AC;
/* SI prefix */
- if (buf[ 9] & 0x01) { floatval[1] *= 1e-6; digits[1] += 6; } /* µ */
- if (buf[ 9] & 0x02) { floatval[1] *= 1e-3; digits[1] += 3; } /* m */
- if (buf[14] & 0x02) { floatval[1] *= 1e3; digits[1] -= 3; } /* k */
- if (buf[14] & 0x01) { floatval[1] *= 1e6; digits[1] -= 6; } /* M */
+ if (buf[ 9] & 0x01) { floatval[1] *= 1e-6; digits[1] += 6; } /* µ */
+ if (buf[ 9] & 0x02) { floatval[1] *= 1e-3; digits[1] += 3; } /* m */
+ if (buf[14] & 0x02) { floatval[1] *= 1e3; digits[1] -= 3; } /* k */
+ if (buf[14] & 0x01) { floatval[1] *= 1e6; digits[1] -= 6; } /* M */
analog[1].encoding->digits = digits[1];
analog[1].spec->spec_digits = digits[1];
sr_dbg("Sending HID set report.");
ret = libusb_control_transfer(usb->devhdl,
- LIBUSB_REQUEST_TYPE_CLASS |
+ LIBUSB_REQUEST_TYPE_CLASS |
LIBUSB_RECIPIENT_INTERFACE |
LIBUSB_ENDPOINT_OUT,
9, /* bRequest: HID set_report */
devc = sdi->priv;
if (low == 30 && high == 130)
token = TOKEN_MEAS_RANGE_30_130;
- else if (low == 30 && high == 80)
+ else if (low == 30 && high == 80)
token = TOKEN_MEAS_RANGE_30_80;
- else if (low == 50 && high == 100)
+ else if (low == 50 && high == 100)
token = TOKEN_MEAS_RANGE_50_100;
- else if (low == 80 && high == 130)
+ else if (low == 80 && high == 130)
token = TOKEN_MEAS_RANGE_80_130;
else
return SR_ERR;
case 0x9:
/* Mean over a time period between 11 seconds and 24 hours.
* Which is so silly that there's no point in expressing
- * either this or the previous case. */
+ * either this or the previous case. */
analog.meaning->mqflags |= SR_MQFLAG_SPL_LAT \
| SR_MQFLAG_SPL_FREQ_WEIGHT_A \
| SR_MQFLAG_SPL_TIME_WEIGHT_F;
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-/** @file
- * <em>Conrad DIGI 35 CPU</em> power supply driver
- * @internal
+/**
+ * @file
+ *
+ * <em>Conrad DIGI 35 CPU</em> power supply driver
+ *
+ * @internal
*/
#include <config.h>
/**
* @file
+ *
* <em>Conrad DIGI 35 CPU</em> power supply driver
+ *
* @internal
*/
#define LOG_PREFIX "demo"
-#define DEFAULT_NUM_LOGIC_CHANNELS 8
-#define DEFAULT_NUM_ANALOG_CHANNELS 4
+#define DEFAULT_NUM_LOGIC_CHANNELS 8
+#define DEFAULT_NUM_ANALOG_CHANNELS 4
/* The size in bytes of chunks to send through the session bus. */
-#define LOGIC_BUFSIZE 4096
+#define LOGIC_BUFSIZE 4096
/* Size of the analog pattern space per channel. */
-#define ANALOG_BUFSIZE 4096
+#define ANALOG_BUFSIZE 4096
-#define DEFAULT_ANALOG_AMPLITUDE 10
-#define ANALOG_SAMPLES_PER_PERIOD 20
+#define DEFAULT_ANALOG_AMPLITUDE 10
+#define ANALOG_SAMPLES_PER_PERIOD 20
/* Logic patterns we can generate. */
enum {
}
static void send_analog_packet(struct analog_gen *ag,
- struct sr_dev_inst *sdi,
- uint64_t *analog_sent,
- uint64_t analog_pos,
- uint64_t analog_todo)
+ struct sr_dev_inst *sdi, uint64_t *analog_sent,
+ uint64_t analog_pos, uint64_t analog_todo)
{
struct sr_datafeed_packet packet;
struct dev_context *devc;
#define LOG_PREFIX "fluke-dmm"
-#define FLUKEDMM_BUFSIZE 256
+#define FLUKEDMM_BUFSIZE 256
/* Always USB-serial, 1ms is plenty. */
#define SERIAL_WRITE_TIMEOUT_MS 1
model = g_malloc(32);
serial_num = g_malloc(32);
rv = ftdi_usb_get_strings(ftdic, dev, vendor, 32,
- model, 32, serial_num, 32);
+ model, 32, serial_num, 32);
switch (rv) {
case 0:
break;
/* Send the logic */
for (i = 0; i < length; i++) {
- devc->logic_buffer[i] = data[i * 2];
+ devc->logic_buffer[i] = data[i * 2];
/* Rescale to -10V - +10V from 0-255. */
devc->analog_buffer[i] = (data[i * 2 + 1] - 128.0f) / 12.8f;
};
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-/** @file
- * Gossen Metrawatt Metrahit 1x/2x drivers
- * @internal
+/**
+ * @file
+ *
+ * Gossen Metrawatt Metrahit 1x/2x drivers
+ *
+ * @internal
*/
#include <config.h>
/** Hardware capabilities for Metrahit 1x/2x devices in send mode. */
static const uint32_t devopts_sm[] = {
SR_CONF_MULTIMETER,
- SR_CONF_THERMOMETER, /**< All GMC 1x/2x multimeters seem to support this */
+ SR_CONF_THERMOMETER, /**< All GMC 1x/2x multimeters seem to support this */
SR_CONF_CONTINUOUS,
SR_CONF_LIMIT_SAMPLES | SR_CONF_GET | SR_CONF_SET,
SR_CONF_LIMIT_MSEC | SR_CONF_GET | SR_CONF_SET,
/** Hardware capabilities for Metrahit 2x devices in bidirectional Mode. */
static const uint32_t devopts_bd[] = {
SR_CONF_MULTIMETER,
- SR_CONF_THERMOMETER, /**< All GMC 1x/2x multimeters seem to support this */
+ SR_CONF_THERMOMETER, /**< All GMC 1x/2x multimeters seem to support this */
SR_CONF_CONTINUOUS,
SR_CONF_LIMIT_SAMPLES | SR_CONF_GET | SR_CONF_SET,
SR_CONF_LIMIT_MSEC | SR_CONF_GET | SR_CONF_SET,
for (cnt = 0; cnt < 4; cnt++) {
byte = read_byte(serial, timeout_us);
if ((byte == -1) ||
- ((byte & MSGID_MASK) != MSGID_DATA))
+ ((byte & MSGID_MASK) != MSGID_DATA))
{
model = METRAHIT_NONE;
bytecnt = 100;
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-/** @file
- * Gossen Metrawatt Metrahit 1x/2x drivers
- * @internal
+/**
+ * @file
+ *
+ * Gossen Metrawatt Metrahit 1x/2x drivers
+ *
+ * @internal
*/
#include <config.h>
devc->value += pow(10.0, cnt) * dgt;
}
sr_spew("process_msg_inf_10() value=%f scale=%d scalet=%d",
- devc->value, devc->scale, devc->scale1000);
+ devc->value, devc->scale, devc->scale1000);
if (devc->value != NAN)
devc->value *= pow(10, devc->scale) * pow(1000.0, devc->scale1000);
send_value(sdi);
}
-/** Dump contents of 14-byte message.
- * @param buf Pointer to array of 14 data bytes.
- * @param[in] raw Write only data bytes, no interpretation.
+/**
+ * Dump contents of 14-byte message.
+ *
+ * @param buf Pointer to array of 14 data bytes.
+ * @param[in] raw Write only data bytes, no interpretation.
*/
static void dump_msg14(guchar *buf, gboolean raw)
{
buf[12], buf[13]);
}
-/** Calc checksum for 14 byte message type.
+/**
+ * Calc checksum for 14 byte message type.
*
- * @param[in] dta Pointer to array of 13 data bytes.
- * @return Checksum.
+ * @param[in] dta Pointer to array of 13 data bytes.
+ * @return Checksum.
*/
static guchar calc_chksum_14(guchar *dta)
{
struct dev_context *devc;
int retc;
gboolean isreq; /* Message is request to multimeter (otherwise response) */
- uint8_t addr; /* Adaptor address */
+ uint8_t addr; /* Adaptor address */
retc = SR_OK;
sr_spew("Measurement Function: %d ", (int)devc->buf[7]);
decode_ctmv_2x(devc->buf[7], devc);
sr_spew("Range: 0x%x", devc->buf[8]);
- decode_rs_2x_TR2(devc->buf[8] & 0x0f, devc); /* Docs wrong, uses conversion table TR_2! */
+ decode_rs_2x_TR2(devc->buf[8] & 0x0f, devc); /* Docs wrong, uses conversion table TR_2! */
devc->autorng = (devc->buf[8] & 0x20) == 0;
// TODO 9, 10: 29S special functions
devc->ubatt = 0.1 * (float)devc->buf[11];
sr_spew("Internal version %d.%d", (int)devc->buf[5], (int)devc->buf[4]);
sr_spew("Comm mode: 0x%x", (int)devc->buf[6]);
sr_spew("Block cnt%%64: %d", (int)devc->buf[7]);
- sr_spew("drpCi: %d drpCh: %d", (int)devc->buf[8], (int)devc->buf[9]);
+ sr_spew("drpCi: %d drpCh: %d", (int)devc->buf[8], (int)devc->buf[9]);
// Semantics undocumented. Possibly Metrahit 29S dropouts stuff?
break;
default:
return TRUE;
}
-/** Create 14 (42) byte command for Metrahit 2x multimeter in bidir mode.
+/**
+ * Create 14 (42) byte command for Metrahit 2x multimeter in bidir mode.
*
- * Actually creates 42 bytes due to the encoding method used.
- * @param[in] addr Device address (0=adapter, 1..15 multimeter; for byte 0).
- * @param[in] func Function code (byte 3).
- * @param[in] params Further parameters (9 bytes)
- * @param[out] buf Buffer to create msg in (42 bytes).
+ * Actually creates 42 bytes due to the encoding method used.
+ *
+ * @param[in] addr Device address (0=adapter, 1..15 multimeter; for byte 0).
+ * @param[in] func Function code (byte 3).
+ * @param[in] params Further parameters (9 bytes)
+ * @param[out] buf Buffer to create msg in (42 bytes).
*/
static void create_cmd_14(guchar addr, guchar func, guchar *params, guchar *buf)
{
return SR_OK;
}
-/** Request status from 2x multimeter (msg 3).
- * @param[in] power_on Try to power on powered off multimeter by sending additional messages.
+/**
+ * Request status from 2x multimeter (msg 3).
+ *
+ * @param[in] power_on Try to power on powered off multimeter by sending
+ * additional messages.
*/
int req_stat14(const struct sr_dev_inst *sdi, gboolean power_on)
{
}
}
-/** Convert GMC model code in bidirectional mode to sigrok-internal one.
+/**
+ * Convert GMC model code in bidirectional mode to sigrok-internal one.
*
- * @param[in] mcode Model code.
+ * @param[in] mcode Model code.
*
- * @return Model code.
+ * @return Model code.
*/
SR_PRIV int gmc_decode_model_bd(uint8_t mcode)
{
}
}
-/** Convert sigrok-internal model code to string.
+/**
+ * Convert sigrok-internal model code to string.
*
- * @param[in] mcode Model code.
+ * @param[in] mcode Model code.
*
- * @return Model code string.
+ * @return Model code string.
*/
SR_PRIV const char *gmc_model_str(enum model mcode)
{
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-/** @file
- * Gossen Metrawatt Metrahit 1x/2x drivers
- * @internal
+/**
+ * @file
+ *
+ * Gossen Metrawatt Metrahit 1x/2x drivers
+ *
+ * @internal
*/
#ifndef LIBSIGROK_HARDWARE_GMC_MH_1X_2X_PROTOCOL_H
#define MSGID_DTA 0x20 /**< Start of data message, displayed, averaged */
#define MSGID_DATA 0x30 /**< Data byte in message */
-#define MSGC_MASK 0x0f /**< Mask to get message byte contents in send mode */
+#define MSGC_MASK 0x0f /**< Mask to get message byte contents in send mode */
#define MSGSRC_MASK 0xc0 /**< Mask to get bits related to message source */
devc = g_malloc0(sizeof(struct dev_context));
devc->frame_limit = 1;
- devc->sample_rate = 0.;
- devc->df_started = FALSE;
+ devc->sample_rate = 0.0;
+ devc->df_started = FALSE;
sdi->priv = devc;
sr_channel_new(sdi, 0, SR_CHANNEL_ANALOG, TRUE, "CH1");
for (i = 0; i < config->analog_channels; i++) {
tmp = sr_voltage_string((*config->vdivs)[state->analog_channels[i].vdiv][0],
(*config->vdivs)[state->analog_channels[i].vdiv][1]);
- sr_info("State of analog channel %d -> %s : %s (coupling) %s (vdiv) %2.2e (offset)",
+ sr_info("State of analog channel %d -> %s : %s (coupling) %s (vdiv) %2.2e (offset)",
i + 1, state->analog_channels[i].state ? "On" : "Off",
(*config->coupling_options)[state->analog_channels[i].coupling],
tmp, state->analog_channels[i].vertical_offset);
err = libusb_claim_interface(usb->devhdl, USB_INTERFACE);
if (err != 0) {
sr_err("Unable to claim interface: %s.",
- libusb_error_name(err));
+ libusb_error_name(err));
return SR_ERR;
}
#define MAX_RENUM_DELAY_MS 3000
#define DEFAULT_VOLTAGE 2
-#define DEFAULT_COUPLING COUPLING_DC
+#define DEFAULT_COUPLING COUPLING_DC
#define DEFAULT_SAMPLERATE SR_MHZ(8)
#define NUM_CHANNELS 2
SR_KHZ(100),
#define SAMPLERATE_REGS \
- 48, 30, 24, 16, 8, 4, 1, 50, 20, 10,
+ 48, 30, 24, 16, 8, 4, 1, 50, 20, 10,
#define VDIV_VALUES \
{ 100, 1000 }, \
/* TODO tune this properly */
#define TICK 1
-#define NUM_TIMEBASE 10
-#define NUM_VDIV 8
+#define NUM_TIMEBASE 10
+#define NUM_VDIV 8
#define NUM_BUFFER_SIZES 2
err = libusb_claim_interface(usb->devhdl, USB_INTERFACE);
if (err != 0) {
sr_err("Unable to claim interface: %s.",
- libusb_error_name(err));
+ libusb_error_name(err));
return SR_ERR;
}
num_samples = transfer->actual_length / 2;
sr_spew("Got %d-%d/%d samples in frame.", devc->samp_received + 1,
- devc->samp_received + num_samples, devc->framesize);
+ devc->samp_received + num_samples, devc->framesize);
/*
* The device always sends a full frame, but the beginning of the frame
/* The rest of this chunk starts with the trigger point. */
sr_dbg("Reached trigger point, %d samples buffered.",
- devc->samp_buffered);
+ devc->samp_buffered);
/* Avoid the corner case where the chunk ended at
* exactly the trigger point. */
/* That was the last chunk in this frame. Send the buffered
* pre-trigger samples out now, in one big chunk. */
sr_dbg("End of frame, sending %d pre-trigger buffered samples.",
- devc->samp_buffered);
+ devc->samp_buffered);
send_chunk(sdi, devc->framebuf, devc->samp_buffered);
/* Mark the end of this frame. */
};
static int send_mq_ac_dc(struct sr_scpi_dev_inst *scpi, const char *mode,
- enum sr_mqflag flags)
+ enum sr_mqflag flags)
{
const char *ac_flag, *dc_flag;
* trigger on (rising or falling)
* The next state is 0x0C
* 0x0C Same as state 0x0F but expects the calibration
- * value for the first channel's position
+ * value for the first channel's position
* (POS1 in the schematics)
* The next state is 0x0D
* 0x0D Same as state 0x0F but expects the calibration
- * value for the second channel's position
+ * value for the second channel's position
* (POS2 in the schematics)
* The next state is 0x0E
* 0x0E Same as state 0x0F but expects the trigger level
usb = sdi->conn;
if (!usb->devhdl)
- /* Nothing to do. */
+ /* Nothing to do. */
return SR_OK;
/* This allows a frontend to configure the device without ever
usb = sdi->conn;
if (!usb->devhdl)
- /* Nothing to do. */
+ /* Nothing to do. */
return SR_OK;
libusb_release_interface(usb->devhdl, LASCAR_INTERFACE);
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
-/** @file
- * <em>Manson HCS-3xxx series</em> power supply driver
- * @internal
- */
+/**
+ * @file
+ *
+ * <em>Manson HCS-3xxx series</em> power supply driver
+ *
+ * @internal
+ */
#include <config.h>
#include "protocol.h"
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
-/** @file
- * <em>Manson HCS-3xxx Series</em> power supply driver
- * @internal
- */
+/**
+ * @file
+ *
+ * <em>Manson HCS-3xxx Series</em> power supply driver
+ *
+ * @internal
+ */
#include <config.h>
#include "protocol.h"
/**
* Read data from interface into buffer blocking until @a lines number of \\r chars
* received.
+ *
* @param serial Previously initialized serial port structure.
* @param[in] lines Number of \\r-terminated lines to read (1-n).
- * @param buf Buffer for result. Contents is NUL-terminated on success.
+ * @param buf Buffer for result. Contents is NUL-terminated on success.
* @param[in] buflen Buffer length (>0).
+ *
* @retval SR_OK Lines received and ending with "OK\r" (success).
* @retval SR_ERR Error.
* @retval SR_ERR_ARG Invalid argument.
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
-/** @file
- * <em>Manson HCS-3xxx Series</em> power supply driver
- * @internal
- */
+/**
+ * @file
+ *
+ * <em>Manson HCS-3xxx Series</em> power supply driver
+ *
+ * @internal
+ */
#ifndef LIBSIGROK_HARDWARE_MANSON_HCS_3XXX_PROTOCOL_H
#define LIBSIGROK_HARDWARE_MANSON_HCS_3XXX_PROTOCOL_H
SR_CONF_OVER_TEMPERATURE_PROTECTION_ACTIVE | SR_CONF_GET,
};
-/* The IDs in this list are only guessed and needs to be verified
- against some real hardware. If at least a few of them matches,
- it will probably be safe to enable the others. */
+/*
+ * The IDs in this list are only guessed and needs to be verified
+ * against some real hardware. If at least a few of them matches,
+ * it will probably be safe to enable the others.
+ */
static const struct maynuo_m97_model supported_models[] = {
// { 53, "M9711" , 30, 150, 150 },
// { 54, "M9712" , 30, 150, 300 },
static GSList *scan(struct sr_dev_driver *di, GSList *options)
{
struct sr_config default_serialcomm = {
- .key = SR_CONF_SERIALCOMM,
- .data = g_variant_new_string("9600/8n1"),
+ .key = SR_CONF_SERIALCOMM,
+ .data = g_variant_new_string("9600/8n1"),
};
struct sr_config default_modbusaddr = {
- .key = SR_CONF_MODBUSADDR,
- .data = g_variant_new_uint64(1),
+ .key = SR_CONF_MODBUSADDR,
+ .data = g_variant_new_uint64(1),
};
GSList *opts = options, *devices;
/* Wait for the last data that was requested from the device. */
uint16_t registers[devc->expecting_registers];
sr_modbus_read_holding_registers(modbus, -1,
- devc->expecting_registers,
- registers);
+ devc->expecting_registers, registers);
}
maynuo_m97_set_bit(modbus, PC1, 0);
uint16_t registers[2];
int ret;
ret = sr_modbus_read_holding_registers(modbus, MODEL, 2, registers);
- *model = RB16(registers+0);
- *version = RB16(registers+1);
+ *model = RB16(registers + 0);
+ *version = RB16(registers + 1);
return ret;
}
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-/** @file
- * <em>Motech LPS-30x series</em> power supply driver
- * @internal
+/**
+ * @file
+ *
+ * <em>Motech LPS-30x series</em> power supply driver
+ *
+ * @internal
*/
#include <config.h>
va_list args;
char buf[LINELEN_MAX];
char *bufptr;
- int buflen;
+ int buflen;
/* Send command */
va_start(args, fmt);
return SR_ERR;
}
-/** Send command and read reply string.
- * @param reply Pointer to buffer of size LINELEN_MAX. Will be NUL-terminated.
+/**
+ * Send command and read reply string.
+ * @param reply Pointer to buffer of size LINELEN_MAX. Will be NUL-terminated.
*/
SR_PRIV int lps_cmd_reply(char *reply, struct sr_serial_dev_inst *serial, const char *fmt, ...)
{
va_list args;
char buf[LINELEN_MAX];
char *bufptr;
- int buflen;
+ int buflen;
reply[0] = '\0';
return result;
}
-/** Read message into buf until "OK" received.
- * @retval SR_OK Msg received; buf and buflen contain result, if any except OK.
- * @retval SR_ERR Error, including timeout.
+/**
+ * Read message into buf until "OK" received.
+ *
+ * @retval SR_OK Msg received; buf and buflen contain result, if any except OK.
+ * @retval SR_ERR Error, including timeout.
*/
SR_PRIV int lps_read_reply(struct sr_serial_dev_inst *serial, char **buf, int *buflen)
{
g_strstrip(buf);
verstr = buf + 4;
}
- else /* Bug in device FW 1.17: Querying version string fails while output is active.
+ else /* Bug in device FW 1.17: Querying version string fails while output is active.
Therefore just print an error message, but do not exit with error. */
sr_err("Failed to query for hardware version: %s.",
sr_strerror(ret));
case SR_CONF_DEVICE_OPTIONS:
if ((ch_idx == 0) || (ch_idx == 1)) /* CH1, CH2 */
*data = g_variant_new_fixed_array(G_VARIANT_TYPE_UINT32,
- devopts_ch12, ARRAY_SIZE(devopts_ch12), sizeof(uint32_t));
+ devopts_ch12, ARRAY_SIZE(devopts_ch12), sizeof(uint32_t));
else /* Must be CH3 */
*data = g_variant_new_fixed_array(G_VARIANT_TYPE_UINT32,
- devopts_ch3, ARRAY_SIZE(devopts_ch3), sizeof(uint32_t));
+ devopts_ch3, ARRAY_SIZE(devopts_ch3), sizeof(uint32_t));
break;
case SR_CONF_VOLTAGE_TARGET:
g_variant_builder_init(&gvb, G_VARIANT_TYPE_ARRAY);
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-/** @file
- * <em>Motech LPS-30x series</em> power supply driver
- * @internal
+/**
+ * @file
+ *
+ * <em>Motech LPS-30x series</em> power supply driver
+ *
+ * @internal
*/
#include <config.h>
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-/** @file
- * <em>Motech LPS-30x series</em> power supply driver
- * @internal
+/**
+ * @file
+ *
+ * <em>Motech LPS-30x series</em> power supply driver
+ *
+ * @internal
*/
#ifndef LIBSIGROK_HARDWARE_MOTECH_LPS_30X_PROTOCOL_H
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-/** @file
- * Norma DM9x0/Siemens B102x DMMs driver.
- * @internal
+/**
+ * @file
+ *
+ * Norma DM9x0/Siemens B102x DMMs driver.
+ *
+ * @internal
*/
#include <config.h>
/* 4: Flags. Evaluating this after setting value! */
flags = xgittoint(devc->buf[4]);
if (flags & 0x04) /* Invalid value */
- value = NAN;
+ value = NAN;
else if (flags & 0x01) /* Overload */
- value = INFINITY;
+ value = INFINITY;
if (flags & 0x02) { /* Duplicate value, has been sent before. */
- sr_spew("Duplicate value, dismissing!");
- devc->buflen = 0;
- return;
+ sr_spew("Duplicate value, dismissing!");
+ devc->buflen = 0;
+ return;
}
sr_spew("range=%d/scale=%f/value=%f", range,
#include <libsigrok/libsigrok.h>
#include "libsigrok-internal.h"
-/** @file
- * Norma DM9x0/Siemens B102x DMMs driver.
- * @internal
+/**
+ * @file
+ *
+ * Norma DM9x0/Siemens B102x DMMs driver.
+ *
+ * @internal
*/
#define LOG_PREFIX "norma-dmm"
-#define NMADMM_BUFSIZE 256
+#define NMADMM_BUFSIZE 256
#define NMADMM_TIMEOUT_MS 2000 /**< Request timeout. */
return SR_OK;
if (rigol_ds_config_set(sdi, ":WAV:SOUR CHAN%d",
- ch->index + 1) != SR_OK)
+ ch->index + 1) != SR_OK)
return SR_ERR;
/* Check that the number of samples will be accepted */
if (rigol_ds_config_set(sdi, ":WAV:POIN %d", devc->analog_frame_size) != SR_OK)
break;
case PROTOCOL_V3:
if (rigol_ds_config_set(sdi, ":WAV:SOUR CHAN%d",
- ch->index + 1) != SR_OK)
+ ch->index + 1) != SR_OK)
return SR_ERR;
if (devc->data_source != DATA_SOURCE_LIVE) {
if (rigol_ds_config_set(sdi, ":WAV:RES") != SR_OK)
for (j = 0; j < ARRAY_SIZE(channel_names); j++)
sr_channel_new(sdi, j, SR_CHANNEL_LOGIC, TRUE,
- channel_names[j]);
+ channel_names[j]);
devc = g_malloc0(sizeof(struct dev_context));
devc->selected_voltage_range = VOLTAGE_RANGE_18_33_V;
};
static struct sr_dev_inst *probe_device(struct sr_scpi_dev_inst *scpi,
- int (*get_hw_id)(struct sr_scpi_dev_inst *scpi,
- struct sr_scpi_hw_info **scpi_response)
- )
+ int (*get_hw_id)(struct sr_scpi_dev_inst *scpi,
+ struct sr_scpi_hw_info **scpi_response))
{
struct dev_context *devc;
struct sr_dev_inst *sdi;
sr_dbg("output %d: %.0f - %.0fV, %.0f - %.0fA, %.0f - %.0fW", i + 1,
spec->voltage[0], spec->voltage[1],
spec->current[0], spec->current[1],
- spec->power[0] , spec->power[1]);
+ spec->power[0], spec->power[1]);
(*channels)[i].name = (char *)philips_pm2800_names[i];
memcpy(&((*channels)[i].voltage), spec, sizeof(float) * 15);
(*channel_groups)[i].name = (char *)philips_pm2800_names[i];
uint32_t baudrate;
/** Packet size in bytes. */
int packet_size;
- /** Request timeout [ms] before request is considered lost and a new
- * one is sent. Used only if device needs polling. */
+ /**
+ * Request timeout [ms] before request is considered lost and a new
+ * one is sent. Used only if device needs polling.
+ */
int64_t req_timeout_ms;
- /** Delay between reception of packet and next request. Some DMMs
- * need this. Used only if device needs polling. */
+ /**
+ * Delay between reception of packet and next request. Some DMMs
+ * need this. Used only if device needs polling.
+ */
int64_t req_delay_ms;
/** Packet request function. */
int (*packet_request)(struct sr_serial_dev_inst *);
int bufoffset;
int buflen;
- /** The timestamp [µs] to send the next request.
- * Used only if device needs polling. */
+ /**
+ * The timestamp [µs] to send the next request.
+ * Used only if device needs polling.
+ */
int64_t req_next_at;
};
* alignment is guaranteed.
*/
out_p = (uint32_t *)&acq->out_packet[acq->out_index * UNIT_SIZE];
- in_p = &acq->xfer_buf_in[acq->in_index];
+ in_p = &acq->xfer_buf_in[acq->in_index];
/*
* Transfer two samples at a time, taking care to swap the 16-bit
* halves of each input word but keeping the samples themselves in
unsigned char reply[512];
devc = sdi->priv;
- usb = sdi->conn;
+ usb = sdi->conn;
command[0] = LWLA_WORD(CMD_READ_MEM32);
command[1] = LWLA_WORD_0(start);
int ret;
devc = sdi->priv;
- usb = sdi->conn;
+ usb = sdi->conn;
ret = lwla_write_reg(usb, REG_CHAN_MASK, devc->channel_mask);
if (ret != SR_OK)
unsigned int chunk_len, count;
devc = sdi->priv;
- acq = devc->acquisition;
+ acq = devc->acquisition;
acq->xfer_out->length = 0;
acq->reg_seq_pos = 0;
int expect_len;
devc = sdi->priv;
- acq = devc->acquisition;
+ acq = devc->acquisition;
switch (devc->state) {
case STATE_STATUS_REQUEST:
const int lreg_count = 10;
devc = sdi->priv;
- usb = sdi->conn;
+ usb = sdi->conn;
command[0] = LWLA_WORD(CMD_READ_LREGS);
command[1] = LWLA_WORD(0);
int ret;
devc = sdi->priv;
- usb = sdi->conn;
- acq = devc->acquisition;
+ usb = sdi->conn;
+ acq = devc->acquisition;
ret = lwla_write_regs(usb, capture_init, ARRAY_SIZE(capture_init));
if (ret != SR_OK)
bulk_long_set(acq, LREG_DIV_COUNT, divider_count);
bulk_long_set(acq, LREG_TRG_VALUE, devc->trigger_values);
- bulk_long_set(acq, LREG_TRG_TYPE, devc->trigger_edge_mask);
+ bulk_long_set(acq, LREG_TRG_TYPE, devc->trigger_edge_mask);
trigger_mask = devc->trigger_mask;
int expect_len;
devc = sdi->priv;
- acq = devc->acquisition;
+ acq = devc->acquisition;
switch (devc->state) {
case STATE_STATUS_REQUEST:
return SR_ERR;
}
acq->mem_addr_fill = bulk_long_get(acq, LREG_MEM_FILL) & 0xFFFFFFFF;
- acq->duration_now = bulk_long_get(acq, LREG_DURATION);
+ acq->duration_now = bulk_long_get(acq, LREG_DURATION);
/* Shift left by one so the bit positions match the LWLA1016. */
acq->status = (bulk_long_get(acq, LREG_STATUS) & 0x3F) << 1;
/*
int ret;
devc = sdi->priv;
- acq = devc->acquisition;
+ acq = devc->acquisition;
devc->state = state;
unsigned int old_status;
devc = sdi->priv;
- acq = devc->acquisition;
+ acq = devc->acquisition;
old_status = acq->status;
if ((*devc->model->handle_response)(sdi) != SR_OK) {
struct acquisition_state *acq;
devc = sdi->priv;
- acq = devc->acquisition;
+ acq = devc->acquisition;
if ((*devc->model->handle_response)(sdi) != SR_OK) {
devc->transfer_error = TRUE;
unsigned int end_addr;
devc = sdi->priv;
- acq = devc->acquisition;
+ acq = devc->acquisition;
/* Prepare session packet. */
- packet.type = SR_DF_LOGIC;
+ packet.type = SR_DF_LOGIC;
packet.payload = &logic;
logic.unitsize = (devc->model->num_channels + 7) / 8;
- logic.data = acq->out_packet;
+ logic.data = acq->out_packet;
end_addr = MIN(acq->mem_addr_next, acq->mem_addr_stop);
acq->in_index = 0;
struct acquisition_state *acq;
devc = sdi->priv;
- acq = devc->acquisition;
+ acq = devc->acquisition;
devc->acquisition = NULL;
(void)fd;
- sdi = cb_data;
+ sdi = cb_data;
devc = sdi->priv;
drvc = sdi->driver->context;
return G_SOURCE_REMOVE;
/* Handle pending USB events without blocking. */
- tv.tv_sec = 0;
+ tv.tv_sec = 0;
tv.tv_usec = 0;
ret = libusb_handle_events_timeout_completed(drvc->sr_ctx->libusb_ctx,
&tv, NULL);
struct dev_context *devc;
struct acquisition_state *acq;
- sdi = transfer->user_data;
+ sdi = transfer->user_data;
devc = sdi->priv;
- acq = devc->acquisition;
+ acq = devc->acquisition;
if (transfer->status != LIBUSB_TRANSFER_COMPLETED) {
sr_err("Transfer to device failed (state %d): %s.",
struct dev_context *devc;
struct acquisition_state *acq;
- sdi = transfer->user_data;
+ sdi = transfer->user_data;
devc = sdi->priv;
- acq = devc->acquisition;
+ acq = devc->acquisition;
if (transfer->status != LIBUSB_TRANSFER_COMPLETED) {
sr_err("Transfer from device failed (state %d): %s.",
struct acquisition_state *acq;
devc = sdi->priv;
- usb = sdi->conn;
+ usb = sdi->conn;
if (devc->acquisition) {
sr_err("Acquisition still in progress?");
struct sr_sw_limits sw_limits;
/* Operational state */
- enum optarif optarif; /**< The device mode (which measures are reported) */
+ enum optarif optarif; /**< The device mode (which measures are reported) */
/* Temporary state across callbacks */
uint8_t buf[TELEINFO_BUF_SIZE];
usb = sdi->conn;
if (!usb->devhdl)
- /* Nothing to do. */
+ /* Nothing to do. */
return SR_OK;
libusb_release_interface(usb->devhdl, 0);
} else if (devc->state == GET_PACKET) {
/* Read a packet from the device. */
ret = serial_read_nonblocking(serial, devc->buf + devc->buflen,
- 4 - devc->buflen);
+ 4 - devc->buflen);
if (ret < 0) {
sr_err("Error reading packet: %d.", ret);
return TRUE;
std_session_send_df_header(sdi);
sr_session_source_add(sdi->session, -1, 0, 10 /* poll_timeout */,
- uni_t_dmm_receive_data, (void *)sdi);
+ uni_t_dmm_receive_data, (void *)sdi);
return SR_OK;
}
#define DMM(ID, CHIPSET, VENDOR, MODEL, BAUDRATE, PACKETSIZE, \
VALID, PARSE, DETAILS) \
- &((struct dmm_info) { \
+ &((struct dmm_info) { \
{ \
.name = ID, \
.longname = VENDOR " " MODEL, \
usb = sdi->conn;
if (!usb->devhdl)
- /* Nothing to do. */
+ /* Nothing to do. */
return SR_OK;
libusb_release_interface(usb->devhdl, USB_INTERFACE);
#define EP_OUT 2
enum {
- DATA_SOURCE_LIVE,
+ DATA_SOURCE_LIVE,
DATA_SOURCE_MEMORY,
};
#define VICTOR_VENDOR "Victor"
#define VICTOR_INTERFACE 0
#define VICTOR_ENDPOINT (LIBUSB_ENDPOINT_IN | 1)
+
static int dev_acquisition_stop(struct sr_dev_inst *sdi);
static const uint32_t drvopts[] = {
usb = sdi->conn;
if (!usb->devhdl)
- /* Nothing to do. */
+ /* Nothing to do. */
return SR_OK;
libusb_release_interface(usb->devhdl, VICTOR_INTERFACE);
.num_ydivs = 8,
},
{
- .model_id = {"710110", "710120", "710130", NULL},
- .model_name = {"DLM2024", "DLM2034", "DLM2054", NULL},
+ .model_id = {"710110", "710120", "710130", NULL},
+ .model_name = {"DLM2024", "DLM2034", "DLM2054", NULL},
.analog_channels = 4,
.digital_channels = 8,
.pods = 1,
},
{
.model_id = {"701307", "701308", "701310", "701311",
- "701312", "701313", NULL},
+ "701312", "701313", NULL},
.model_name = {"DL9040", "DL9040L", "DL9140", "DL9140L",
- "DL9240", "DL9240L", NULL},
+ "DL9240", "DL9240L", NULL},
.analog_channels = 4,
.digital_channels = 0,
.pods = 0,
}
SR_PRIV int analyzer_read_data(libusb_device_handle *devh, void *buffer,
- unsigned int size)
+ unsigned int size)
{
return gl_read_bulk(devh, buffer, size);
}
}
g_filter_status[i] |=
- 1 << ((2 * channel) + (type == FILTER_LOW ? 1 : 0));
+ 1 << ((2 * channel) + (type == FILTER_LOW ? 1 : 0));
g_filter_enable = 1;
}
SR_PRIV void analyzer_set_freq(int freq, int scale);
SR_PRIV void analyzer_set_ramsize_trigger_address(unsigned int address);
SR_PRIV void analyzer_set_triggerbar_address(unsigned int address);
-SR_PRIV unsigned int analyzer_get_ramsize_trigger_address(void );
+SR_PRIV unsigned int analyzer_get_ramsize_trigger_address(void );
SR_PRIV unsigned int analyzer_get_triggerbar_address(void);
SR_PRIV void analyzer_set_compression(unsigned int type);
SR_PRIV void analyzer_set_memory_size(unsigned int size);
SR_PRIV void analyzer_wait(libusb_device_handle *devh, int set, int unset);
SR_PRIV void analyzer_read_start(libusb_device_handle *devh);
SR_PRIV int analyzer_read_data(libusb_device_handle *devh, void *buffer,
- unsigned int size);
+ unsigned int size);
SR_PRIV void analyzer_read_stop(libusb_device_handle *devh);
SR_PRIV void analyzer_start(libusb_device_handle *devh);
SR_PRIV void analyzer_configure(libusb_device_handle *devh);
case SR_CONF_DEVICE_OPTIONS:
if (!sdi) {
*data = g_variant_new_fixed_array(G_VARIANT_TYPE_UINT32,
- drvopts, ARRAY_SIZE(drvopts), sizeof(uint32_t));
+ drvopts, ARRAY_SIZE(drvopts), sizeof(uint32_t));
} else {
*data = g_variant_new_fixed_array(G_VARIANT_TYPE_UINT32,
- devopts, ARRAY_SIZE(devopts), sizeof(uint32_t));
+ devopts, ARRAY_SIZE(devopts), sizeof(uint32_t));
}
break;
case SR_CONF_SAMPLERATE:
SR_PRIV int gl_read_bulk(libusb_device_handle *devh, void *buffer,
unsigned int size)
{
- unsigned char packet[8] =
- { 0, 0, 0, 0, size & 0xff, (size & 0xff00) >> 8,
- (size & 0xff0000) >> 16, (size & 0xff000000) >> 24 };
+ unsigned char packet[8] = {
+ 0, 0, 0, 0, size & 0xff, (size & 0xff00) >> 8,
+ (size & 0xff0000) >> 16, (size & 0xff000000) >> 24
+ };
int ret, transferred = 0;
ret = libusb_control_transfer(devh, CTRL_OUT, 0x4, REQ_READBULK,
}
}
-/** Allocate struct sr_config.
- * A floating reference can be passed in for data.
- * @private
+/**
+ * Allocate struct sr_config.
+ *
+ * A floating reference can be passed in for data.
+ *
+ * @private
*/
SR_PRIV struct sr_config *sr_config_new(uint32_t key, GVariant *data)
{
return src;
}
-/** Free struct sr_config.
- * @private
+/**
+ * Free struct sr_config.
+ *
+ * @private
*/
SR_PRIV void sr_config_free(struct sr_config *src)
{
* Otherwise it must be NULL. If sdi is != NULL, sdi->priv must
* also be != NULL.
* @param[in] cg The channel group on the device for which to list the
- * values, or NULL.
+ * values, or NULL.
* @param[in] key The configuration key (SR_CONF_*).
* @param[in,out] data Pointer to a GVariant where the value will be stored.
* Must not be NULL. The caller is given ownership of the GVariant
* @retval SR_OK Success.
* @retval SR_ERR Error.
* @retval SR_ERR_ARG The driver doesn't know that key, but this is not to be
- * interpreted as an error by the caller; merely as an indication
- * that it's not applicable.
+ * interpreted as an error by the caller; merely as an indication
+ * that it's not applicable.
*
* @since 0.3.0
*/
* @retval SR_OK Success.
* @retval SR_ERR Error.
* @retval SR_ERR_ARG The driver doesn't know that key, but this is not to be
- * interpreted as an error by the caller; merely as an indication
- * that it's not applicable.
+ * interpreted as an error by the caller; merely as an indication
+ * that it's not applicable.
*
* @since 0.3.0
*/
* @retval SR_OK Success.
* @retval SR_ERR Error.
* @retval SR_ERR_ARG The driver doesn't know that key, but this is not to be
- * interpreted as an error by the caller; merely as an indication
- * that it's not applicable.
+ * interpreted as an error by the caller; merely as an indication
+ * that it's not applicable.
*
* @since 0.3.0
*/
#define LOG_PREFIX "input/binary"
-#define MAX_CHUNK_SIZE 4096
-#define DEFAULT_NUM_CHANNELS 8
-#define DEFAULT_SAMPLERATE 0
+#define MAX_CHUNK_SIZE 4096
+#define DEFAULT_NUM_CHANNELS 8
+#define DEFAULT_SAMPLERATE 0
struct context {
gboolean started;
/* Comment prefix character(s). */
GString *comment;
- /* Termination character(s) used in current stream. */
+ /* Termination character(s) used in current stream. */
char *termination;
/* Determines if sample data is stored in multiple columns. */
#define LOG_PREFIX "input/raw_analog"
/* How many bytes at a time to process and send to the session bus. */
-#define CHUNK_SIZE 4096
-#define DEFAULT_NUM_CHANNELS 1
-#define DEFAULT_SAMPLERATE 0
+#define CHUNK_SIZE 4096
+#define DEFAULT_NUM_CHANNELS 1
+#define DEFAULT_SAMPLERATE 0
struct context {
gboolean started;
#define MAX_POD_COUNT 12
#define HEADER_SIZE 80
-#define TIMESTAMP_RESOLUTION ((double)0.000000000078125) /* 0.078125 ns */
+#define TIMESTAMP_RESOLUTION ((double)0.000000000078125) /* 0.078125 ns */
/*
* The resolution equals a sampling freq of 12.8 GHz. That's a bit high
enum {
AD_COMPR_NONE = 0, /* File created with /NOCOMPRESS */
- AD_COMPR_QCOMP = 6 /* File created with /COMPRESS or /QUICKCOMPRESS */
+ AD_COMPR_QCOMP = 6, /* File created with /COMPRESS or /QUICKCOMPRESS */
};
struct context {
inc->device = device_id;
inc->trigger_timestamp = RL64(buf->str + 32);
- inc->compression = R8(buf->str + 48); /* Maps to the enum. */
- inc->record_mode = R8(buf->str + 55); /* Maps to the enum. */
+ inc->compression = R8(buf->str + 48); /* Maps to the enum. */
+ inc->record_mode = R8(buf->str + 55); /* Maps to the enum. */
inc->record_size = record_size;
inc->record_count = RL32(buf->str + 60);
inc->last_record = RL32S(buf->str + 64);
/*
* Reads a single VCD section from input file and parses it to name/contents.
- * e.g. $timescale 1ps $end => "timescale" "1ps"
+ * e.g. $timescale 1ps $end => "timescale" "1ps"
*/
static gboolean parse_section(GString *buf, gchar **name, gchar **contents)
{
#define LOG_PREFIX "input/wav"
/* How many bytes at a time to process and send to the session bus. */
-#define CHUNK_SIZE 4096
+#define CHUNK_SIZE 4096
/* Minimum size of header + 1 8-bit mono PCM sample. */
#define MIN_DATA_CHUNK_OFFSET 45
int unit;
int exponent;
} units[] = {
- { SR_UNIT_UNITLESS, 0 }, /* no unit */
- { SR_UNIT_OHM, 0 }, /* Ohm */
- { SR_UNIT_OHM, 3 }, /* kOhm */
- { SR_UNIT_OHM, 6 }, /* MOhm */
- { -1, 0 }, /* ??? */
- { SR_UNIT_HENRY, -6 }, /* uH */
- { SR_UNIT_HENRY, -3 }, /* mH */
- { SR_UNIT_HENRY, 0 }, /* H */
- { SR_UNIT_HENRY, 3 }, /* kH */
- { SR_UNIT_FARAD, -12 }, /* pF */
- { SR_UNIT_FARAD, -9 }, /* nF */
- { SR_UNIT_FARAD, -6 }, /* uF */
- { SR_UNIT_FARAD, -3 }, /* mF */
- { SR_UNIT_PERCENTAGE, 0 }, /* % */
- { SR_UNIT_DEGREE, 0 }, /* degree */
+ { SR_UNIT_UNITLESS, 0 }, /* no unit */
+ { SR_UNIT_OHM, 0 }, /* Ohm */
+ { SR_UNIT_OHM, 3 }, /* kOhm */
+ { SR_UNIT_OHM, 6 }, /* MOhm */
+ { -1, 0 }, /* ??? */
+ { SR_UNIT_HENRY, -6 }, /* uH */
+ { SR_UNIT_HENRY, -3 }, /* mH */
+ { SR_UNIT_HENRY, 0 }, /* H */
+ { SR_UNIT_HENRY, 3 }, /* kH */
+ { SR_UNIT_FARAD, -12 }, /* pF */
+ { SR_UNIT_FARAD, -9 }, /* nF */
+ { SR_UNIT_FARAD, -6 }, /* uF */
+ { SR_UNIT_FARAD, -3 }, /* mF */
+ { SR_UNIT_PERCENTAGE, 0 }, /* % */
+ { SR_UNIT_DEGREE, 0 }, /* degree */
};
const uint8_t *buf;
int digits, exponent;
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-/** @file
- * @internal
- */
+/**
+ * @file
+ *
+ * @internal
+ */
#ifndef LIBSIGROK_LIBSIGROK_INTERNAL_H
#define LIBSIGROK_LIBSIGROK_INTERNAL_H
* @retval SR_OK This module knows the format.
* @retval SR_ERR_NA There wasn't enough data for this module to
* positively identify the format.
- * @retval SR_ERR_DATA This module knows the format, but cannot handle it.
- * This means the stream is either corrupt, or indicates a feature
- * that the module does not support.
+ * @retval SR_ERR_DATA This module knows the format, but cannot handle
+ * it. This means the stream is either corrupt, or indicates a
+ * feature that the module does not support.
* @retval SR_ERR This module does not know the format.
*/
int (*format_match) (GHashTable *metadata);
*/
int (*end) (struct sr_input *in);
- /**
- * Reset the input module's input handling structures.
- *
- * Causes the input module to reset its internal state so that we can
- * re-send the input data from the beginning without having to
- * re-create the entire input module.
- *
- * @retval SR_OK Success.
- * @retval other Negative error code.
- */
+ /**
+ * Reset the input module's input handling structures.
+ *
+ * Causes the input module to reset its internal state so that we can
+ * re-send the input data from the beginning without having to
+ * re-create the entire input module.
+ *
+ * @retval SR_OK Success.
+ * @retval other Negative error code.
+ */
int (*reset) (struct sr_input *in);
/**
/** Output module instance. */
struct sr_output {
- /** A pointer to this output's module. */
+ /** A pointer to this output's module. */
const struct sr_output_module *module;
/**
/** Transform module instance. */
struct sr_transform {
- /** A pointer to this transform's module. */
+ /** A pointer to this transform's module. */
const struct sr_transform_module *module;
/**
static const struct sr_modbus_dev_inst *modbus_devs[] = {
#ifdef HAVE_LIBSERIALPORT
- &modbus_serial_rtu_dev, /* Must be last as it matches any resource. */
+ &modbus_serial_rtu_dev, /* Must be last as it matches any resource. */
#endif
};
/* Flush line buffers. */
g_string_append_len(*out, ctx->lines[j]->str, ctx->lines[j]->len);
g_string_append_c(*out, '\n');
- if (j == ctx->num_enabled_channels - 1 && ctx->trigger > -1) {
+ if (j == ctx->num_enabled_channels - 1 && ctx->trigger > -1) {
offset = ctx->trigger + ctx->trigger / 8;
g_string_append_printf(*out, "T:%*s^ %d\n", offset, "", ctx->trigger);
ctx->trigger = -1;
/* Flush line buffers. */
g_string_append_len(*out, ctx->lines[j]->str, ctx->lines[j]->len);
g_string_append_c(*out, '\n');
- if (j == ctx->num_enabled_channels - 1 && ctx->trigger > -1) {
+ if (j == ctx->num_enabled_channels - 1 && ctx->trigger > -1) {
offset = ctx->trigger + ctx->trigger / 8;
g_string_append_printf(*out, "T:%*s^ %d\n", offset, "", ctx->trigger);
ctx->trigger = -1;
if (outc->analog_index_map[index] == channel->index)
break;
if (outc->analog_index_map[index] == -1)
- return SR_ERR_ARG; /* Channel index was not in the list */
+ return SR_ERR_ARG; /* Channel index was not in the list */
index += outc->first_analog_index;
return SR_ERR_ARG;
}
if (open_cb && close_cb && read_cb) {
- ctx->resource_open_cb = open_cb;
+ ctx->resource_open_cb = open_cb;
ctx->resource_close_cb = close_cb;
- ctx->resource_read_cb = read_cb;
- ctx->resource_cb_data = cb_data;
+ ctx->resource_read_cb = read_cb;
+ ctx->resource_cb_data = cb_data;
} else if (!open_cb && !close_cb && !read_cb) {
- ctx->resource_open_cb = &resource_open_default;
+ ctx->resource_open_cb = &resource_open_default;
ctx->resource_close_cb = &resource_close_default;
- ctx->resource_read_cb = &resource_read_default;
- ctx->resource_cb_data = ctx;
+ ctx->resource_read_cb = &resource_read_default;
+ ctx->resource_cb_data = ctx;
} else {
sr_err("%s: inconsistent callback pointers.", __func__);
return SR_ERR_ARG;
* @param max_size Size limit. Error out if the resource is larger than this.
*
* @return A buffer containing the resource data, or NULL on failure. Must
- * be freed by the caller using g_free().
+ * be freed by the caller using g_free().
*
* @private
*/
&scpi_libgpib_dev,
#endif
#ifdef HAVE_LIBSERIALPORT
- &scpi_serial_dev, /* must be last as it matches any resource */
+ &scpi_serial_dev, /* Must be last as it matches any resource. */
#endif
};
sr_err("Incompletely read SCPI response.");
return SR_ERR;
} else if (len > 0) {
- laststart = g_get_monotonic_time();
+ laststart = g_get_monotonic_time();
}
offset += len;
g_string_set_size(response, offset);
}
tcp->address = g_strdup(params[1]);
- tcp->port = g_strdup(params[2]);
- tcp->socket = -1;
+ tcp->port = g_strdup(params[2]);
+ tcp->socket = -1;
return SR_OK;
}
};
/* Some USBTMC-specific enums, as defined in the USBTMC standard. */
-#define SUBCLASS_USBTMC 0x03
-#define USBTMC_USB488 0x01
+#define SUBCLASS_USBTMC 0x03
+#define USBTMC_USB488 0x01
enum {
/* USBTMC control requests */
#define USB488_DEV_CAP_SCPI 0x08
/* Bulk messages constants */
-#define USBTMC_BULK_HEADER_SIZE 12
+#define USBTMC_BULK_HEADER_SIZE 12
/* Bulk MsgID values */
-#define DEV_DEP_MSG_OUT 1
-#define REQUEST_DEV_DEP_MSG_IN 2
-#define DEV_DEP_MSG_IN 2
+#define DEV_DEP_MSG_OUT 1
+#define REQUEST_DEV_DEP_MSG_IN 2
+#define DEV_DEP_MSG_IN 2
/* bmTransferAttributes */
-#define EOM 0x01
-#define TERM_CHAR_ENABLED 0x02
+#define EOM 0x01
+#define TERM_CHAR_ENABLED 0x02
struct usbtmc_blacklist {
uint16_t vid;
/* Devices that publish RL1 support, but don't support it. */
static struct usbtmc_blacklist blacklist_remote[] = {
- { 0x1ab1, 0x0588 }, /* Rigol DS1000 series */
- { 0x1ab1, 0x04b0 }, /* Rigol DS2000 series */
- { 0x0957, 0x0588 }, /* Agilent DSO1000 series (rebadged Rigol DS1000) */
- { 0x0b21, 0xffff }, /* All Yokogawa devices */
+ { 0x1ab1, 0x0588 }, /* Rigol DS1000 series */
+ { 0x1ab1, 0x04b0 }, /* Rigol DS2000 series */
+ { 0x0957, 0x0588 }, /* Agilent DSO1000 series (rebadged Rigol DS1000) */
+ { 0x0b21, 0xffff }, /* All Yokogawa devices */
ALL_ZERO
};
return SR_OK;
sr_dbg("Locking out local control.");
- ret = libusb_control_transfer(usb->devhdl,
- LIBUSB_ENDPOINT_IN |
- LIBUSB_REQUEST_TYPE_CLASS |
- LIBUSB_RECIPIENT_INTERFACE,
- REN_CONTROL, 1,
- uscpi->interface,
- &status, 1,
- TRANSFER_TIMEOUT);
+ ret = libusb_control_transfer(usb->devhdl, LIBUSB_ENDPOINT_IN |
+ LIBUSB_REQUEST_TYPE_CLASS | LIBUSB_RECIPIENT_INTERFACE,
+ REN_CONTROL, 1, uscpi->interface, &status, 1, TRANSFER_TIMEOUT);
if (ret < 0 || status != USBTMC_STATUS_SUCCESS) {
if (ret < 0)
sr_dbg("Failed to enter REN state: %s.", libusb_error_name(ret));
return SR_ERR;
}
- ret = libusb_control_transfer(usb->devhdl,
- LIBUSB_ENDPOINT_IN |
- LIBUSB_REQUEST_TYPE_CLASS |
- LIBUSB_RECIPIENT_INTERFACE,
- LOCAL_LOCKOUT, 0,
- uscpi->interface,
- &status, 1,
- TRANSFER_TIMEOUT);
+ ret = libusb_control_transfer(usb->devhdl, LIBUSB_ENDPOINT_IN |
+ LIBUSB_REQUEST_TYPE_CLASS | LIBUSB_RECIPIENT_INTERFACE,
+ LOCAL_LOCKOUT, 0, uscpi->interface, &status, 1,
+ TRANSFER_TIMEOUT);
if (ret < 0 || status != USBTMC_STATUS_SUCCESS) {
if (ret < 0)
sr_dbg("Failed to enter local lockout state: %s.",
return;
sr_dbg("Returning local control.");
- ret = libusb_control_transfer(usb->devhdl,
- LIBUSB_ENDPOINT_IN |
- LIBUSB_REQUEST_TYPE_CLASS |
- LIBUSB_RECIPIENT_INTERFACE,
- GO_TO_LOCAL, 0,
- uscpi->interface,
- &status, 1,
- TRANSFER_TIMEOUT);
+ ret = libusb_control_transfer(usb->devhdl, LIBUSB_ENDPOINT_IN |
+ LIBUSB_REQUEST_TYPE_CLASS | LIBUSB_RECIPIENT_INTERFACE,
+ GO_TO_LOCAL, 0, uscpi->interface, &status, 1, TRANSFER_TIMEOUT);
if (ret < 0 || status != USBTMC_STATUS_SUCCESS) {
if (ret < 0)
sr_dbg("Failed to clear local lockout state: %s.",
for (intfidx = 0; intfidx < confdes->bNumInterfaces; intfidx++) {
intfdes = confdes->interface[intfidx].altsetting;
if (intfdes->bInterfaceClass != LIBUSB_CLASS_APPLICATION ||
- intfdes->bInterfaceSubClass != SUBCLASS_USBTMC ||
+ intfdes->bInterfaceSubClass != SUBCLASS_USBTMC ||
intfdes->bInterfaceProtocol != USBTMC_USB488)
continue;
uscpi->interface = intfdes->bInterfaceNumber;
}
/* Get capabilities. */
- ret = libusb_control_transfer(usb->devhdl,
- LIBUSB_ENDPOINT_IN |
- LIBUSB_REQUEST_TYPE_CLASS |
- LIBUSB_RECIPIENT_INTERFACE,
- GET_CAPABILITIES, 0,
- uscpi->interface,
- capabilities, sizeof(capabilities),
- TRANSFER_TIMEOUT);
+ ret = libusb_control_transfer(usb->devhdl, LIBUSB_ENDPOINT_IN |
+ LIBUSB_REQUEST_TYPE_CLASS | LIBUSB_RECIPIENT_INTERFACE,
+ GET_CAPABILITIES, 0, uscpi->interface, capabilities,
+ sizeof(capabilities), TRANSFER_TIMEOUT);
if (ret == sizeof(capabilities)) {
uscpi->usbtmc_int_cap = capabilities[ 4];
uscpi->usbtmc_dev_cap = capabilities[ 5];
uscpi->usb488_dev_cap = capabilities[15];
}
sr_dbg("Device capabilities: %s%s%s%s%s, %s, %s",
- uscpi->usb488_dev_cap & USB488_DEV_CAP_SCPI ? "SCPI, " : "",
- uscpi->usbtmc_dev_cap & USBTMC_DEV_CAP_TERMCHAR ? "TermChar, ": "",
- uscpi->usbtmc_int_cap & USBTMC_INT_CAP_LISTEN_ONLY? "L3, " :
- uscpi->usbtmc_int_cap & USBTMC_INT_CAP_TALK_ONLY ? "" : "L4, ",
- uscpi->usbtmc_int_cap & USBTMC_INT_CAP_TALK_ONLY ? "T5, " :
- uscpi->usbtmc_int_cap & USBTMC_INT_CAP_LISTEN_ONLY? "" : "T6, ",
- uscpi->usb488_dev_cap & USB488_DEV_CAP_SR1 ? "SR1" : "SR0",
- uscpi->usb488_dev_cap & USB488_DEV_CAP_RL1 ? "RL1" : "RL0",
- uscpi->usb488_dev_cap & USB488_DEV_CAP_DT1 ? "DT1" : "DT0");
+ uscpi->usb488_dev_cap & USB488_DEV_CAP_SCPI ? "SCPI, " : "",
+ uscpi->usbtmc_dev_cap & USBTMC_DEV_CAP_TERMCHAR ? "TermChar, ": "",
+ uscpi->usbtmc_int_cap & USBTMC_INT_CAP_LISTEN_ONLY ? "L3, " :
+ uscpi->usbtmc_int_cap & USBTMC_INT_CAP_TALK_ONLY ? "" : "L4, ",
+ uscpi->usbtmc_int_cap & USBTMC_INT_CAP_TALK_ONLY ? "T5, " :
+ uscpi->usbtmc_int_cap & USBTMC_INT_CAP_LISTEN_ONLY ? "" : "T6, ",
+ uscpi->usb488_dev_cap & USB488_DEV_CAP_SR1 ? "SR1" : "SR0",
+ uscpi->usb488_dev_cap & USB488_DEV_CAP_RL1 ? "RL1" : "RL0",
+ uscpi->usb488_dev_cap & USB488_DEV_CAP_DT1 ? "DT1" : "DT0");
scpi_usbtmc_remote(uscpi);
uint8_t bmTransferAttributes,
char TermChar)
{
- W8(header+ 0, MsgID);
- W8(header+ 1, bTag);
- W8(header+ 2, ~bTag);
- W8(header+ 3, 0);
- WL32(header+ 4, TransferSize);
- W8(header+ 8, bmTransferAttributes);
- W8(header+ 9, TermChar);
- WL16(header+10, 0);
+ W8(header + 0, MsgID);
+ W8(header + 1, bTag);
+ W8(header + 2, ~bTag);
+ W8(header + 3, 0);
+ WL32(header + 4, TransferSize);
+ W8(header + 8, bmTransferAttributes);
+ W8(header + 9, TermChar);
+ WL16(header + 10, 0);
}
static int usbtmc_bulk_in_header_read(void *header, uint8_t MsgID,
int32_t *TransferSize,
uint8_t *bmTransferAttributes)
{
- if (R8(header+0) != MsgID ||
- R8(header+1) != bTag ||
- R8(header+2) != (unsigned char)~bTag)
+ if (R8(header + 0) != MsgID ||
+ R8(header + 1) != bTag ||
+ R8(header + 2) != (unsigned char)~bTag)
return SR_ERR;
if (TransferSize)
- *TransferSize = RL32(header+4);
+ *TransferSize = RL32(header + 4);
if (bmTransferAttributes)
- *bmTransferAttributes = R8(header+8);
+ *bmTransferAttributes = R8(header + 8);
+
return SR_OK;
}
struct sr_usb_dev_inst *usb = uscpi->usb;
int padded_size, ret, transferred;
- if (data && size+USBTMC_BULK_HEADER_SIZE+3 > (int)sizeof(uscpi->buffer)) {
+ if (data && (size + USBTMC_BULK_HEADER_SIZE + 3) > (int)sizeof(uscpi->buffer)) {
sr_err("USBTMC bulk out transfer is too big.");
return SR_ERR;
}
uscpi->bTag++;
- uscpi->bTag += !uscpi->bTag; /* bTag == 0 is invalid so avoid it. */
+ uscpi->bTag += !uscpi->bTag; /* bTag == 0 is invalid so avoid it. */
usbtmc_bulk_out_header_write(uscpi->buffer, msg_id, uscpi->bTag,
size, transfer_attributes, 0);
if (data)
- memcpy(uscpi->buffer+USBTMC_BULK_HEADER_SIZE, data, size);
+ memcpy(uscpi->buffer + USBTMC_BULK_HEADER_SIZE, data, size);
else
size = 0;
size += USBTMC_BULK_HEADER_SIZE;
padded_size = (size + 3) & ~0x3;
- memset(uscpi->buffer+size, 0, padded_size - size);
+ memset(uscpi->buffer + size, 0, padded_size - size);
ret = libusb_bulk_transfer(usb->devhdl, uscpi->bulk_out_ep,
uscpi->buffer, padded_size, &transferred,
*
* @param serial Previously initialized serial port structure.
* @param[in] flags Flags to use when opening the serial port. Possible flags
- * include SERIAL_RDWR, SERIAL_RDONLY.
+ * include SERIAL_RDWR, SERIAL_RDONLY.
*
* If the serial structure contains a serialcomm string, it will be
* passed to serial_set_paramstr() after the port is opened.
* @param[in] timeout_ms Timeout in ms, or 0 for no timeout.
*
* @retval SR_ERR_ARG Invalid argument.
- * @retval SR_ERR Other error.
- * @retval other The number of bytes read. If this is less than the number
+ * @retval SR_ERR Other error.
+ * @retval other The number of bytes read. If this is less than the number
* requested, the timeout was reached.
*
* @private
* @param[in] count The number of bytes to read.
*
* @retval SR_ERR_ARG Invalid argument.
- * @retval SR_ERR Other error.
- * @retval other The number of bytes read.
+ * @retval SR_ERR Other error.
+ * @retval other The number of bytes read.
*
* @private
*/
* @param[in] parity The parity setting to use (0 = none, 1 = even, 2 = odd).
* @param[in] stopbits The number of stop bits to use (1 or 2).
* @param[in] flowcontrol The flow control settings to use (0 = none,
- * 1 = RTS/CTS, 2 = XON/XOFF).
+ * 1 = RTS/CTS, 2 = XON/XOFF).
* @param[in] rts Status of RTS line (0 or 1; required by some interfaces).
* @param[in] dtr Status of DTR line (0 or 1; required by some interfaces).
*
* @param serial Previously initialized serial port structure.
* @param[in] paramstr A serial communication parameters string of the form
* "<baudrate>/<bits><parity><stopbits>{/<option>}".\n
- * Examples: "9600/8n1", "600/7o2/dtr=1/rts=0" or "460800/8n1/flow=2".\n
+ * Examples: "9600/8n1", "600/7o2/dtr=1/rts=0" or "460800/8n1/flow=2".\n
* \<baudrate\>=integer Baud rate.\n
* \<bits\>=5|6|7|8 Number of data bits.\n
* \<parity\>=n|e|o None, even, odd.\n
* @param[in] packet_size Size, in bytes, of a valid packet.
* @param is_valid Callback that assesses whether the packet is valid or not.
* @param[in] timeout_ms The timeout after which, if no packet is detected, to
- * abort scanning.
+ * abort scanning.
* @param[in] baudrate The baudrate of the serial port. This parameter is not
- * critical, but it helps fine tune the serial port polling
- * delay.
+ * critical, but it helps fine tune the serial port polling
+ * delay.
*
* @retval SR_OK Valid packet was found within the given timeout.
* @retval SR_ERR Failure.
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
-/** @file
- * Standard API helper functions.
- * @internal
- */
+/**
+ * @file
+ *
+ * Standard API helper functions.
+ *
+ * @internal
+ */
#include <config.h>
#include <glib.h>
*
* @param limits software limits instance
* @returns TRUE if any of the software limits has been reached and the driver
- * should stop data acquisition, otherwise FALSE.
+ * should stop data acquisition, otherwise FALSE.
*/
SR_PRIV gboolean sr_sw_limits_check(struct sr_sw_limits *limits)
{
/* * @cond PRIVATE */
#define LOG_PREFIX "trigger"
/* * @endcond */
-
+
/**
* @file
*