コード例 #1
0
ファイル: JUsb.java プロジェクト: krwlive1/Flashtool
 public static void writeBytes(byte[] towrite) throws Exception {
   ByteArrayInputStream in = new ByteArrayInputStream(towrite);
   boolean hasData = true;
   int loop = 0;
   while (hasData) {
     try {
       int read = in.read(data);
       if (read > 0) {
         dev.bulk_write(0x01, BytesUtil.getReply(data, read), 0);
       } else hasData = false;
     } catch (LibUsbTimeoutException e) {
       // TODO Auto-generated catch block
       e.printStackTrace();
     } catch (LibUsbPipeException e) {
       // TODO Auto-generated catch block
       e.printStackTrace();
     } catch (LibUsbNoDeviceException e) {
       // TODO Auto-generated catch block
       e.printStackTrace();
     } catch (LibUsbTransmissionException e) {
       // TODO Auto-generated catch block
       e.printStackTrace();
     } catch (LibUsbOtherException e) {
       // TODO Auto-generated catch block
       e.printStackTrace();
     }
   }
   in.close();
 }
コード例 #2
0
ファイル: JUsb.java プロジェクト: krwlive1/Flashtool
 private static UsbDevice getDevice() {
   UsbDevice device = null;
   ArrayList<UsbDevice> devices = new ArrayList<UsbDevice>();
   try {
     devices = (ArrayList<UsbDevice>) us.visitUsbDevices(new VendorProductVisitor(0xfce));
   } catch (LibUsbNoDeviceException e) {
     // TODO Auto-generated catch block
     e.printStackTrace();
   } catch (LibUsbPermissionException e) {
     // TODO Auto-generated catch block
     e.printStackTrace();
   } catch (LibUsbOtherException e) {
     // TODO Auto-generated catch block
     e.printStackTrace();
   }
   if (devices.size() > 0) {
     device = devices.get(0);
   }
   return device;
 }