mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-22 11:23:34 +08:00
Added config macro UAVCAN_TOSTRING
This commit is contained in:
@@ -3,7 +3,6 @@
|
||||
* Copyright (C) 2014 Pavel Kirienko <pavel.kirienko@gmail.com>
|
||||
*/
|
||||
|
||||
#include <cstdio>
|
||||
#include <cassert>
|
||||
#include <uavcan/driver/can.hpp>
|
||||
|
||||
@@ -57,6 +56,7 @@ bool CanFrame::priorityHigherThan(const CanFrame& rhs) const
|
||||
return clean_id < rhs_clean_id;
|
||||
}
|
||||
|
||||
#if UAVCAN_TOSTRING
|
||||
std::string CanFrame::toString(StringRepresentation mode) const
|
||||
{
|
||||
using namespace std; // For snprintf()
|
||||
@@ -115,5 +115,6 @@ std::string CanFrame::toString(StringRepresentation mode) const
|
||||
}
|
||||
return std::string(buf);
|
||||
}
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
*/
|
||||
|
||||
#include <cassert>
|
||||
#include <string>
|
||||
#include <uavcan/marshal/bit_stream.hpp>
|
||||
#include <uavcan/transport/transfer_buffer.hpp>
|
||||
|
||||
@@ -73,6 +72,7 @@ int BitStream::read(uint8_t* bytes, const int bitlen)
|
||||
return ResultOk;
|
||||
}
|
||||
|
||||
#if UAVCAN_TOSTRING
|
||||
std::string BitStream::toString() const
|
||||
{
|
||||
std::string out;
|
||||
@@ -97,5 +97,6 @@ std::string BitStream::toString() const
|
||||
}
|
||||
return out;
|
||||
}
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
*/
|
||||
|
||||
#include <algorithm>
|
||||
#include <string>
|
||||
#include <cassert>
|
||||
#include <limits>
|
||||
#include <uavcan/transport/can_io.hpp>
|
||||
@@ -15,6 +14,7 @@ namespace uavcan
|
||||
/*
|
||||
* CanRxFrame
|
||||
*/
|
||||
#if UAVCAN_TOSTRING
|
||||
std::string CanRxFrame::toString(StringRepresentation mode) const
|
||||
{
|
||||
std::string out = CanFrame::toString(mode);
|
||||
@@ -25,6 +25,7 @@ std::string CanRxFrame::toString(StringRepresentation mode) const
|
||||
out += '0' + iface_index;
|
||||
return out;
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* CanTxQueue::Entry
|
||||
@@ -57,6 +58,7 @@ bool CanTxQueue::Entry::qosLowerThan(const CanFrame& rhs_frame, Qos rhs_qos) con
|
||||
return frame.priorityLowerThan(rhs_frame);
|
||||
}
|
||||
|
||||
#if UAVCAN_TOSTRING
|
||||
std::string CanTxQueue::Entry::toString() const
|
||||
{
|
||||
std::string str_qos;
|
||||
@@ -78,6 +80,7 @@ std::string CanTxQueue::Entry::toString() const
|
||||
}
|
||||
return str_qos + frame.toString();
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* CanTxQueue
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
*/
|
||||
|
||||
#include <cassert>
|
||||
#include <cstdio>
|
||||
#include <uavcan/transport/frame.hpp>
|
||||
#include <uavcan/transport/can_io.hpp>
|
||||
|
||||
@@ -194,6 +193,7 @@ bool Frame::operator==(const Frame& rhs) const
|
||||
std::equal(payload_, payload_ + payload_len_, rhs.payload_);
|
||||
}
|
||||
|
||||
#if UAVCAN_TOSTRING
|
||||
std::string Frame::toString() const
|
||||
{
|
||||
using namespace std; // For snprintf()
|
||||
@@ -223,6 +223,7 @@ std::string Frame::toString() const
|
||||
ofs += snprintf(buf + ofs, BUFLEN - ofs, "]");
|
||||
return std::string(buf);
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* RxFrame
|
||||
@@ -244,6 +245,7 @@ bool RxFrame::parse(const CanRxFrame& can_frame)
|
||||
return true;
|
||||
}
|
||||
|
||||
#if UAVCAN_TOSTRING
|
||||
std::string RxFrame::toString() const
|
||||
{
|
||||
std::string out = Frame::toString();
|
||||
@@ -254,5 +256,6 @@ std::string RxFrame::toString() const
|
||||
out += '0' + iface_index_;
|
||||
return out;
|
||||
}
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
* Copyright (C) 2014 Pavel Kirienko <pavel.kirienko@gmail.com>
|
||||
*/
|
||||
|
||||
#include <cstdio>
|
||||
#include <uavcan/transport/outgoing_transfer_registry.hpp>
|
||||
|
||||
namespace uavcan
|
||||
@@ -10,6 +9,7 @@ namespace uavcan
|
||||
/*
|
||||
* OutgoingTransferRegistryKey
|
||||
*/
|
||||
#if UAVCAN_TOSTRING
|
||||
std::string OutgoingTransferRegistryKey::toString() const
|
||||
{
|
||||
using namespace std;
|
||||
@@ -18,5 +18,6 @@ std::string OutgoingTransferRegistryKey::toString() const
|
||||
int(data_type_id_.get()), int(transfer_type_), int(destination_node_id_.get()));
|
||||
return std::string(buf);
|
||||
}
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
*/
|
||||
|
||||
#include <cassert>
|
||||
#include <cstdio>
|
||||
#include <uavcan/transport/frame.hpp>
|
||||
#include <uavcan/transport/can_io.hpp>
|
||||
|
||||
|
||||
@@ -4,8 +4,6 @@
|
||||
|
||||
#include <cassert>
|
||||
#include <cstdlib>
|
||||
#include <cstdio>
|
||||
#include <string>
|
||||
#include <uavcan/transport/transfer_buffer.hpp>
|
||||
|
||||
namespace uavcan
|
||||
@@ -13,6 +11,7 @@ namespace uavcan
|
||||
/*
|
||||
* TransferBufferManagerKey
|
||||
*/
|
||||
#if UAVCAN_TOSTRING
|
||||
std::string TransferBufferManagerKey::toString() const
|
||||
{
|
||||
using namespace std; // For snprintf()
|
||||
@@ -20,6 +19,7 @@ std::string TransferBufferManagerKey::toString() const
|
||||
snprintf(buf, sizeof(buf), "nid=%i tt=%i", int(node_id_.get()), int(transfer_type_));
|
||||
return std::string(buf);
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* DynamicTransferBuffer::Block
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
*/
|
||||
|
||||
#include <cstdlib>
|
||||
#include <cstdio>
|
||||
#include <cassert>
|
||||
#include <algorithm>
|
||||
#include <uavcan/debug.hpp>
|
||||
|
||||
@@ -3,8 +3,6 @@
|
||||
*/
|
||||
|
||||
#include <cstring>
|
||||
#include <cstdio>
|
||||
#include <string>
|
||||
#include <cassert>
|
||||
#include <uavcan/data_type.hpp>
|
||||
#include <uavcan/transport/crc.hpp>
|
||||
@@ -54,6 +52,7 @@ bool DataTypeDescriptor::match(DataTypeKind kind, DataTypeID id) const
|
||||
return (kind_ == kind) && (id_ == id);
|
||||
}
|
||||
|
||||
#if UAVCAN_TOSTRING
|
||||
std::string DataTypeDescriptor::toString() const
|
||||
{
|
||||
char kindch = '?';
|
||||
@@ -80,6 +79,7 @@ std::string DataTypeDescriptor::toString() const
|
||||
static_cast<unsigned long long>(signature_.get()));
|
||||
return std::string(buf);
|
||||
}
|
||||
#endif
|
||||
|
||||
bool DataTypeDescriptor::operator==(const DataTypeDescriptor& rhs) const
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user