Happy new year to everyone!

I use the Kingst LA2016 logic analyser and found that it doesn't work in
Windows environment. There is an USB transfer that is built from a
packed struct:

typedef struct sample_config {
    uint32_t sample_depth;
    uint32_t psa;
    uint16_t u1;
    uint32_t u2;
    uint16_t clock_divisor;
} __attribute__((__packed__)) sample_config_t;

The __attribute__((__packed__)) should cause that the offset of u2 is 2
less than the offset of u1, since u1 is a 16-bit value. The Windows
version in my owen build version as well as the nightly build from
https://sigrok.org/wiki/Downloads sends 18 bytes instead of the expected
16 bytes as the Linux version does.

Linux:
40 0D 03 00 00 10 27 00 00 00 66 66 66 00 01 00
Windows:
40 0D 03 00 00 10 27 00 00 00 00 00 66 66 66 00 01 00

The MXE compiler, that is used for compiling the Windows version ignores
silently this attribute. This can be verified by a simple "Hello, World"
style program.

I have implemented a workaround and pushed it to
https://github.com/harper23/libsigrok. I am not satisfied with the
approach, because the struct is first filled, but not used to actually
transfer the data. Instead an additional buffer is used. But the fixed
shows how it could be done as long as the MXE compiler doesn't respects
the __attribute__((__packed__).

I also thought about a conditional compilation but didn't found a macro
to evaluate with the preprocessor. I think it's also not good to add
such conditionals because of a compiler bug.

Best regards,
Helge



_______________________________________________
sigrok-devel mailing list
sigrok-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sigrok-devel

Reply via email to