예제 #1
0
void VerifySticker::runTest()
{
    QProcess avrdude;

    emit testMessage(testName(), infoMessage, stickerNum, 
            QString("Verifying sticker ") + QString::number(stickerNum));

    selectSticker(stickerNum);

    avrdude.start("./avrdude", QStringList()
            << "-C" << configFile
            << "-c" << "linuxgpio"
            << "-P" << "linuxgpio"
            << "-p" << partName
            << "-U" << (QString("flash:v:") + firmwareFile)
    );
    if (!avrdude.waitForStarted()) {
        testError("Unable to start avrdude");
        return;
    }

    avrdude.closeWriteChannel();
    if (!avrdude.waitForFinished()) {
        testError("avrdude never finished");
        return;
    }

    if (avrdude.exitCode()) {
        testError(QString("Failed to verify"));
        return;
    }
    emit testMessage(testName(), testPass, stickerNum, "Test passed");
}
예제 #2
0
TEST_F(ProtocolTest, testProtocols)
{
	testSharedMessages();
	testMessage(AutoSolveStartedMessage());
	testMessage(AutoSolveAbortedMessage());
	testMessage(UndoMessage());
}
예제 #3
0
void SetStickerFuse::runTest()
{
    QProcess avrdude;

    emit testMessage(testName(), infoMessage, stickerNum, 
            QString("Setting fuse ") + fuseName 
            + " to 0x" + QString::number(fuseValue, 16));

    selectSticker(stickerNum);

    avrdude.start("./avrdude", QStringList()
            << "-C" << configFile
            << "-c" << "linuxgpio"
            << "-P" << "linuxgpio"
            << "-p" << partName
            << "-U" << (QString() 
                  + fuseName + ":w:0x" + QString::number(fuseValue, 16) + ":m")
    );
    if (!avrdude.waitForStarted()) {
        testError("Unable to start avrdude");
        return;
    }

    avrdude.closeWriteChannel();
    if (!avrdude.waitForFinished()) {
        testError("avrdude never finished");
        return;
    }

    if (avrdude.exitCode()) {
        testError(QString("avrdude returned an error: ") + avrdude.readAll());
        return;
    }
}
예제 #4
0
void Test::sendChannels(uint16_t channel1, uint16_t channel2)
{
    m_channels.chan1_raw = channel1;
    m_channels.chan2_raw = channel2;

    mavlink_message_t buf;
    mavlink_msg_rc_channels_encode(SYSTEM_ID, COMPONENT_ID, &buf, &m_channels);
    testMessage(buf);
}
예제 #5
0
void Test::sendStatusText(MAV_SEVERITY severity, const char* text)
{
    mavlink_statustext_t msg;
    memcpy(msg.text, text, 50);
    msg.severity = severity;

    mavlink_message_t buf;
    mavlink_msg_statustext_encode(SYSTEM_ID, COMPONENT_ID, &buf, &msg);
    testMessage(buf);
}
예제 #6
0
TEST_F(ProtocolTest, testProtocols)
{
	testSharedMessages();
	testMessage(AddCaveMessage(1, false));
	testMessage(AddRopeMessage(1, 2));
	testMessage(LightStateMessage(1, false));
	testMessage(RemoveRopeMessage(1));
	testMessage(UpdateCollectedTypeMessage(EntityType::NONE, false));
	testMessage(WaterHeightMessage(1.0f));
	testMessage(WaterImpactMessage(1.0f, 1.0f));
	testMessage(DropMessage());
}
예제 #7
0
void Test::sendCurrentPosition(float lattitude, float longtitude, float altitude)
{
    mavlink_gps_raw_int_t msg;
    msg.lat = (int32_t)(lattitude * 1e7);
    msg.lon = (int32_t)(longtitude * 1e7);
    msg.alt = (int32_t)(altitude * 1000);

    mavlink_message_t buf;
    mavlink_msg_gps_raw_int_encode(SYSTEM_ID, COMPONENT_ID, &buf, &msg);
    testMessage(buf);
}
예제 #8
0
void Test::sendHomePosition(float lattitude, float longtitude, float altitude)
{
    mavlink_home_position_t msg;
    msg.latitude = (int32_t)(lattitude * 1e7);
    msg.longitude = (int32_t)(longtitude * 1e7);
    msg.altitude = (int32_t)(altitude * 1000);

    mavlink_message_t buf;
    mavlink_msg_home_position_encode(SYSTEM_ID, COMPONENT_ID, &buf, &msg);
    testMessage(buf);
}
예제 #9
0
void Test::sendParameter(const char* parameterId, float value)
{
    mavlink_param_value_t msg;
    msg.param_count = 1;
    strcpy(msg.param_id, parameterId);
    msg.param_index = -1;
    msg.param_value = value;

    mavlink_message_t buf;
    mavlink_msg_param_value_encode(SYSTEM_ID, COMPONENT_ID, &buf, &msg);
    testMessage(buf);
}
예제 #10
0
void Test::sendEkfStatusReport(float ekfVariance)
{
    mavlink_ekf_status_report_t msg;
    msg.compass_variance = ekfVariance;
    msg.pos_horiz_variance = ekfVariance;
    msg.pos_vert_variance = ekfVariance;
    msg.terrain_alt_variance = ekfVariance;
    msg.velocity_variance = ekfVariance;

    mavlink_message_t buf;
    mavlink_msg_ekf_status_report_encode(SYSTEM_ID, COMPONENT_ID, &buf, &msg);
    testMessage(buf);
}
예제 #11
0
void Test::sendSystemStatus(uint8_t batteryPercentage, float batteryVoltage)
{
    mavlink_sys_status_t msg;
    msg.battery_remaining = batteryPercentage;
    msg.voltage_battery = (uint16_t)(batteryVoltage * 1000);
    msg.onboard_control_sensors_present = MAV_SYS_STATUS_SENSOR_3D_MAG | MAV_SYS_STATUS_SENSOR_3D_GYRO;
    msg.onboard_control_sensors_enabled = MAV_SYS_STATUS_SENSOR_3D_MAG | MAV_SYS_STATUS_SENSOR_3D_GYRO;
    msg.onboard_control_sensors_health = MAV_SYS_STATUS_SENSOR_3D_MAG;

    mavlink_message_t buf;
    mavlink_msg_sys_status_encode(SYSTEM_ID, COMPONENT_ID, &buf, &msg);
    testMessage(buf);
}
예제 #12
0
void Test::sendVfrHud(float groundSpeed, int16_t heading, int16_t throttle, float climbRate)
{
    mavlink_vfr_hud_t msg;
    msg.airspeed = 0;
    msg.alt = 0;
    msg.climb = climbRate;
    msg.groundspeed = groundSpeed;
    msg.heading = heading;
    msg.throttle = throttle;

    mavlink_message_t buf;
    mavlink_msg_vfr_hud_encode(SYSTEM_ID, COMPONENT_ID, &buf, &msg);
    testMessage(buf);
}
예제 #13
0
int main(int argc, char **argv)
{
    try
    {
        std::string cmd;
        std::string testMessage("Scream!");

        if (argc > 1)
            cmd = std::string(argv[1]);
        else
            cmd = "echo " + testMessage;

        io::PipeStream ps(cmd);

        io::StandardOutStream stdo;
        size_t ioSize = ps.streamTo(stdo);
        stdo.close();

        // check echo output size vs test message size plus newline
        if (argc == 1 && ioSize != testMessage.size() + 1)
            std::cerr << "Invalid I/O size:  " << ioSize << std::endl;

        if (ps.close() != 0)
        {
            std::cout << "Child Process Successful but Internally Failed!" << 
                std::endl;
        }
        else
        {
            std::cout << "Child Process Successful!" << std::endl;
        }
    }
    catch (const except::Throwable& ex)
    {
        std::cerr << "Caught C++ exception: " << 
            ex.getMessage() << std::endl;
    }
    catch (const std::exception& ex)
    {
        std::cerr << "Caught standard exception from " << 
            ex.what() << std::endl;
    }
    catch (...)
    {
        std::cerr << "Caught unnamed Unwanted exception" << std::endl;
    }

    return 0;
}
예제 #14
0
void Test::sendHearbeat(bool armed, MAV_STATE state)
{
    mavlink_heartbeat_t hearbeat;
    hearbeat.autopilot = MAV_AUTOPILOT_ARDUPILOTMEGA;
    hearbeat.base_mode = 0;
    if (armed)
    {
        hearbeat.base_mode |= MAV_MODE_FLAG_SAFETY_ARMED;
    }

    hearbeat.custom_mode = Aircraft::CustomMode_PositionHold;
    hearbeat.mavlink_version = 1;
    hearbeat.system_status = state;
    hearbeat.type = MAV_TYPE_QUADROTOR;
//    hearbeat.type = MAV_TYPE_GCS;

    mavlink_message_t buf;
    mavlink_msg_heartbeat_encode(SYSTEM_ID, COMPONENT_ID, &buf, &hearbeat);
    testMessage(buf);
}
예제 #15
0
파일: node.cpp 프로젝트: sawrubh/ghs
void Node::readMessage() {
  if (!this->messages.empty()) {
    pthread_mutex_lock(&(this->mutex));
    message msg = this->messages.front();
    this->messages.pop();
    int i;
    for (i = 0; i < this->numEdges; ++i) {
      if (this->edges[i].weight == msg.weight)
        break;
    }
    pthread_mutex_unlock(&(this->mutex));
    if(this->state == 0)
      this->wakeup();

    switch(msg.id) {
      case 0:
        connect(msg.args[0], i);
        break;
      case 1:
        initiate(msg.args[0], msg.args[1], msg.args[2], i);
        break;
      case 2:
        testMessage(msg.args[0], msg.args[1], i);
        break;
      case 3:
        accept(i);
        break;
      case 4:
        reject(i);
        break;
      case 5:
        reportMessage(msg.args[0], i);
        break;
      case 6:
        changeRootMessage(i);
        break;
      case 7:
        this->wakeup();
    }
  }
}
예제 #16
0
void ChibiTest::selectSticker(int stickerNum)
{
    QProcess s;

    emit testMessage(testName(), setStickerNum, stickerNum, "");

    if (stickerNum > 4)
        return;

    s.start("./select_sticker", QStringList() << QString::number(stickerNum));

    if (!s.waitForStarted()) {
        testError("Unable to select sticker");
        return;
    }

    s.closeWriteChannel();
    s.waitForFinished();
    if (s.exitCode()) {
        testError(QString("select_sticker returned an error: ") + s.readAll());
        return;
    }
}
예제 #17
0
void ChibiTest::testDebug(const QString string)
{
    emit testMessage(testName(), debugMessage, 0, string);
}
예제 #18
0
void ChibiTest::testError(const QString string)
{
    emit testMessage(testName(), errorMessage, 0, string);
}
예제 #19
0
void ChibiTest::testInfo(const QString string)
{
    emit testMessage(testName(), infoMessage, 0, string);
}