The problem is this:
Currently based in linux libusb to andriod transfer data via usb, pc terminal is host, android phones end of accesory.
In the end pc:
The first traverse all USB devices, all devices are discovered:
0 Device:. ProductID: 2 VendorID: 7531 SerialNum: 0000:02:03.0
1 Device:. ProductID: 1 VendorID: 7531 SerialNum: 0000:02:00.0
2 Device:. ProductID: 3 VendorID: 3599 SerialNum: 0000:02:00.0
3 Device:. ProductID: 2 VendorID: 3599 SerialNum: 0000:02:00.0
4 Device:. ProductID: 8 VendorID: 3599 SerialNum: 000650268328
5 Device:. ProductID: 26720 VendorID: 1256 SerialNum: 323013cd532210db
The last of my mobile devices, ProductID: 26720 VendorID: 1256.
Because the phone is not accesory under mode, so be adjusted so that the android usb into accessory mode.
The second traverse all USB devices, all devices are discovered:
0 Device:. ProductID: 2 VendorID: 7531 SerialNum: 0000:02:03.0
1 Device:. ProductID: 1 VendorID: 7531 SerialNum: 0000:02:00.0
2 Device:. ProductID: 3 VendorID: 3599 SerialNum: 0000:02:00.0
3 Device:. ProductID: 2 VendorID: 3599 SerialNum: 0000:02:00.0
4 Device:. ProductID: 8 VendorID: 3599 SerialNum: 000650268328
5 Device:. ProductID: 11521 VendorID: 6353 SerialNum: 323013cd532210db
At this discovery android mobile terminal into the Accessory mode approach. Can communicate.
Attach the android device transferred to the main code
Accessory modeunsigned short protocol;
int ret = libusb_control_transfer (vars-> dev_handle, 0x80 | 0x40, 51, 0, 0, (unsigned char *) (& protocol), sizeof (protocol), 0);
send_string (vars-> dev_handle, 0, "BiZhiTech");
send_string (vars-> dev_handle, 1, "BiZhiTech");
send_string (vars-> dev_handle, 2, "BiZhiTech");
send_string (vars-> dev_handle, 3, "1.0");
send_string (vars-> dev_handle, 4, "http://www.bizhitech.com");
send_string (vars-> dev_handle, 5, "1234567890");
ret = libusb_control_transfer (vars-> dev_handle, 0x00 | 0x40, 53, 0, 0, NULL, 0, 0);
send_string defined as follows:
static void send_string (struct libusb_device_handle * device, int index, const char * string)
{
/ / Some devices can't handle back-to-back requests, so delay a bit
int ret = libusb_control_transfer (device, 0x00 | 0x40, 52, 0, index, (unsigned char *) string, strlen (string) +1,0);
}
However, under the premise of not unplug the usb, I want to re-adjust back ProuductID and VendorID. In other words, let the android mobile terminal exit Accesory mode approach.
Is there any way to adjust back.
<-! Main posts under Banner (D4) -><-! Posts under the main text (D5) ->
Reply:
Some people understand? Ask God to help!
Reply:
you mean control the phone (in accessory mode) into normal mode?
Reply:
how about using usb_reset (handle)
Reply:
Well, after using the usb_reset, vendor_ID and productID will not change.
My goal is through usb, making the computer to communicate with the mobile phone android.
But only in the Accessory mode android phone when they can communicate with the phone? I do not know understand this right.
Reply:
I also get the HID libusb based literacy program, compile it prompts no config.h, the landlord has not met? If encountered, how to solve?
Reply:
Can you send me a copy of the code to see? Thanks.
Reply:
Are you saying that I did not compile the libusb library config.h file? ? ?
No comments:
Post a Comment