Improve readability and clarity of some numbers.

This commit is contained in:
Uwe Hermann 2015-03-22 23:07:30 +01:00
parent f3f19d1131
commit 1a46cc62e2
37 changed files with 101 additions and 100 deletions

View File

@ -419,7 +419,7 @@ static int sigma_fpga_init_bitbang(struct dev_context *devc)
0x01, 0x03, 0x03, 0x01, 0x01, 0x01, 0x01, 0x01,
0x01, 0x01,
};
int i, ret, timeout = 10000;
int i, ret, timeout = (10 * 1000);
uint8_t data;
/* Section 2. part 1), do the FPGA suicide. */
@ -441,7 +441,7 @@ static int sigma_fpga_init_bitbang(struct dev_context *devc)
if (data & (1 << 5))
return 0;
/* The D6 was not asserted yet, wait a bit. */
g_usleep(10000);
g_usleep(10 * 1000);
}
return SR_ERR_TIMEOUT;
@ -590,7 +590,7 @@ static int upload_firmware(int firmware_idx, struct dev_context *devc)
}
/* Four times the speed of sigmalogan - Works well. */
ret = ftdi_set_baudrate(ftdic, 750000);
ret = ftdi_set_baudrate(ftdic, 750 * 1000);
if (ret < 0) {
sr_err("ftdi_set_baudrate failed: %s",
ftdi_get_error_string(ftdic));

View File

@ -187,7 +187,7 @@ SR_PRIV int brymen_stream_detect(struct sr_serial_dev_inst *serial,
"ms, baudrate = %d).", serial->port, timeout_ms, baudrate);
/* Assume 8n1 transmission. That is 10 bits for every byte. */
byte_delay_us = 10 * (1000000 / baudrate);
byte_delay_us = 10 * ((1000 * 1000) / baudrate);
start = g_get_monotonic_time();
packet_len = i = ibuf = len = 0;

View File

@ -23,7 +23,7 @@
#define SERIALCOMM "9600/8n1"
/* 23ms is the longest interval between tokens. */
#define MAX_SCAN_TIME 25 * 1000
#define MAX_SCAN_TIME_US (25 * 1000)
static const uint32_t scanopts[] = {
SR_CONF_CONN,
@ -104,7 +104,7 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options)
devices = NULL;
drvc = di->priv;
start = g_get_monotonic_time();
while (g_get_monotonic_time() - start < MAX_SCAN_TIME) {
while (g_get_monotonic_time() - start < MAX_SCAN_TIME_US) {
if (serial_read_nonblocking(serial, &c, 1) == 1 && c == 0xa5) {
/* Found one. */
sdi = g_malloc0(sizeof(struct sr_dev_inst));

View File

@ -32,11 +32,11 @@
#define SAMPLES_PER_PACKET 50
/* Various temporary storage, at least 8 bytes. */
#define BUF_SIZE SAMPLES_PER_PACKET * 2
#define BUF_SIZE (SAMPLES_PER_PACKET * 2)
/* When in hold mode, force the last measurement out at this interval.
* We're using 50ms, which duplicates the non-hold 20Hz update rate. */
#define HOLD_REPEAT_INTERVAL 50 * 1000
#define HOLD_REPEAT_INTERVAL (50 * 1000)
enum {
TOKEN_WEIGHT_TIME_FAST = 0x02,

View File

@ -57,7 +57,7 @@ SR_PRIV int send_msg1(const struct sr_dev_inst *sdi, char cmd, int param)
* Wait 50ms to ensure that the device does not swallow any of the
* following commands.
*/
g_usleep(50000);
g_usleep(50 * 1000);
return SR_OK;
}

View File

@ -757,7 +757,7 @@ static int prepare_data(int fd, int revents, void *cb_data)
/* How many samples should we have sent by now? */
time = g_get_monotonic_time();
elapsed = time - devc->starttime;
expected_samplenum = elapsed * devc->cur_samplerate / 1000000;
expected_samplenum = elapsed * devc->cur_samplerate / (1000 * 1000);
/* But never more than the limit, if there is one. */
if (!devc->continuous)

View File

@ -181,7 +181,7 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options)
break;
/* The Scopemeter 199B, at least, requires this
* after all the 115k/9.6k confusion. */
g_usleep(5000);
g_usleep(5 * 1000);
}
}

View File

@ -28,7 +28,8 @@
#include "protocol.h"
#include "dslogic.h"
#define FW_BUFSIZE 4096
#define FW_BUFSIZE (4 * 1024)
int dslogic_fpga_firmware_upload(const struct sr_dev_inst *sdi,
const char *filename)
{

View File

@ -108,7 +108,7 @@ static enum model scan_model_sm(struct sr_serial_dev_inst *serial)
gint64 timeout_us;
model = METRAHIT_NONE;
timeout_us = g_get_monotonic_time() + 1 * 1000 * 1000;
timeout_us = g_get_monotonic_time() + (1 * 1000 * 1000);
/*
* Try to find message consisting of device code and several
@ -296,7 +296,7 @@ static GSList *scan_2x_bd232(struct sr_dev_driver *di, GSList *options)
goto exit_err;
/* Wait for reply from device(s) for up to 2s. */
timeout_us = g_get_monotonic_time() + 2*1000*1000;
timeout_us = g_get_monotonic_time() + (2 * 1000 * 1000);
while (timeout_us > g_get_monotonic_time()) {
/* Receive reply (14 bytes) */

View File

@ -1236,7 +1236,7 @@ SR_PRIV int gmc_mh_2x_receive_data(int fd, int revents, void *cb_data)
if (sdi->status == SR_ST_ACTIVE) {
if (devc->response_pending) {
gint64 elapsed_us = g_get_monotonic_time() - devc->req_sent_at;
if (elapsed_us > 1*1000*1000) /* Timeout! */
if (elapsed_us > (1 * 1000 * 1000)) /* Timeout! */
devc->response_pending = FALSE;
}
if (!devc->response_pending) {
@ -1342,13 +1342,13 @@ int req_stat14(const struct sr_dev_inst *sdi, gboolean power_on)
sr_info("Write some data and wait 3s to turn on powered off device...");
if (serial_write_blocking(serial, msg, sizeof(msg), 0) < 0)
return SR_ERR;
g_usleep(1*1000*1000);
g_usleep(1 * 1000 * 1000);
if (serial_write_blocking(serial, msg, sizeof(msg), 0) < 0)
return SR_ERR;
g_usleep(1*1000*1000);
g_usleep(1 * 1000 * 1000);
if (serial_write_blocking(serial, msg, sizeof(msg), 0) < 0)
return SR_ERR;
g_usleep(1*1000*1000);
g_usleep(1 * 1000 * 1000);
serial_flush(serial);
}
@ -1534,7 +1534,7 @@ SR_PRIV int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *s
if (serial_write_blocking(sdi->conn, msg, sizeof(msg), 0) < 0)
return SR_ERR;
else
g_usleep(2000000); /* Wait to ensure transfer before interface switched off. */
g_usleep(2 * 1000 * 1000); /* Wait to ensure transfer before interface switched off. */
break;
case SR_CONF_LIMIT_MSEC:
devc->limit_msec = g_variant_get_uint64(data);

View File

@ -72,13 +72,13 @@ static const char *channel_names[] = {
};
static const uint64_t buffersizes_32k[] = {
10240, 32768,
(10 * 1024), (32 * 1024),
};
static const uint64_t buffersizes_512k[] = {
10240, 524288,
(10 * 1024), (512 * 1024),
};
static const uint64_t buffersizes_14k[] = {
10240, 14336,
(10 * 1024), (14 * 1024),
};
static const struct dso_profile dev_profiles[] = {

View File

@ -49,7 +49,7 @@
#define EEPROM_CHANNEL_OFFSETS 0x08
/* All models have this for their "fast" mode. */
#define FRAMESIZE_SMALL 10240
#define FRAMESIZE_SMALL (10 * 1024)
enum control_requests {
CTRL_READ_EEPROM = 0xa2,

View File

@ -225,11 +225,11 @@ static int dev_open(struct sr_dev_inst *sdi)
libusb_fill_control_transfer(devc->xfer_in, usb->devhdl,
devc->xfer_buf_in, sl2_receive_transfer_in,
sdi, USB_TIMEOUT);
sdi, USB_TIMEOUT_MS);
libusb_fill_control_transfer(devc->xfer_out, usb->devhdl,
devc->xfer_buf_out, sl2_receive_transfer_out,
sdi, USB_TIMEOUT);
sdi, USB_TIMEOUT_MS);
memset(buffer, 0, sizeof(buffer));

View File

@ -754,12 +754,12 @@ SR_PRIV int sl2_transfer_in(libusb_device_handle *dev_handle, uint8_t *data)
{
return libusb_control_transfer(dev_handle, USB_REQUEST_TYPE_IN,
USB_HID_GET_REPORT, USB_HID_REPORT_TYPE_FEATURE, USB_INTERFACE,
(unsigned char *)data, PACKET_LENGTH, USB_TIMEOUT);
(unsigned char *)data, PACKET_LENGTH, USB_TIMEOUT_MS);
}
SR_PRIV int sl2_transfer_out(libusb_device_handle *dev_handle, uint8_t *data)
{
return libusb_control_transfer(dev_handle, USB_REQUEST_TYPE_OUT,
USB_HID_SET_REPORT, USB_HID_REPORT_TYPE_FEATURE, USB_INTERFACE,
(unsigned char *)data, PACKET_LENGTH, USB_TIMEOUT);
(unsigned char *)data, PACKET_LENGTH, USB_TIMEOUT_MS);
}

View File

@ -34,7 +34,7 @@
#define USB_VID_PID "20a0.4123"
#define USB_INTERFACE 0
#define USB_TIMEOUT 5000
#define USB_TIMEOUT_MS (5 * 1000)
#define USB_REQUEST_TYPE_IN (LIBUSB_REQUEST_TYPE_CLASS | \
LIBUSB_RECIPIENT_INTERFACE | LIBUSB_ENDPOINT_IN)

View File

@ -30,7 +30,7 @@
#define LOG_PREFIX "ikalogic-scanaplus"
#define COMPRESSED_BUF_SIZE (64 * 1024)
#define COMPRESSED_BUF_SIZE (64 * 1024)
/* Private, per-device-instance driver context. */
struct dev_context {

View File

@ -27,7 +27,7 @@
#define LOG_PREFIX "kecheng-kc-330b"
#define EP_IN 0x80 | 1
#define EP_IN (0x80 | 1)
#define EP_OUT 2
/* 500ms */

View File

@ -390,7 +390,7 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
;
libusb_fill_bulk_transfer(xfer_in, usb->devhdl, LASCAR_EP_IN,
resp, sizeof(resp), mark_xfer, 0, 10000);
resp, sizeof(resp), mark_xfer, 0, BULK_XFER_TIMEOUT);
if (libusb_submit_transfer(xfer_in) != 0) {
libusb_free_transfer(xfer_in);
libusb_free_transfer(xfer_out);
@ -411,7 +411,7 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
tv.tv_sec = 0;
tv.tv_usec = 0;
while (!xfer_in->user_data || !xfer_out->user_data) {
g_usleep(5000);
g_usleep(SLEEP_US_LONG);
libusb_handle_events_timeout(drvc->sr_ctx->libusb_ctx, &tv);
}
if (xfer_in->user_data != GINT_TO_POINTER(1) ||

View File

@ -111,7 +111,7 @@ SR_PRIV int lascar_get_config(libusb_device_handle *dev_hdl,
/* Keep a read request waiting in the wings, ready to pounce
* the moment the device sends something. */
libusb_fill_bulk_transfer(xfer_in, dev_hdl, LASCAR_EP_IN,
buf, 256, mark_xfer, 0, 10000);
buf, 256, mark_xfer, 0, BULK_XFER_TIMEOUT);
if (libusb_submit_transfer(xfer_in) != 0)
goto cleanup;
@ -132,7 +132,7 @@ SR_PRIV int lascar_get_config(libusb_device_handle *dev_hdl,
start = 0;
break;
}
g_usleep(5000);
g_usleep(SLEEP_US_LONG);
libusb_handle_events_timeout(drvc->sr_ctx->libusb_ctx, &tv);
}
if (!start) {
@ -165,7 +165,7 @@ SR_PRIV int lascar_get_config(libusb_device_handle *dev_hdl,
start = 0;
break;
}
g_usleep(5000);
g_usleep(SLEEP_US_LONG);
libusb_handle_events_timeout(drvc->sr_ctx->libusb_ctx, &tv);
}
if (!start) {
@ -189,9 +189,9 @@ cleanup:
libusb_cancel_transfer(xfer_out);
start = g_get_monotonic_time();
while (!xfer_in->user_data || !xfer_out->user_data) {
if (g_get_monotonic_time() - start > 10000)
if (g_get_monotonic_time() - start > EVENTS_TIMEOUT)
break;
g_usleep(1000);
g_usleep(SLEEP_US_SHORT);
libusb_handle_events_timeout(drvc->sr_ctx->libusb_ctx, &tv);
}
}
@ -228,7 +228,7 @@ static int lascar_save_config(libusb_device_handle *dev_hdl,
/* Keep a read request waiting in the wings, ready to pounce
* the moment the device sends something. */
libusb_fill_bulk_transfer(xfer_in, dev_hdl, LASCAR_EP_IN,
buf, 256, mark_xfer, 0, 10000);
buf, 256, mark_xfer, 0, BULK_XFER_TIMEOUT);
if (libusb_submit_transfer(xfer_in) != 0) {
ret = SR_ERR;
goto cleanup;
@ -247,7 +247,7 @@ static int lascar_save_config(libusb_device_handle *dev_hdl,
tv.tv_sec = 0;
tv.tv_usec = 0;
while (!xfer_out->user_data) {
g_usleep(5000);
g_usleep(SLEEP_US_LONG);
libusb_handle_events_timeout(drvc->sr_ctx->libusb_ctx, &tv);
}
@ -258,7 +258,7 @@ static int lascar_save_config(libusb_device_handle *dev_hdl,
goto cleanup;
}
while (!xfer_in->user_data || !xfer_out->user_data) {
g_usleep(5000);
g_usleep(SLEEP_US_LONG);
libusb_handle_events_timeout(drvc->sr_ctx->libusb_ctx, &tv);
}
@ -275,9 +275,9 @@ cleanup:
libusb_cancel_transfer(xfer_out);
start = g_get_monotonic_time();
while (!xfer_in->user_data || !xfer_out->user_data) {
if (g_get_monotonic_time() - start > 10000)
if (g_get_monotonic_time() - start > EVENTS_TIMEOUT)
break;
g_usleep(1000);
g_usleep(SLEEP_US_SHORT);
libusb_handle_events_timeout(drvc->sr_ctx->libusb_ctx, &tv);
}
}
@ -462,7 +462,7 @@ static void lascar_el_usb_dispatch(struct sr_dev_inst *sdi, unsigned char *buf,
break;
for (i = 0; i < samples; i++) {
s = (buf[i * 2] << 8) | buf[i * 2 + 1];
analog.data[i] = (s * devc->co_high + devc->co_low) / 1000000;
analog.data[i] = (s * devc->co_high + devc->co_low) / (1000 * 1000);
if (analog.data[i] < 0.0)
analog.data[i] = 0.0;
}

View File

@ -30,10 +30,15 @@
#define LASCAR_INTERFACE 0
#define LASCAR_EP_IN 0x82
#define LASCAR_EP_OUT 2
/* Max 100ms for a device to positively identify. */
#define SCAN_TIMEOUT 100000
#define MAX_CONFIGBLOCK_SIZE 256
/* Max 100ms for a device to positively identify. */
#define SCAN_TIMEOUT (100 * 1000)
#define BULK_XFER_TIMEOUT (10 * 1000)
#define EVENTS_TIMEOUT (10 * 1000)
#define SLEEP_US_LONG (5 * 1000)
#define SLEEP_US_SHORT (1 * 1000)
/** Private, per-device-instance driver context. */
struct dev_context {
void *cb_data;

View File

@ -83,6 +83,8 @@ static const uint64_t samplerates[] = {
SR_HZ(1),
};
#define RESPONSE_DELAY_US (10 * 1000)
SR_PRIV struct sr_dev_driver ols_driver_info;
static int init(struct sr_dev_driver *di, struct sr_context *sr_ctx)
@ -150,8 +152,7 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options)
}
send_shortcommand(serial, CMD_ID);
/* Wait 10ms for a response. */
g_usleep(10000);
g_usleep(RESPONSE_DELAY_US);
if (sp_input_waiting(serial->data) == 0) {
sr_dbg("Didn't get any reply.");
@ -175,8 +176,7 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options)
*/
send_shortcommand(serial, CMD_METADATA);
/* Wait 10ms for a response. */
g_usleep(10000);
g_usleep(RESPONSE_DELAY_US);
if (sp_input_waiting(serial->data) != 0) {
/* Got metadata. */

View File

@ -241,7 +241,7 @@ static int rigol_ds_check_stop(const struct sr_dev_inst *sdi)
if (tmp & 0x10) {
sr_warn("Single shot acquisition failed, retrying...");
/* Sleep a bit, otherwise the single shot will often fail */
g_usleep(500000);
g_usleep(500 * 1000);
rigol_ds_config_set(sdi, ":SING");
rigol_ds_set_wait_event(devc, WAIT_STOP);
return SR_ERR;
@ -277,7 +277,7 @@ static int rigol_ds_block_wait(const struct sr_dev_inst *sdi)
* it too much with SCPI requests but don't wait too
* long for short sample frame sizes.
*/
g_usleep(devc->analog_frame_size < 15000 ? 100000 : 1000000);
g_usleep(devc->analog_frame_size < (15 * 1000) ? (100 * 1000) : (1000 * 1000));
/* "READ,nnnn" (still working) or "IDLE,nnnn" (finished) */
if (sr_scpi_get_string(sdi->conn, ":WAV:STAT?", &buf) != SR_OK)
@ -285,7 +285,7 @@ static int rigol_ds_block_wait(const struct sr_dev_inst *sdi)
if (parse_int(buf + 5, &len) != SR_OK)
return SR_ERR;
} while (buf[0] == 'R' && len < 1000000);
} while (buf[0] == 'R' && len < (1000 * 1000));
}
rigol_ds_set_wait_event(devc, WAIT_NONE);
@ -310,7 +310,7 @@ SR_PRIV int rigol_ds_config_set(const struct sr_dev_inst *sdi, const char *forma
if (devc->model->series->protocol == PROTOCOL_V2) {
/* The DS1000 series needs this stupid delay, *OPC? doesn't work. */
sr_spew("delay %dms", 100);
g_usleep(100000);
g_usleep(100 * 1000);
return SR_OK;
} else {
return sr_scpi_get_opc(sdi->conn);

View File

@ -29,10 +29,10 @@
#define LOG_PREFIX "rigol-ds"
/* Size of acquisition buffers */
#define ACQ_BUFFER_SIZE 32768
#define ACQ_BUFFER_SIZE (32 * 1024)
/* Maximum number of samples to retrieve at once. */
#define ACQ_BLOCK_SIZE 30000
#define ACQ_BLOCK_SIZE (30 * 1000)
#define MAX_ANALOG_CHANNELS 4
#define MAX_DIGITAL_CHANNELS 16

View File

@ -23,8 +23,8 @@
#include <errno.h>
#include <glib/gstdio.h>
#define BITSTREAM_MAX_SIZE 262144 /* bitstream size limit for safety */
#define BITSTREAM_HEADER_SIZE 4 /* transfer header size in bytes */
#define BITSTREAM_MAX_SIZE (256 * 1024) /* bitstream size limit for safety */
#define BITSTREAM_HEADER_SIZE 4 /* transfer header size in bytes */
/* Load a bitstream file into memory. Returns a newly allocated array
* consisting of a 32-bit length field followed by the bitstream data.
@ -110,7 +110,7 @@ SR_PRIV int lwla_send_bitstream(const struct sr_usb_dev_inst *usb,
/* Transfer the entire bitstream in one URB. */
ret = libusb_bulk_transfer(usb->devhdl, EP_BITSTREAM,
stream, length, &xfer_len, USB_TIMEOUT);
stream, length, &xfer_len, USB_TIMEOUT_MS);
g_free(stream);
if (ret != 0) {
@ -126,7 +126,7 @@ SR_PRIV int lwla_send_bitstream(const struct sr_usb_dev_inst *usb,
sr_info("FPGA bitstream download of %d bytes done.", xfer_len);
/* This delay appears to be necessary for reliable operation. */
g_usleep(30000);
g_usleep(30 * 1000);
return SR_OK;
}
@ -143,7 +143,7 @@ SR_PRIV int lwla_send_command(const struct sr_usb_dev_inst *usb,
xfer_len = 0;
ret = libusb_bulk_transfer(usb->devhdl, EP_COMMAND,
(unsigned char *)command, cmd_len * 2,
&xfer_len, USB_TIMEOUT);
&xfer_len, USB_TIMEOUT_MS);
if (ret != 0) {
sr_dbg("Failed to send command %d: %s.",
LWLA_TO_UINT16(command[0]), libusb_error_name(ret));
@ -169,7 +169,7 @@ SR_PRIV int lwla_receive_reply(const struct sr_usb_dev_inst *usb,
xfer_len = 0;
ret = libusb_bulk_transfer(usb->devhdl, EP_REPLY,
(unsigned char *)reply, reply_len * 4,
&xfer_len, USB_TIMEOUT);
&xfer_len, USB_TIMEOUT_MS);
if (ret != 0) {
sr_dbg("Failed to receive reply: %s.", libusb_error_name(ret));
return SR_ERR;

View File

@ -65,7 +65,7 @@ static int capture_setup(const struct sr_dev_inst *sdi)
uint64_t divider_count;
uint64_t trigger_mask;
uint64_t memory_limit;
uint16_t command[3 + 10*4];
uint16_t command[3 + (10 * 4)];
devc = sdi->priv;
acq = devc->acquisition;
@ -923,13 +923,13 @@ SR_PRIV int lwla_start_acquisition(const struct sr_dev_inst *sdi)
libusb_fill_bulk_transfer(acq->xfer_out, usb->devhdl, EP_COMMAND,
(unsigned char *)acq->xfer_buf_out, 0,
&receive_transfer_out,
(struct sr_dev_inst *)sdi, USB_TIMEOUT);
(struct sr_dev_inst *)sdi, USB_TIMEOUT_MS);
libusb_fill_bulk_transfer(acq->xfer_in, usb->devhdl, EP_REPLY,
(unsigned char *)acq->xfer_buf_in,
sizeof acq->xfer_buf_in,
&receive_transfer_in,
(struct sr_dev_inst *)sdi, USB_TIMEOUT);
(struct sr_dev_inst *)sdi, USB_TIMEOUT_MS);
regvals = devc->reg_write_seq;

View File

@ -35,7 +35,7 @@
#define USB_VID_PID "2961.6689"
#define USB_INTERFACE 0
#define USB_TIMEOUT 3000 /* ms */
#define USB_TIMEOUT_MS 3000
#define NUM_CHANNELS 34
@ -46,7 +46,7 @@
/** Unit and packet size for the sigrok logic datafeed.
*/
#define UNIT_SIZE ((NUM_CHANNELS + 7) / 8)
#define PACKET_LENGTH 10000 /* units */
#define PACKET_LENGTH (10 * 1000) /* units */
/** Size of the acquisition buffer in device memory units.
*/

View File

@ -34,7 +34,7 @@
#define USB_INTERFACE 0
#define USB_CONFIGURATION 1
#define EP_IN 0x80 | 2
#define EP_IN (0x80 | 2)
#define EP_OUT 2
enum {

View File

@ -29,7 +29,7 @@
#define VICTOR_PID 0xd237
#define VICTOR_VENDOR "Victor"
#define VICTOR_INTERFACE 0
#define VICTOR_ENDPOINT LIBUSB_ENDPOINT_IN | 1
#define VICTOR_ENDPOINT (LIBUSB_ENDPOINT_IN | 1)
SR_PRIV struct sr_dev_driver victor_dmm_driver_info;
static int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data);

View File

@ -33,13 +33,13 @@
#define LOG_PREFIX "yokogawa-dlm"
#define MAX_INSTRUMENT_VERSIONS 4
#define RECEIVE_BUFFER_SIZE (4096)
#define RECEIVE_BUFFER_SIZE 4096
/* See Communication Interface User's Manual on p. 268 (:WAVeform:ALL:SEND?). */
#define DLM_MAX_FRAME_LENGTH (12500)
#define DLM_MAX_FRAME_LENGTH 12500
/* See Communication Interface User's Manual on p. 269 (:WAVeform:SEND?). */
#define DLM_DIVISION_FOR_WORD_FORMAT (3200)
#define DLM_DIVISION_FOR_BYTE_FORMAT (12.5)
#define DLM_DIVISION_FOR_WORD_FORMAT 3200
#define DLM_DIVISION_FOR_BYTE_FORMAT 12.5
enum trigger_slopes {
SLOPE_POSITIVE,
@ -121,18 +121,13 @@ struct dev_context {
gboolean data_pending;
};
/*--- api.c -----------------------------------------------------------------*/
SR_PRIV int dlm_data_request(const struct sr_dev_inst *sdi);
/*--- protocol.c ------------------------------------------------------------*/
SR_PRIV int dlm_model_get(char *model_id, char **model_name, int *model_index);
SR_PRIV int dlm_device_init(struct sr_dev_inst *sdi, int model_index);
SR_PRIV int dlm_data_receive(int fd, int revents, void *cb_data);
SR_PRIV void dlm_scope_state_destroy(struct scope_state *state);
SR_PRIV int dlm_scope_state_query(struct sr_dev_inst *sdi);
SR_PRIV int dlm_sample_rate_query(const struct sr_dev_inst *sdi);
SR_PRIV int dlm_channel_data_request(const struct sr_dev_inst *sdi);
#endif

View File

@ -42,7 +42,7 @@
LIBUSB_RECIPIENT_INTERFACE)
#define EP1_BULK_IN (LIBUSB_ENDPOINT_IN | 1)
#define TIMEOUT 5000 /* Timeout in ms */
#define TIMEOUT_MS (5 * 1000)
enum {
REQ_READBULK = 0x82,
@ -57,7 +57,7 @@ static int gl_write_address(libusb_device_handle *devh, unsigned int address)
int ret;
ret = libusb_control_transfer(devh, CTRL_OUT, 0xc, REQ_WRITEADDR,
0, packet, 1, TIMEOUT);
0, packet, 1, TIMEOUT_MS);
if (ret != 1)
sr_err("%s: %s.", __func__, libusb_error_name(ret));
return ret;
@ -69,7 +69,7 @@ static int gl_write_data(libusb_device_handle *devh, unsigned int val)
int ret;
ret = libusb_control_transfer(devh, CTRL_OUT, 0xc, REQ_WRITEDATA,
0, packet, 1, TIMEOUT);
0, packet, 1, TIMEOUT_MS);
if (ret != 1)
sr_err("%s: %s.", __func__, libusb_error_name(ret));
return ret;
@ -81,7 +81,7 @@ static int gl_read_data(libusb_device_handle *devh)
int ret;
ret = libusb_control_transfer(devh, CTRL_IN, 0xc, REQ_READDATA,
0, packet, 1, TIMEOUT);
0, packet, 1, TIMEOUT_MS);
if (ret != 1)
sr_err("%s: %s, val=%hhx.", __func__,
libusb_error_name(ret), packet[0]);
@ -97,13 +97,13 @@ SR_PRIV int gl_read_bulk(libusb_device_handle *devh, void *buffer,
int ret, transferred = 0;
ret = libusb_control_transfer(devh, CTRL_OUT, 0x4, REQ_READBULK,
0, packet, 8, TIMEOUT);
0, packet, 8, TIMEOUT_MS);
if (ret != 8)
sr_err("%s: libusb_control_transfer: %s.", __func__,
libusb_error_name(ret));
ret = libusb_bulk_transfer(devh, EP1_BULK_IN, buffer, size,
&transferred, TIMEOUT);
&transferred, TIMEOUT_MS);
if (ret < 0)
sr_err("%s: libusb_bulk_transfer: %s.", __func__,
libusb_error_name(ret));

View File

@ -23,7 +23,7 @@
SR_PRIV unsigned int get_memory_size(int type)
{
if (type == MEMORY_SIZE_8K)
return 8 * 1024;
return (8 * 1024);
else if (type <= MEMORY_SIZE_8M)
return (32 * 1024) << type;
else
@ -63,9 +63,9 @@ SR_PRIV int set_limit_samples(struct dev_context *devc, uint64_t samples)
devc->limit_samples = samples;
if (samples <= 2 * 1024)
if (samples <= (2 * 1024))
devc->memory_size = MEMORY_SIZE_8K;
else if (samples <= 16 * 1024)
else if (samples <= (16 * 1024))
devc->memory_size = MEMORY_SIZE_64K;
else
devc->memory_size = 19 - clz(samples - 1);

View File

@ -28,9 +28,9 @@
#define LOG_PREFIX "input/chronovu-la8"
#define DEFAULT_NUM_CHANNELS 8
#define DEFAULT_SAMPLERATE 100000000L
#define MAX_CHUNK_SIZE 4096
#define CHRONOVU_LA8_FILESIZE 8 * 1024 * 1024 + 5
#define DEFAULT_SAMPLERATE SR_MHZ(100)
#define MAX_CHUNK_SIZE (4 * 1024)
#define CHRONOVU_LA8_FILESIZE ((8 * 1024 * 1024) + 5)
struct context {
gboolean started;

View File

@ -173,7 +173,7 @@ static void fancyprint(int unit, int mqflags, float value, GString *out)
g_string_append(out, " %oA");
break;
case SR_UNIT_CONCENTRATION:
g_string_append_printf(out, "%f ppm", value * 1000000);
g_string_append_printf(out, "%f ppm", value * (1000 * 1000));
break;
case SR_UNIT_REVOLUTIONS_PER_MINUTE:
si_printf(value, out, "RPM");

View File

@ -26,7 +26,7 @@
#define LOG_PREFIX "scpi"
#define SCPI_READ_RETRIES 100
#define SCPI_READ_RETRY_TIMEOUT 10000
#define SCPI_READ_RETRY_TIMEOUT_US (10 * 1000)
/**
* Parse a string representation of a boolean-like value into a gboolean.
@ -578,7 +578,7 @@ SR_PRIV int sr_scpi_get_opc(struct sr_scpi_dev_inst *scpi)
sr_scpi_get_bool(scpi, SCPI_CMD_OPC, &opc);
if (opc)
return SR_OK;
g_usleep(SCPI_READ_RETRY_TIMEOUT);
g_usleep(SCPI_READ_RETRY_TIMEOUT_US);
}
return SR_ERR;

View File

@ -28,7 +28,7 @@
#include "libsigrok-internal.h"
#define LOG_PREFIX "scpi_vxi"
#define VXI_DEFAULT_TIMEOUT 2000 /* in ms */
#define VXI_DEFAULT_TIMEOUT_MS 2000
struct scpi_vxi {
char *address;
@ -74,7 +74,7 @@ static int scpi_vxi_open(void *priv)
/* Set link parameters */
link_parms.clientId = (long) vxi->client;
link_parms.lockDevice = 0;
link_parms.lock_timeout = VXI_DEFAULT_TIMEOUT;
link_parms.lock_timeout = VXI_DEFAULT_TIMEOUT_MS;
link_parms.device = "inst0";
if (!(link_resp = create_link_1(&link_parms, vxi->client))) {
@ -124,8 +124,8 @@ static int scpi_vxi_send(void *priv, const char *command)
len = strlen(terminated_command);
write_parms.lid = vxi->link;
write_parms.io_timeout = VXI_DEFAULT_TIMEOUT;
write_parms.lock_timeout = VXI_DEFAULT_TIMEOUT;
write_parms.io_timeout = VXI_DEFAULT_TIMEOUT_MS;
write_parms.lock_timeout = VXI_DEFAULT_TIMEOUT_MS;
write_parms.flags = DF_END;
write_parms.data.data_len = MIN(len, vxi->max_send_size);
write_parms.data.data_val = terminated_command;
@ -169,8 +169,8 @@ static int scpi_vxi_read_data(void *priv, char *buf, int maxlen)
Device_ReadResp *read_resp;
read_parms.lid = vxi->link;
read_parms.io_timeout = VXI_DEFAULT_TIMEOUT;
read_parms.lock_timeout = VXI_DEFAULT_TIMEOUT;
read_parms.io_timeout = VXI_DEFAULT_TIMEOUT_MS;
read_parms.lock_timeout = VXI_DEFAULT_TIMEOUT_MS;
read_parms.flags = 0;
read_parms.termChar = 0;
read_parms.requestSize = maxlen;

View File

@ -693,7 +693,7 @@ SR_PRIV int serial_stream_detect(struct sr_serial_dev_inst *serial,
}
/* Assume 8n1 transmission. That is 10 bits for every byte. */
byte_delay_us = 10 * (1000000 / baudrate);
byte_delay_us = 10 * ((1000 * 1000) / baudrate);
start = g_get_monotonic_time();
i = ibuf = len = 0;

View File

@ -23,7 +23,7 @@
#include "../include/libsigrok/libsigrok.h"
#include "lib.h"
#define BUFSIZE 1000000
#define BUFSIZE (1000 * 1000)
enum {
CHECK_ALL_LOW,