A new way to get the demo resource directory path

This commit is contained in:
dreamsourcelabTAI 2023-06-01 17:20:49 +08:00
parent e7058fcb1f
commit 56e401e7a9
10 changed files with 209 additions and 258 deletions

View File

@ -73,6 +73,8 @@ bool AppControl::Init()
qs = GetAppDataDir(); qs = GetAppDataDir();
cs = pv::path::ToUnicodePath(qs); cs = pv::path::ToUnicodePath(qs);
dsv_info("GetAppDataDir:\"%s\"", cs.c_str()); dsv_info("GetAppDataDir:\"%s\"", cs.c_str());
cs = pv::path::ToUnicodePath(qs);
ds_set_user_data_dir(cs.c_str());
qs = GetFirmwareDir(); qs = GetFirmwareDir();
cs = pv::path::ToUnicodePath(qs); cs = pv::path::ToUnicodePath(qs);

View File

@ -1270,5 +1270,40 @@ void LogicSnapshot::free_decode_lpb(void *lbp)
} }
} }
void LogicSnapshot::free_head_blocks(int count)
{
for (unsigned int i = 0; i < _channel_num; i++)
{
for (int j=0; j<count; j++)
{
if (_ch_data[i][0].lbp[j] != NULL){
free(_ch_data[i][0].lbp[j]);
_ch_data[i][0].lbp[j] = NULL;
}
}
int rnum = (int)_ch_data[i].size();
uint64_t lst_top = 0;
uint64_t lst_val = 0;
for (int r=0; r<rnum; r++)
{
}
_ch_data[i][0].tog = (_ch_data[i][0].tog) << count;
_ch_data[i][0].value = (_ch_data[i][0].value) << count;
for (int k=count; k < Scale; k++)
{
}
int len = (int)_ch_data[i].size();
}
}
} // namespace data } // namespace data
} // namespace pv } // namespace pv

View File

@ -222,6 +222,8 @@ private:
void move_first_node_to_last(); void move_first_node_to_last();
void free_head_blocks(int count);
private: private:
std::vector<std::vector<struct RootNode>> _ch_data; std::vector<std::vector<struct RootNode>> _ch_data;
uint8_t _byte_fraction; uint8_t _byte_fraction;

View File

@ -353,11 +353,12 @@ static GSList *scan(GSList *options)
else { else {
char *firmware; char *firmware;
char *res_path = DS_RES_PATH; char *res_path = DS_RES_PATH;
if (!(firmware = g_try_malloc(strlen(res_path)+strlen(prof->firmware)+1))) { if (!(firmware = g_try_malloc(strlen(res_path)+strlen(prof->firmware) + 5))) {
sr_err("Firmware path malloc error!"); sr_err("Firmware path malloc error!");
return NULL; return NULL;
} }
strcpy(firmware, res_path); strcpy(firmware, res_path);
strcat(firmware, "/");
strcat(firmware, prof->firmware); strcat(firmware, prof->firmware);
sr_info("Install firmware bin file, device:\"%s\", file:\"%s\"", prof->model, firmware); sr_info("Install firmware bin file, device:\"%s\", file:\"%s\"", prof->model, firmware);

View File

@ -1875,11 +1875,13 @@ SR_PRIV int dsl_dev_open(struct sr_dev_driver *di, struct sr_dev_inst *sdi, gboo
if (!(*fpga_done)) { if (!(*fpga_done)) {
char *fpga_bit; char *fpga_bit;
char *res_path = DS_RES_PATH; char *res_path = DS_RES_PATH;
if (!(fpga_bit = g_try_malloc(strlen(res_path)+strlen(devc->profile->fpga_bit33)+1))) { if (!(fpga_bit = g_try_malloc(strlen(res_path)+strlen(devc->profile->fpga_bit33) + 5))) {
sr_err("fpag_bit path malloc error!"); sr_err("fpag_bit path malloc error!");
return SR_ERR_MALLOC; return SR_ERR_MALLOC;
} }
strcpy(fpga_bit, res_path); strcpy(fpga_bit, res_path);
strcat(fpga_bit, "/");
switch(devc->th_level) { switch(devc->th_level) {
case SR_TH_3V3: case SR_TH_3V3:
strcat(fpga_bit, devc->profile->fpga_bit33); strcat(fpga_bit, devc->profile->fpga_bit33);

View File

@ -439,11 +439,12 @@ static GSList *scan(GSList *options)
else { else {
char *firmware; char *firmware;
char *res_path = DS_RES_PATH; char *res_path = DS_RES_PATH;
if (!(firmware = g_try_malloc(strlen(res_path)+strlen(prof->firmware)+1))) { if (!(firmware = g_try_malloc(strlen(res_path)+strlen(prof->firmware) + 5))) {
sr_err("Firmware path malloc error!"); sr_err("Firmware path malloc error!");
return NULL; return NULL;
} }
strcpy(firmware, res_path); strcpy(firmware, res_path);
strcat(firmware, "/");
strcat(firmware, prof->firmware); strcat(firmware, prof->firmware);
sr_info("Install firmware bin file, device:\"%s\", file:\"%s\"", prof->model, firmware); sr_info("Install firmware bin file, device:\"%s\", file:\"%s\"", prof->model, firmware);
@ -1066,11 +1067,12 @@ static int config_set(int id, GVariant *data, struct sr_dev_inst *sdi,
char *fpga_bit; char *fpga_bit;
char *res_path = DS_RES_PATH; char *res_path = DS_RES_PATH;
if (!(fpga_bit = g_try_malloc(strlen(res_path) + strlen(devc->profile->fpga_bit33) + 1))) { if (!(fpga_bit = g_try_malloc(strlen(res_path) + strlen(devc->profile->fpga_bit33) + 5))) {
sr_err("fpag_bit path malloc error!"); sr_err("fpag_bit path malloc error!");
return SR_ERR_MALLOC; return SR_ERR_MALLOC;
} }
strcpy(fpga_bit, res_path); strcpy(fpga_bit, res_path);
strcat(fpga_bit, "/");
switch(devc->th_level) switch(devc->th_level)
{ {

View File

@ -39,6 +39,8 @@
#include "../../log.h" #include "../../log.h"
extern char DS_USR_PATH[500];
/* Message logging helpers with subsystem-specific prefix string. */ /* Message logging helpers with subsystem-specific prefix string. */
#undef LOG_PREFIX #undef LOG_PREFIX
@ -49,6 +51,19 @@
#define BUFSIZE 512*1024 #define BUFSIZE 512*1024
#define DSO_BUFSIZE 10*1024 #define DSO_BUFSIZE 10*1024
#define PATTERN_COUNT 20
#define RANDOM_NAME "random"
struct demo_mode_pattern
{
char *patterns[PATTERN_COUNT+1];
int count;
};
static struct demo_mode_pattern demo_pattern_array[3];
static int b_load_directory = 0;
static char* demo_mode_names[3] = {"logic", "dso", "analog"};
static struct DEMO_channels logic_channel_modes[] = { static struct DEMO_channels logic_channel_modes[] = {
{DEMO_LOGIC125x16, LOGIC, SR_CHANNEL_LOGIC, 16, 1, SR_MHZ(1), SR_Mn(1), {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)"}, SR_KHZ(10), SR_MHZ(125), "Use 16 Channels (Max 125MHz)"},
@ -86,6 +101,10 @@ static struct sr_dev_driver *di = &demo_driver_info;
extern struct ds_trigger *trigger; extern struct ds_trigger *trigger;
static int get_pattern_mode_from_file(const char *sub_dir, struct demo_mode_pattern* info, int max_count);
static int get_pattern_mode_index_by_string(uint8_t device_mode, const char* pattern);
static const char* get_pattern_name(uint8_t device_mode, int index);
static int vdev_init(struct sr_dev_inst *sdi) static int vdev_init(struct sr_dev_inst *sdi)
{ {
struct session_vdev* vdev = sdi->priv; struct session_vdev* vdev = sdi->priv;
@ -337,151 +356,91 @@ static void get_last_packet_len(struct sr_datafeed_logic *logic,struct session_v
vdev->post_data_len = vdev->total_samples/8; vdev->post_data_len = vdev->total_samples/8;
} }
static void init_pattern_mode_list() static int get_pattern_mode_index_by_string(uint8_t device_mode, const char* pattern)
{ {
int i; int dex = 0;
if(pattern_logic_count != 1)
struct demo_mode_pattern* info = &demo_pattern_array[device_mode];
while (dex < info->count)
{ {
for(i = 1 ;i < pattern_logic_count ; i++) if (strcmp(info->patterns[dex], pattern) == 0)
{ return dex;
if(pattern_strings_logic[i] != NULL) dex++;
{
g_safe_free(pattern_strings_logic[i]);
}
}
}
if(pattern_dso_count != 1)
{
for(i = 1 ;i < pattern_dso_count ; i++)
{
if(pattern_strings_dso[i] != NULL)
{
g_safe_free(pattern_strings_dso[i]);
}
}
}
if(pattern_analog_count != 1)
{
for(i = 1 ;i < pattern_analog_count ; i++)
{
if(pattern_strings_analog[i] != NULL)
{
g_safe_free(pattern_strings_analog[i]);
}
}
} }
return -1;
} }
static int get_pattern_mode_index_by_string(uint8_t device_mode , const char* str) static const char* get_pattern_name(uint8_t device_mode, int index)
{ {
int index = PATTERN_INVALID, struct demo_mode_pattern* info = &demo_pattern_array[device_mode];
i = PATTERN_RANDOM; if (index >= 0 && index < info->count){
if (device_mode == LOGIC) return info->patterns[index];
{ }
while (pattern_strings_logic[i] != NULL)
{
if(!strcmp(str,pattern_strings_logic[i]))
{
index = i;
break;
}
else
i++;
}
}
else if (device_mode == DSO)
{
while (pattern_strings_dso[i] != NULL)
{
if(!strcmp(str,pattern_strings_dso[i]))
{
index = i;
break;
}
else
i++;
}
}
else
{
while (pattern_strings_analog[i] != NULL)
{
if(!strcmp(str,pattern_strings_analog[i]))
{
index = i;
break;
}
else
i++;
}
}
if(index == PATTERN_INVALID) assert(0);
index = PATTERN_RANDOM; return NULL;
return index;
} }
static int get_pattern_mode_from_file(uint8_t device_mode) static int get_pattern_mode_from_file(const char *sub_dir, struct demo_mode_pattern* info, int max_count)
{ {
const gchar * filename = NULL; const gchar * filename = NULL;
char dir_str[500]; char dir_path_buf[500];
int index = 1; int index = 1;
int str_len; int str_len;
char *dir_path = dir_path_buf;
char *file_path = NULL;
char short_name[50];
int i;
int num;
strcpy(dir_str,DS_RES_PATH); assert(sub_dir);
memset(dir_str+strlen(dir_str)-strlen("res/"),0,strlen("res/")); assert(info);
strcat(dir_str,"demo/");
if(device_mode == LOGIC) for (i=0; i<max_count; i++){
strcat(dir_str,"logic/"); info->patterns[i] = NULL;
else if(device_mode == DSO) }
strcat(dir_str,"dso/"); info->patterns[max_count] = NULL;
else if(device_mode == ANALOG)
strcat(dir_str,"analog/"); info->patterns[0] = RANDOM_NAME;
num = 1;
info->count = num;
strcpy(dir_path, DS_USR_PATH);
strcat(dir_path,"/demo/");
strcat(dir_path, sub_dir);
GDir *dir = NULL; GDir *dir = NULL;
dir = g_dir_open(dir_str,0,NULL); dir = g_dir_open(dir_path,0,NULL);
if(dir == NULL) if(dir == NULL)
{ {
sr_err("Faild to open dir:%s", dir_path);
return SR_ERR; return SR_ERR;
} }
while ((filename = g_dir_read_name(dir)) != NULL) while ((filename = g_dir_read_name(dir)) != NULL)
{ {
if (FALSE == g_file_test(filename,G_FILE_TEST_IS_DIR)) if (FALSE == g_file_test(filename,G_FILE_TEST_IS_DIR))
{ {
if(strstr(filename,".demo") != NULL) file_path = filename;
{
str_len = strlen(filename)-strlen(".demo");
char *file_name = g_try_malloc0(str_len+1);
if (file_name == NULL)
{
sr_err("%s: file_name malloc failed", __func__);
return SR_ERR_MALLOC;
}
strncpy(file_name,filename,str_len);
file_name[str_len] = 0;
if(device_mode == LOGIC) if(strstr(file_path,".demo") != NULL)
pattern_strings_logic[index] = file_name; {
else if(device_mode == DSO) str_len = strlen(file_path) - 5;
pattern_strings_dso[index] = file_name; strncpy(short_name,file_path, sizeof(short_name)-1);
else if(device_mode == ANALOG) short_name[str_len] = 0;
pattern_strings_analog[index] = file_name; info->patterns[num++] = g_strdup(short_name);
if(index < 99)
index++; if (num >= max_count)
break;
} }
} }
} }
g_dir_close(dir); g_dir_close(dir);
if(device_mode == LOGIC) info->count = num;
pattern_logic_count = index;
else if(device_mode == DSO)
pattern_dso_count = index;
else if(device_mode == ANALOG)
pattern_analog_count = index;
return SR_OK; return SR_OK;
} }
@ -489,92 +448,53 @@ static int get_pattern_mode_from_file(uint8_t device_mode)
static void scan_dsl_file(struct sr_dev_inst *sdi) static void scan_dsl_file(struct sr_dev_inst *sdi)
{ {
struct session_vdev * vdev = sdi->priv; struct session_vdev * vdev = sdi->priv;
int dex;
init_pattern_mode_list();
get_pattern_mode_from_file(LOGIC); if (b_load_directory == 0){
get_pattern_mode_from_file(DSO); get_pattern_mode_from_file(demo_mode_names[LOGIC], &demo_pattern_array[LOGIC], PATTERN_COUNT);
get_pattern_mode_from_file(ANALOG); get_pattern_mode_from_file(demo_mode_names[DSO], &demo_pattern_array[DSO], PATTERN_COUNT);
get_pattern_mode_from_file(demo_mode_names[ANALOG], &demo_pattern_array[ANALOG], PATTERN_COUNT);
b_load_directory = 1;
}
if(PATTERN_RANDOM <get_pattern_mode_index_by_string(LOGIC, DEFAULT_LOGIC_FILE)) dex = get_pattern_mode_index_by_string(LOGIC, DEFAULT_LOGIC_FILE);
{
int index = get_pattern_mode_index_by_string(LOGIC, DEFAULT_LOGIC_FILE); if(dex == -1)
char * str = pattern_strings_logic[index]; dex = PATTERN_RANDOM;
pattern_strings_logic[index] = pattern_strings_logic[PATTERN_DEFAULT];
pattern_strings_logic[PATTERN_DEFAULT] = str; vdev->sample_generator = dex;
vdev->sample_generator = PATTERN_DEFAULT; sdi->mode = LOGIC;
sdi->mode = LOGIC; reset_dsl_path(sdi, dex);
reset_dsl_path(sdi,LOGIC,PATTERN_DEFAULT);
}
else
{
vdev->sample_generator = PATTERN_RANDOM;
sdi->mode = LOGIC;
reset_dsl_path(sdi,LOGIC,PATTERN_RANDOM);
}
} }
static int reset_dsl_path(struct sr_dev_inst *sdi,uint8_t device_mode ,uint8_t pattern_mode) static int reset_dsl_path(struct sr_dev_inst *sdi, uint8_t pattern_mode)
{ {
unzFile archive = NULL; struct demo_mode_pattern *info = NULL;
if(sdi->path != NULL) if(sdi->path != NULL)
g_safe_free(sdi->path); g_safe_free(sdi->path);
char *str = g_try_malloc0(500); char file_path[500];
strcpy(str,DS_RES_PATH);
memset(str+strlen(str)-strlen("res/"),0,strlen("res/")); strcpy(file_path, DS_USR_PATH);
strcat(str,"demo/"); strcat(file_path,"/demo/");
if (pattern_mode != PATTERN_RANDOM) if (pattern_mode != PATTERN_RANDOM)
{ {
switch (device_mode) info = &demo_pattern_array[sdi->mode];
{ assert(pattern_mode < info->count);
case LOGIC:
if(NULL != pattern_strings_logic[pattern_mode])
{
strcat(str,"logic/");
strcat(str,pattern_strings_logic[pattern_mode]);
}
break;
case DSO:
if(NULL != pattern_strings_dso[pattern_mode])
{
strcat(str,"dso/");
strcat(str,pattern_strings_dso[pattern_mode]);
}
break;
case ANALOG:
if(NULL != pattern_strings_analog[pattern_mode])
{
strcat(str,"analog/");
strcat(str,pattern_strings_analog[pattern_mode]);
}
break;
default:
break;
}
strcat(str,".demo");
}
if(pattern_mode != PATTERN_RANDOM) strcat(file_path, demo_mode_names[sdi->mode]);
{ strcat(file_path, "/");
archive = unzOpen64(str); strcat(file_path, info->patterns[pattern_mode]);
if (NULL != archive){ strcat(file_path,".demo");
sdi->path = str;
return SR_OK;
}
else{
g_safe_free(str);
sdi->path = g_strdup("");
return SR_ERR;
}
sdi->path = g_strdup(file_path);
} }
else{ else{
g_safe_free(str);
sdi->path = g_strdup(""); sdi->path = g_strdup("");
return SR_OK;
} }
return SR_OK;
} }
static void adjust_samplerate(struct sr_dev_inst *sdi) static void adjust_samplerate(struct sr_dev_inst *sdi)
@ -664,6 +584,11 @@ static int hw_init(struct sr_context *sr_ctx)
return std_hw_init(sr_ctx, di, LOG_PREFIX); return std_hw_init(sr_ctx, di, LOG_PREFIX);
} }
static int clean_up()
{
return SR_OK;
}
static GSList *hw_scan(GSList *options) static GSList *hw_scan(GSList *options)
{ {
struct sr_dev_inst *sdi; struct sr_dev_inst *sdi;
@ -801,6 +726,8 @@ static int config_get(int id, GVariant **data, const struct sr_dev_inst *sdi,
{ {
(void)cg; (void)cg;
char *patter_name = NULL;
assert(sdi); assert(sdi);
assert(sdi->priv); assert(sdi->priv);
@ -821,12 +748,8 @@ static int config_get(int id, GVariant **data, const struct sr_dev_inst *sdi,
*data = g_variant_new_boolean(vdev->instant); *data = g_variant_new_boolean(vdev->instant);
break; break;
case SR_CONF_PATTERN_MODE: case SR_CONF_PATTERN_MODE:
if(sdi->mode == LOGIC) patter_name = get_pattern_name(sdi->mode, vdev->sample_generator);
*data = g_variant_new_string(pattern_strings_logic[vdev->sample_generator]); *data = g_variant_new_string(patter_name);
else if(sdi->mode == DSO)
*data = g_variant_new_string(pattern_strings_dso[vdev->sample_generator]);
else
*data = g_variant_new_string(pattern_strings_analog[vdev->sample_generator]);
break; break;
case SR_CONF_MAX_HEIGHT: case SR_CONF_MAX_HEIGHT:
*data = g_variant_new_string(maxHeights[vdev->max_height]); *data = g_variant_new_string(maxHeights[vdev->max_height]);
@ -954,6 +877,7 @@ static int config_set(int id, GVariant *data, struct sr_dev_inst *sdi,
const char *stropt; const char *stropt;
unsigned int i; unsigned int i;
int nv; int nv;
uint8_t tmp_sample_generator;
assert(sdi); assert(sdi);
assert(sdi->priv); assert(sdi->priv);
@ -977,36 +901,36 @@ static int config_set(int id, GVariant *data, struct sr_dev_inst *sdi,
switch (sdi->mode) switch (sdi->mode)
{ {
case LOGIC: case LOGIC:
if(SR_OK == reset_dsl_path(sdi,sdi->mode ,PATTERN_DEFAULT)) nv = get_pattern_mode_index_by_string(LOGIC, DEFAULT_LOGIC_FILE);
{ if (nv != -1)
vdev->sample_generator = PATTERN_DEFAULT; vdev->sample_generator = nv;
}
else else
{
vdev->sample_generator = PATTERN_RANDOM; vdev->sample_generator = PATTERN_RANDOM;
}
reset_dsl_path(sdi,vdev->sample_generator);
break; break;
case DSO: case DSO:
reset_dsl_path(sdi,sdi->mode ,PATTERN_RANDOM); reset_dsl_path(sdi, PATTERN_RANDOM);
vdev->sample_generator = PATTERN_RANDOM; vdev->sample_generator = PATTERN_RANDOM;
break; break;
case ANALOG: case ANALOG:
reset_dsl_path(sdi,sdi->mode ,PATTERN_RANDOM); reset_dsl_path(sdi, PATTERN_RANDOM);
vdev->sample_generator = PATTERN_RANDOM; vdev->sample_generator = PATTERN_RANDOM;
break; break;
default:
break;
} }
load_virtual_device_session(sdi); load_virtual_device_session(sdi);
break; break;
case SR_CONF_PATTERN_MODE: case SR_CONF_PATTERN_MODE:
stropt = g_variant_get_string(data, NULL); stropt = g_variant_get_string(data, NULL);
uint8_t tmp_sample_generator = vdev->sample_generator; tmp_sample_generator = vdev->sample_generator;
vdev->sample_generator = get_pattern_mode_index_by_string(sdi->mode , stropt); nv = get_pattern_mode_index_by_string(sdi->mode , stropt);
if(SR_OK != reset_dsl_path(sdi,sdi->mode,vdev->sample_generator))
{ if(nv == -1)
vdev->sample_generator = PATTERN_RANDOM; vdev->sample_generator = PATTERN_RANDOM;
} else
vdev->sample_generator = nv;
reset_dsl_path(sdi, vdev->sample_generator);
if(sdi->mode == LOGIC) if(sdi->mode == LOGIC)
{ {
if(vdev->sample_generator == PATTERN_RANDOM) if(vdev->sample_generator == PATTERN_RANDOM)
@ -1021,9 +945,9 @@ static int config_set(int id, GVariant *data, struct sr_dev_inst *sdi,
} }
else{ else{
load_virtual_device_session(sdi); load_virtual_device_session(sdi);
} }
} }
sr_dbg("%s: setting pattern to %d", sr_dbg("%s: setting pattern to %d",
__func__, vdev->sample_generator); __func__, vdev->sample_generator);
break; break;
@ -1148,9 +1072,6 @@ static int config_set(int id, GVariant *data, struct sr_dev_inst *sdi,
case SR_CONF_INSTANT: case SR_CONF_INSTANT:
vdev->instant = g_variant_get_boolean(data); vdev->instant = g_variant_get_boolean(data);
break; break;
case SR_CONF_DEMO_INIT:
load_virtual_device_session(sdi);
break;
case SR_CONF_LOOP_MODE: case SR_CONF_LOOP_MODE:
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);
@ -1189,6 +1110,7 @@ static int config_list(int key, GVariant **data, const struct sr_dev_inst *sdi,
GVariant *gvar; GVariant *gvar;
GVariantBuilder gvb; GVariantBuilder gvb;
struct demo_mode_pattern *info = NULL;
(void)sdi; (void)sdi;
struct session_vdev *vdev = sdi->priv; struct session_vdev *vdev = sdi->priv;
@ -1219,18 +1141,8 @@ static int config_list(int key, GVariant **data, const struct sr_dev_inst *sdi,
*data = g_variant_builder_end(&gvb); *data = g_variant_builder_end(&gvb);
break; break;
case SR_CONF_PATTERN_MODE: case SR_CONF_PATTERN_MODE:
if(sdi->mode == LOGIC) info = &demo_pattern_array[sdi->mode];
{ *data = g_variant_new_strv(info->patterns, info->count);
*data = g_variant_new_strv(pattern_strings_logic, pattern_logic_count);
}
else if (sdi->mode == DSO)
{
*data = g_variant_new_strv(pattern_strings_dso, pattern_dso_count);
}
else
{
*data = g_variant_new_strv(pattern_strings_analog, pattern_analog_count);
}
break; break;
case SR_CONF_MAX_HEIGHT: case SR_CONF_MAX_HEIGHT:
*data = g_variant_new_strv(maxHeights, ARRAY_SIZE(maxHeights)); *data = g_variant_new_strv(maxHeights, ARRAY_SIZE(maxHeights));
@ -2826,7 +2738,7 @@ SR_PRIV struct sr_dev_driver demo_driver_info = {
.api_version = 1, .api_version = 1,
.driver_type = DRIVER_TYPE_DEMO, .driver_type = DRIVER_TYPE_DEMO,
.init = hw_init, .init = hw_init,
.cleanup = NULL, .cleanup = clean_up,
.scan = hw_scan, .scan = hw_scan,
.dev_mode_list = hw_dev_mode_list, .dev_mode_list = hw_dev_mode_list,
.config_get = config_get, .config_get = config_get,

View File

@ -125,8 +125,7 @@
#define ANALOG_DEFAULT_MAP_MAX (gdouble)+5 #define ANALOG_DEFAULT_MAP_MAX (gdouble)+5
enum DEMO_PATTERN { enum DEMO_PATTERN {
PATTERN_INVALID = -1,
PATTERN_RANDOM = 0, PATTERN_RANDOM = 0,
PATTERN_DEFAULT = 1, PATTERN_DEFAULT = 1,
}; };
@ -151,13 +150,6 @@ enum DEMO_LOGIC_CHANNEL_INDEX {
LOGIC1000x3 = 3, LOGIC1000x3 = 3,
}; };
static char *pattern_strings_logic[100] = {"random"};
static char *pattern_strings_dso[100] = {"random"};
static char *pattern_strings_analog[100] = {"random"};
static int pattern_logic_count = 1;
static int pattern_dso_count= 1;
static int pattern_analog_count= 1;
static uint64_t samplerates_file[1]; static uint64_t samplerates_file[1];
static uint64_t samplecounts_file[1]; static uint64_t samplecounts_file[1];
@ -165,7 +157,7 @@ static GTimer *packet_interval = NULL;
static GTimer *run_time = NULL; static GTimer *run_time = NULL;
static int max_probe_num = 0; static int max_probe_num = 0;
extern char DS_RES_PATH[500];
static int64_t analog_count = 0; static int64_t analog_count = 0;
static gboolean channel_mode_change = FALSE; static gboolean channel_mode_change = FALSE;
static uint64_t packet_num; static uint64_t packet_num;
@ -465,17 +457,12 @@ static int delay_time(struct session_vdev *vdev);
static void get_last_packet_len(struct sr_datafeed_logic *logic,struct session_vdev * vdev); static void get_last_packet_len(struct sr_datafeed_logic *logic,struct session_vdev * vdev);
static void init_pattern_mode_list();
static int get_bit(uint64_t timebase); static int get_bit(uint64_t timebase);
static int get_pattern_mode_index_by_string(uint8_t device_mode , const char* str);
static int get_pattern_mode_from_file(uint8_t device_mode);
static void scan_dsl_file(struct sr_dev_inst *sdi); static void scan_dsl_file(struct sr_dev_inst *sdi);
static int reset_dsl_path(struct sr_dev_inst *sdi,uint8_t device_mode ,uint8_t pattern_mode); static int reset_dsl_path(struct sr_dev_inst *sdi, uint8_t pattern_mode);
static void adjust_samplerate(struct sr_dev_inst *sdi); static void adjust_samplerate(struct sr_dev_inst *sdi);

View File

@ -42,7 +42,10 @@
#undef LOG_PREFIX #undef LOG_PREFIX
#define LOG_PREFIX "lib_main: " #define LOG_PREFIX "lib_main: "
char DS_RES_PATH[500] = {0}; // Have been encoding.
char DS_RES_PATH[500];
char DS_USR_PATH[500];
struct sr_lib_context struct sr_lib_context
{ {
@ -242,20 +245,20 @@ SR_API int ds_lib_exit()
* Set the firmware binary file directory * Set the firmware binary file directory
*/ */
SR_API void ds_set_firmware_resource_dir(const char *dir) SR_API void ds_set_firmware_resource_dir(const char *dir)
{ {
memset(DS_RES_PATH, 0, sizeof(DS_RES_PATH));
if (dir) if (dir)
{
strcpy(DS_RES_PATH, dir); strcpy(DS_RES_PATH, dir);
}
int len = strlen(DS_RES_PATH); /**
if (DS_RES_PATH[len - 1] != '/') * Set user data directory.
{ */
DS_RES_PATH[len] = '/'; SR_API void ds_set_user_data_dir(const char *dir)
DS_RES_PATH[len + 1] = 0; {
} memset(DS_USR_PATH, 0, sizeof(DS_USR_PATH));
if (dir)
sr_info("Firmware resource directory:\"%s\"", DS_RES_PATH); strcpy(DS_USR_PATH, dir);
}
} }
/** /**

View File

@ -1390,6 +1390,11 @@ SR_API void ds_set_datafeed_callback(ds_datafeed_callback_t cb);
*/ */
SR_API void ds_set_firmware_resource_dir(const char *dir); SR_API void ds_set_firmware_resource_dir(const char *dir);
/**
* Set user data directory.
*/
SR_API void ds_set_user_data_dir(const char *dir);
/** /**
* Get the device list, if the field _handle is 0, the list visited to end. * Get the device list, if the field _handle is 0, the list visited to end.
* User need call free() to release the buffer. If the list is empty, the out_list is null. * User need call free() to release the buffer. If the list is empty, the out_list is null.