Ejemplo n.º 1
0
      bool
      getMonitors(void)
      {
        UCTK::Frame frame;
        frame.setId(PKT_ID_STATE);

        if (!m_ctl->sendFrame(frame))
          return false;

        if (frame.getPayloadSize() != 6)
          return false;

        // MCU Voltage.
        uint16_t tmp_u16 = 0;
        frame.get(tmp_u16, 0);
        IMC::Voltage v;
        v.value = tmp_u16 / 1000.0;
        m_mcu_ent->dispatch(v);

        // Voltage.
        frame.get(tmp_u16, 2);
        m_voltage.value = tmp_u16 / 1000.0;
        dispatch(m_voltage);

        // Current.
        frame.get(tmp_u16, 4);
        m_current.value = tmp_u16 / 1000.0;
        dispatch(m_current);

        m_wdog.reset();
        return true;
      }
Ejemplo n.º 2
0
      void
      Interface::getFirmwareName(FirmwareInfo& info)
      {
        UCTK::Frame frame;
        frame.setId(PKT_ID_NAME);
        frame.setPayloadSize(0);

        if (!sendFrame(frame))
          throw std::runtime_error(DTR("failed to get firmware name"));

        info.name.assign((const char*)frame.getPayload(), frame.getPayloadSize());
      }
Ejemplo n.º 3
0
      void
      Interface::getFirmwareVersion(FirmwareInfo& info)
      {
        UCTK::Frame frame;
        frame.setId(PKT_ID_VERSION);
        frame.setPayloadSize(0);

        if (!sendFrame(frame))
          throw std::runtime_error(DTR("failed to get firmware version"));

        if (frame.getPayloadSize() != 3)
          throw std::runtime_error(DTR("invalid firmware version"));

        frame.get(info.major, 0);
        frame.get(info.minor, 1);
        frame.get(info.patch, 2);
      }
Ejemplo n.º 4
0
      bool
      getConstantParameters(void)
      {
        UCTK::Frame frame;
        frame.setId(PKT_ID_PARAMS);
        if (!m_ctl->sendFrame(frame))
          return false;

        if (frame.getPayloadSize() != 4)
          return false;

        frame.get(m_min_dur, 0);
        frame.get(m_max_dur, 2);

        m_dif_dur = m_max_dur - m_min_dur;

        return true;
      }