Commit fe930ae2 authored by Federico Vaga's avatar Federico Vaga

Merge branch 'hotfix/tools' into develop

parents b281e255 6ae307aa
......@@ -57,7 +57,8 @@ enum adc_supported_boards {
struct adc_buffer {
void *data; /**< container for all the samples */
void *metadata; /**< description of the acquisition */
int samplesize; /**< size of a single sample in Byte */
int samplesize; /**< size of a single sample in Byte (a sample for
each channel, e.g 4 chan 14bit sample => samplesize = 8 Byte) */
int nsamples; /**< number of samples in the buffer */
struct adc_dev *dev; /**< the device used for the acquisition */
void *mapaddr; /**< mmap address */
......
......@@ -690,9 +690,9 @@ static void fald_acq_print_data(struct adc_buffer *buf,
data = buf->data;
/* Print data */
for (j = 0; j < nsamples / nchan; j++) {
for (j = 0; j < nsamples; j++) {
if ( (n > 0 && j < n) ||
(n < 0 && (nsamples / nchan - j) <= (-n)) ) {
(n < 0 && (nsamples - j) <= (-n)) ) {
printf("%5i ", j - pre);
for (ch = 0; ch < nchan; ch++)
printf("%7i", *(data++));
......@@ -876,14 +876,17 @@ static int fald_acq_parse_args_basic(int argc, char *argv[])
strdevid++; /* +1 to skip '@' */
sscanf(strdevid, "0x%x", &devid);
len = (int)(strdevid - 1 - optarg); /* -1 count '@' it will be replaced by 0 */
/* -1 count '@' it will be replaced by 0
* +1 for \0
*/
len = (int)(strdevid - 1 - optarg + 1);
devname = malloc(len);
if (!devname) {
fprintf(stderr, "Cannot allocate memory\n");
exit(1);
}
memset(devname, 0, len);
strncpy(devname, optarg, len);
strncpy(devname, optarg, len - 1);
fprintf(stdout, "%s: %s -> type:%s, devid:%s\n",
_argv[0], optarg, devname, strdevid);
......@@ -952,7 +955,7 @@ int main(int argc, char *argv[])
* configuration
*/
memset(&cfg_brd, 0, sizeof(struct adc_conf));
cfg_acq.type = ADC_CONF_TYPE_ACQ;
cfg_brd.type = ADC_CONF_TYPE_BRD;
adc_set_conf_mask_all(&cfg_brd, adc);
err = adc_retrieve_config(adc, &cfg_brd);
if (err) {
......@@ -975,9 +978,9 @@ int main(int argc, char *argv[])
adc_get_conf(&cfg_brd, ADC_CONF_BRD_N_CHAN, &nchan);
adc_get_conf(&cfg_acq, ADC_CONF_ACQ_PRE_SAMP, &pre);
adc_get_conf(&cfg_acq, ADC_CONF_ACQ_POST_SAMP, &post);
adc_get_conf(&cfg_acq, ADC_CONF_ACQ_POST_SAMP, &bits);
adc_get_conf(&cfg_acq, ADC_CONF_ACQ_N_BITS, &bits);
adc_get_conf(&cfg_acq, ADC_CONF_ACQ_N_SHOTS, &nshots);
nsamples = (pre + post) * nchan;
nsamples = pre + post;
ssize = (bits + (8 - 1)) / 8; /* get sample size - round up */
buf = adc_request_buffer(adc, nsamples, NULL /* alloc */, 0);
......@@ -1030,9 +1033,11 @@ int main(int argc, char *argv[])
}
}
adc_close(adc);
adc_release_buffer(adc, buf, NULL);
adc_close(adc);
adc_exit();
free(devname);
exit(EXIT_SUCCESS);
err_conf_get:
......@@ -1041,5 +1046,6 @@ err_parse:
err_open:
err_devid_invalid:
adc_exit();
free(devname);
exit(EXIT_FAILURE);
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment