diff --git a/DSView/demo/logic/demo.demo b/DSView/demo/logic/demo.demo deleted file mode 100644 index 2ec55572..00000000 Binary files a/DSView/demo/logic/demo.demo and /dev/null differ diff --git a/DSView/demo/logic/eeprom.demo b/DSView/demo/logic/eeprom.demo deleted file mode 100644 index 5f6aab52..00000000 Binary files a/DSView/demo/logic/eeprom.demo and /dev/null differ diff --git a/DSView/demo/logic/protocol.demo b/DSView/demo/logic/protocol.demo new file mode 100644 index 00000000..6161065b Binary files /dev/null and b/DSView/demo/logic/protocol.demo differ diff --git a/DSView/demo/logic/spi.demo b/DSView/demo/logic/spi.demo deleted file mode 100644 index 2d67addb..00000000 Binary files a/DSView/demo/logic/spi.demo and /dev/null differ diff --git a/libsigrok4DSL/hardware/demo/demo.c b/libsigrok4DSL/hardware/demo/demo.c index 86344612..31e2d041 100644 --- a/libsigrok4DSL/hardware/demo/demo.c +++ b/libsigrok4DSL/hardware/demo/demo.c @@ -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 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; @@ -1888,44 +1891,66 @@ 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(!instant) { - gdouble percent = total_time_elapsed / total_time; - int buf_len = percent* DSO_PACKET_LEN; - if(buf_len %2 != 0) - buf_len -=1; - pack_buffer->post_len = buf_len; - } - else - { - uint8_t top0; - uint8_t top1; - if(sample_generator == PATTERN_RANDOM) + if (total_time_elapsed < total_time) { - top0 = *((uint8_t*)pack_buffer->post_buf + pack_buffer->post_buf_len -2); - top1 = *((uint8_t*)pack_buffer->post_buf + pack_buffer->post_buf_len -1); + gdouble percent = total_time_elapsed / total_time; + int buf_len = percent* DSO_PACKET_LEN; + if(buf_len %2 != 0) + buf_len +=1; + pack_buffer->post_len = buf_len; } else { - top0 = *((uint8_t*)pack_buffer->post_buf + get_bit(vdev->timebase) -2); - top1 = *((uint8_t*)pack_buffer->post_buf + get_bit(vdev->timebase) -1); + uint8_t top0; + uint8_t top1; + if(sample_generator == PATTERN_RANDOM) + { + top0 = *((uint8_t*)pack_buffer->post_buf + pack_buffer->post_buf_len -2); + top1 = *((uint8_t*)pack_buffer->post_buf + pack_buffer->post_buf_len -1); + } + else + { + top0 = *((uint8_t*)pack_buffer->post_buf + get_bit(vdev->timebase) -2); + top1 = *((uint8_t*)pack_buffer->post_buf + get_bit(vdev->timebase) -1); + } + + + for(int i = pack_buffer->post_len -1; i > 1; i -= 2){ + *((uint8_t*)pack_buffer->post_buf + i) = *((uint8_t*)pack_buffer->post_buf + i - 2); + } + + for(int i = pack_buffer->post_len -2; i > 0; i -= 2){ + *((uint8_t*)pack_buffer->post_buf + i) = *((uint8_t*)pack_buffer->post_buf + i - 2); + } + + *(uint8_t*)pack_buffer->post_buf = top0; + *((uint8_t*)pack_buffer->post_buf + 1)= top1; + pack_buffer->post_len = DSO_PACKET_LEN; } - - - for(int i = pack_buffer->post_len -1; i > 1; i -= 2){ - *((uint8_t*)pack_buffer->post_buf + i) = *((uint8_t*)pack_buffer->post_buf + i - 2); - } - - for(int i = pack_buffer->post_len -2; i > 0; i -= 2){ - *((uint8_t*)pack_buffer->post_buf + i) = *((uint8_t*)pack_buffer->post_buf + i - 2); - } - - *(uint8_t*)pack_buffer->post_buf = top0; - *((uint8_t*)pack_buffer->post_buf + 1)= top1; - pack_buffer->post_len = DSO_PACKET_LEN; } + else + { + if(DSO_PACKET_LEN >total_num) + { + uint64_t total_packet_num = total_time*DSO_PACKET_NUM_PER_SEC; + pack_buffer->post_len = DSO_PACKET_LEN/total_packet_num; + total_num += pack_buffer->post_len; + } + else + { + pack_buffer->post_len = DSO_PACKET_LEN; + bToEnd = 1; + instant = FALSE; + } + } + if (pack_buffer->post_len >= byte_align * chan_num) { @@ -1944,11 +1969,11 @@ static int receive_data_dso(int fd, int revents, const struct sr_dev_inst *sdi) ds_data_forward(sdi, &packet); } - if(instant) - { - bToEnd = 1; - instant = FALSE; - } + // if(instant) + // { + // bToEnd = 1; + // instant = FALSE; + // } if (bToEnd || revents == -1) { diff --git a/libsigrok4DSL/hardware/demo/demo.h b/libsigrok4DSL/hardware/demo/demo.h index 8a2b84be..de574896 100644 --- a/libsigrok4DSL/hardware/demo/demo.h +++ b/libsigrok4DSL/hardware/demo/demo.h @@ -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