@@ -276,7 +276,6 @@ static const uint64_t samplerates[] = {
276276 SR_MHZ (50 ),
277277 SR_MHZ (100 ),
278278 SR_MHZ (200 ),
279- SR_MHZ (400 ),
280279};
281280
282281//static const uint64_t samplecounts[] = {
@@ -321,10 +320,10 @@ static const uint64_t samplecounts[] = {
321320
322321/* We name the probes 0-7 on our demo driver. */
323322static const char * probe_names [NUM_PROBES + 1 ] = {
324- "CH0 " , "CH1 " , "CH2 " , "CH3 " ,
325- "CH4 " , "CH5 " , "CH6 " , "CH7 " ,
326- "CH8 " , "CH9 " , "CH10 " , "CH11 " ,
327- "CH12 " , "CH13 " , "CH14 " , "CH15 " ,
323+ "0 " , "1 " , "2 " , "3 " ,
324+ "4 " , "5 " , "6 " , "7 " ,
325+ "8 " , "9 " , "10 " , "11 " ,
326+ "12 " , "13 " , "14 " , "15 " ,
328327 NULL ,
329328};
330329
@@ -714,8 +713,8 @@ static int config_set(int id, GVariant *data, struct sr_dev_inst *sdi,
714713 devc -> limit_samples_show = devc -> limit_samples ;
715714 } else if (sdi -> mode == ANALOG ) {
716715 num_probes = DS_MAX_ANALOG_PROBES_NUM ;
717- devc -> cur_samplerate = SR_HZ ( 100 );
718- devc -> limit_samples = SR_KB (1 );
716+ devc -> cur_samplerate = SR_KHZ ( 1 );
717+ devc -> limit_samples = SR_KB (2 );
719718 devc -> limit_samples_show = devc -> limit_samples ;
720719 } else {
721720 num_probes = 0 ;
@@ -765,6 +764,9 @@ static int config_set(int id, GVariant *data, struct sr_dev_inst *sdi,
765764 ret = SR_OK ;
766765 } else if (id == SR_CONF_PROBE_EN ) {
767766 ch -> enabled = g_variant_get_boolean (data );
767+ if (en_ch_num (sdi ) != 0 ) {
768+ devc -> limit_samples_show = DEMO_MAX_DSO_DEPTH / en_ch_num (sdi );
769+ }
768770 sr_dbg ("%s: setting ENABLE of channel %d to %d" , __func__ ,
769771 ch -> index , ch -> enabled );
770772 ret = SR_OK ;
@@ -858,8 +860,15 @@ static int config_list(int key, GVariant **data, const struct sr_dev_inst *sdi,
858860 g_variant_builder_init (& gvb , G_VARIANT_TYPE ("a{sv}" ));
859861// gvar = g_variant_new_fixed_array(G_VARIANT_TYPE("t"), samplerates,
860862// ARRAY_SIZE(samplerates), sizeof(uint64_t));
861- gvar = g_variant_new_from_data (G_VARIANT_TYPE ("at" ),
862- samplerates , ARRAY_SIZE (samplerates )* sizeof (uint64_t ), TRUE, NULL , NULL );
863+ if (sdi -> mode == ANALOG )
864+ gvar = g_variant_new_from_data (G_VARIANT_TYPE ("at" ),
865+ samplerates , 16 * sizeof (uint64_t ), TRUE, NULL , NULL );
866+ else if (sdi -> mode == LOGIC )
867+ gvar = g_variant_new_from_data (G_VARIANT_TYPE ("at" ),
868+ samplerates , 19 * sizeof (uint64_t ), TRUE, NULL , NULL );
869+ else
870+ gvar = g_variant_new_from_data (G_VARIANT_TYPE ("at" ),
871+ samplerates , ARRAY_SIZE (samplerates )* sizeof (uint64_t ), TRUE, NULL , NULL );
863872 g_variant_builder_add (& gvb , "{sv}" , "samplerates" , gvar );
864873 * data = g_variant_builder_end (& gvb );
865874 break ;
@@ -1071,7 +1080,7 @@ static int receive_data(int fd, int revents, const struct sr_dev_inst *sdi)
10711080 samples_to_send = MIN (samples_to_send ,
10721081 devc -> limit_samples - devc -> pre_index );
10731082 } else if (sdi -> mode == ANALOG ) {
1074- samples_to_send = ceil (samples_elaspsed / 2 );
1083+ samples_to_send = ceil (samples_elaspsed );
10751084 samples_to_send = MIN (samples_to_send ,
10761085 devc -> limit_samples - devc -> pre_index );
10771086 } else {
@@ -1090,7 +1099,10 @@ static int receive_data(int fd, int revents, const struct sr_dev_inst *sdi)
10901099
10911100 if (samples_to_send > 0 && !devc -> stop ) {
10921101 sending_now = MIN (samples_to_send , (sdi -> mode == DSO ) ? DSO_BUFSIZE : BUFSIZE );
1093- samples_generator (devc -> buf , sending_now , sdi , devc );
1102+ if (sdi -> mode == ANALOG )
1103+ samples_generator (devc -> buf , sending_now * 2 , sdi , devc );
1104+ else
1105+ samples_generator (devc -> buf , sending_now , sdi , devc );
10941106
10951107 if (devc -> trigger_stage != 0 ) {
10961108 for (i = 0 ; i < sending_now ; i ++ ) {
@@ -1123,10 +1135,7 @@ static int receive_data(int fd, int revents, const struct sr_dev_inst *sdi)
11231135 }
11241136 }
11251137
1126- if (sdi -> mode == ANALOG )
1127- devc -> samples_counter += sending_now /2 ;
1128- else
1129- devc -> samples_counter += sending_now ;
1138+ devc -> samples_counter += sending_now ;
11301139 if (sdi -> mode == DSO && !devc -> instant &&
11311140 devc -> samples_counter > devc -> limit_samples )
11321141 devc -> samples_counter = devc -> limit_samples ;
@@ -1157,7 +1166,7 @@ static int receive_data(int fd, int revents, const struct sr_dev_inst *sdi)
11571166 packet .type = SR_DF_ANALOG ;
11581167 packet .payload = & analog ;
11591168 analog .probes = sdi -> channels ;
1160- analog .num_samples = sending_now / 2 ;
1169+ analog .num_samples = sending_now ;
11611170 analog .unit_bits = 8 ;
11621171 analog .mq = SR_MQ_VOLTAGE ;
11631172 analog .unit = SR_UNIT_VOLT ;
@@ -1241,7 +1250,7 @@ static int hw_dev_acquisition_start(struct sr_dev_inst *sdi,
12411250 //std_session_send_df_header(cb_data, LOG_PREFIX);
12421251 std_session_send_df_header (sdi , LOG_PREFIX );
12431252
1244- if (!(devc -> buf = g_try_malloc (((sdi -> mode == DSO ) ? DSO_BUFSIZE : BUFSIZE )* sizeof (uint16_t )))) {
1253+ if (!(devc -> buf = g_try_malloc (((sdi -> mode == DSO ) ? DSO_BUFSIZE : ( sdi -> mode == ANALOG ) ? 2 * BUFSIZE : BUFSIZE )* sizeof (uint16_t )))) {
12451254 sr_err ("buf for receive_data malloc failed." );
12461255 return FALSE;
12471256 }
0 commit comments