diff options
author | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2011-12-16 19:56:47 +0000 |
---|---|---|
committer | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2011-12-16 19:56:47 +0000 |
commit | ca08ac22269b1fe54d9d959d5facf27e6ca322b5 (patch) | |
tree | 5f428a716ad80999faca211045d1ac82facdf007 /apps/examples/adc/adc_main.c | |
parent | b03d1197ae95ef880475e7e4f98e1b8a78340a66 (diff) | |
download | px4-nuttx-ca08ac22269b1fe54d9d959d5facf27e6ca322b5.tar.gz px4-nuttx-ca08ac22269b1fe54d9d959d5facf27e6ca322b5.tar.bz2 px4-nuttx-ca08ac22269b1fe54d9d959d5facf27e6ca322b5.zip |
Fix the data format used in apps/examples/adc
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@4193 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'apps/examples/adc/adc_main.c')
-rw-r--r-- | apps/examples/adc/adc_main.c | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/apps/examples/adc/adc_main.c b/apps/examples/adc/adc_main.c index e85ee7653..176e7a191 100644 --- a/apps/examples/adc/adc_main.c +++ b/apps/examples/adc/adc_main.c @@ -94,9 +94,9 @@ int MAIN_NAME(int argc, char *argv[]) { - uint8_t sample[ADC_SAMPLE_SIZE]; + struct adc_msg_s samples[CONFIG_EXAMPLES_ADC_GROUPSIZE]; + size_t readsize; ssize_t nbytes; - FAR adc_sample_t *ptr; #if defined(CONFIG_NSH_BUILTIN_APPS) || defined(CONFIG_EXAMPLES_ADC_NSAMPLES) long nsamples; #endif @@ -165,9 +165,10 @@ int MAIN_NAME(int argc, char *argv[]) msgflush(); - /* Read one sample of size ADC_SAMPLE_SIZE */ + /* Read CONFIG_EXAMPLES_ADC_GROUPSIZE samples */ - nbytes = read(fd, sample, ADC_SAMPLE_SIZE); + readsize = CONFIG_EXAMPLES_ADC_GROUPSIZE * sizeof(struct adc_msg_s); + nbytes = read(fd, sample, readsize); message("Bytes read: %d\n", nbytes); /* Handle unexpected return values */ @@ -185,10 +186,10 @@ int MAIN_NAME(int argc, char *argv[]) message(MAIN_STRING "Interrupted read...\n"); } - else if (nbytes != ADC_SAMPLE_SIZE) + else if (nbytes != readsize) { message(MAIN_STRING "Unexpected read size=%d, expected=%d, Ignoring\n", - nbytes, ADC_SAMPLE_SIZE); + nbytes, readsize); } /* Print the sample data on successful return */ @@ -196,10 +197,10 @@ int MAIN_NAME(int argc, char *argv[]) else { message("Sample :\n"); - ptr = (FAR adc_sample_t*)sample; for (i = 0; i < CONFIG_EXAMPLES_ADC_GROUPSIZE; i++) { - message("%d: " SAMPLE_FMT "\n", i, ptr[i]); + message("%d: channel: %d value: %d\n", + i, sample[i].am_channel, sample[i].am_data); } } } |