Communication with CDC ACM device on Linux via USB - c

I've got some serial device connected via CDC-ACM USB device so it is possible to communicate with it via /dev/ttyACM1 from Linux perspective.
The end device is the device which contains RTC which allows me to get the current date and time from it via CDC-ACM. It is working fine form user space.
Below is the device descriptor of my CDC-ACM USB device:
Device Descriptor:
bLength 18
bDescriptorType 1
bcdUSB 2.00
bDeviceClass 2
bDeviceSubClass 0
bDeviceProtocol 0
bMaxPacketSize0 64
idVendor 0xyyyy
idProduct 0xzzzz
bcdDevice 2.00
iManufacturer 1 xxxxxxxxxxxxxx
iProduct 2 yyyyyyyyyyyyyy
iSerial 3 zzzzzzzzzzzzzz
bNumConfigurations 1
Configuration Descriptor:
bLength 9
bDescriptorType 2
wTotalLength 67
bNumInterfaces 2
bConfigurationValue 1
iConfiguration 0
bmAttributes 0xc0
Self Powered
MaxPower 100mA
Interface Descriptor:
bLength 9
bDescriptorType 4
bInterfaceNumber 0
bAlternateSetting 0
bNumEndpoints 1
bInterfaceClass 2
bInterfaceSubClass 2
bInterfaceProtocol 1
iInterface 0
CDC Header:
bcdCDC 1.10
CDC Call Management:
bmCapabilities 0x00
bDataInterface 1
CDC ACM:
bmCapabilities 0x02
line coding and serial state
CDC Union:
bMasterInterface 0
bSlaveInterface 1
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x82 EP 2 IN
bmAttributes 3
Transfer Type Interrupt
Synch Type None
Usage Type Data
wMaxPacketSize 0x0008 1x 8 bytes
bInterval 255
Interface Descriptor:
bLength 9
bDescriptorType 4
bInterfaceNumber 1
bAlternateSetting 0
bNumEndpoints 2
bInterfaceClass 10
bInterfaceSubClass 0
bInterfaceProtocol 0
iInterface 0
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x01 EP 1 OUT
bmAttributes 2
Transfer Type Bulk
Synch Type None
Usage Type Data
wMaxPacketSize 0x0040 1x 64 bytes
bInterval 0
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x81 EP 1 IN
bmAttributes 2
Transfer Type Bulk
Synch Type None
Usage Type Data
wMaxPacketSize 0x0040 1x 64 bytes
bInterval 0
Device Status: 0x0001
Self Powered
Now - I'd like to set date and time via this CDC-ACM connection using kernel API via USB. I thought that it is enough to send the same request string for date and time via bulk-out ep1 and receive the response via bulk-in ep81. I tried to do it with usb_bulk_msg() and when I'm sending request string with this proc - it returns 0. Next, when I'm sending request for reading response from this device I get -110 (-ETIMEDOUT).
Seems like the linux kernel is sending my first request properly because it returns 0, but for some reasons this request is not received by the end device because it doesn't responded with anything because timeout (-110) occured.
I'm wondering if I didn't miss something with my code and that is why it is not working. Any ideas what can be wrong?
Is it enough to use just only bulk-in and bulk-out endpoints to communicate with end device or anything else should be done before the right transmission?

Related

Unpack Dec from Hex - via bit offsets

I have a block of hex data which inicludes settings of a sensor, I will include the beginning snippet of the hex (LSB first):
F501517C 8150D4DE 04010200 70010101
05F32A04 F4467000 00000AFF 0502D402
This comes straight from the documentation to decode this hex to dec:
3.1. Full identifier and settings record (0x7C)
Offset Length (bytes) Field description
0x00 6 Full identifier
0x06 40 Settings
3.1.1 Full identifier
Offset Field description
0x00 Product Type
0x01 Device Type
0x02 Software Major Version
0x03 Software Minor Version
0x04 Hardware Major Version
0x05 Hardware Minor Version
3.1.2 Settings
Offset Length(bit) Offset(bit) Default value Min Max Field Description
0x00 8 0 0 0 255 Country number
0x01 8 0 0 0 255 District number
0x02 16 0 0 0 9999 Sensor number
...
0x27
This being the only information I have to decode this. The offset column must be the trick to understanding this.
What are the hex values offset from?
I see 7C in the first hex string.
The Settings section goes to 0x27 = 39 in decimal which is stated in the 3.1 section as the length being 40.
The given hex bytes are byte offset from the beginning of the data.
Assuming that your given dump is little endian 32-bit, let's have a look:
Value in dump - separated in bytes - bytes in memory
F501517C - F5 01 51 7C - 7C 51 01 F5
8150D4DE - 81 50 D4 DE - DE D4 50 81
04010200 - 04 01 02 00 - 00 02 01 04
Now let's assign them to the fields. The next list has both records concatenated.
Byte Offset Field description
7C 0x00 Product Type
51 0x01 Device Type
01 0x02 Software Major Version
F5 0x03 Software Minor Version
DE 0x04 Hardware Major Version
D4 0x05 Hardware Minor Version
Byte Offset Length(bit) Offset(bit) Default value Min Max Field Description
50 0x00 8 0 0 0 255 Country number
81 0x01 8 0 0 0 255 District number
00,02 0x02 16 0 0 0 9999 Sensor number
Whether the result makes sense, is your decision:
Product Type = 0x7C
Device Type = 0x51 = 81 decimal (could also be ASCII 'Q')
Software Major.Minor Version = 0x01.0xF5 = 1.245 decimal
Hardware Major.Minor Version = 0xDE.0xD4 = 222.212
Country number = 0x50 = 80 decimal (could also be ASCII 'P')
District number = 0x81 = 129 decimal (perhaps 0x01 = 1 with bit 7 set?)
Sensor number = 0x0002 = 2 decimal (big endian assumed)

Access to USB Ethernet adapter in LXC

I've created a LXC container in Ubuntu 18.04. Physically, there is an USB to Ethernet adapter connected on the host machine. After starting the LXC container, how to access the USB ethernet adapter? Are there configurations for LXC to do?
The info on the Host machine:
rui#rui-desktop:~$ ifconfig
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet6 fe80::f763:92fe:8145:163 prefixlen 64 scopeid 0x20<link>
ether 00:0e:c6:c9:1a:18 txqueuelen 1000 (Ethernet)
RX packets 1 bytes 46 (46.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 158 bytes 29470 (29.4 KB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
eth1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1430
inet 173.39.202.159 netmask 255.255.255.128 broadcast 173.39.202.255
inet6 fe80::2e0:4cff:fe68:12c prefixlen 64 scopeid 0x20<link>
ether 00:e0:4c:68:01:2c txqueuelen 1000 (Ethernet)
RX packets 1911906 bytes 851840909 (851.8 MB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 350546 bytes 25613552 (25.6 MB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
device interrupt 149 base 0xd000
lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10<host>
loop txqueuelen 1 (Local Loopback)
RX packets 35420 bytes 2918763 (2.9 MB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 35420 bytes 2918763 (2.9 MB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
lxcbr0: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500
inet 10.0.3.1 netmask 255.255.255.0 broadcast 0.0.0.0
inet6 fe80::216:3eff:fe00:0 prefixlen 64 scopeid 0x20<link>
ether 00:16:3e:00:00:00 txqueuelen 1000 (Ethernet)
RX packets 859 bytes 86124 (86.1 KB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 831 bytes 88890 (88.8 KB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
rndis0: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500
ether be:86:e5:ee:9a:ed txqueuelen 1000 (Ethernet)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
usb0: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500
ether be:86:e5:ee:9a:ef txqueuelen 1000 (Ethernet)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
eth0 is the interface that I want to access, and the output from lsusb is
rui#rui-desktop:~$ lsusb
Bus 002 Device 002: ID 0bda:0411 Realtek Semiconductor Corp.
Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
**Bus 001 Device 015: ID 0b95:7720 ASIX Electronics Corp. AX88772**
Bus 001 Device 002: ID 0bda:5411 Realtek Semiconductor Corp.
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
LXC container info:
Last login: Sat Feb 24 17:40:28 UTC 2018 on pts/0
Welcome to Ubuntu 18.04.3 LTS (GNU/Linux 4.9.140-tegra aarch64)
* Documentation: https://help.ubuntu.com
* Management: https://landscape.canonical.com
* Support: https://ubuntu.com/advantage
cisco#ul:~$ ip addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
40: eth0#if41: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000
link/ether 00:16:3e:d6:9b:38 brd ff:ff:ff:ff:ff:ff link-netnsid 0
inet 10.0.3.194/24 brd 10.0.3.255 scope global dynamic eth0
valid_lft 3586sec preferred_lft 3586sec
inet6 fe80::216:3eff:fed6:9b38/64 scope link
valid_lft forever preferred_lft forever
Adding these setting in /var/lib/lxc/ul/config make it working.
lxc.net.1.type = phys
lxc.net.1.link = eth0
lxc.net.1.flags = up
lxc.net.1.hwaddr = 00:0e:c6:c9:1a:18

Data payload for ZigBee thermostat to change the system mode of the thermostat in API mode

Can anyone tell me what is the data payload to change the system mode of the ZigBee based thermostat?
I have found the cluster ID and attribute ID for the system mode i.e 0x0201 (cluster ID) & 0x001C (attribute ID) but unable to frame the data payload.
Zigbee walker output
Digi International -- ZDO/ZCL Walker v1.03
Started at Mon Nov 11 10:14:28 2019
Performing discovery on 00-0d-6f-00-0a-93-e5-40.
Endpoint 0x01 Profile 0x0104 Device 0x0301 Ver 0x00
input/server cluster 0x0000
attr 0x0000, type 0x20 (UNSIGNED_8BIT) 0x01 = 1
attr 0x0002, type 0x20 (UNSIGNED_8BIT) 0x02 = 2
attr 0x0003, type 0x20 (UNSIGNED_8BIT) 0x03 = 3
attr 0x0004, type 0x42 (STRING_CHAR) "Centralite"
attr 0x0005, type 0x42 (STRING_CHAR) "3157100-E"
attr 0x0007, type 0x30 (ENUM_8BIT) 0x81 = 129
input/server cluster 0x0001
attr 0x0020, type 0x20 (UNSIGNED_8BIT) 0x1C = 28
attr 0x0036, type 0x20 (UNSIGNED_8BIT) 0x00 = 0
attr 0x0037, type 0x20 (UNSIGNED_8BIT) 0x00 = 0
attr 0x0038, type 0x20 (UNSIGNED_8BIT) 0x00 = 0
attr 0x0039, type 0x20 (UNSIGNED_8BIT) 0x00 = 0
attr 0x003E, type 0x1B (BITMAP_32BIT) 0x00000000
input/server cluster 0x0003
attr 0x0000, type 0x21 (UNSIGNED_16BIT) 0x0000 = 0
input/server cluster 0x0020
attr 0x0000, type 0x23 (UNSIGNED_32BIT) 0x00000000 = 0
attr 0x0001, type 0x23 (UNSIGNED_32BIT) 0x0000001C = 28
attr 0x0002, type 0x21 (UNSIGNED_16BIT) 0x0001 = 1
attr 0x0003, type 0x21 (UNSIGNED_16BIT) 0x0014 = 20
attr 0x0004, type 0x23 (UNSIGNED_32BIT) 0x000000F0 = 240
attr 0x0005, type 0x23 (UNSIGNED_32BIT) 0x0000001C = 28
attr 0x0006, type 0x21 (UNSIGNED_16BIT) 0x0078 = 120
input/server cluster 0x0201
attr 0x0000, type 0x29 (SIGNED_16BIT) 0x0B39 = 2873
attr 0x0003, type 0x29 (SIGNED_16BIT) 0x02BC = 700
attr 0x0004, type 0x29 (SIGNED_16BIT) 0x0BB8 = 3000
attr 0x0005, type 0x29 (SIGNED_16BIT) 0x02BC = 700
attr 0x0006, type 0x29 (SIGNED_16BIT) 0x0C80 = 3200
attr 0x0009, type 0x18 (BITMAP_8BIT) 0xFF
attr 0x0010, type 0x28 (SIGNED_8BIT) 0x00 = 0
attr 0x0011, type 0x29 (SIGNED_16BIT) 0x029A = 666
attr 0x0012, type 0x29 (SIGNED_16BIT) 0x029A = 666
attr 0x0015, type 0x29 (SIGNED_16BIT) 0x02BC = 700
attr 0x0016, type 0x29 (SIGNED_16BIT) 0x0BB8 = 3000
attr 0x0017, type 0x29 (SIGNED_16BIT) 0x02BC = 700
attr 0x0018, type 0x29 (SIGNED_16BIT) 0x0BB8 = 3000
attr 0x0019, type 0x28 (SIGNED_8BIT) 0x0A = 10
attr 0x001B, type 0x30 (ENUM_8BIT) 0x05 = 5
attr 0x001C, type 0x30 (ENUM_8BIT) 0x00 = 0
attr 0x001E, type 0x30 (ENUM_8BIT) 0x00 = 0
attr 0x0023, type 0x30 (ENUM_8BIT) 0x00 = 0
attr 0x0024, type 0x21 (UNSIGNED_16BIT) 0xFFFF = 65535
attr 0x0025, type 0x18 (BITMAP_8BIT) 0x00
attr 0x0029, type 0x19 (BITMAP_16BIT) 0x0000
attr 0x0030, type 0x30 (ENUM_8BIT) 0x00 = 0
attr 0x0031, type 0x29 (SIGNED_16BIT) 0x8000 = 32768
input/server cluster 0x0202
attr 0x0000, type 0x30 (ENUM_8BIT) 0x05 = 5
attr 0x0001, type 0x30 (ENUM_8BIT) 0x04 = 4
input/server cluster 0x0204
attr 0x0000, type 0x30 (ENUM_8BIT) 0x00 = 0
attr 0x0001, type 0x30 (ENUM_8BIT) 0x00 = 0
input/server cluster 0x0B05
attr 0x0100, type 0x23 (UNSIGNED_32BIT) 0x08000000 = 134217728
attr 0x0101, type 0x23 (UNSIGNED_32BIT) 0x08000001 = 134217729
attr 0x0102, type 0x23 (UNSIGNED_32BIT) 0x08000157 = 134218071
attr 0x0103, type 0x23 (UNSIGNED_32BIT) 0x08006CA7 = 134245543
attr 0x0104, type 0x21 (UNSIGNED_16BIT) 0x01ED = 493
attr 0x0105, type 0x21 (UNSIGNED_16BIT) 0x01EF = 495
attr 0x0106, type 0x21 (UNSIGNED_16BIT) 0x023E = 574
attr 0x0107, type 0x21 (UNSIGNED_16BIT) 0x0218 = 536
attr 0x0108, type 0x21 (UNSIGNED_16BIT) 0x0050 = 80
attr 0x0109, type 0x21 (UNSIGNED_16BIT) 0x0048 = 72
attr 0x010A, type 0x21 (UNSIGNED_16BIT) 0x0000 = 0
attr 0x010B, type 0x21 (UNSIGNED_16BIT) 0x0000 = 0
attr 0x010C, type 0x21 (UNSIGNED_16BIT) 0x0000 = 0
attr 0x010D, type 0x21 (UNSIGNED_16BIT) 0x0003 = 3
attr 0x010E, type 0x21 (UNSIGNED_16BIT) 0x0000 = 0
attr 0x010F, type 0x21 (UNSIGNED_16BIT) 0x0000 = 0
attr 0x0110, type 0x21 (UNSIGNED_16BIT) 0x0000 = 0
attr 0x0111, type 0x21 (UNSIGNED_16BIT) 0x0000 = 0
attr 0x0112, type 0x21 (UNSIGNED_16BIT) 0x0000 = 0
attr 0x0113, type 0x21 (UNSIGNED_16BIT) 0x0000 = 0
attr 0x0114, type 0x21 (UNSIGNED_16BIT) 0x0000 = 0
attr 0x0115, type 0x21 (UNSIGNED_16BIT) 0x0001 = 1
attr 0x0116, type 0x21 (UNSIGNED_16BIT) 0x0000 = 0
attr 0x0117, type 0x21 (UNSIGNED_16BIT) 0x0000 = 0
attr 0x0118, type 0x21 (UNSIGNED_16BIT) 0x0000 = 0
attr 0x0119, type 0x21 (UNSIGNED_16BIT) 0x0000 = 0
attr 0x011A, type 0x21 (UNSIGNED_16BIT) 0x0000 = 0
attr 0x011B, type 0x21 (UNSIGNED_16BIT) 0x2401 = 9217
attr 0x011C, type 0x20 (UNSIGNED_8BIT) 0xFF = 255
attr 0x011D, type 0x28 (SIGNED_8BIT) 0xDA = 218
output/client cluster 0x000A
no attributes
output/client cluster 0x0019
attr 0x0000, type 0xF0 (IEEE_ADDR) ff-ff-ff-ff-ff-ff-ff-ff
attr 0x0001, type 0x23 (UNSIGNED_32BIT) 0xFFFFFFFF = 4294967295
attr 0x0002, type 0x23 (UNSIGNED_32BIT) 0x04045010 = 67391504
attr 0x0004, type 0x23 (UNSIGNED_32BIT) 0xFFFFFFFF = 4294967295
attr 0x0006, type 0x30 (ENUM_8BIT) 0x00 = 0
attr 0x0007, type 0x21 (UNSIGNED_16BIT) 0xC2DF = 49887
attr 0x0008, type 0x21 (UNSIGNED_16BIT) 0x0023 = 35
attr 0x0009, type 0x21 (UNSIGNED_16BIT) 0x1388 = 5000
attr 0x000A, type 0x23 (UNSIGNED_32BIT) 0x5BAF4865 = 1538213989
Completed at Mon Nov 11 10:15:02 2019
(34 seconds elapsed)
I am constructing the frame as per this - [Send Zigbee cluster library (ZCL) commands with the API][1]
Following is my constructed frame to change the system mode of the thermostat still the below frame is not changing the system mode(OFF,HEAT,Cool).
7E 00 19 11 01 00 0D 6F 00 0A 93 E5 40 FF FE 01 01 02 01 01 04 00 00 00 01 00 00 1C 8B
Can someone help me with the correct frame especially with data payload part to change the system mode of the thermostat?
Have you confirmed you can join the Nest thermostat's network? You'll need to manually assemble the ZCL (Zigbee Cluster Library) frame to read or write that attribute ID.
If you have an 802.15.4 sniffer, you might be able to monitor communications between the thermostat and another device to determine what's happening, and potentially figure out how to reproduce those frames from the XBee. It's been a while since I've worked with Zigbee networks, so I don't know what the standards are for Home Automation right now, and how difficult it is to join an existing HA network.
You didn't specify a language, but Digi provides an Open Source XBee Host C Library to interface with its XBee modules (which you specified in a tag) and it includes a ZCL and ZDO/ZDP (Zigbee Data Objects/Profile) layer. One of the samples (Zigbee Walker) uses ZDO and ZCL discovery to dump a list of endpoints, clusters and attributes on a device.

USB vendor specific class with Bulk transfer in LPC1769 Microcontroller

I am trying to achieve USB vendor specific class with Bulk transfer in LPC1769 Microcontroller.
I got an USB Biometric module, extracted it's device information. Accordingly I have configured the following descriptor.
const uint8_t USB_DeviceDescriptor[]={};
const uint8_t USB_ConfigDescriptor[]={};
const uint8_t USB_StringDescriptor[]={};
Now my USB Biometric device and my LPC1769 device has similar type of device information
(I have seen it from my Ubuntu PC using this command "lsusb -v")
But, when I am plugging it to windows it should come to USB class (Trident symbol list) in device manager. USB Bio-metric device is listing under "Universal Serial Bus controller".
I am not able to find any Any document, flowchart
Could anyone please guide me how to established communication in vendor specific class.
USB biometric device information
Bus 003 Device 023: ID 16d1:0407
Couldn't open device, some information will be missing
Device Descriptor:
bLength 18
bDescriptorType 1
bcdUSB 2.00
bDeviceClass 0 (Defined at Interface level)
bDeviceSubClass 0
bDeviceProtocol 0
bMaxPacketSize0 64
idVendor 0x16d1
idProduct 0x0407
bcdDevice 0.00
iManufacturer 1
iProduct 2
iSerial 0
bNumConfigurations 1
Configuration Descriptor:
bLength 9
bDescriptorType 2
wTotalLength 32
bNumInterfaces 1
bConfigurationValue 1
iConfiguration 0
bmAttributes 0x80
(Bus Powered)
MaxPower 300mA
Interface Descriptor:
bLength 9
bDescriptorType 4
bInterfaceNumber 0
bAlternateSetting 0
bNumEndpoints 2
bInterfaceClass 255 Vendor Specific Class
bInterfaceSubClass 0
bInterfaceProtocol 0
iInterface 0
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x82 EP 2 IN
bmAttributes 2
Transfer Type Bulk
Synch Type None
Usage Type Data
wMaxPacketSize 0x0200 1x 512 bytes
bInterval 0
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x01 EP 1 OUT
bmAttributes 2
Transfer Type Bulk
Synch Type None
Usage Type Data
wMaxPacketSize 0x0200 1x 512 bytes
bInterval 0
My LPC1769 USB device Information
Bus 003 Device 018: ID 1fc9:2002 NXP Semiconductors
Couldn't open device, some information will be missing
Device Descriptor:
bLength 18
bDescriptorType 1
bcdUSB 2.00
bDeviceClass 0 (Defined at Interface level)
bDeviceSubClass 0
bDeviceProtocol 0
bMaxPacketSize0 64
idVendor 0x1fc9 NXP Semiconductors
idProduct 0x2002
bcdDevice 1.00
iManufacturer 1
iProduct 2
iSerial 1
bNumConfigurations 1
Configuration Descriptor:
bLength 9
bDescriptorType 2
wTotalLength 32
bNumInterfaces 1
bConfigurationValue 1
iConfiguration 0
bmAttributes 0x80
(Bus Powered)
MaxPower 500mA
Interface Descriptor:
bLength 9
bDescriptorType 4
bInterfaceNumber 0
bAlternateSetting 0
bNumEndpoints 2
bInterfaceClass 255 Vendor Specific Class
bInterfaceSubClass 0
bInterfaceProtocol 0
iInterface 3
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x01 EP 1 OUT
bmAttributes 2
Transfer Type Bulk
Synch Type None
Usage Type Data
wMaxPacketSize 0x0200 1x 512 bytes
bInterval 1
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x82 EP 2 IN
bmAttributes 2
Transfer Type Bulk
Synch Type None
Usage Type Data
wMaxPacketSize 0x0200 1x 512 bytes
bInterval 1
Thanking you in advance.
bEndpointAddress 0x01 EP 1 OUT
bmAttributes 2
Transfer Type Bulk
Synch Type None
Usage Type Data
wMaxPacketSize 0x0200 1x 512 bytes
The LPC1769 only supports USB full speed, thus Bulk EPs have a wMaxPacketSize of 64 Bytes max. Only high speed devices support 512 byte Bulk EPs.
To operate "vendor specific" class USB devices, you use either a specific kernel driver or LibUSB/WinUSB as driver together with a user mode application.
Whenever there is no driver installed for particular USB device (VID and PID), it will shows "?Other devices"
in the device manager. But, for my case it was listing under "Communication Devices Class" although I have
change my USB class protocol to "Vendor Specific Class". Why? The driver instance is trying to map with the
same VID and PID. I have changed my identical to that of USB Bio-metric device. It shows in the "Universal
Serial Bus Controller listing".
Now, you can integrate the same with your Android Tab with "Android Studio Platform" there is an API called "UsbManager"
http://developer.android.com/reference/android/hardware/usb/UsbManager.html
Thanks for your participation.

LibUSB driver issues: timeout

I am attempting to write a linux driver for a printer. I have run USBSnoop on windows XP and obtained the log. In this log it sets wMaxPacketSize to 1026. After i set the interface i get the response of 75 bytes. If i set it to 64 (in the lsusb output) i obviously only get 64 bytes back.
My issue is on a bulk transfer to/from the device i get timeouts. I think i have the same problem as here: http://libusb.6.n5.nabble.com/libusb-bulk-transfer-return-timeout-error-and-transferred-set-to-0-td5712761.html
I performed the libusb_clear_halt() and i get a similar result to the linked post above. Down the bottom of it says "split buffer into 64 bytes manually" to solve it. My question is how to split the packets? This is my first time using LibUSB.
Here is the output of lsusb -v
Bus 002 Device 009: ID 07ce:c000
Device Descriptor:
bLength 18
bDescriptorType 1
bcdUSB 2.00
bDeviceClass 7 Printer
bDeviceSubClass 1 Printer
bDeviceProtocol 2 Bidirectional
bMaxPacketSize0 64
idVendor 0x07ce
idProduct 0xc000
bcdDevice 1.00
iManufacturer 1 COPAL
iProduct 2 COPAL USB Printer
iSerial 0
bNumConfigurations 1
Configuration Descriptor:
bLength 9
bDescriptorType 2
wTotalLength 32
bNumInterfaces 1
bConfigurationValue 1
iConfiguration 0
bmAttributes 0xc0
Self Powered
MaxPower 200mA
Interface Descriptor:
bLength 9
bDescriptorType 4
bInterfaceNumber 0
bAlternateSetting 0
bNumEndpoints 2
bInterfaceClass 7 Printer
bInterfaceSubClass 1 Printer
bInterfaceProtocol 2 Bidirectional
iInterface 0
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x01 EP 1 OUT
bmAttributes 2
Transfer Type Bulk
Synch Type None
Usage Type Data
wMaxPacketSize 0x0040 1x 64 bytes
bInterval 0
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x82 EP 2 IN
bmAttributes 2
Transfer Type Bulk
Synch Type None
Usage Type Data
wMaxPacketSize 0x0040 1x 64 bytes
bInterval 0
Device Qualifier (for other device speed):
bLength 10
bDescriptorType 6
bcdUSB 0.00
bDeviceClass 0 (Defined at Interface level)
bDeviceSubClass 0
bDeviceProtocol 0
bMaxPacketSize0 0
bNumConfigurations 0
Device Status: 0x0001
Self Powered
Edit: this was in the dmesg
usb 2-1.1: new high-speed USB device number 9 using ehci_hcd
usb 2-1.1: config 1 interface 0 altsetting 0 bulk endpoint 0x1 has invalid maxpacket 64
usb 2-1.1: config 1 interface 0 altsetting 0 bulk endpoint 0x82 has invalid maxpacket 64
Edit: I think it may be that linux is getting in the way. On wireshark and i can see the packets come back correctly but not calling my callback function. I already removed the usblp driver. Any ideas?
Got a similar problem. Haven't figured out why I get the timeout errors, yet. Though it seems like they occur much more often for larger package sizes. If you want to split your package, just write yourself a function that splits your large buffer[1024] into packages of 64 bytes, then do a loop that always takes the next 64 bytes from the buffer, puts it in a small_buffer[64] and sends them via usb.

Resources