2
0
forked from Ivasoft/DSView

Merge pull request #618 from yunyaobaihong/demo

demo protocol file
This commit is contained in:
dreamsourcelabTAI
2023-05-15 15:31:12 +08:00
committed by GitHub
6 changed files with 33 additions and 26 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -261,9 +261,9 @@ static int scan_dsl_file(struct sr_dev_inst *sdi)
get_pattern_mode_from_file(DSO);
get_pattern_mode_from_file(ANALOG);
if(PATTERN_RANDOM <get_pattern_mode_index_by_string(LOGIC, "demo"))
if(PATTERN_RANDOM <get_pattern_mode_index_by_string(LOGIC, DEFAULT_LOGIC_FILE))
{
int index = get_pattern_mode_index_by_string(LOGIC, "demo");
int index = get_pattern_mode_index_by_string(LOGIC, DEFAULT_LOGIC_FILE);
char * str = pattern_strings_logic[index];
pattern_strings_logic[index] = pattern_strings_logic[PATTERN_DEFAULT];
pattern_strings_logic[PATTERN_DEFAULT] = str;
@@ -1116,6 +1116,7 @@ static int hw_dev_acquisition_start(struct sr_dev_inst *sdi,
vdiv_change = TRUE;
packet_time = DSO_PACKET_TIME;
g_timer_start(run_time);
total_num = 0;
sr_session_source_add(-1, 0, 0, receive_data_dso, sdi);
}
else if(sdi->mode == ANALOG)
@@ -1812,37 +1813,39 @@ static int receive_data_dso(int fd, int revents, const struct sr_dev_inst *sdi)
if(timebase_change || vdiv_change)
{
int index;
int bit = get_bit(vdev->timebase);
int bit = get_bit(vdev->timebase);
void* tmp_buf = g_try_malloc0(bit);
for(int i = 0 ; i < bit ; i++)
if(sample_generator!= PATTERN_RANDOM)
{
if(i%2 == 0)
void* tmp_buf = g_try_malloc0(bit);
for(int i = 0 ; i < bit ; i++)
{
if(bit == 10)
index = i * 16;
if(i%2 == 0)
{
if(bit == 10)
index = i * 16;
else
index = i * 100 / (bit / 2);
}
else
index = i * 100 / (bit / 2);
{
if(bit == 10)
index = (i-1) * 16 + 1;
else
index = (i-1) * 100 / (bit / 2) + 1;
}
*((uint8_t*)tmp_buf+ i) = *((uint8_t*)pack_buffer->post_buf + index + 30);
}
else
for(int i = 0 ; i < DSO_PACKET_LEN/bit ; i++)
{
if(bit == 10)
index = (i-1) * 16 + 1;
else
index = (i-1) * 100 / (bit / 2) + 1;
memcpy(pack_buffer->post_buf+i*bit,tmp_buf,bit);
}
*((uint8_t*)tmp_buf+ i) = *((uint8_t*)pack_buffer->post_buf + index + 30);
}
for(int i = 0 ; i < DSO_PACKET_LEN/bit ; i++)
{
memcpy(pack_buffer->post_buf+i*bit,tmp_buf,bit);
g_free(tmp_buf);
}
g_free(tmp_buf);
for(int i = 0 ; i < pack_buffer->post_buf_len; i++)
{
tem = 0;
@@ -1890,12 +1893,13 @@ static int receive_data_dso(int fd, int revents, const struct sr_dev_inst *sdi)
gdouble total_time = vdev->timebase /(gdouble)SR_SEC(1)*(gdouble)10;
gdouble total_time_elapsed = g_timer_elapsed(run_time, NULL);
if (total_time_elapsed < total_time && !instant)
if (total_time_elapsed < total_time&&!instant)
{
gdouble percent = total_time_elapsed / total_time;
int buf_len = percent* DSO_PACKET_LEN;
if(buf_len %2 != 0)
buf_len -=1;
buf_len +=1;
pack_buffer->post_len = buf_len;
}
else

View File

@@ -56,6 +56,7 @@ static int max_probe_num = 0;
extern char DS_RES_PATH[500];
uint8_t sample_generator;
static int64_t analog_count = 0;
static uint64_t total_num = 0;
struct session_packet_buffer;
@@ -250,6 +251,8 @@ static const uint64_t samplerates[] = {
#define CAPS_FEATURE_ZERO (1 << 4)
/* end */
#define DEFAULT_LOGIC_FILE "protocol"
#define SEC 1
#define LOGIC_POST_DATA_PER_SECOND(n) ((n)/(8))
#define LOGIC_PACKET_NUM_PER_SEC (gdouble)200
@@ -259,7 +262,7 @@ static const uint64_t samplerates[] = {
#define LOGIC_MIN_PACKET_NUM(n) (LOGIC_POST_DATA_PER_SECOND(n))/(LOGIC_MIN_PACKET_LEN)
#define LOGIC_MIN_PACKET_TIME(n) ((SEC)/(gdouble)(LOGIC_MIN_PACKET_NUM(n)))
#define DSO_PACKET_NUM_PER_SEC (gdouble)200
#define DSO_PACKET_NUM_PER_SEC (gdouble)100
#define DSO_PACKET_TIME ((SEC)/(DSO_PACKET_NUM_PER_SEC))
#define DSO_PACKET_LEN 20000