我想使用libusb-1.0庫直接尋址USB設備(收據打印機)。我設法使用另一臺打印機(也用於打印收據,但另一個品牌),但我現在嘗試的一個提出了一個新問題:它有兩個端點,都在IN方向(設備 - >主機),所以我不知道如何將數據發送到打印機!libusb端點方向打印機
這是給我的lsusb -v(抱歉,這是一個有點長):
Bus 003 Device 015: ID 04b3:4535 IBM Corp. 4610 Suremark Printer
Device Descriptor:
bLength 18
bDescriptorType 1
bcdUSB 1.10
bDeviceClass 0 (Defined at Interface level)
bDeviceSubClass 0
bDeviceProtocol 0
bMaxPacketSize0 64
idVendor 0x04b3 IBM Corp.
idProduct 0x4535 4610 Suremark Printer
bcdDevice 2.16
iManufacturer 1 (c) Copyright IBM Corp. 2000
iProduct 2 IBM Retail USB 4610 SureMark Printer
iSerial 3 NO SERIAL NUMBER
bNumConfigurations 1
Configuration Descriptor:
bLength 9
bDescriptorType 2
wTotalLength 59
bNumInterfaces 2
bConfigurationValue 1
iConfiguration 0
bmAttributes 0x40
(Missing must-be-set bit!)
Self Powered
MaxPower 0mA
Interface Descriptor:
bLength 9
bDescriptorType 4
bInterfaceNumber 0
bAlternateSetting 0
bNumEndpoints 1
bInterfaceClass 3 Human Interface Device
bInterfaceSubClass 0 No Subclass
bInterfaceProtocol 0 None
iInterface 4 Firmware Upgrade Interface (Usage = A000h, Usage Page = FF45h)
HID Device Descriptor:
bLength 9
bDescriptorType 33
bcdHID 1.10
bCountryCode 0 Not supported
bNumDescriptors 1
bDescriptorType 34 Report
wDescriptorLength 53
Report Descriptor: (length is 53)
Item(Global): Usage Page, data= [ 0x45 0xff ] 65349
(null)
Item(Local): Usage, data= [ 0x00 0xa0 ] 40960
(null)
Item(Main ): Collection, data= [ 0x01 ] 1
Application
Item(Global): Report Size, data= [ 0x08 ] 8
Item(Global): Report Count, data= [ 0x07 0x01 ] 263
Item(Global): Logical Minimum, data= [ 0x00 ] 0
Item(Global): Logical Maximum, data= [ 0xff 0x00 ] 255
Item(Local): Usage, data= [ 0x01 0xa0 ] 40961
(null)
Item(Main ): Output, data= [ 0x02 ] 2
Data Variable Absolute No_Wrap Linear
Preferred_State No_Null_Position Non_Volatile Bitfield
Item(Global): Report Size, data= [ 0x08 ] 8
Item(Global): Report Count, data= [ 0x08 ] 8
Item(Global): Logical Minimum, data= [ 0x00 ] 0
Item(Global): Logical Maximum, data= [ 0xff 0x00 ] 255
Item(Local): Usage, data= [ 0x02 0xa0 ] 40962
(null)
Item(Main ): Input, data= [ 0x02 ] 2
Data Variable Absolute No_Wrap Linear
Preferred_State No_Null_Position Non_Volatile Bitfield
Item(Local): Usage, data= [ 0x03 0xa0 ] 40963
(null)
Item(Global): Report Size, data= [ 0x08 ] 8
Item(Global): Report Count, data= [ 0x05 0x01 ] 261
Item(Global): Logical Minimum, data= [ 0x00 ] 0
Item(Global): Logical Maximum, data= [ 0xff 0x00 ] 255
Item(Main ): Feature, data= [ 0x02 ] 2
Data Variable Absolute No_Wrap Linear
Preferred_State No_Null_Position Non_Volatile Bitfield
Item(Main ): End Collection, data=none
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x81 EP 1 IN
bmAttributes 3
Transfer Type Interrupt
Synch Type None
Usage Type Data
wMaxPacketSize 0x0008 1x 8 bytes
bInterval 4
Interface Descriptor:
bLength 9
bDescriptorType 4
bInterfaceNumber 1
bAlternateSetting 0
bNumEndpoints 1
bInterfaceClass 3 Human Interface Device
bInterfaceSubClass 0 No Subclass
bInterfaceProtocol 0 None
iInterface 5 Printer Interface (Usage = 3500h, Usage Page = FF45h)
HID Device Descriptor:
bLength 9
bDescriptorType 33
bcdHID 1.00
bCountryCode 0 Not supported
bNumDescriptors 1
bDescriptorType 34 Report
wDescriptorLength 71
Report Descriptor: (length is 71)
Item(Global): Usage Page, data= [ 0x45 0xff ] 65349
(null)
Item(Local): Usage, data= [ 0x00 0x35 ] 13568
(null)
Item(Main ): Collection, data= [ 0x01 ] 1
Application
Item(Global): Report ID, data= [ 0x01 ] 1
Item(Global): Report Size, data= [ 0x08 ] 8
Item(Global): Report Count, data= [ 0xfe 0x03 ] 1022
Item(Global): Logical Minimum, data= [ 0x00 ] 0
Item(Global): Logical Maximum, data= [ 0xff 0x00 ] 255
Item(Local): Usage, data= [ 0x01 0x35 ] 13569
(null)
Item(Main ): Output, data= [ 0x02 ] 2
Data Variable Absolute No_Wrap Linear
Preferred_State No_Null_Position Non_Volatile Bitfield
Item(Global): Report Size, data= [ 0x08 ] 8
Item(Global): Report Count, data= [ 0x0f ] 15
Item(Global): Logical Minimum, data= [ 0x00 ] 0
Item(Global): Logical Maximum, data= [ 0xff 0x00 ] 255
Item(Local): Usage, data= [ 0x02 0x35 ] 13570
(null)
Item(Main ): Input, data= [ 0x02 ] 2
Data Variable Absolute No_Wrap Linear
Preferred_State No_Null_Position Non_Volatile Bitfield
Item(Global): Report Size, data= [ 0x08 ] 8
Item(Global): Report Count, data= [ 0x00 0x01 ] 256
Item(Global): Logical Minimum, data= [ 0x00 ] 0
Item(Global): Logical Maximum, data= [ 0xff 0x00 ] 255
Item(Local): Usage, data= [ 0x03 0x35 ] 13571
(null)
Item(Main ): Feature, data= [ 0x02 ] 2
Data Variable Absolute No_Wrap Linear
Preferred_State No_Null_Position Non_Volatile Bitfield
Item(Global): Report ID, data= [ 0x02 ] 2
Item(Global): Report Size, data= [ 0x08 ] 8
Item(Global): Report Count, data= [ 0xfe ] 254
Item(Global): Logical Minimum, data= [ 0x00 ] 0
Item(Global): Logical Maximum, data= [ 0xff 0x00 ] 255
Item(Local): Usage, data= [ 0x11 0x35 ] 13585
(null)
Item(Main ): Output, data= [ 0x02 ] 2
Data Variable Absolute No_Wrap Linear
Preferred_State No_Null_Position Non_Volatile Bitfield
Item(Main ): End Collection, data=none
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x82 EP 2 IN
bmAttributes 3
Transfer Type Interrupt
Synch Type None
Usage Type Data
wMaxPacketSize 0x0010 1x 16 bytes
bInterval 4
Device Status: 0x0001
Self Powered
如果我正確讀取,我們可以看到有2個接口(21號線),各接口的端點(第33行和第96行),但每個都是類型IN(行84和158),因此在設備到主機的方向操作,所以我真的不知道如何發送任何數據到打印機:-(
您是否嘗試通過控制傳輸在端點0x00發送數據? – dryman
不,我沒有,因爲我不知道應該爲bmRequestType和bRequest參數放置什麼。 我也嘗試使用hidapi庫,但沒有成功... :( – Zorn
爲了搞清楚哪些數據發送你應該使用原始驅動程序使用USB嗅探器 – dryman