mirror of
https://github.com/DreamSourceLab/DSView.git
synced 2025-01-13 13:32:53 +08:00
Merge pull request #624 from yunyaobaihong/demo
demo:logic random probemode updata
This commit is contained in:
commit
55a7184b4a
@ -49,11 +49,23 @@
|
|||||||
#define BUFSIZE 512*1024
|
#define BUFSIZE 512*1024
|
||||||
#define DSO_BUFSIZE 10*1024
|
#define DSO_BUFSIZE 10*1024
|
||||||
|
|
||||||
|
static struct DEMO_channels logic_channel_modes[] = {
|
||||||
|
{DEMO_LOGIC125x16, LOGIC, SR_CHANNEL_LOGIC, 16, 1, SR_MHZ(1), SR_Mn(1),
|
||||||
|
SR_KHZ(10), SR_MHZ(125), "Use 16 Channels (Max 125MHz)"},
|
||||||
|
{DEMO_LOGIC250x12, LOGIC, SR_CHANNEL_LOGIC, 12, 1, SR_MHZ(1), SR_Mn(1),
|
||||||
|
SR_KHZ(10), SR_MHZ(250), "Use 12 Channels (Max 250MHz)"},
|
||||||
|
{DEMO_LOGIC500x6, LOGIC, SR_CHANNEL_LOGIC, 6, 1, SR_MHZ(1), SR_Mn(1),
|
||||||
|
SR_KHZ(10), SR_MHZ(500), "Use 6 Channels (Max 500MHz)"},
|
||||||
|
{DEMO_LOGIC1000x3, LOGIC, SR_CHANNEL_LOGIC, 3, 1, SR_MHZ(1), SR_Mn(1),
|
||||||
|
SR_KHZ(10), SR_GHZ(1), "Use 3 Channels (Max 1GHz)"},
|
||||||
|
};
|
||||||
|
|
||||||
|
static struct sr_list_item logic_channel_mode_list[ARRAY_SIZE(logic_channel_modes)+1];
|
||||||
|
|
||||||
static struct DEMO_channels channel_modes[] = {
|
static struct DEMO_channels channel_modes[] = {
|
||||||
// LA Stream
|
// LA Stream
|
||||||
{DEMO_LOGIC100x16, LOGIC, SR_CHANNEL_LOGIC, 16, 1, SR_MHZ(1), SR_Mn(1),
|
{DEMO_LOGIC100x16, LOGIC, SR_CHANNEL_LOGIC, 16, 1, SR_MHZ(1), SR_Mn(1),
|
||||||
SR_KHZ(10), SR_GHZ(1), "Use 16 Channels (Max 20MHz)"},
|
SR_KHZ(10), SR_GHZ(1), "Use 16 Channels (Max 20MHz)"},
|
||||||
//updata
|
|
||||||
|
|
||||||
// DAQ
|
// DAQ
|
||||||
{DEMO_ANALOG10x2, ANALOG, SR_CHANNEL_ANALOG, 2, 8, SR_MHZ(1), SR_Mn(1),
|
{DEMO_ANALOG10x2, ANALOG, SR_CHANNEL_ANALOG, 2, 8, SR_MHZ(1), SR_Mn(1),
|
||||||
@ -74,6 +86,58 @@ static struct sr_dev_driver *di = &demo_driver_info;
|
|||||||
|
|
||||||
extern struct ds_trigger *trigger;
|
extern struct ds_trigger *trigger;
|
||||||
|
|
||||||
|
static int logic_adjust_probe(struct sr_dev_inst *sdi, int num_probes)
|
||||||
|
{
|
||||||
|
uint16_t j;
|
||||||
|
struct sr_channel *probe;
|
||||||
|
struct DSL_context *devc = sdi->priv;
|
||||||
|
GSList *l;
|
||||||
|
|
||||||
|
assert(num_probes > 0);
|
||||||
|
|
||||||
|
j = g_slist_length(sdi->channels);
|
||||||
|
while(j < num_probes) {
|
||||||
|
if (!(probe = sr_channel_new(j, SR_CHANNEL_LOGIC,
|
||||||
|
TRUE, probe_names[j])))
|
||||||
|
return SR_ERR;
|
||||||
|
sdi->channels = g_slist_append(sdi->channels, probe);
|
||||||
|
j++;
|
||||||
|
}
|
||||||
|
|
||||||
|
while(j > num_probes) {
|
||||||
|
sdi->channels = g_slist_delete_link(sdi->channels, g_slist_last(sdi->channels));
|
||||||
|
j--;
|
||||||
|
}
|
||||||
|
|
||||||
|
for(l = sdi->channels; l; l = l->next) {
|
||||||
|
probe = (struct sr_channel *)l->data;
|
||||||
|
probe->enabled = TRUE;
|
||||||
|
probe->type = SR_CHANNEL_LOGIC;
|
||||||
|
}
|
||||||
|
return SR_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void logic_adjust_samplerate(struct session_vdev * vdev)
|
||||||
|
{
|
||||||
|
vdev->samplerates_max_index = ARRAY_SIZE(samplerates) - 1;
|
||||||
|
while (samplerates[vdev->samplerates_max_index] >
|
||||||
|
logic_channel_modes[logic_index].max_samplerate)
|
||||||
|
vdev->samplerates_max_index--;
|
||||||
|
|
||||||
|
vdev->samplerates_min_index = 0;
|
||||||
|
while (samplerates[vdev->samplerates_min_index] <
|
||||||
|
logic_channel_modes[logic_index].min_samplerate)
|
||||||
|
vdev->samplerates_min_index++;
|
||||||
|
|
||||||
|
assert(vdev->samplerates_max_index >= vdev->samplerates_min_index);
|
||||||
|
|
||||||
|
if (vdev->samplerate > samplerates[vdev->samplerates_max_index])
|
||||||
|
vdev->samplerate = samplerates[vdev->samplerates_max_index];
|
||||||
|
|
||||||
|
if (vdev->samplerate < samplerates[vdev->samplerates_min_index])
|
||||||
|
vdev->samplerate = samplerates[vdev->samplerates_min_index];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static void init_analog_random_data(struct session_vdev * vdev)
|
static void init_analog_random_data(struct session_vdev * vdev)
|
||||||
{
|
{
|
||||||
@ -773,6 +837,9 @@ static int config_get(int id, GVariant **data, const struct sr_dev_inst *sdi,
|
|||||||
case SR_CONF_REF_MAX:
|
case SR_CONF_REF_MAX:
|
||||||
*data = g_variant_new_uint32(vdev->ref_max);
|
*data = g_variant_new_uint32(vdev->ref_max);
|
||||||
break;
|
break;
|
||||||
|
case SR_CONF_CHANNEL_MODE:
|
||||||
|
*data = g_variant_new_int16(ch_mode);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
return SR_ERR_NA;
|
return SR_ERR_NA;
|
||||||
}
|
}
|
||||||
@ -789,6 +856,7 @@ static int config_set(int id, GVariant *data, struct sr_dev_inst *sdi,
|
|||||||
struct session_vdev *vdev;
|
struct session_vdev *vdev;
|
||||||
const char *stropt;
|
const char *stropt;
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
|
int nv;
|
||||||
|
|
||||||
assert(sdi);
|
assert(sdi);
|
||||||
assert(sdi->priv);
|
assert(sdi->priv);
|
||||||
@ -799,18 +867,10 @@ static int config_set(int id, GVariant *data, struct sr_dev_inst *sdi,
|
|||||||
{
|
{
|
||||||
case SR_CONF_SAMPLERATE:
|
case SR_CONF_SAMPLERATE:
|
||||||
vdev->samplerate = g_variant_get_uint64(data);
|
vdev->samplerate = g_variant_get_uint64(data);
|
||||||
if(sdi->mode == LOGIC && sample_generator >PATTERN_RANDOM)
|
|
||||||
{
|
|
||||||
samplerates_file[0] = vdev->samplerate;
|
|
||||||
}
|
|
||||||
sr_dbg("Setting samplerate to %llu.", vdev->samplerate);
|
sr_dbg("Setting samplerate to %llu.", vdev->samplerate);
|
||||||
break;
|
break;
|
||||||
case SR_CONF_LIMIT_SAMPLES:
|
case SR_CONF_LIMIT_SAMPLES:
|
||||||
vdev->total_samples = g_variant_get_uint64(data);
|
vdev->total_samples = g_variant_get_uint64(data);
|
||||||
if(sdi->mode == LOGIC && sample_generator >PATTERN_RANDOM)
|
|
||||||
{
|
|
||||||
samplecounts_file[0] = vdev->total_samples;
|
|
||||||
}
|
|
||||||
sr_dbg("Setting limit samples to %llu.", vdev->total_samples);
|
sr_dbg("Setting limit samples to %llu.", vdev->total_samples);
|
||||||
break;
|
break;
|
||||||
case SR_CONF_LIMIT_MSEC:
|
case SR_CONF_LIMIT_MSEC:
|
||||||
@ -821,9 +881,13 @@ static int config_set(int id, GVariant *data, struct sr_dev_inst *sdi,
|
|||||||
{
|
{
|
||||||
case LOGIC:
|
case LOGIC:
|
||||||
if(SR_OK == reset_dsl_path(sdi,sdi->mode ,PATTERN_DEFAULT))
|
if(SR_OK == reset_dsl_path(sdi,sdi->mode ,PATTERN_DEFAULT))
|
||||||
|
{
|
||||||
sample_generator = PATTERN_DEFAULT;
|
sample_generator = PATTERN_DEFAULT;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
sample_generator = PATTERN_RANDOM;
|
sample_generator = PATTERN_RANDOM;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case DSO:
|
case DSO:
|
||||||
reset_dsl_path(sdi,sdi->mode ,PATTERN_RANDOM);
|
reset_dsl_path(sdi,sdi->mode ,PATTERN_RANDOM);
|
||||||
@ -845,7 +909,6 @@ static int config_set(int id, GVariant *data, struct sr_dev_inst *sdi,
|
|||||||
{
|
{
|
||||||
sample_generator = PATTERN_RANDOM;
|
sample_generator = PATTERN_RANDOM;
|
||||||
}
|
}
|
||||||
|
|
||||||
sr_dbg("%s: setting pattern to %d",
|
sr_dbg("%s: setting pattern to %d",
|
||||||
__func__, sample_generator);
|
__func__, sample_generator);
|
||||||
break;
|
break;
|
||||||
@ -892,11 +955,14 @@ static int config_set(int id, GVariant *data, struct sr_dev_inst *sdi,
|
|||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
if(ch->coupling == 0)
|
if(ch->coupling == 0)
|
||||||
|
{
|
||||||
ch->hw_offset = 178;
|
ch->hw_offset = 178;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
ch->hw_offset = 128;
|
ch->hw_offset = 128;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case SR_CONF_PROBE_HW_OFFSET:
|
case SR_CONF_PROBE_HW_OFFSET:
|
||||||
ch->hw_offset = g_variant_get_uint16(data);
|
ch->hw_offset = g_variant_get_uint16(data);
|
||||||
@ -918,13 +984,19 @@ static int config_set(int id, GVariant *data, struct sr_dev_inst *sdi,
|
|||||||
ch->coupling = g_variant_get_byte(data);
|
ch->coupling = g_variant_get_byte(data);
|
||||||
ch->hw_offset = ch->offset;
|
ch->hw_offset = ch->offset;
|
||||||
}
|
}
|
||||||
else{
|
else
|
||||||
|
{
|
||||||
ch->coupling = g_variant_get_byte(data);
|
ch->coupling = g_variant_get_byte(data);
|
||||||
if(ch->coupling == 0)
|
if(ch->coupling == 0)
|
||||||
|
{
|
||||||
ch->hw_offset = 178;
|
ch->hw_offset = 178;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
ch->hw_offset = 128;
|
ch->hw_offset = 128;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case SR_CONF_TRIGGER_SOURCE:
|
case SR_CONF_TRIGGER_SOURCE:
|
||||||
@ -972,6 +1044,23 @@ static int config_set(int id, GVariant *data, struct sr_dev_inst *sdi,
|
|||||||
vdev->is_loop = g_variant_get_boolean(data);
|
vdev->is_loop = g_variant_get_boolean(data);
|
||||||
sr_info("Set demo loop mode:%d", vdev->is_loop);
|
sr_info("Set demo loop mode:%d", vdev->is_loop);
|
||||||
break;
|
break;
|
||||||
|
case SR_CONF_CHANNEL_MODE:
|
||||||
|
nv = g_variant_get_int16(data);
|
||||||
|
if(sdi->mode == LOGIC && sample_generator == PATTERN_RANDOM)
|
||||||
|
{
|
||||||
|
for(i = 0 ; i < ARRAY_SIZE(logic_channel_modes);i++)
|
||||||
|
{
|
||||||
|
if(logic_channel_modes[i].id == nv)
|
||||||
|
{
|
||||||
|
logic_index = i;
|
||||||
|
ch_mode = nv;
|
||||||
|
logic_adjust_probe(sdi,logic_channel_modes[i].num);
|
||||||
|
logic_adjust_samplerate(vdev);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
sr_err("Unknown capability: %d.", id);
|
sr_err("Unknown capability: %d.", id);
|
||||||
return SR_ERR_NA;
|
return SR_ERR_NA;
|
||||||
@ -1055,6 +1144,24 @@ static int config_list(int key, GVariant **data, const struct sr_dev_inst *sdi,
|
|||||||
case SR_CONF_PROBE_MAP_UNIT:
|
case SR_CONF_PROBE_MAP_UNIT:
|
||||||
*data = g_variant_new_strv(probeMapUnits, ARRAY_SIZE(probeMapUnits));
|
*data = g_variant_new_strv(probeMapUnits, ARRAY_SIZE(probeMapUnits));
|
||||||
break;
|
break;
|
||||||
|
case SR_CONF_CHANNEL_MODE:
|
||||||
|
if(sdi->mode == LOGIC&& sample_generator == PATTERN_RANDOM)
|
||||||
|
{
|
||||||
|
for(int i = 0;i<ARRAY_SIZE(logic_channel_mode_list);i++)
|
||||||
|
{
|
||||||
|
logic_channel_mode_list[i].id = logic_channel_modes[i].id;
|
||||||
|
logic_channel_mode_list[i].name = logic_channel_modes[i].descr;
|
||||||
|
if(i == ARRAY_SIZE(logic_channel_mode_list)-1)
|
||||||
|
{
|
||||||
|
logic_channel_mode_list[i].id = -1;
|
||||||
|
logic_channel_mode_list[i].name = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
*data = g_variant_new_uint64((uint64_t)&logic_channel_mode_list);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
return SR_ERR_ARG;
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
return SR_ERR_ARG;
|
return SR_ERR_ARG;
|
||||||
}
|
}
|
||||||
@ -1985,7 +2092,6 @@ static int receive_data_dso(int fd, int revents, const struct sr_dev_inst *sdi)
|
|||||||
tem = DSO_MIN_VAL;
|
tem = DSO_MIN_VAL;
|
||||||
else
|
else
|
||||||
tem-= high_gate;
|
tem-= high_gate;
|
||||||
// test[i] = tem;
|
|
||||||
*((uint8_t*)pack_buffer->post_buf + i) = (uint8_t)tem;
|
*((uint8_t*)pack_buffer->post_buf + i) = (uint8_t)tem;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2308,124 +2414,25 @@ static int load_virtual_device_session(struct sr_dev_inst *sdi)
|
|||||||
unz_file_info64 fileInfo;
|
unz_file_info64 fileInfo;
|
||||||
|
|
||||||
struct sr_channel *probe;
|
struct sr_channel *probe;
|
||||||
int ret, devcnt, i, j;
|
int devcnt, i, j;
|
||||||
uint16_t probenum;
|
|
||||||
uint64_t tmp_u64, total_probes, enabled_probes;
|
uint64_t tmp_u64, total_probes, enabled_probes;
|
||||||
uint16_t p;
|
char **sections, **keys, *metafile, *val,*probe_name;
|
||||||
int64_t tmp_64;
|
|
||||||
char **sections, **keys, *metafile, *val;
|
|
||||||
char probename[SR_MAX_PROBENAME_LEN + 1];
|
|
||||||
int mode = LOGIC;
|
int mode = LOGIC;
|
||||||
int channel_type = SR_CHANNEL_LOGIC;
|
int channel_type = SR_CHANNEL_LOGIC;
|
||||||
double tmp_double;
|
|
||||||
int version = 1;
|
int version = 1;
|
||||||
|
|
||||||
|
struct session_vdev * vdev = sdi->priv;
|
||||||
|
|
||||||
assert(sdi);
|
assert(sdi);
|
||||||
if (sample_generator != PATTERN_RANDOM)
|
if (sample_generator != PATTERN_RANDOM)
|
||||||
{
|
{
|
||||||
assert(sdi->path);
|
assert(sdi->path);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sdi->mode == LOGIC && sample_generator == PATTERN_RANDOM)
|
switch (sdi->mode)
|
||||||
{
|
|
||||||
sdi->driver->config_set(SR_CONF_SAMPLERATE,
|
|
||||||
g_variant_new_uint64(SR_MHZ(1)), sdi, NULL, NULL);
|
|
||||||
sdi->driver->config_set(SR_CONF_LIMIT_SAMPLES,
|
|
||||||
g_variant_new_uint64(SR_MHZ(1)), sdi, NULL, NULL);
|
|
||||||
sr_dev_probes_free(sdi);
|
|
||||||
sdi->driver->config_set(SR_CONF_CAPTURE_NUM_PROBES,
|
|
||||||
g_variant_new_uint64(16), sdi, NULL, NULL);
|
|
||||||
sdi->driver->config_set(SR_CONF_NUM_BLOCKS,
|
|
||||||
g_variant_new_uint64(6), sdi, NULL, NULL);
|
|
||||||
|
|
||||||
char* probe_val;
|
|
||||||
for (int i = 0; i < 16; i++)
|
|
||||||
{
|
|
||||||
probe_val = probe_names[i];
|
|
||||||
if (!(probe = sr_channel_new(i, SR_CHANNEL_LOGIC, TRUE, probe_val)))
|
|
||||||
{
|
|
||||||
sr_err("%s: create channel failed", __func__);
|
|
||||||
sr_dev_inst_free(sdi);
|
|
||||||
return SR_ERR;
|
|
||||||
}
|
|
||||||
|
|
||||||
sdi->channels = g_slist_append(sdi->channels, probe);
|
|
||||||
}
|
|
||||||
adjust_samplerate(sdi);
|
|
||||||
}
|
|
||||||
else if(sdi->mode == DSO)
|
|
||||||
{
|
|
||||||
sdi->driver->config_set(SR_CONF_SAMPLERATE,
|
|
||||||
g_variant_new_uint64(SR_MHZ(100)), sdi, NULL, NULL);
|
|
||||||
sdi->driver->config_set(SR_CONF_LIMIT_SAMPLES,
|
|
||||||
g_variant_new_uint64(SR_KHZ(10)), sdi, NULL, NULL);
|
|
||||||
sr_dev_probes_free(sdi);
|
|
||||||
sdi->driver->config_set(SR_CONF_CAPTURE_NUM_PROBES,
|
|
||||||
g_variant_new_uint64(2), sdi, NULL, NULL);
|
|
||||||
sdi->driver->config_set(SR_CONF_NUM_BLOCKS,
|
|
||||||
g_variant_new_uint64(1), sdi, NULL, NULL);
|
|
||||||
char* probe_val;
|
|
||||||
for (int i = 0; i < 2; i++)
|
|
||||||
{
|
|
||||||
probe_val = probe_names[i];
|
|
||||||
if (!(probe = sr_channel_new(i, SR_CHANNEL_DSO, TRUE, probe_val)))
|
|
||||||
{
|
|
||||||
sr_err("%s: create channel failed", __func__);
|
|
||||||
sr_dev_inst_free(sdi);
|
|
||||||
return SR_ERR;
|
|
||||||
}
|
|
||||||
probe->enabled = TRUE;
|
|
||||||
probe->coupling = 1;
|
|
||||||
probe->vdiv = 1000;
|
|
||||||
probe->vfactor = 1000;
|
|
||||||
probe->hw_offset = 128;
|
|
||||||
probe->offset = 128;
|
|
||||||
probe->trig_value = 0.5;
|
|
||||||
sdi->channels = g_slist_append(sdi->channels, probe);
|
|
||||||
}
|
|
||||||
adjust_samplerate(sdi);
|
|
||||||
}
|
|
||||||
else if(sdi->mode == ANALOG)
|
|
||||||
{
|
|
||||||
sdi->driver->config_set(SR_CONF_SAMPLERATE,
|
|
||||||
g_variant_new_uint64(SR_MHZ(1)), sdi, NULL, NULL);
|
|
||||||
sdi->driver->config_set(SR_CONF_LIMIT_SAMPLES,
|
|
||||||
g_variant_new_uint64(SR_MHZ(1)), sdi, NULL, NULL);
|
|
||||||
sr_dev_probes_free(sdi);
|
|
||||||
sdi->driver->config_set(SR_CONF_CAPTURE_NUM_PROBES,
|
|
||||||
g_variant_new_uint64(2), sdi, NULL, NULL);
|
|
||||||
sdi->driver->config_set(SR_CONF_NUM_BLOCKS,
|
|
||||||
g_variant_new_uint64(1), sdi, NULL, NULL);
|
|
||||||
char* probe_val;
|
|
||||||
for (int i = 0; i < 2; i++)
|
|
||||||
{
|
|
||||||
probe_val = probe_names[i];
|
|
||||||
if (!(probe = sr_channel_new(i, SR_CHANNEL_ANALOG, TRUE, probe_val)))
|
|
||||||
{
|
|
||||||
sr_err("%s: create channel failed", __func__);
|
|
||||||
sr_dev_inst_free(sdi);
|
|
||||||
return SR_ERR;
|
|
||||||
}
|
|
||||||
|
|
||||||
probe->enabled = TRUE;
|
|
||||||
probe->bits = 8;
|
|
||||||
probe->vdiv = 1000;
|
|
||||||
probe->hw_offset = 128;
|
|
||||||
probe->offset = 128;
|
|
||||||
probe->coupling = 1;
|
|
||||||
probe->vfactor = 1;
|
|
||||||
probe->trig_value = 128;
|
|
||||||
probe->map_default = TRUE;
|
|
||||||
probe->map_unit = "V";
|
|
||||||
probe->map_min = -(probe->vdiv * probe->vfactor * DS_CONF_DSO_VDIVS / 2000.0);
|
|
||||||
probe->map_max = probe->vdiv * probe->vfactor * DS_CONF_DSO_VDIVS / 2000.0;
|
|
||||||
|
|
||||||
sdi->channels = g_slist_append(sdi->channels, probe);
|
|
||||||
}
|
|
||||||
adjust_samplerate(sdi);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
|
case LOGIC:
|
||||||
|
if(sample_generator != PATTERN_RANDOM){
|
||||||
archive = unzOpen64(sdi->path);
|
archive = unzOpen64(sdi->path);
|
||||||
if (NULL == archive)
|
if (NULL == archive)
|
||||||
{
|
{
|
||||||
@ -2510,28 +2517,31 @@ static int load_virtual_device_session(struct sr_dev_inst *sdi)
|
|||||||
else if (!strcmp(keys[j], "samplerate"))
|
else if (!strcmp(keys[j], "samplerate"))
|
||||||
{
|
{
|
||||||
sr_parse_sizestring(val, &tmp_u64);
|
sr_parse_sizestring(val, &tmp_u64);
|
||||||
sdi->driver->config_set(SR_CONF_SAMPLERATE,
|
vdev->samplerate = tmp_u64;
|
||||||
g_variant_new_uint64(tmp_u64), sdi, NULL, NULL);
|
if(sdi->mode == LOGIC && sample_generator >PATTERN_RANDOM)
|
||||||
|
{
|
||||||
|
samplerates_file[0] = vdev->samplerate;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (!strcmp(keys[j], "total samples"))
|
else if (!strcmp(keys[j], "total samples"))
|
||||||
{
|
{
|
||||||
tmp_u64 = strtoull(val, NULL, 10);
|
tmp_u64 = strtoull(val, NULL, 10);
|
||||||
sdi->driver->config_set(SR_CONF_LIMIT_SAMPLES,
|
vdev->total_samples = tmp_u64;
|
||||||
g_variant_new_uint64(tmp_u64), sdi, NULL, NULL);
|
if(sdi->mode == LOGIC && sample_generator >PATTERN_RANDOM)
|
||||||
|
{
|
||||||
|
samplecounts_file[0] = vdev->total_samples;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (!strcmp(keys[j], "total blocks"))
|
else if (!strcmp(keys[j], "total blocks"))
|
||||||
{
|
{
|
||||||
tmp_u64 = strtoull(val, NULL, 10);
|
tmp_u64 = strtoull(val, NULL, 10);
|
||||||
sdi->driver->config_set(SR_CONF_NUM_BLOCKS,
|
vdev->num_blocks = tmp_u64;
|
||||||
g_variant_new_uint64(tmp_u64), sdi, NULL, NULL);
|
|
||||||
}
|
}
|
||||||
else if (!strcmp(keys[j], "total probes"))
|
else if (!strcmp(keys[j], "total probes"))
|
||||||
{
|
{
|
||||||
sr_dev_probes_free(sdi);
|
sr_dev_probes_free(sdi);
|
||||||
total_probes = strtoull(val, NULL, 10);
|
total_probes = strtoull(val, NULL, 10);
|
||||||
sdi->driver->config_set(SR_CONF_CAPTURE_NUM_PROBES,
|
vdev->num_probes = total_probes;
|
||||||
g_variant_new_uint64(total_probes), sdi, NULL, NULL);
|
|
||||||
}
|
}
|
||||||
else if (!strncmp(keys[j], "probe", 5))
|
else if (!strncmp(keys[j], "probe", 5))
|
||||||
{
|
{
|
||||||
@ -2559,7 +2569,93 @@ static int load_virtual_device_session(struct sr_dev_inst *sdi)
|
|||||||
g_key_file_free(kf);
|
g_key_file_free(kf);
|
||||||
g_safe_free(metafile);
|
g_safe_free(metafile);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
vdev->samplerate = LOGIC_DEFAULT_SAMPLERATE;
|
||||||
|
vdev->total_samples = LOGIC_DEFAULT_TOTAL_SAMPLES;
|
||||||
|
vdev->num_probes = LOGIC_DEFAULT_NUM_PROBE;
|
||||||
|
sr_dev_probes_free(sdi);
|
||||||
|
|
||||||
|
for (int i = 0; i < LOGIC_DEFAULT_NUM_PROBE; i++)
|
||||||
|
{
|
||||||
|
probe_name = probe_names[i];
|
||||||
|
if (!(probe = sr_channel_new(i, SR_CHANNEL_LOGIC, TRUE, probe_name)))
|
||||||
|
{
|
||||||
|
sr_err("%s: create channel failed", __func__);
|
||||||
|
sr_dev_inst_free(sdi);
|
||||||
|
return SR_ERR;
|
||||||
|
}
|
||||||
|
sdi->channels = g_slist_append(sdi->channels, probe);
|
||||||
|
}
|
||||||
|
//updata
|
||||||
|
ch_mode = DEMO_LOGIC125x16;
|
||||||
|
logic_index = LOGIC125x16;
|
||||||
|
logic_adjust_samplerate(sdi->priv);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case DSO:
|
||||||
|
vdev->samplerate = DSO_DEFAULT_SAMPLERATE;
|
||||||
|
vdev->total_samples = DSO_DEFAULT_TOTAL_SAMPLES;
|
||||||
|
vdev->num_probes = DSO_DEFAULT_NUM_PROBE;
|
||||||
|
vdev->num_blocks = DSO_DEFAULT_NUM_BLOCK;
|
||||||
|
sr_dev_probes_free(sdi);
|
||||||
|
|
||||||
|
for (int i = 0; i < DSO_DEFAULT_NUM_PROBE; i++)
|
||||||
|
{
|
||||||
|
probe_name = probe_names[i];
|
||||||
|
if (!(probe = sr_channel_new(i, SR_CHANNEL_DSO, TRUE, probe_name)))
|
||||||
|
{
|
||||||
|
sr_err("%s: create channel failed", __func__);
|
||||||
|
sr_dev_inst_free(sdi);
|
||||||
|
return SR_ERR;
|
||||||
|
}
|
||||||
|
probe->enabled = DSO_DEFAULT_ENABLE;
|
||||||
|
probe->coupling = DSO_DEFAULT_COUPLING;
|
||||||
|
probe->vdiv = DSO_DEFAULT_VIDV;
|
||||||
|
probe->vfactor = DSO_DEFAULT_VFACOTR;
|
||||||
|
probe->hw_offset = DSO_DEFAULT_HW_OFFSET;
|
||||||
|
probe->offset = DSO_DEFAULT_OFFSET;
|
||||||
|
probe->trig_value = DSO_DEFAULT_TRIG_VAL;
|
||||||
|
sdi->channels = g_slist_append(sdi->channels, probe);
|
||||||
|
}
|
||||||
|
adjust_samplerate(sdi);
|
||||||
|
break;
|
||||||
|
case ANALOG:
|
||||||
|
vdev->samplerate = ANALOG_DEFAULT_SAMPLERATE;
|
||||||
|
vdev->total_samples = ANALOG_DEFAULT_TOTAL_SAMPLES;
|
||||||
|
vdev->num_probes = ANALOG_DEFAULT_NUM_PROBE;
|
||||||
|
vdev->num_blocks = ANALOG_DEFAULT_NUM_BLOCK;
|
||||||
|
sr_dev_probes_free(sdi);
|
||||||
|
|
||||||
|
for (int i = 0; i < ANALOG_DEFAULT_NUM_PROBE; i++)
|
||||||
|
{
|
||||||
|
probe_name = probe_names[i];
|
||||||
|
if (!(probe = sr_channel_new(i, SR_CHANNEL_ANALOG, TRUE, probe_name)))
|
||||||
|
{
|
||||||
|
sr_err("%s: create channel failed", __func__);
|
||||||
|
sr_dev_inst_free(sdi);
|
||||||
|
return SR_ERR;
|
||||||
|
}
|
||||||
|
probe->bits = ANALOG_DEFAULT_BIT;
|
||||||
|
probe->enabled = ANALOG_DEFAULT_ENABLE;
|
||||||
|
probe->coupling = ANALOG_DEFAULT_COUPLING;
|
||||||
|
probe->vdiv = ANALOG_DEFAULT_VIDV;
|
||||||
|
probe->vfactor = ANALOG_DEFAULT_VFACOTR;
|
||||||
|
probe->hw_offset = ANALOG_DEFAULT_HW_OFFSET;
|
||||||
|
probe->offset = ANALOG_DEFAULT_OFFSET;
|
||||||
|
probe->trig_value = ANALOG_DEFAULT_TRIG_VAL;
|
||||||
|
probe->map_default = ANALOG_DEFAULT_MAP_DEFAULT;
|
||||||
|
probe->map_unit = ANALOG_DEFAULT_MAP_UNIT;
|
||||||
|
probe->map_min = ANALOG_DEFAULT_MAP_MIN;
|
||||||
|
probe->map_max = ANALOG_DEFAULT_MAP_MAX;
|
||||||
|
|
||||||
|
sdi->channels = g_slist_append(sdi->channels, probe);
|
||||||
|
}
|
||||||
|
adjust_samplerate(sdi);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
return SR_OK;
|
return SR_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -31,6 +31,26 @@ enum DEMO_PATTERN {
|
|||||||
PATTERN_DEFAULT = 1,
|
PATTERN_DEFAULT = 1,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum DEMO_LOGIC_CHANNEL_ID {
|
||||||
|
DEMO_LOGIC125x16 = 16,
|
||||||
|
DEMO_LOGIC250x12 = 17,
|
||||||
|
DEMO_LOGIC500x6 = 18,
|
||||||
|
DEMO_LOGIC1000x3 = 19,
|
||||||
|
};
|
||||||
|
|
||||||
|
enum DEMO_CHANNEL_ID {
|
||||||
|
DEMO_LOGIC100x16 = 0,
|
||||||
|
DEMO_ANALOG10x2 = 1 ,
|
||||||
|
DEMO_DSO200x2 = 2,
|
||||||
|
};
|
||||||
|
|
||||||
|
enum DEMO_LOGIC_CHANNEL_INDEX {
|
||||||
|
LOGIC125x16 = 0,
|
||||||
|
LOGIC250x12 = 1,
|
||||||
|
LOGIC500x6 = 2,
|
||||||
|
LOGIC1000x3 = 3,
|
||||||
|
};
|
||||||
|
|
||||||
static char *pattern_strings_logic[100] = {"random"};
|
static char *pattern_strings_logic[100] = {"random"};
|
||||||
static char *pattern_strings_dso[100] = {"random"};
|
static char *pattern_strings_dso[100] = {"random"};
|
||||||
static char *pattern_strings_analog[100] = {"random"};
|
static char *pattern_strings_analog[100] = {"random"};
|
||||||
@ -59,6 +79,9 @@ uint8_t sample_generator;
|
|||||||
static int64_t analog_count = 0;
|
static int64_t analog_count = 0;
|
||||||
static uint64_t total_num = 0;
|
static uint64_t total_num = 0;
|
||||||
|
|
||||||
|
static enum DEMO_LOGIC_CHANNEL_ID ch_mode = DEMO_LOGIC125x16;
|
||||||
|
static enum DEMO_LOGIC_CHANNEL_INDEX logic_index = LOGIC125x16;
|
||||||
|
|
||||||
struct session_packet_buffer;
|
struct session_packet_buffer;
|
||||||
|
|
||||||
static const uint64_t vdivs10to2000[] = {
|
static const uint64_t vdivs10to2000[] = {
|
||||||
@ -151,11 +174,7 @@ struct DEMO_profile {
|
|||||||
struct DEMO_caps dev_caps;
|
struct DEMO_caps dev_caps;
|
||||||
};
|
};
|
||||||
|
|
||||||
enum DEMO_CHANNEL_ID {
|
|
||||||
DEMO_LOGIC100x16 = 0,
|
|
||||||
DEMO_ANALOG10x2 = 1 ,
|
|
||||||
DEMO_DSO200x2 = 2,
|
|
||||||
};
|
|
||||||
|
|
||||||
struct DEMO_channels {
|
struct DEMO_channels {
|
||||||
enum DEMO_CHANNEL_ID id;
|
enum DEMO_CHANNEL_ID id;
|
||||||
@ -234,7 +253,8 @@ static const uint64_t samplerates[] = {
|
|||||||
SR_MHZ(40),
|
SR_MHZ(40),
|
||||||
SR_MHZ(50),
|
SR_MHZ(50),
|
||||||
SR_MHZ(100),
|
SR_MHZ(100),
|
||||||
SR_MHZ(200),
|
SR_MHZ(125),
|
||||||
|
SR_MHZ(250),
|
||||||
SR_MHZ(400),
|
SR_MHZ(400),
|
||||||
SR_MHZ(500),
|
SR_MHZ(500),
|
||||||
SR_MHZ(800),
|
SR_MHZ(800),
|
||||||
@ -286,7 +306,7 @@ static const uint64_t samplerates[] = {
|
|||||||
#define ANALOG_MIN_PACKET_NUM(n) ((ANALOG_POST_DATA_PER_SECOND(n))/(ANALOG_MIN_PACKET_LEN))
|
#define ANALOG_MIN_PACKET_NUM(n) ((ANALOG_POST_DATA_PER_SECOND(n))/(ANALOG_MIN_PACKET_LEN))
|
||||||
#define ANALOG_PACKET_ALIGN 2
|
#define ANALOG_PACKET_ALIGN 2
|
||||||
|
|
||||||
#define LOGIC_HW_DEPTH (SR_GHZ(16))
|
#define LOGIC_HW_DEPTH (SR_GHZ(1))
|
||||||
|
|
||||||
|
|
||||||
#define LOGIC_MAX_PROBE_NUM 16
|
#define LOGIC_MAX_PROBE_NUM 16
|
||||||
@ -316,6 +336,40 @@ static const uint64_t samplerates[] = {
|
|||||||
|
|
||||||
#define ANALOG_RETE(n) ((n/SR_HZ(10)))
|
#define ANALOG_RETE(n) ((n/SR_HZ(10)))
|
||||||
|
|
||||||
|
//defult value
|
||||||
|
#define LOGIC_DEFAULT_SAMPLERATE SR_MHZ(1)
|
||||||
|
#define LOGIC_DEFAULT_TOTAL_SAMPLES SR_MHZ(1)
|
||||||
|
#define LOGIC_DEFAULT_NUM_PROBE 16
|
||||||
|
|
||||||
|
#define DSO_DEFAULT_SAMPLERATE SR_MHZ(100)
|
||||||
|
#define DSO_DEFAULT_TOTAL_SAMPLES SR_KHZ(10)
|
||||||
|
#define DSO_DEFAULT_NUM_PROBE 2
|
||||||
|
#define DSO_DEFAULT_NUM_BLOCK 1
|
||||||
|
#define DSO_DEFAULT_ENABLE TRUE
|
||||||
|
#define DSO_DEFAULT_COUPLING 1
|
||||||
|
#define DSO_DEFAULT_VIDV SR_V(1)
|
||||||
|
#define DSO_DEFAULT_VFACOTR SR_V(1)
|
||||||
|
#define DSO_DEFAULT_HW_OFFSET 128
|
||||||
|
#define DSO_DEFAULT_OFFSET 128
|
||||||
|
#define DSO_DEFAULT_TRIG_VAL 0.5
|
||||||
|
|
||||||
|
#define ANALOG_DEFAULT_SAMPLERATE SR_MHZ(1)
|
||||||
|
#define ANALOG_DEFAULT_TOTAL_SAMPLES SR_MHZ(1)
|
||||||
|
#define ANALOG_DEFAULT_NUM_PROBE 2
|
||||||
|
#define ANALOG_DEFAULT_NUM_BLOCK 1
|
||||||
|
#define ANALOG_DEFAULT_BIT 8
|
||||||
|
#define ANALOG_DEFAULT_ENABLE TRUE
|
||||||
|
#define ANALOG_DEFAULT_COUPLING 1
|
||||||
|
#define ANALOG_DEFAULT_VIDV SR_V(1)
|
||||||
|
#define ANALOG_DEFAULT_VFACOTR SR_mV(1)
|
||||||
|
#define ANALOG_DEFAULT_HW_OFFSET 128
|
||||||
|
#define ANALOG_DEFAULT_OFFSET 128
|
||||||
|
#define ANALOG_DEFAULT_TRIG_VAL 128
|
||||||
|
#define ANALOG_DEFAULT_MAP_DEFAULT TRUE
|
||||||
|
#define ANALOG_DEFAULT_MAP_UNIT "V"
|
||||||
|
#define ANALOG_DEFAULT_MAP_MIN (gdouble)-5
|
||||||
|
#define ANALOG_DEFAULT_MAP_MAX (gdouble)+5
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static const char *maxHeights[] = {
|
static const char *maxHeights[] = {
|
||||||
@ -480,6 +534,12 @@ static const int ranx[] = {
|
|||||||
-41, 36, -8, 46, 47, -34, 28, -39, 7, -32, 38, -27, 28, -3, -8, 43, -37, -24, 6, 3,
|
-41, 36, -8, 46, 47, -34, 28, -39, 7, -32, 38, -27, 28, -3, -8, 43, -37, -24, 6, 3,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static int get_logic_probe_type_index_by_probe_type(int probe_type);
|
||||||
|
|
||||||
|
static int logic_adjust_probe(struct sr_dev_inst *sdi, int num_probes);
|
||||||
|
|
||||||
|
static void logic_adjust_samplerate(struct session_vdev * vdev);
|
||||||
|
|
||||||
static void init_analog_random_data(struct session_vdev * vdev);
|
static void init_analog_random_data(struct session_vdev * vdev);
|
||||||
|
|
||||||
static void delay_time();
|
static void delay_time();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user