⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 usb_string_descriptor.java

📁 usbio Ver 2.40 source code!!! 做USB开发的值得
💻 JAVA
字号:
package de.thesycon.usbio.structs;

import java.io.*;

/**
 * USB string descriptor class.
 */
public class USB_STRING_DESCRIPTOR extends USB_COMMON_DESCRIPTOR
{
	public final static int MAX_DESCRIPTOR_BUFFER_SIZE = 2047;
	public final static int SIZE = MAX_DESCRIPTOR_BUFFER_SIZE;

	/** The string provides a readable description.*/
	public String Str = "";
	/** Byte array representation the string.*/
	public byte[] ByteArray = new byte[MAX_DESCRIPTOR_BUFFER_SIZE];

	/**
	 * Standard constructor of the USB_STRING_DESCRIPTOR class.
	 */
	public USB_STRING_DESCRIPTOR() {
		Size = MAX_DESCRIPTOR_BUFFER_SIZE;
	}

	public void parseByteArray(byte[] Bytes, int length) {
		try {
			if ((length >= 2) && (length <= Bytes.length)) {
				this.bLength = Bytes[0];
				this.bDescriptorType = Bytes[1];
				int len;
				if (Bytes.length < MAX_DESCRIPTOR_BUFFER_SIZE) {
					len = Bytes.length;
				} else {
					len = MAX_DESCRIPTOR_BUFFER_SIZE;
				}
				System.arraycopy(Bytes,0,this.ByteArray,0,len);
				this.Str = new String(this.ByteArray,2,length - 2,"UTF-16LE");
			}
		}
		catch (UnsupportedEncodingException ex) {
			System.out.println(ex);
		}
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -