2
0
forked from Ivasoft/DSView

fix: Failed to export data with each format

This commit is contained in:
dreamsourcelabTAI
2023-06-17 11:30:33 +08:00
parent b03a52e65a
commit 3226adfc7d
9 changed files with 41 additions and 4 deletions

View File

@@ -769,8 +769,13 @@ void StoreSession::export_proc(data::Snapshot *snapshot)
output.module = (sr_output_module*) _outModule;
output.sdi = _session->get_device()->inst();
output.param = NULL;
if(_outModule->init)
_outModule->init(&output, params);
if(_outModule->init){
if(_outModule->init(&output, params) != SR_OK){
dsv_err("Failed to init export module.");
return;
}
}
QFile file(_file_name);
file.open(QIODevice::WriteOnly | QIODevice::Text);
@@ -836,7 +841,7 @@ void StoreSession::export_proc(data::Snapshot *snapshot)
g_slist_free(meta.config);
if (channel_type == SR_CHANNEL_LOGIC) {
_unit_count = logic_snapshot->get_sample_count();
_unit_count = logic_snapshot->get_ring_sample_count();
int blk_num = logic_snapshot->get_block_num();
bool sample;
std::vector<uint8_t *> buf_vec;

View File

@@ -25,6 +25,7 @@
#include <unistd.h>
#include <sys/time.h>
#include "../log.h"
#include <stdlib.h>
/* Message logging helpers with subsystem-specific prefix string. */
@@ -60,6 +61,7 @@ static int init(struct sr_input *in, const char *filename)
sr_err("Input format context malloc failed.");
return SR_ERR_MALLOC;
}
memset(ctx, 0, sizeof(struct context));
num_probes = DEFAULT_NUM_PROBES;
ctx->samplerate = 0;

View File

@@ -65,6 +65,7 @@
#include <string.h>
#include <ctype.h>
#include "../log.h"
#include <stdlib.h>
/* Message logging helpers with subsystem-specific prefix string. */
@@ -334,6 +335,7 @@ static int init(struct sr_input *in, const char *filename)
sr_err("Input format context malloc failed.");
return SR_ERR_MALLOC;
}
memset(ctx, 0, sizeof(struct context));
num_probes = DEFAULT_NUM_PROBES;
ctx->samplerate = 0;

View File

@@ -25,6 +25,7 @@
#include <fcntl.h>
#include <string.h>
#include "../log.h"
#include <stdlib.h>
#undef LOG_PREFIX
#define LOG_PREFIX "input/wav: "
@@ -99,6 +100,7 @@ static int init(struct sr_input *in, const char *filename)
sr_err("%s,ERROR:failed to alloc memory.", __func__);
return SR_ERR_MALLOC;
}
memset(ctx, 0, sizeof(struct context));
/* Create a virtual device. */
in->sdi = sr_dev_inst_new(LOGIC, SR_ST_ACTIVE, NULL, NULL, NULL);

View File

@@ -25,6 +25,10 @@
#include <glib.h>
#include "../config.h" /* Needed for PACKAGE_STRING and others. */
#include "../log.h"
#include <stdio.h>
#undef LOG_PREFIX
#define LOG_PREFIX "csv: "
struct context {
unsigned int num_enabled_channels;
@@ -60,7 +64,7 @@ struct context {
static int init(struct sr_output *o, GHashTable *options)
{
struct context *ctx;
struct context *ctx = NULL;
struct sr_channel *ch;
GSList *l;
int i;
@@ -74,6 +78,7 @@ static int init(struct sr_output *o, GHashTable *options)
sr_err("%s,ERROR:failed to alloc memory.", __func__);
return SR_ERR;
}
memset(ctx, 0, sizeof(struct context));
o->priv = ctx;
ctx->separator = ',';
@@ -90,6 +95,7 @@ static int init(struct sr_output *o, GHashTable *options)
continue;
ctx->num_enabled_channels++;
}
ctx->channel_index = malloc(sizeof(int) * ctx->num_enabled_channels);
ctx->channel_unit = malloc(sizeof(int) * ctx->num_enabled_channels);
ctx->channel_scale = malloc(sizeof(float) * ctx->num_enabled_channels);

View File

@@ -26,6 +26,10 @@
#include <glib.h>
#include "../config.h" /* Needed for PACKAGE_STRING and others. */
#include "../log.h"
#include <stdio.h>
#undef LOG_PREFIX
#define LOG_PREFIX "gnuplot: "
struct context {
unsigned int num_enabled_channels;
@@ -61,6 +65,7 @@ static int init(struct sr_output *o, GHashTable *options)
sr_err("%s,ERROR:failed to alloc memory.", __func__);
return SR_ERR;
}
memset(ctx, 0, sizeof(struct context));
o->priv = ctx;
ctx->num_enabled_channels = 0;

View File

@@ -21,8 +21,12 @@
#include "../libsigrok-internal.h"
#include <string.h>
#include "../log.h"
#include <stdio.h>
#undef LOG_PREFIX
#define LOG_PREFIX "output "
/**
* @file
*
@@ -262,6 +266,7 @@ SR_API const struct sr_output *sr_output_new(const struct sr_output_module *omod
sr_err("%s,ERROR:failed to alloc memory.", __func__);
return SR_ERR;
}
memset(op, 0, sizeof(struct sr_output));
op->module = omod;
op->sdi = sdi;

View File

@@ -29,6 +29,10 @@
#include <assert.h>
#include "../log.h"
#include "../version.h"
#include <stdio.h>
#undef LOG_PREFIX
#define LOG_PREFIX "srzip: "
struct out_context {
uint64_t samplerate;
@@ -49,6 +53,7 @@ static int init(struct sr_output *o, GHashTable *options)
sr_err("%s,ERROR:failed to alloc memory.", __func__);
return SR_ERR;
}
memset(outc, 0, sizeof(struct out_context));
o->priv = outc;
outc->zipArchive = NULL;

View File

@@ -26,6 +26,10 @@
#include <glib.h>
#include "../config.h" /* Needed for PACKAGE and others. */
#include "../log.h"
#include <stdio.h>
#undef LOG_PREFIX
#define LOG_PREFIX "vcd: "
struct context {
int num_enabled_channels;
@@ -66,6 +70,7 @@ static int init(struct sr_output *o, GHashTable *options)
sr_err("%s,ERROR:failed to alloc memory.", __func__);
return SR_ERR;
}
memset(ctx, 0, sizeof(struct context));
o->priv = ctx;
ctx->num_enabled_channels = num_enabled_channels;