J'essaye d'importer la libhid pour causer avec un perif Hid-usb mais je seche.
(http://libhid.alioth.debian.org/doc/)
le bout de code
Code : Tout sélectionner
Enumeration
#HID_RET_SUCCESS =0
#HID_RET_INVALID_PARAMETER =1
#HID_RET_NOT_INITIALISED =2
#HID_RET_ALREADY_INITIALISED=3
#HID_RET_FAIL_FIND_BUSSES =4
#HID_RET_FAIL_FIND_DEVICES =5
#HID_RET_FAIL_OPEN_DEVICE =6
#HID_RET_DEVICE_NOT_FOUND =7
#HID_RET_DEVICE_NOT_OPENED =8
#HID_RET_DEVICE_ALREADY_OPENED =9
#HID_RET_FAIL_CLOSE_DEVICE =10
#HID_RET_FAIL_CLAIM_IFACE =11
#HID_RET_FAIL_DETACH_DRIVER =12
#HID_RET_NOT_HID_DEVICE =13
#HID_RET_HID_DESC_SHORT =14
#HID_RET_REPORT_DESC_SHORT =15
#HID_RET_REPORT_DESC_LONG =16
#HID_RET_FAIL_ALLOC =17
#HID_RET_OUT_OF_SPACE =18
#HID_RET_FAIL_SET_REPORT =19
#HID_RET_FAIL_GET_REPORT =20
#HID_RET_FAIL_INT_READ =21
#HID_RET_NOT_FOUND =22
#HID_RET_TIMEOUT =23
EndEnumeration
Structure THIDInterfaceMatcher
vendor_id.u
product_id.u
EndStructure
Structure THidNode
UPage.i
Usage.i
EndStructure
Structure THidPath
Size.c
Node.THidNode[10]
EndStructure
Structure THidData
Value.l
Path.THIDPath
ReportID.c
Offset.c
Size.c
Type.c
Attribute.c
Unit.l
UnitExp.c
LogMin.l
LogMax.l
PhyMin.l
PhyMax.l
EndStructure
Structure THidParser
ReportDesc.c[6144]
ReportDescSize.i
Pos.i
Item.c
Value.l
Dat.THidData
OffsetTab.c[900]
ReportCount.c
Count.c
UPage.i
UsageTab.THidNode[50]
UsageSize.c
nObject.c
nReport.c
EndStructure
Structure THIDInterface
dev_handle.l
device.l
Iface.i
id.c[32]
hid_data.THidData
hid_parser.THidParser
EndStructure
ImportC "/usr/lib/libhid.so"
hid_init()
hid_cleanup()
hid_new_HIDInterface()
hid_force_open (HIDInterface, iface,HIDInterfaceMatcher,Retries)
hid_open(HIDInterface, iface,HIDInterfaceMatcher)
hid_interrupt_read(HIDinterface,Adr,buf,len,f)
hid_close(HIDInterface)
EndImport
Dim buf.c(15)
Matcher.THIDInterfaceMatcher
Matcher\vendor_id=$20FF
Matcher\product_id=$0100
*Matcher=@Matcher
Debug hid_init(); ok return 0
H=hid_new_HIDInterface(); semble ok retourne un handle
*H.THIDInterface=@H
Debug *H\device
Debug hid_force_open(*H,1,*Matcher,3); retourne 9 ==> #HID_RET_DEVICE_ALREADY_OPENED
Debug hid_interrupt_read(*H,$82,@buf(),15,0);retourne 21 ==> #HID_RET_FAIL_INT_READ
L'install de la lib et le perif sont fonctionnel car tout fonctionne avec un exemple realisé en python via python-hid
J'ai déja un problème pour déclarer un tableau statique à 2 dimensions dans une structure
j'ai essayé OffsetTab.c[300,3] , OffsetTab.c[300][3] mais pb n'en veut pas et je ne trouve rien dans la doc
Ensuite je doit merder sur le typage, bref je galère
Si quelqu'un a une idée il est le bien venu
Merci