📄 usbio.java
字号:
*
* @param BufDesc Reference to a caller-provided buffer descriptor.
* The buffer receives the data transferred in the IN data phase.
* When the function is called the buffer descriptor specifies the size, in bytes, of the
* buffer.
* After the function successfully returned the buffer descriptor contains
* the number of valid bytes returned in the buffer.
*
* @param Request Reference to a caller-provided variable that defines the request to be generated.
*
* @return The function returns 0 if successful, an USBIO error code otherwise.
*
* @see de.thesycon.usbio.UsbIo#open(int, int, String)
* @see de.thesycon.usbio.UsbIo#classOrVendorOutRequest(USBIO_DATA_BUFFER, USBIO_CLASS_OR_VENDOR_REQUEST)
* @see de.thesycon.usbio.structs.USBIO_CLASS_OR_VENDOR_REQUEST#USBIO_CLASS_OR_VENDOR_REQUEST
*/
public int classOrVendorInRequest(USBIO_DATA_BUFFER BufDesc, USBIO_CLASS_OR_VENDOR_REQUEST Request) {
if (BufDesc == null) {
return USBIO_ERR_INVALID_PARAM;
}
if (BufDesc.Buffer() == null) {
return USBIO_ERR_INVALID_PARAM;
}
if (Request == null) {
return USBIO_ERR_INVALID_PARAM;
}
byte[] req = Request.buildByteArray();
int[] bytecount = new int[1];
bytecount[0] = BufDesc.getNumberOfBytesToTransfer();
int Status = classOrVendorInRequest(Handle, BufDesc.Buffer(), bytecount, req);
BufDesc.setBytesTransferred(bytecount[0]);
Request.parseByteArray(req);
return Status;
}
/**
* Sends a class or vendor specific request with a data phase in host to device (OUT) direction.
* <p>
* The device must have been opened before this function is called.
* <p>
* This function is a wrapper for the IOCTL_USBIO_CLASS_OR_VENDOR_OUT_REQUEST operation.
*
* @param BufDesc Reference to a caller-provided buffer descriptor.
* The buffer receives the data transferred in the IN data phase.
* When the function is called the buffer descriptor specifies the size, in bytes, of the
* buffer.
* After the function successfully returned the buffer descriptor contains
* the number of bytes transferred.
*
* @param Request Reference to a caller-provided variable that defines the request to be generated.
*
* @return The function returns 0 if successful, an USBIO error code otherwise.
*
* @see de.thesycon.usbio.UsbIo#open(int, int, String)
* @see de.thesycon.usbio.UsbIo#classOrVendorInRequest(USBIO_DATA_BUFFER, USBIO_CLASS_OR_VENDOR_REQUEST)
* @see de.thesycon.usbio.structs.USBIO_CLASS_OR_VENDOR_REQUEST#USBIO_CLASS_OR_VENDOR_REQUEST
*/
public int classOrVendorOutRequest(USBIO_DATA_BUFFER BufDesc, USBIO_CLASS_OR_VENDOR_REQUEST Request) {
if (BufDesc == null) {
return USBIO_ERR_INVALID_PARAM;
}
if (BufDesc.Buffer() == null) {
return USBIO_ERR_INVALID_PARAM;
}
if (Request == null) {
return USBIO_ERR_INVALID_PARAM;
}
byte[] req = Request.buildByteArray();
int[] bytecount = new int[1];
bytecount[0] = BufDesc.getNumberOfBytesToTransfer();
int Status = classOrVendorOutRequest(Handle, BufDesc.Buffer(), bytecount, req);
BufDesc.setBytesTransferred(bytecount[0]);
Request.parseByteArray(req);
return Status;
}
/**
* Simulates a device disconnect/connect cycle.
* <p>
* This function causes a device disconnect/connect cycle and
* an unload/load cycle for the USBIO device driver as well.
* <p>
* Note: CyclePort does not work on multi-interface devices
* (see also problems.txt in the USBIO package).
* <p>
* The device must have been opened before this function is called.
* <p>
* This function is a wrapper for the IOCTL_USBIO_CYCLE_PORT operation.
*
* @return The function returns 0 if successful, an USBIO error code otherwise.
*
* @see de.thesycon.usbio.UsbIo#open(int, int, String)
* @see de.thesycon.usbio.UsbIo#resetDevice()
*/
public int cyclePort() {
return cyclePort(Handle);
}
/**
* Force an USB reset.
* <p>
* This function causes an USB reset to be issued on the hub port the device
* is connected to.
* This will abort all pending read and write requests and unbind all pipes.
* The device will be set to the unconfigured state.
* <p>
* Note: The device must be in the configured state when this function
* is called.
* ResetDevice does not work when the system-provided USB multi-interface driver
* is used (see also problems.txt in the USBIO package).
* <p>
* The device must have been opened before this function is called.
* <p>
* This function is a wrapper for the IOCTL_USBIO_RESET_DEVICE operation.
*
* @return The function returns 0 if successful, an USBIO error code otherwise.
*
* @see de.thesycon.usbio.UsbIo#open(int, int, String)
* @see de.thesycon.usbio.UsbIo#setConfiguration(USBIO_SET_CONFIGURATION)
* @see de.thesycon.usbio.UsbIo#unconfigureDevice()
* @see de.thesycon.usbio.UsbIo#cyclePort()
* @see de.thesycon.usbio.UsbIoPipe#bind(int, byte, int, String)
* @see de.thesycon.usbio.UsbIoPipe#unbind()
* @see de.thesycon.usbio.UsbIoPipe#abortPipe()
*/
public int resetDevice() {
return resetDevice(Handle);
}
/**
* Get the current USB frame number from the host controller.
* <p>
* The returned frame number is a 32 bit value.
* The 11 least significant bits correspond to the frame
* number in the USB frame token.
* <p>
* The device must have been opened and configured before this function is called.
* <p>
* This function is a wrapper for the IOCTL_USBIO_GET_CURRENT_FRAME_NUMBER operation.
*
* @param FrameNumber If the function call is successful this variable returns the
* current frame number.
*
* @return The function returns 0 if successful, an USBIO error code otherwise.
*
* @see de.thesycon.usbio.UsbIo#open(int, int, String)
*/
public int getCurrentFrameNumber(int[] FrameNumber) {
if (FrameNumber == null) {
return USBIO_ERR_INVALID_PARAM;
}
return getCurrentFrameNumber(Handle, FrameNumber);
}
/**
* Send a get status request to the USB device.
* <p>
* The device must have been opened and configured before this function is called.
* <p>
* This function is a wrapper for the IOCTL_USBIO_GET_STATUS operation.
*
* @param StatusValue If the function call is successful this variable returns the
* 16-bit value that is returned by the recipient in response to the
* get status request.
* The interpretation of the value is specific to the recipient.
* Refer to the USB specification.
*
* @param Recipient Specifies the recipient of the request.
*
* @param Index Specifies the index value for the get status request.
* The values are defined by the device.
* Refer to the USB specification.
*
* @return The function returns 0 if successful, an USBIO error code otherwise.
*
* @see de.thesycon.usbio.UsbIo#open(int, int, String)
* @see de.thesycon.usbio.UsbIo#setFeature(int, short, short)
* @see de.thesycon.usbio.UsbIo#clearFeature(int, short, short)
*/
public int getStatus(short[] StatusValue, int Recipient, short Index) {
if (StatusValue == null) {
return USBIO_ERR_INVALID_PARAM;
}
return getStatus(Handle, StatusValue, Recipient, Index);
}
/**
* This function returns the active alternate setting of an interface.
* <p>
* The device must have been opened and configured before this function is called.
* <p>
* This function is a wrapper for the IOCTL_USBIO_GET_INTERFACE operation.
*
* @param AlternateSetting If the function call is successful this variable returns the
* current alternate setting of the interface.
*
* @param Interface Specifies the index of the interface to be queried.
*
* @return The function returns 0 if successful, an USBIO error code otherwise.
*
* @see de.thesycon.usbio.UsbIo#open(int, int, String)
* @see de.thesycon.usbio.UsbIo#setConfiguration(USBIO_SET_CONFIGURATION)
* @see de.thesycon.usbio.UsbIo#setInterface(USBIO_INTERFACE_SETTING)
*/
public int getInterface(byte[] AlternateSetting, short Interface) {
if (AlternateSetting == null) {
return USBIO_ERR_INVALID_PARAM;
}
return getInterface(Handle, AlternateSetting, Interface);
}
/**
* This function changes the alternate setting of an interface.
* <p>
* The device must have been opened and configured before this function is called.
* <p>
* This function is a wrapper for the IOCTL_USBIO_SET_INTERFACE operation.
*
* @param InterfaceSetting Reference to a caller-provided structure that specifies the
* interface and the alternate settings to be set.
*
* @return The function returns 0 if successful, an USBIO error code otherwise.
*
* @see de.thesycon.usbio.UsbIo#open(int, int, String)
* @see de.thesycon.usbio.UsbIo#setConfiguration(USBIO_SET_CONFIGURATION)
* @see de.thesycon.usbio.UsbIo#getInterface(byte[], short)
* @see de.thesycon.usbio.structs.USBIO_INTERFACE_SETTING#USBIO_INTERFACE_SETTING
*/
public int setInterface(USBIO_INTERFACE_SETTING InterfaceSetting) {
if (InterfaceSetting == null) {
return USBIO_ERR_INVALID_PARAM;
}
byte[] data = InterfaceSetting.buildByteArray();
int Status = setInterface(Handle, data);
InterfaceSetting.parseByteArray(data);
return Status;
}
/**
* Returns the current device power state.
* <p>
* The device must have been opened before this function is called.
* <p>
* This function is a wrapper for the IOCTL_USBIO_GET_DEVICE_POWER_STATE operation.
*
* @param DevicePowerState If the function call is successful this variable returns the
* current device power state.
*
* @return The function returns 0 if successful, an USBIO error code otherwise.
*
* @see de.thesycon.usbio.UsbIo#open(int, int, String)
* @see de.thesycon.usbio.UsbIo#setDevicePowerState(int)
*/
public int getDevicePowerState(int[] DevicePowerState) {
if (DevicePowerState == null) {
return USBIO_ERR_INVALID_PARAM;
}
return getDevicePowerState(Handle, DevicePowerState);
}
/**
* Set the device power state.
* <p>
* In order to set the device to suspend it must be in the configured state.
* <p>
* When the device is set to suspend all pending read and write requests will
* be returned by the USBIO driver with an error status of USBIO_ERR_POWER_DOWN.
* An application can ignore this error status and submit the requests to the
* driver again.
* <p>
* The device must have been opened before this function is called.
* <p>
* This function is a wrapper for the IOCTL_USBIO_SET_DEVICE_POWER_STATE operation.
*
* @param DevicePowerState If the function call is successful this variable returns the
* current device power state.
*
* @return The function returns 0 if successful, an USBIO error code otherwise.
*
* @see de.thesycon.usbio.UsbIo#open(int, int, String)
* @see de.thesycon.usbio.UsbIo#getDevicePowerState(int[])
*/
public int setDevicePowerState(int DevicePowerState) {
return setDevicePowerState(Handle, DevicePowerState);
}
/**
* Send a clear feature request to the USB device.
* <p>
* In order to set the device to suspend it must be in the configured state.
* <p>
* The device must have been opened before this function is called.
* <p>
* This function is a wrapper for the IOCTL_USBIO_CLEAR_FEATURE operation.
*
* @param Recipient Specifies the recipient of the request.
*
* @param FeatureSelector Specifies the feature selector value for the request.
* The values are defined by the recipient. Refer to the USB specification.
*
* @param Index Specifies the index value for the set feature request.
* The values are defined by the device. Refer to the USB specification.
*
* @return The function returns 0 if successful, an USBIO error code otherwise.
*
* @see de.thesycon.usbio.UsbIo#open(int, int, String)
* @see de.thesycon.usbio.UsbIo#setFeature(int, short, short)
* @see de.thesycon.usbio.UsbIo#getStatus(short[], int, short)
*/
public int clearFeature(int Recipient, short FeatureSelector, short Index) {
return clearFeature(Handle, Recipient, FeatureSelector, Index);
}
/**
* Send a set feature request to the USB device.
* <p>
* In order to set the device to suspend it must be in the configured state.
* <p>
* The device must have been opened before this function is called.
* <p>
* This function is a wrapper for the IOCTL_USBIO_SET_FEATURE operation.
*
* @param Recipient Specifies the recipient of the request.
*
* @param FeatureSelector Specifies the feature selector value for the request.
* The values are defined by the recipient. Refer to the USB specification.
*
* @param Index Specifies the index value for the set feature request.
* The values are defined by the device. Refer to the USB specification.
*
* @return The function returns 0 if successful, an USBIO error code otherwise.
*
* @see de.thesycon.usbio.UsbIo#open(int, int, String)
* @see de.thesycon.usbio.UsbIo#clearFeature(int, short, short)
* @see de.thesycon.usbio.UsbIo#getStatus(short[], int, short)
*/
public int setFeature(int Recipient, short FeatureSelector, short Index) {
return setFeature(Handle, Recipient, FeatureSelector, Index);
}
/**
* Get a descriptor from the device.
* <p>
* The device must have been opened before this function is called.
* <p>
* This function is a wrapper for the IOCTL_USBIO_GET_DESCRIPTOR operation.
*
* @param BufDesc Reference to a caller-provided buffer descriptor.
* The buffer receives the requested descriptor.
* When the function is called the buffer descriptor specifies the size, in bytes, of the
* buffer.
* After the function successfully returned the buffer descriptor contains
* the number of valid bytes returned in the buffer.
*
* @param Recipient Specifies the recipient of the request.
*
* @param DescriptorType The type of the descriptor to request.
*
* @param DescriptorIndex The index of the descriptor to request.
*
* @param LanguageId The language ID of the descriptor to request.
* Used for string descriptors only.
*
* @return The function returns 0 if successful, an USBIO error code otherwise.
*
* @see de.thesycon.usbio.UsbIo#open(int, int, String)
* @see de.thesycon.usbio.UsbIo#getDeviceDescriptor(USB_DEVICE_DESCRIPTOR)
* @see de.thesycon.usbio.UsbIo#getConfigurationDescriptor(USBIO_DATA_BUFFER, byte)
* @see de.thesycon.usbio.UsbIo#getStringDescriptor(USB_STRING_DESCRIPTOR, byte, int)
* @see de.thesycon.usbio.UsbIo#setDescriptor(USBIO_DATA_BUFFER, int, byte, byte, short)
*/
public int getDescriptor(USBIO_DATA_BUFFER BufDesc, int Recipient, byte DescriptorType, byte DescriptorIndex, short LanguageId) {
if (BufDesc == null) {
return USBIO_ERR_INVALID_PARAM;
}
if (BufDesc.Buffer() == null) {
return USBIO_ERR_INVALID_PARAM;
}
int[] bytecount = new int[1];
bytecount[0] = BufDesc.getNumberOfBytesToTransfer();
int Status = getDescriptor(Handle, BufDesc.Buffer(), bytecount, Recipient, DescriptorType, DescriptorIndex, LanguageId);
BufDesc.setBytesTransferred(bytecount[0]);
return Status;
}
/**
* Get a descriptor from the device.
* <p>
* The device must have been opened before this function is called.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -