영어로 된 영어는 제 언어가 아닙니다.Java를 사용하여 연결 한 단일 USB 장치의 세부 정보 찾기
나는 학생이며 솔직히 말해서 프로젝트에 노력하고있다.
사용되는 언어는 JAVA이고 IDE는 일식입니다.
현재 저는 http://usb4java.org/에서 다운로드 한 프로젝트에 LIBUSB를 사용했습니다. 그것은 꽤 도움이되고 내 장치의 세부 정보 목록을 얻을 수있었습니다. 내 문제는 ... 단지 장치 004를 식별하고 싶다고 가정 해 보겠습니다. 이에 대한 제안이 있습니까? ? 나는 그것을 두 번 스캔 해보고 출력을 비교하려고했지만 주어진 데이터 유형으로 인해 실패했다. 일치하지 않는다. 처음에는 데이터 유형이 arraylist 일 수 있지만 그렇지 않다고 생각했습니다. 비교를 할 수 있도록 출력을 텍스트 파일에 저장하는 다른 방법이 있습니까?
libusb 예제 온라인에서 가져온 코드.
public class UsbBench {
/**
* Main method.
*
* @param args
* Command-line arguments (Ignored)
* @throws IOException
*/
public static void main(String[] args) throws IOException
{
// Create the libusb context
Context context = new Context();
// Initialize the libusb context
int result = LibUsb.init(context);
if (result < 0)
{
throw new LibUsbException("Unable to initialize libusb", result);
}
// Read the USB device list
DeviceList list = new DeviceList();
result = LibUsb.getDeviceList(context, list);
if (result < 0)
{
throw new LibUsbException("Unable to get device list", result);
}
try
{
// Iterate over all devices and list them
for (Device device: list)
{
int address = LibUsb.getDeviceAddress(device);
int busNumber = LibUsb.getBusNumber(device);
DeviceDescriptor descriptor = new DeviceDescriptor();
result = LibUsb.getDeviceDescriptor(device, descriptor);
if (result < 0)
{
throw new LibUsbException(
"Unable to read device descriptor", result);
}
}
}
finally
{
// Ensure the allocated device list is freed
LibUsb.freeDeviceList(list, true);
}
// Deinitialize the libusb context
LibUsb.exit(context);
}
}
그리고 그것은 또한 좋은 노력하고 있습니다. OUTPUT :
Bus 002, Device 003: Vendor 1bcf, Product 2c6e
Bus 001, Device 002: Vendor 06cb, Product 2970
Bus 001, Device 003: Vendor 0461, Product 4ded
Bus 001, Device 001: Vendor 8086, Product 8c31
Bus 002, Device 001: Vendor 8086, Product 8c26
Bus 002, Device 004: Vendor 04ca, Product 300b
Bus 002, Device 005: Vendor 8087, Product 8000
그래서 내 문제는 ... 어떤 제안이에 거기에 난 그냥 예를 들어 장치 004 에 대해 확인하기를 원하는 경우를 생각 해보자. ? 이것은 또한 stackoverflow 내 처음입니다. 겸손하게 당신의 전문성을 추구합니다. 감사. 감사.
"002 장치 002의 장치 식별"이란 무엇을 의미합니까? 그 장치가 실제로 무엇인지 알아 내려고한다는 뜻입니까? 공급 업체 및 제품 코드를 해석하는 방법을 묻는 중입니까? [USB ID 저장소] (http://www.linux-usb.org/usb-ids.html) –
[USB ID 데이터베이스] (http://www.the-sz.com/products/usbid/)를 사용해보십시오.) –
나는 무엇을 의미합니까? 나는 단 하나의 USB로 범위를 좁히려 고 모든 목록 대신에 나오길 원합니다. 코드를 개선하여 USB 장치를 감지 할 때 유연하게 사용할 수 있습니다. –