예제 #1
0
 private void uploadImage(InputStream fileinputstream, int buffer) throws X10FlashException {
   try {
     processHeader(fileinputstream);
     int readCount;
     do {
       if (buffer == 0x1000) readCount = fileinputstream.read(readarray4);
       else readCount = fileinputstream.read(readarray65);
       if (readCount > 0)
         if (buffer == 0x1000)
           cmd.send(
               Command.CMD06, BytesUtil.getReply(readarray4, readCount), (readCount == buffer));
         else
           cmd.send(
               Command.CMD06, BytesUtil.getReply(readarray65, readCount), (readCount == buffer));
       if (readCount != buffer) break;
     } while (true);
     fileinputstream.close();
     if (USBFlash.getLastFlags() == 0) getLastError();
   } catch (Exception e) {
     try {
       fileinputstream.close();
     } catch (Exception cl) {
     }
     throw new X10FlashException(e.getMessage());
   }
 }
예제 #2
0
 public void send(int cmd, byte data[], boolean ongoing) throws X10FlashException, IOException {
   writeCommand(cmd, data, ongoing);
   reply = USBFlash.getLastReply();
   if (USBFlash.getLastFlags() == 0) {
     writeCommand(Command.CMD07, Command.VALNULL, false);
     throw new X10FlashException(getLastReplyString());
   }
   while (isMultiPacketMessage()) {
     writeCommand(cmd, data, ongoing);
     reply = Bytes.concat(reply, USBFlash.getLastReply());
     if (USBFlash.getLastFlags() == 0) {
       writeCommand(Command.CMD07, Command.VALNULL, false);
       throw new X10FlashException(getLastReplyString());
     }
   }
   LogProgress.updateProgress();
 }
예제 #3
0
 private void processHeader(InputStream fileinputstream) throws X10FlashException {
   try {
     byte abyte0[] = new byte[6];
     int j = fileinputstream.read(abyte0);
     if (j != 6) {
       fileinputstream.close();
       throw new X10FlashException("Error in processHeader");
     }
     int k;
     byte abyte1[] = new byte[4];
     System.arraycopy(abyte0, 2, abyte1, 0, 4);
     k = BytesUtil.getInt(abyte1);
     abyte1 = new byte[k - 6];
     k = fileinputstream.read(abyte1);
     if (k != abyte1.length) {
       fileinputstream.close();
       throw new X10FlashException("Error in processHeader");
     }
     cmd.send(Command.CMD05, BytesUtil.concatAll(abyte0, abyte1), false);
     if (USBFlash.getLastFlags() == 0) getLastError();
   } catch (IOException ioe) {
     throw new X10FlashException("Error in processHeader : " + ioe.getMessage());
   }
 }
예제 #4
0
 public boolean isMultiPacketMessage() {
   return (USBFlash.getLastFlags() & 4) > 0;
 }