2 messages in net.java.dev.jna.users[jna-users] Unsupported argument type...
FromSent OnAttachments
Dave KennedyNov 14, 2008 5:33 pm.java, .java
Timothy WallNov 14, 2008 9:07 pm 
Actions with this message:
Paste this link in email or IM:
Paste this link in email or IM:
Atom feed for this thread
Paste this URL into your reader:
Subject:[jna-users] Unsupported argument type <enum> at parameter 0 of functionActions...
From:Dave Kennedy (dave@gmail.com)
Date:Nov 14, 2008 5:33:46 pm
List:net.java.dev.jna.users
Attachments:

Hi,

I am trying to use enum's, but both HIDP_REPORT_TYPE and USAGE cause runtime error (compiles OK) "Unsupported argument type". HIDP_REPORT_TYPE is defined in HIDLibrary.java and USAGE is in USAGE.JAVA . HIDLibrary.java and USAGE.JAVA are attached.

Unsupported argument type hid.HIDLibrary$HIDP_REPORT_TYPE at parameter 0 of function HidP_GetUsageValue

result = hidLibrary.HidP_GetUsageValue( HIDLibrary.HIDP_REPORT_TYPE.HidP_Input, USAGE.UPG_MSR, linkCollection, USAGE.UID_TRACK_1_DECODE_STATUS, tk1DcdSts, preparsedData, readBuffer, capabilities.InputReportByteLength);

package hid; ... public interface HIDLibrary extends Library, W32API, UUID { ... int HidP_GetUsageValue( HIDP_REPORT_TYPE ReportType, USAGE UsagePage, char LinkCollection, USAGE Usage, IntByReference UsageValue, Pointer PreparsedData, PointerByReference Report, char ReportLength ); ... }

/* * To change this template, choose Tools | Templates * and open the template in the editor. */

package hid;

import win32.*; import com.sun.jna.Native; import com.sun.jna.Structure; import com.sun.jna.Pointer; import com.sun.jna.ptr.IntByReference; import com.sun.jna.ptr.PointerByReference;

public interface HIDLibrary extends W32API, UUID {

/** * The HIDP_REPORT_TYPE enumeration type is used to specify a HID report
type. */ public enum HIDP_REPORT_TYPE { HidP_Input, HidP_Output, HidP_Feature }

/** * The HIDP_CAPS structure contains information about * a top-level collection's capability. */ public static class _HIDP_CAPS extends Structure { public char Usage; // A usage ID value is an unsigned 16-bit value. public char UsagePage; public char InputReportByteLength; public char OutputReportByteLength; public char FeatureReportByteLength; public char[] Reserved = new char[17]; public char NumberLinkCollectionNodes; public char NumberInputButtonCaps; public char NumberInputValueCaps; public char NumberInputDataIndices; public char NumberOutputButtonCaps; public char NumberOutputValueCaps; public char NumberOutputDataIndices; public char NumberFeatureButtonCaps; public char NumberFeatureValueCaps; public char NumberFeatureDataIndices; }

/** * The HIDP_VALUE_CAPS structure contains information that describes * the capability of a set of HID control values * (either a single usage or a usage range). typedef struct _HIDP_VALUE_CAPS { USAGE UsagePage; UCHAR ReportID; BOOLEAN IsAlias; USHORT BitField; USHORT LinkCollection; USAGE LinkUsage; USAGE LinkUsagePage; BOOLEAN IsRange; BOOLEAN IsStringRange; BOOLEAN IsDesignatorRange; BOOLEAN IsAbsolute; BOOLEAN HasNull; UCHAR Reserved; USHORT BitSize; USHORT ReportCount; USHORT Reserved2[5]; ULONG UnitsExp; ULONG Units; LONG LogicalMin, LogicalMax; LONG PhysicalMin, PhysicalMax; union { struct { USAGE UsageMin, UsageMax; USHORT StringMin, StringMax; USHORT DesignatorMin, DesignatorMax; USHORT DataIndexMin, DataIndexMax; } Range; struct { USAGE Usage, Reserved1; USHORT StringIndex, Reserved2; USHORT DesignatorIndex, Reserved3; USHORT DataIndex, Reserved4; } NotRange; }; } HIDP_VALUE_CAPS, *PHIDP_VALUE_CAPS; */ public static class _HIDP_VALUE_CAPS extends Structure { public Integer usagePage; public Byte reportID; public Integer bitField; public Integer linkCollection; public Integer linkUsage; public Integer linkUsagePage; public Byte isRange; public Byte isStringRange; public Byte isDesignatorRange; public Byte isAbsolute; public Byte hasNull; public Byte reserved1; public Integer bitSize; public Integer reportCount; public Integer[] reserved2 = new Integer[5]; public Long unitsExp; public Long units; public Long logicalMin, logicalMax; public Long physicalMin, physicalMax; public Integer UsageMin, UsageMax; public Integer StringMin, StringMax; public Integer DesignatorMin, DesignatorMax; public Integer DataIndexMin, DataIndexMax; }

public static class BUFFER extends Structure { public byte[] data = new byte[255]; }

/** * The HIDD_ATTRIBUTES structure contains vendor information about a
HIDClass device. * typedef struct _HIDD_ATTRIBUTES { * ULONG Size; Specifies the size, in bytes, of a
HIDD_ATTRIBUTES structure. * USHORT VendorID; Specifies a HID device's vendor ID. * USHORT ProductID; Specifies a HID device's product ID. * USHORT VersionNumber; Specifies the manufacturer's revision number for
a HIDClass device * } HIDD_ATTRIBUTES, *PHIDD_ATTRIBUTES; */ public static class _HIDD_ATTRIBUTES extends Structure { public int size; public char vendorID; //ASCII. Java's 'char' also can be used as an
unsigned short, public char productID; // i.e. it represents numbers from 0 up to 2^16 public char versionNumber; }

HIDLibrary INSTANCE = (HIDLibrary)Native.loadLibrary("hid",
HIDLibrary.class);

// The HidD_GetHidGuid routine // returns the device interface GUID for HIDClass devices. // VOID // HidD_GetHidGuid( // OUT LPGUID HidGuid // ); void HidD_GetHidGuid(_GUID hidGuid);

// The HidD_GetProductString routine returns the embedded string of // a top-level collection that identifies the manufacturer's product. // // BOOLEAN // HidD_GetProductString( // IN HANDLE HidDeviceObject, // OUT PVOID Buffer, // IN ULONG BufferLength // ); boolean HidD_GetProductString( Pointer hidDeviceObject, BUFFER buffer, int bufferLength );

/** * The HidD_GetAttributes routine returns the attributes of * a specified top-level collection * - the HID's Vendor ID, Product ID, and Version Number. * BOOLEAN * HidD_GetAttributes( * IN HANDLE HidDeviceObject, * OUT PHIDD_ATTRIBUTES Attributes * ); */ boolean HidD_GetAttributes( Pointer hidDeviceObject, _HIDD_ATTRIBUTES attributes );

// The routine successfully returned the value data. public static int HIDP_STATUS_SUCCESS = 0x110000;

// Typedef enum defines a set of integer constants for HidP_Report_Type // Remember to declare these as integers (16 bits) public static int HidP_Input = 0; // HID USB swipe reader usages public static int UPG_MSR = 0xFF00; public static int UID_DECODING_RDR = 0x1;

public static int UID_TRACK_1_DATA = 0x30; public static int UID_TRACK_2_DATA = 0x31; public static int UID_TRACK_3_DATA = 0x32;

/** * The HidP_GetSpecificValueCaps routine returns a value capability array * that describes all HID control values that meet a specified selection
criteria. * NTSTATUS * HidP_GetSpecificValueCaps( * IN HIDP_REPORT_TYPE ReportType, * IN USAGE UsagePage, * IN USHORT LinkCollection, * IN USAGE Usage, * OUT PHIDP_VALUE_CAPS ValueCaps, * IN OUT PULONG ValueCapsLength, * IN PHIDP_PREPARSED_DATA PreparsedData * ); */ int HidP_GetSpecificValueCaps ( short reportType, short usagePage, char linkCollection, short usage, _HIDP_VALUE_CAPS valueCaps, int valueCapsLength, Pointer preparsedData );

boolean HidD_FreePreparsedData(Pointer preparsedData);

/** * The HidP_GetUsageValue routine extracts the data associated with a * HID control value that matches the selection criteria in a HID report. */ int HidP_GetUsageValue( HIDP_REPORT_TYPE ReportType, USAGE UsagePage, char LinkCollection, USAGE Usage, IntByReference UsageValue, Pointer PreparsedData, PointerByReference Report, char ReportLength );

/** * The HidP_GetUsageValueArray routine extracts the data associated with a * HID control usage value array from a HID report. */

int HidP_GetUsageValueArray( HIDP_REPORT_TYPE ReportType, USAGE UsagePage, char LinkCollection, // OPTIONAL USAGE Usage, IntByReference UsageValue, char UsageValueByteLength, Pointer PreparsedData, PointerByReference Report, int ReportLength );

/* * HidD_GetPreparsedData * The HidD_GetPreparsedData routine returns a top-level collection's
preparsed data. */ boolean HidD_GetPreparsedData( HANDLE HidDeviceObject, IntByReference PreparsedData );

/* * HidP_GetCaps * The HidP_GetCaps routine returns a top-level collection's HIDP_CAPS
structure. */ int HidP_GetCaps( int PreparsedData, _HIDP_CAPS Capabilities ); }

/* * To change this template), choose Tools | Templates * and open the template in the editor. */

package hid;

/** * HID USB swipe reader usages * @author Dave */ public enum USAGE { UPG_MSR(0xFF00), UID_DECODING_RDR(0x1),

UID_TRACK_1_DECODE_STATUS(0x20), UID_TRACK_2_DECODE_STATUS(0x21), UID_TRACK_3_DECODE_STATUS(0x22), UID_MAGNEPRINT_STATUS(0x23), UID_TRACK_1_LEN(0x28), UID_TRACK_2_LEN(0x29), UID_TRACK_3_LEN(0x2A), UID_MAGNEPRINT_LEN(0x2B), UID_TRACK_1_DATA(0x30), UID_TRACK_2_DATA(0x31), UID_TRACK_3_DATA(0x32), UID_MAGNEPRINT_DATA(0x33), UID_CARD_ENCODE_TYPE(0x38), UID_CARD_STATUS(0x39), UID_DEVICE_SERIAL_NUMBER(0x40), UID_SEQUENCE_COUNTER(0x41), USB_UID_ENCRYPT_STATUS(0x42), USB_UID_DUKPT_KSN(0x46), USB_UID_MTK1_LEN(0x47), USB_UID_MTK2_LEN(0x48), USB_UID_MTK3_LEN(0x49), USB_UID_MTK1_DATA(0x4A), USB_UID_MTK2_DATA(0x4B), USB_UID_MTK3_DATA(0x4C), USB_UID_ESESSID(0x50);

private final int usage;

public int getUsage() { return this.usage; }

// constructor USAGE(int usage) { this.usage = usage; } }