예제 #1
0
 /**
  * デバイスの検出
  *
  * @param i_timeout_ms タイムアウトする時間[ms]
  * @return true:デバイスが存在
  * @throws MbedJsException MbedJS例外
  */
 public boolean isActive(int i_timeout_ms) throws MbedJsException {
   sleep_ms(ATP3011.AQTK_STARTUP_WAIT_MS);
   long start = System.currentTimeMillis();
   do {
     if (this._i2c.write(this._addr, new byte[] {0x00}, false) == 0) {
       this._last_call_in_msec = System.currentTimeMillis();
       return true;
     }
     sleep_ms(ATP3011.AQTK_POLL_WAIT_MS);
   } while (System.currentTimeMillis() - start < i_timeout_ms);
   return false;
 }
예제 #2
0
 /**
  * ビジー状態のチェック
  *
  * @return true:ビジー
  * @throws MbedJsException MbedJS例外
  */
 public boolean isBusy() throws MbedJsException {
   // 最終呼び出し時刻チェック
   long now = System.currentTimeMillis();
   if (now - this._last_call_in_msec < AQTK_POLL_WAIT_MS) {
     return true;
   }
   this._last_call_in_msec = now;
   // I2C通信
   I2C.ReadResult rr = this._i2c.read(_addr, 1, false);
   byte c = rr.data[0];
   if (c != 0) {
     return false;
   }
   return c == '*' || c == 0xff;
 }
예제 #3
0
 private void _initDevice() {
   this._last_call_in_msec = System.currentTimeMillis();
 }
예제 #4
0
 /**
  * コマンドの書き込み
  *
  * @param i_msg 書き込む文字列
  * @throws MbedJsException MbedJS例外
  */
 public void write(byte[] i_msg) throws MbedJsException {
   this._i2c.write(this._addr, i_msg, false);
   this._last_call_in_msec = System.currentTimeMillis();
 }