我能以某种方式增加 USB 端点的大小吗?
Can I somehow increase the size of USB Endpoint?
这是我为打开 USB 设备而编写的代码
private void openDevice(UsbDevice device){
Log.v(TAG, "USB device setup initiated");
Map<String, UsbDevice> connectedDevices = usbManager.getDeviceList();
if (!connectedDevices.isEmpty()) {
if (device.getVendorId() == USB_VENDOR_ID && device.getProductId() == USB_PRODUCT_ID) {
Log.i(TAG, "Device found: " + device.getDeviceName());
Log.i(TAG, "Ready to open USB device connection");
connection = usbManager.openDevice(this.device);
intface = this.device.getInterface(0);
connection.claimInterface(intface, true);
USBisOpen = true;
Log.v(TAG, "USB is Opened");
}
}
}
这是我为打开端点而编写的代码。
for(int i = 0; i < intface.getEndpointCount(); ++i){
endpoint = intface.getEndpoint(i);
if(endpoint.getType() == UsbConstants.USB_ENDPOINT_XFER_BULK && endpoint.getDirection() == UsbConstants.USB_DIR_IN){
Log.v(TAG, "endpoint index is " + i);
break;
}
}
Log.v(TAG, "Transferable Buffer Size is: " + endpoint.getMaxPacketSize());
所以,我对 'getMaxPacketSize()' 方法很好奇。
有没有办法以某种方式我可以操纵它的大小?我在 class
中找到了这个构造函数代码
public UsbEndpoint(int address, int attributes, int maxPacketSize, int interval) {
mAddress = address;
mAttributes = attributes;
mMaxPacketSize = maxPacketSize;
mInterval = interval;
}
但是好像不能这样使用
UsbEndpoint endpoint = new UsbEndpoint(address, attributes, size, interval);
代码中的注释说 'UsbEndpoint should only be instantiated by UsbService implementation' 这与此有关吗?
感谢您阅读我的问题。
端点的最大大小是 USB 规范定义的参数。
您不能更改设备的端点大小(最大数据包大小)。根据规格,以下是最大尺寸 -
USB 3.0
批量 - 1024 字节
控制 - 512 字节
等时 - 1024 字节
中断 - 1024 字节
USB 2.0(高速)
批量 - 512 字节
控制 - 64 字节
等时 - 1024 字节
中断 - 1024 字节
端点的最大数据包大小是 USB 设备固件的 属性。如果您能够修改固件,那么您可以更改最大数据包大小,但这可能是一个复杂的过程,并且对于大多数 USB 设备来说通常是不可能的。
典型的 PC 操作系统从设备读取 USB 描述符,以确定每个端点的最大数据包大小。正确的 USB 驱动程序将使用这些最大数据包大小来确保与设备的通信正常工作。
这是我为打开 USB 设备而编写的代码
private void openDevice(UsbDevice device){
Log.v(TAG, "USB device setup initiated");
Map<String, UsbDevice> connectedDevices = usbManager.getDeviceList();
if (!connectedDevices.isEmpty()) {
if (device.getVendorId() == USB_VENDOR_ID && device.getProductId() == USB_PRODUCT_ID) {
Log.i(TAG, "Device found: " + device.getDeviceName());
Log.i(TAG, "Ready to open USB device connection");
connection = usbManager.openDevice(this.device);
intface = this.device.getInterface(0);
connection.claimInterface(intface, true);
USBisOpen = true;
Log.v(TAG, "USB is Opened");
}
}
}
这是我为打开端点而编写的代码。
for(int i = 0; i < intface.getEndpointCount(); ++i){
endpoint = intface.getEndpoint(i);
if(endpoint.getType() == UsbConstants.USB_ENDPOINT_XFER_BULK && endpoint.getDirection() == UsbConstants.USB_DIR_IN){
Log.v(TAG, "endpoint index is " + i);
break;
}
}
Log.v(TAG, "Transferable Buffer Size is: " + endpoint.getMaxPacketSize());
所以,我对 'getMaxPacketSize()' 方法很好奇。 有没有办法以某种方式我可以操纵它的大小?我在 class
中找到了这个构造函数代码public UsbEndpoint(int address, int attributes, int maxPacketSize, int interval) {
mAddress = address;
mAttributes = attributes;
mMaxPacketSize = maxPacketSize;
mInterval = interval;
}
但是好像不能这样使用
UsbEndpoint endpoint = new UsbEndpoint(address, attributes, size, interval);
代码中的注释说 'UsbEndpoint should only be instantiated by UsbService implementation' 这与此有关吗?
感谢您阅读我的问题。
端点的最大大小是 USB 规范定义的参数。 您不能更改设备的端点大小(最大数据包大小)。根据规格,以下是最大尺寸 -
USB 3.0
批量 - 1024 字节
控制 - 512 字节
等时 - 1024 字节
中断 - 1024 字节
USB 2.0(高速)
批量 - 512 字节
控制 - 64 字节
等时 - 1024 字节
中断 - 1024 字节
端点的最大数据包大小是 USB 设备固件的 属性。如果您能够修改固件,那么您可以更改最大数据包大小,但这可能是一个复杂的过程,并且对于大多数 USB 设备来说通常是不可能的。
典型的 PC 操作系统从设备读取 USB 描述符,以确定每个端点的最大数据包大小。正确的 USB 驱动程序将使用这些最大数据包大小来确保与设备的通信正常工作。