mirror of
https://github.com/DreamSourceLab/DSView.git
synced 2025-01-13 13:32:53 +08:00
The print format for type uint64_t
This commit is contained in:
parent
c8d226bd04
commit
dc70371195
@ -37,6 +37,7 @@
|
||||
#include "pv/ui/langresource.h"
|
||||
#include <QDateTime>
|
||||
#include <string>
|
||||
#include <ds_types.h>
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <windows.h>
|
||||
@ -216,7 +217,7 @@ bool bHighScale = true;
|
||||
std::string strTime = dateTime .toString("yyyy-MM-dd hh:mm:ss").toStdString();
|
||||
dsv_info("%s", strTime.c_str());
|
||||
|
||||
int bit_width = sizeof(long);
|
||||
int bit_width = sizeof(u64_t);
|
||||
if (bit_width != 8){
|
||||
dsv_err("Can only run on 64 bit systems");
|
||||
return 0;
|
||||
|
@ -34,8 +34,8 @@
|
||||
#include "../view/logicsignal.h"
|
||||
#include "../dsvdef.h"
|
||||
#include "../log.h"
|
||||
|
||||
#include "../ui/langresource.h"
|
||||
#include <ds_types.h>
|
||||
|
||||
using namespace pv::data::decode;
|
||||
using namespace std;
|
||||
@ -551,7 +551,8 @@ void DecoderStack::decode_data(const uint64_t decode_start, const uint64_t decod
|
||||
|
||||
if (end_index >= align_sample_count){
|
||||
end_index = align_sample_count - 1;
|
||||
dsv_info("Reset the decode end sample, new:%lu, old:%lu", end_index, decode_end);
|
||||
dsv_info("Reset the decode end sample, new:%llu, old:%llu",
|
||||
(u64_t)end_index, (u64_t)decode_end);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -660,7 +661,7 @@ void DecoderStack::decode_data(const uint64_t decode_start, const uint64_t decod
|
||||
}
|
||||
}
|
||||
|
||||
dsv_info("%s%lu", "send to decoder times: ", entry_cnt);
|
||||
dsv_info("%s%llu", "send to decoder times: ", (u64_t)entry_cnt);
|
||||
|
||||
if (error != NULL)
|
||||
g_free(error);
|
||||
@ -716,7 +717,8 @@ void DecoderStack::execute_decode_stack()
|
||||
decode_end = max(dec->decode_end(), decode_end);
|
||||
}
|
||||
|
||||
dsv_info("decoder start sample:%lu, end sample:%lu, count:%lu", decode_start, decode_end, decode_end - decode_start + 1);
|
||||
dsv_info("decoder start sample:%llu, end sample:%llu, count:%llu",
|
||||
(u64_t)decode_start, (u64_t)decode_end, (u64_t)(decode_end - decode_start + 1));
|
||||
|
||||
// Start the session
|
||||
srd_session_metadata_set(session, SRD_CONF_SAMPLERATE,
|
||||
|
@ -46,6 +46,7 @@ DecoderOptions::DecoderOptions(pv::data::DecoderStack* decoder_stack, data::deco
|
||||
_decoder(decoder)
|
||||
{
|
||||
assert(_decoder);
|
||||
(void)decoder_stack;
|
||||
|
||||
const srd_decoder *const dec = _decoder->decoder();
|
||||
assert(dec);
|
||||
|
@ -30,6 +30,6 @@
|
||||
#ifndef _DS_TYPES_H
|
||||
#define _DS_TYPES_H
|
||||
|
||||
typedef unsigned long u64_t;
|
||||
typedef unsigned long long u64_t;
|
||||
|
||||
#endif
|
@ -2309,7 +2309,7 @@ static void receive_transfer(struct libusb_transfer *transfer)
|
||||
if (devc->abort)
|
||||
devc->status = DSL_STOP;
|
||||
|
||||
sr_detail("%lu: receive_transfer(): status %d; timeout %d; received %d bytes.",
|
||||
sr_detail("%llu: receive_transfer(): status %d; timeout %d; received %d bytes.",
|
||||
(u64_t)g_get_monotonic_time(), transfer->status, transfer->timeout, transfer->actual_length);
|
||||
|
||||
switch (transfer->status) {
|
||||
@ -2441,7 +2441,7 @@ static void receive_header(struct libusb_transfer *transfer)
|
||||
devc->status = DSL_ERROR;
|
||||
if (!devc->abort && transfer->status == LIBUSB_TRANSFER_COMPLETED &&
|
||||
trigger_pos->check_id == TRIG_CHECKID) {
|
||||
sr_info("%lu: receive_trigger_pos(): status %d; timeout %d; received %d bytes.",
|
||||
sr_info("%llu: receive_trigger_pos(): status %d; timeout %d; received %d bytes.",
|
||||
(u64_t)g_get_monotonic_time(), transfer->status, transfer->timeout, transfer->actual_length);
|
||||
remain_cnt = trigger_pos->remain_cnt_h;
|
||||
remain_cnt = (remain_cnt << 32) + trigger_pos->remain_cnt_l;
|
||||
|
@ -919,11 +919,11 @@ static int config_set(int id, GVariant *data, struct sr_dev_inst *sdi,
|
||||
{
|
||||
case SR_CONF_SAMPLERATE:
|
||||
vdev->samplerate = g_variant_get_uint64(data);
|
||||
sr_dbg("Setting samplerate to %lu.", (u64_t)vdev->samplerate);
|
||||
sr_dbg("Setting samplerate to %llu.", (u64_t)vdev->samplerate);
|
||||
break;
|
||||
case SR_CONF_LIMIT_SAMPLES:
|
||||
vdev->total_samples = g_variant_get_uint64(data);
|
||||
sr_dbg("Setting limit samples to %lu.", (u64_t)vdev->total_samples);
|
||||
sr_dbg("Setting limit samples to %llu.", (u64_t)vdev->total_samples);
|
||||
break;
|
||||
case SR_CONF_LIMIT_MSEC:
|
||||
break;
|
||||
@ -1034,7 +1034,7 @@ static int config_set(int id, GVariant *data, struct sr_dev_inst *sdi,
|
||||
g_timer_start(run_time);
|
||||
vdev->timebase_change = TRUE;
|
||||
}
|
||||
sr_dbg("Setting timebase to %lu.", (u64_t)vdev->timebase);
|
||||
sr_dbg("Setting timebase to %llu.", (u64_t)vdev->timebase);
|
||||
break;
|
||||
case SR_CONF_PROBE_COUPLING:
|
||||
if(sdi->mode != LOGIC)
|
||||
|
@ -236,11 +236,11 @@ static gboolean parse_header(FILE *file, struct context *ctx)
|
||||
if (q % p != 0)
|
||||
{
|
||||
/* Does not happen unless time value is non-standard */
|
||||
sr_warn("Inexact rounding of samplerate, %lu / %lu to %lu Hz.",
|
||||
sr_warn("Inexact rounding of samplerate, %llu / %llu to %llu Hz.",
|
||||
(u64_t)q, (u64_t)p, (u64_t)ctx->samplerate);
|
||||
}
|
||||
|
||||
sr_dbg("Samplerate: %lu", (u64_t)ctx->samplerate);
|
||||
sr_dbg("Samplerate: %llu", (u64_t)ctx->samplerate);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -476,7 +476,7 @@ static void parse_contents(FILE *file, const struct sr_dev_inst *sdi, struct con
|
||||
prev_timestamp = timestamp - ctx->compress;
|
||||
}
|
||||
|
||||
sr_dbg("New timestamp: %lu", (u64_t)timestamp);
|
||||
sr_dbg("New timestamp: %llu", (u64_t)timestamp);
|
||||
|
||||
/* Generate samples from prev_timestamp up to timestamp - 1. */
|
||||
send_samples(sdi, prev_values, timestamp - prev_timestamp);
|
||||
|
@ -212,7 +212,7 @@ static int receive(const struct sr_output *o, const struct sr_datafeed_packet *p
|
||||
memcpy(ctx->prevsample, sample, logic->unitsize);
|
||||
|
||||
/* The first column is a counter (needed for gnuplot). */
|
||||
g_string_append_printf(*out, "%lu\t", (u64_t)ctx->samplecount-1);
|
||||
g_string_append_printf(*out, "%llu\t", (u64_t)ctx->samplecount-1);
|
||||
|
||||
/* The next columns are the values of all channels. */
|
||||
for (p = 0; p < ctx->num_enabled_channels; p++) {
|
||||
|
@ -290,7 +290,7 @@ static void datafeed_dump(const struct sr_datafeed_packet *packet)
|
||||
break;
|
||||
case SR_DF_LOGIC:
|
||||
logic = packet->payload;
|
||||
sr_dbg("bus: Received SR_DF_LOGIC packet (%lu bytes).",
|
||||
sr_dbg("bus: Received SR_DF_LOGIC packet (%llu bytes).",
|
||||
(u64_t)logic->length);
|
||||
break;
|
||||
case SR_DF_DSO:
|
||||
|
@ -1072,19 +1072,19 @@ static int config_set(int id, GVariant *data, struct sr_dev_inst *sdi,
|
||||
case SR_CONF_SAMPLERATE:
|
||||
vdev->samplerate = g_variant_get_uint64(data);
|
||||
samplerates[0] = vdev->samplerate;
|
||||
sr_dbg("Setting samplerate to %lu.", (u64_t)vdev->samplerate);
|
||||
sr_dbg("Setting samplerate to %llu.", (u64_t)vdev->samplerate);
|
||||
break;
|
||||
case SR_CONF_TIMEBASE:
|
||||
vdev->timebase = g_variant_get_uint64(data);
|
||||
sr_dbg("Setting timebase to %lu.", (u64_t)vdev->timebase);
|
||||
sr_dbg("Setting timebase to %llu.", (u64_t)vdev->timebase);
|
||||
break;
|
||||
case SR_CONF_MAX_TIMEBASE:
|
||||
vdev->max_timebase = g_variant_get_uint64(data);
|
||||
sr_dbg("Setting max timebase to %lu.", (u64_t)vdev->max_timebase);
|
||||
sr_dbg("Setting max timebase to %llu.", (u64_t)vdev->max_timebase);
|
||||
break;
|
||||
case SR_CONF_MIN_TIMEBASE:
|
||||
vdev->min_timebase = g_variant_get_uint64(data);
|
||||
sr_dbg("Setting min timebase to %lu.", (u64_t)vdev->min_timebase);
|
||||
sr_dbg("Setting min timebase to %llu.", (u64_t)vdev->min_timebase);
|
||||
break;
|
||||
case SR_CONF_UNIT_BITS:
|
||||
vdev->unit_bits = g_variant_get_byte(data);
|
||||
@ -1105,19 +1105,19 @@ static int config_set(int id, GVariant *data, struct sr_dev_inst *sdi,
|
||||
case SR_CONF_LIMIT_SAMPLES:
|
||||
vdev->total_samples = g_variant_get_uint64(data);
|
||||
samplecounts[0] = vdev->total_samples;
|
||||
sr_dbg("Setting limit samples to %lu.", (u64_t)vdev->total_samples);
|
||||
sr_dbg("Setting limit samples to %llu.", (u64_t)vdev->total_samples);
|
||||
break;
|
||||
case SR_CONF_TRIGGER_TIME:
|
||||
vdev->trig_time = g_variant_get_int64(data);
|
||||
sr_dbg("Setting trigger time to %lu.", (u64_t)vdev->trig_time);
|
||||
sr_dbg("Setting trigger time to %llu.", (u64_t)vdev->trig_time);
|
||||
break;
|
||||
case SR_CONF_TRIGGER_POS:
|
||||
vdev->trig_pos = g_variant_get_uint64(data);
|
||||
sr_dbg("Setting trigger position to %lu.", (u64_t)vdev->trig_pos);
|
||||
sr_dbg("Setting trigger position to %llu.", (u64_t)vdev->trig_pos);
|
||||
break;
|
||||
case SR_CONF_NUM_BLOCKS:
|
||||
vdev->num_blocks = g_variant_get_uint64(data);
|
||||
sr_dbg("Setting block number to %lu.", (u64_t)vdev->num_blocks);
|
||||
sr_dbg("Setting block number to %llu.", (u64_t)vdev->num_blocks);
|
||||
break;
|
||||
case SR_CONF_CAPTURE_NUM_PROBES:
|
||||
vdev->num_probes = g_variant_get_uint64(data);
|
||||
|
@ -62,24 +62,24 @@ SR_API char *sr_si_string_u64(uint64_t x, const char *unit)
|
||||
unit = "";
|
||||
|
||||
if ((x >= SR_GHZ(1)) && (x % SR_GHZ(1) == 0)) {
|
||||
return g_strdup_printf("%lu G%s", (u64_t)(x / SR_GHZ(1)), unit);
|
||||
return g_strdup_printf("%llu G%s", (u64_t)(x / SR_GHZ(1)), unit);
|
||||
} else if ((x >= SR_GHZ(1)) && (x % SR_GHZ(1) != 0)) {
|
||||
return g_strdup_printf("%lu.%lu G%s",
|
||||
return g_strdup_printf("%llu.%llu G%s",
|
||||
(u64_t)(x / SR_GHZ(1)), (u64_t)(x % SR_GHZ(1)), unit);
|
||||
} else if ((x >= SR_MHZ(1)) && (x % SR_MHZ(1) == 0)) {
|
||||
return g_strdup_printf("%lu M%s",
|
||||
return g_strdup_printf("%llu M%s",
|
||||
(u64_t)(x / SR_MHZ(1)), unit);
|
||||
} else if ((x >= SR_MHZ(1)) && (x % SR_MHZ(1) != 0)) {
|
||||
return g_strdup_printf("%lu.%lu M%s",
|
||||
return g_strdup_printf("%llu.%llu M%s",
|
||||
(u64_t)(x / SR_MHZ(1)), (u64_t)(x % SR_MHZ(1)), unit);
|
||||
} else if ((x >= SR_KHZ(1)) && (x % SR_KHZ(1) == 0)) {
|
||||
return g_strdup_printf("%lu k%s",
|
||||
return g_strdup_printf("%llu k%s",
|
||||
(u64_t)(x / SR_KHZ(1)), unit);
|
||||
} else if ((x >= SR_KHZ(1)) && (x % SR_KHZ(1) != 0)) {
|
||||
return g_strdup_printf("%lu.%lu K%s",
|
||||
return g_strdup_printf("%llu.%llu K%s",
|
||||
(u64_t)(x / SR_KHZ(1)), (u64_t)(x % SR_KHZ(1)), unit);
|
||||
} else {
|
||||
return g_strdup_printf("%lu %s", (u64_t)x, unit);
|
||||
return g_strdup_printf("%llu %s", (u64_t)x, unit);
|
||||
}
|
||||
|
||||
sr_err("%s: Error creating SI units string.", __func__);
|
||||
@ -107,24 +107,24 @@ SR_API char *sr_iec_string_u64(uint64_t x, const char *unit)
|
||||
unit = "";
|
||||
|
||||
if ((x >= SR_GB(1)) && (x % SR_GB(1) == 0)) {
|
||||
return g_strdup_printf("%lu G%s", (u64_t)(x / SR_GB(1)), unit);
|
||||
return g_strdup_printf("%llu G%s", (u64_t)(x / SR_GB(1)), unit);
|
||||
} else if ((x >= SR_GB(1)) && (x % SR_GB(1) != 0)) {
|
||||
return g_strdup_printf("%lu.%lu G%s",
|
||||
return g_strdup_printf("%llu.%llu G%s",
|
||||
(u64_t)(x / SR_GB(1)), (u64_t)(x % SR_GB(1)), unit);
|
||||
} else if ((x >= SR_MB(1)) && (x % SR_MB(1) == 0)) {
|
||||
return g_strdup_printf("%lu M%s",
|
||||
return g_strdup_printf("%llu M%s",
|
||||
(u64_t)(x / SR_MB(1)), unit);
|
||||
} else if ((x >= SR_MB(1)) && (x % SR_MB(1) != 0)) {
|
||||
return g_strdup_printf("%lu.%lu M%s",
|
||||
return g_strdup_printf("%llu.%llu M%s",
|
||||
(u64_t)(x / SR_MB(1)), (u64_t)(x % SR_MB(1)), unit);
|
||||
} else if ((x >= SR_KB(1)) && (x % SR_KB(1) == 0)) {
|
||||
return g_strdup_printf("%lu k%s",
|
||||
return g_strdup_printf("%llu k%s",
|
||||
(u64_t)(x / SR_KB(1)), unit);
|
||||
} else if ((x >= SR_KB(1)) && (x % SR_KB(1) != 0)) {
|
||||
return g_strdup_printf("%lu.%lu K%s",
|
||||
return g_strdup_printf("%llu.%llu K%s",
|
||||
(u64_t)(x / SR_KB(1)), (u64_t)(x % SR_KB(1)), unit);
|
||||
} else {
|
||||
return g_strdup_printf("%lu %s", (u64_t)x, unit);
|
||||
return g_strdup_printf("%llu %s", (u64_t)x, unit);
|
||||
}
|
||||
|
||||
sr_err("%s: Error creating SI units string.", __func__);
|
||||
@ -188,13 +188,13 @@ SR_API char *sr_period_string(uint64_t frequency)
|
||||
}
|
||||
|
||||
if (frequency >= SR_GHZ(1))
|
||||
r = snprintf(o, 30, "%lu ns", (u64_t)(frequency / 1000000000));
|
||||
r = snprintf(o, 30, "%llu ns", (u64_t)(frequency / 1000000000));
|
||||
else if (frequency >= SR_MHZ(1))
|
||||
r = snprintf(o, 30, "%lu us", (u64_t)(frequency / 1000000));
|
||||
r = snprintf(o, 30, "%llu us", (u64_t)(frequency / 1000000));
|
||||
else if (frequency >= SR_KHZ(1))
|
||||
r = snprintf(o, 30, "%lu ms", (u64_t)(frequency / 1000));
|
||||
r = snprintf(o, 30, "%llu ms", (u64_t)(frequency / 1000));
|
||||
else
|
||||
r = snprintf(o, 30, "%lu s", (u64_t)frequency);
|
||||
r = snprintf(o, 30, "%llu s", (u64_t)frequency);
|
||||
|
||||
if (r < 0) {
|
||||
/* Something went wrong... */
|
||||
@ -241,7 +241,7 @@ SR_API char *sr_time_string(uint64_t time)
|
||||
else if (time >= SR_US(1))
|
||||
r = snprintf(o, 30, "%0.2lf us", time * 1.0 / SR_US(1));
|
||||
else
|
||||
r = snprintf(o, 30, "%lu ns", (u64_t)time);
|
||||
r = snprintf(o, 30, "%llu ns", (u64_t)time);
|
||||
|
||||
if (r < 0) {
|
||||
/* Something went wrong... */
|
||||
@ -277,9 +277,9 @@ SR_API char *sr_voltage_string(uint64_t v_p, uint64_t v_q)
|
||||
}
|
||||
|
||||
if (v_q == 1000)
|
||||
r = snprintf(o, 30, "%lumV", (u64_t)v_p);
|
||||
r = snprintf(o, 30, "%llumV", (u64_t)v_p);
|
||||
else if (v_q == 1)
|
||||
r = snprintf(o, 30, "%luV", (u64_t)v_p);
|
||||
r = snprintf(o, 30, "%lluV", (u64_t)v_p);
|
||||
else
|
||||
r = snprintf(o, 30, "%gV", (float)v_p / (float)v_q);
|
||||
|
||||
|
@ -117,6 +117,6 @@ void srtest_check_samplerate(struct sr_context *sr_ctx, const char *drivername,
|
||||
srtest_driver_init(sr_ctx, driver);;
|
||||
srtest_set_samplerate(driver, samplerate);
|
||||
s = srtest_get_samplerate(driver);
|
||||
fail_unless(s == samplerate, "%s: Incorrect samplerate: %lu.",
|
||||
fail_unless(s == samplerate, "%s: Incorrect samplerate: %llu.",
|
||||
drivername, (u64_t)s);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user