예제 #1
0
 // Bootloader messages are initially created long enough for
 // the message and checksum. The message is then framed with control
 // characters before being returned
 public static QsiMessage getReadBootVersion() {
   QsiMessage m = new QsiMessage(3);
   m.setOpCode(RD_VER);
   m.setLength(2);
   m.setChecksum();
   return m.frame();
 }
예제 #2
0
 public static QsiMessage getReset() {
   QsiMessage m = new QsiMessage(3);
   m.setOpCode(0);
   m.setLength(0);
   m.setChecksum();
   return m.frame();
 }
예제 #3
0
 public static QsiMessage getClearStatus() {
   // OP_REQ_CLEAR_ERROR_STATUS
   QsiMessage m = new QsiMessage(3);
   m.setElement(0, 17);
   m.setElement(1, 0);
   m.setElement(2, 0);
   return m;
 }
예제 #4
0
 public static QsiMessage getReadCV(int cv, ProgrammingMode mode) {
   // OP_REQ_READ_CV
   QsiMessage m = new QsiMessage(4);
   m.setElement(0, 9);
   m.setElement(1, 1);
   m.setElement(2, 0);
   m.setElement(3, cv);
   return m;
 }
예제 #5
0
 public static QsiMessage getWriteCV(int cv, int val, ProgrammingMode mode) {
   // OP_REQ_WRITE_CV
   QsiMessage m = new QsiMessage(5);
   m.setElement(0, 30);
   m.setElement(1, 2);
   m.setElement(2, 0);
   m.setElement(3, cv);
   m.setElement(4, val);
   return m;
 }
예제 #6
0
 // [AC] 11/09/2002 QSI doesn't currently support registered mode
 public static QsiMessage getReadRegister(int reg) { // Vx
   //        if (reg>8) log.error("register number too large: "+reg);
   //        QsiMessage m = new QsiMessage(2);
   //        m.setOpCode('V');
   //        String s = ""+reg;
   //        m.setElement(1, s.charAt(s.length()-1));
   //        return m;
   QsiMessage m = new QsiMessage(1);
   m.setOpCode(' ');
   return m;
 }
예제 #7
0
 public static QsiMessage getWriteRegister(int reg, int val) { // Sx xx
   //        if (reg>8) log.error("register number too large: "+reg);
   //        QsiMessage m = new QsiMessage(4);
   //        m.setOpCode('S');
   //        String s = ""+reg;
   //        m.setElement(1, s.charAt(s.length()-1));
   //        addIntAsTwoHex(val, m, 2);
   //        return m;
   QsiMessage m = new QsiMessage(1);
   m.setOpCode(' ');
   return m;
 }
예제 #8
0
 public QsiMessage v4frame() {
   int i = 0;
   // Create new message to hold the framed one
   QsiMessage f = new QsiMessage(MAXSIZE);
   f.setElement(0, ':');
   // copy existing message adding CRLF
   for (i = 1; i <= _nDataChars; i++) {
     f.setElement(i, _dataChars[i - 1]);
   }
   f.setElement(i++, CR);
   f.setElement(i++, LF);
   f._nDataChars = i;
   // return new message
   return f;
 }
예제 #9
0
 public static QsiMessage getWriteEE(int addr, int[] data) {
   QsiMessage m = new QsiMessage(6 + data.length);
   m.setOpCode(WT_EEDATA);
   m.setLength(data.length);
   m.setAddress(addr & 0xff);
   m.setData(data);
   m.setChecksum();
   return m.frame();
 }
예제 #10
0
 public static QsiMessage getv4ExtAddr() {
   // Create a v4 bootloader extended address message
   int l = 14;
   int[] data = {0, 0};
   QsiMessage m = new QsiMessage(l);
   m.setV4Length(2);
   m.setV4Address(0);
   m.setV4RecType(4);
   m.setV4Data(data);
   m.setV4Checksum(0, 0, 4, data);
   return m.v4frame();
 }
예제 #11
0
 public static QsiMessage getV4WriteFlash(int addr, int[] data, int type) {
   // Create a v4 bootloader message which is same format as a record
   // in the hex file
   int l = (data.length + 5) * 2;
   QsiMessage m = new QsiMessage(l);
   m.setV4Length(data.length);
   m.setV4Address(addr);
   m.setV4RecType(type);
   m.setV4Data(data);
   m.setV4Checksum(data.length, addr, type, data);
   return m.v4frame();
 }
예제 #12
0
 public static QsiMessage getEraseFlash(int addr, int rows) {
   QsiMessage m = new QsiMessage(6);
   m.setOpCode(ER_FLASH);
   // Erase a number of 64 byte rows
   m.setLength(rows);
   m.setAddress(addr);
   m.setChecksum();
   return m.frame();
 }
예제 #13
0
 public static QsiMessage getV4EndOfFile() {
   // Create a v4 bootloader end of file message
   int l = 10;
   QsiMessage m = new QsiMessage(l);
   m.setV4Length(0);
   m.setV4Address(0);
   m.setV4RecType(1);
   m.setV4Checksum(0, 0, 1, new int[0]);
   return m.v4frame();
 }
예제 #14
0
 public QsiMessage frame() {
   int j = 2;
   // Create new message to hold the framed one
   QsiMessage f = new QsiMessage(MAXSIZE);
   f.setElement(0, STX);
   f.setElement(1, STX);
   // copy existing message adding DLE
   for (int i = 0; i < _nDataChars; i++) {
     if (_dataChars[i] == STX || _dataChars[i] == ETX || _dataChars[i] == DLE) {
       f.setElement(j++, DLE);
     }
     f.setElement(j++, _dataChars[i]);
   }
   f.setElement(j++, ETX);
   f._nDataChars = j;
   // return new message
   return f;
 }
예제 #15
0
 public static QsiMessage getWriteFlash(int addr, int[] data) {
   int l = data.length;
   // Writes are rounded up to multiples of 8 bytes
   if (l % 8 != 0) {
     l = l + (8 - l % 8);
   }
   // and data padded with erased condition
   int padded[] = new int[l];
   for (int i = 0; i < l; i++) {
     if (i < data.length) {
       padded[i] = data[i];
     } else {
       padded[i] = 0xff;
     }
   }
   QsiMessage m = new QsiMessage(6 + l);
   m.setOpCode(WT_FLASH);
   // length is number of 8 byte blocks
   m.setLength(l / 8);
   m.setAddress(addr);
   m.setData(padded);
   m.setChecksum();
   return m.frame();
 }
예제 #16
0
 // static methods to return a formatted message
 public static QsiMessage getEnableMain() {
   QsiMessage m = new QsiMessage(1);
   m.setOpCode('+');
   return m;
 }
예제 #17
0
 public static QsiMessage getKillMain() {
   QsiMessage m = new QsiMessage(1);
   m.setOpCode('-');
   return m;
 }
예제 #18
0
 // [AC] 11/09/2002 Leave QSI in programmer mode. Don't want to go
 // to booster mode as this would power up the track.
 public static QsiMessage getExitProgMode() {
   QsiMessage m = new QsiMessage(1);
   m.setOpCode(' ');
   return m;
 }