原生结构体如下:
typedef struct iodbpmc {
short type_a ; /* Kind of PMC address /
short type_d ; / Type of the PMC data /
short datano_s ; / Start PMC address number /
short datano_e ; / End PMC address number /
union {
char cdata[N] ;/ The PMC data(byte type) /
short idata[N] ;/ (word type) /
long ldata[N] ;/ (long type) /
} u ; / N is the number of written data */
} IODBPMC ;
java 模拟如下:
public class IODBPMC extends Structure {
public short type_a; // Kind of PMC address
public short type_d; // Type of the PMC data
public short datano_s; // Start PMC address number
public short datano_e; // End PMC address number
public union u ;
public static class ByReference extends IODBPMC implements Structure.ByReference {
}
public static class ByValue extends IODBPMC implements Structure.ByValue {
}
public static class union extends Union {
public byte[] cdata = new byte[5];
public short[] idata = new short[5] ;
public NativeLong[] ldata = new NativeLong[5];
public static class ByReference extends union implements Union.ByReference {
}
public static class ByValue extends union implements Union.ByValue {
}
protected List<String> getFieldOrder() {
return Arrays.asList(new String[] { "cdata", "idata", "ldata" });
}
}
protected List<String> getFieldOrder() {
return Arrays.asList(new String[] { "type_a", "type_d", "datano_s", "datano_e", "u" });
}
}
测试结果智能写入0,使用C#写的小程序就能完成写入