コード例 #1
0
ファイル: event_tracer.hpp プロジェクト: BillTian/uavcan
 virtual void onEvent(uavcan::dynamic_node_id_server::TraceCode code, uavcan::int64_t argument)
 {
     const uavcan::MonotonicDuration ts = SystemClockDriver().getMonotonic() - startup_ts_;
     std::cout << "EVENT [" << id_ << "]\t" << ts.toString() << "\t"
               << code << "\t" << getEventName(code) << "\t" << argument << std::endl;
     event_log_.push_back(EventLogEntry(code, argument));
 }
コード例 #2
0
void NodeStatusProvider::setStatusPublishingPeriod(uavcan::MonotonicDuration period)
{
    const MonotonicDuration maximum = MonotonicDuration::fromMSec(protocol::NodeStatus::MAX_PUBLICATION_PERIOD_MS);
    const MonotonicDuration minimum = MonotonicDuration::fromMSec(protocol::NodeStatus::MIN_PUBLICATION_PERIOD_MS);

    period = min(period, maximum);
    period = max(period, minimum);
    TimerBase::startPeriodic(period);

    const MonotonicDuration tx_timeout = period - MonotonicDuration::fromUSec(period.toUSec() / 20);
    node_status_pub_.setTxTimeout(tx_timeout);

    UAVCAN_TRACE("NodeStatusProvider", "Status pub period: %s, TX timeout: %s",
                 period.toString().c_str(), node_status_pub_.getTxTimeout().toString().c_str());
}