On Fri, Jul 25, 2014 at 06:25:16PM +0200, Matthieu CASTET wrote:
> Le Thu, 24 Jul 2014 19:23:53 +0200,
> Bert Vermeulen <[email protected]> a écrit :
>
> > On 07/24/2014 12:01 PM, Matthieu CASTET wrote:
> > > Hi,
> > >
> > > I have something that is working for logic signal, but the analog part
> > > is weird.
> >
> > Excellent! Do you have some code we can look at, on github or some place?
> >
> I attached the current version of the code. Code need cleaning.
I see the code needs some cleaning, but still, I have at least one
important comment:
> [...]
> +
> +struct WaveformHeader {
> + int32_t HeaderSize;
> + int32_t WaveformType;
> + int32_t NWaveformBuffers;
> + int32_t Points;
> + int32_t Count;
> + uint32_t /*float*/ XDisplayRange;
> + uint64_t /*double*/ XDisplayOrigin;
> + uint64_t /*double*/ XIncrement;
> + uint64_t /*double*/ XOrigin;
> + int32_t XUnits;
> + int32_t YUnits;
> + uint8_t Date[DATE_TIME_STRING_LENGTH];
> + uint8_t Time[DATE_TIME_STRING_LENGTH];
> + uint8_t Frame[FRAME_STRING_LENGTH];
> + uint8_t WaveformLabel[SIGNAL_STRING_LENGTH];
> + uint32_t /*double*/ TimeTag;
> + uint32_t SegmentIndex;
> +};
> +
> +struct WaveformDataHeader {
> + int32_t HeaderSize;
> + int16_t BufferType;
> + int16_t BytesPerPoint;
> + int32_t BufferSize;
> + uint8_t data[0];
> +};
> +
> [...]
> +
> + /* goto waveform header */
> + data += 12;
> + for (i = 0; i < ctx->num_channels; i++) {
> + struct WaveformHeader *whdr = (struct WaveformHeader *)data;
You can't map raw data from the file to a struct like this for at least
2 reasons:
- the compiler is free to add some alignment padding between the struct
fields which would prevent them to map to the data you expect
- the data stored in the file may not match the endianness of the host
trying to read it
To solve this issue, you should use the RL16() and RL32() macro to read
directly from raw data. (you may need to add a RL64() version of the
macro)
> + struct WaveformDataHeader *wdhdr;
> +[...]
> + wdhdr = (struct WaveformDataHeader *)data;
Same here.
Aurel
------------------------------------------------------------------------------
Want fast and easy access to all the code in your enterprise? Index and
search up to 200,000 lines of code with a free copy of Black Duck
Code Sight - the same software that powers the world's largest code
search on Ohloh, the Black Duck Open Hub! Try it now.
http://p.sf.net/sfu/bds
_______________________________________________
sigrok-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/sigrok-devel