Hello eveyone,
I have solved this problem with a simple program usb_settestmode.c Also one can change this program to set the host to get into Test Mode with changing the Tier 2 Hub Address to Root Hub Address(host), but i do not confirmed that. If someone tried please tell me the results. Thanks anyway!
/*
* Filename: usb_settestmode.c
* USB 2.0一致性测试
* 设置Hub port进入Test Mode
*/
#include <stdio.h>
#include <fcntl.h>
#include <errno.h>
#include <linux/usbdevice_fs.h>
#include <asm/byteorder.h>
#include <sys/ioctl.h>
int main(void)
{
int fd, ret;
/* the request is come from the USB 2.0 Specification */
struct usbdevfs_ctrltransfer test_req = {
.bRequestType = 0x23,
.bRequest = 3, // SET_FEATURE
.wValue = 21, // PORT_TEST
.wIndex = 0x0401, // Test_Packet And Port 1
.wLength = 0,
.timeout = 1000,
};
fd = open("/dev/bus/usb/001/002", O_RDWR); // Tier2 Hub Address(Or you change this to Root Hub's Address)
if (fd < 0) {
perror("open");
return -1;
}
ret = ioctl(fd, USBDEVFS_CONTROL, &test_req);
if (ret < 0) {
perror("ioctl");
return -1;
}
}
Best Regards
bo xu