reduce footprint with KNX_NO_PRINT

This commit is contained in:
Thomas Kunze 2024-08-19 18:07:27 +02:00
parent 546300d705
commit 9294257985
34 changed files with 61 additions and 36 deletions

View File

@ -14,6 +14,7 @@ namespace py = pybind11;
#include <vector>
#include <algorithm>
#include "knx/bits.h"
#include "knx/platform/linux_platform.h"
#include "knx/bau57B0.h"
#include "knx/group_object_table_object.h"

View File

@ -1,9 +1,9 @@
#include <cstring>
#include "address_table_object.h"
#include "bits.h"
#include "data_property.h"
#include "util/logger.h"
#include "bits.h"
#define LOGGER Logger::logger("AddressTableObject")

View File

@ -42,6 +42,7 @@ uint8_t APDU::length() const
string APDU::toString() const
{
#ifndef KNX_NO_PRINT
string value = "APDU: " + enum_name(type()) + " ";
value += byte2hex(_data[0] & 0x3);
@ -54,4 +55,7 @@ string APDU::toString() const
}
return value;
#else
return "";
#endif
}

View File

@ -5,9 +5,10 @@
#include "apdu.h"
#include "bau.h"
#include "string.h"
#include "bits.h"
#include <stdio.h>
#include "util/logger.h"
#include "bits.h"
#define LOGGER Logger::logger("ApplicationLayer")
const SecurityControl ApplicationLayer::noSecurity

View File

@ -1,10 +1,10 @@
#include "application_program_object.h"
#include "bits.h"
#include "data_property.h"
#include "callback_property.h"
#include "dptconvert.h"
#include <cstring>
#include "util/logger.h"
#include "bits.h"
#define LOGGER Logger::logger("ApplicationProgramObject")

View File

@ -1,8 +1,13 @@
#pragma once
#include "table_object.h"
#include "bits.h"
enum ParameterFloatEncodings
{
Float_Enc_DPT9 = 0, // 2 Byte. See Chapter 3.7.2 section 3.10 (Datapoint Types 2-Octet Float Value)
Float_Enc_IEEE754Single = 1, // 4 Byte. C++ float
Float_Enc_IEEE754Double = 2, // 8 Byte. C++ double
};
class ApplicationProgramObject : public TableObject
{
public:

View File

@ -1,9 +1,9 @@
#include <cstring>
#include "association_table_object.h"
#include "bits.h"
#include "data_property.h"
#include "util/logger.h"
#include "bits.h"
#define LOGGER Logger::logger("AssociationTableObject")

View File

@ -8,7 +8,7 @@ const uint8_t* popByte(uint8_t& b, const uint8_t* data)
return data;
}
#ifndef KNX_NO_PRINT
std::string byte2hex(const uint8_t byte)
{
const char* hex = "0123456789ABCDEF";
@ -33,7 +33,6 @@ std::string array2hex(const uint8_t* value, size_t length)
return result;
}
#ifndef KNX_NO_PRINT
void printHex(const char* suffix, const uint8_t* data, size_t length, bool newline)
{
print(suffix);

View File

@ -70,11 +70,10 @@
void attachInterrupt(uint32_t pin, voidFuncPtr callback, uint32_t mode);
#endif
#ifndef KNX_NO_PRINT
std::string byte2hex(const uint8_t byte);
std::string word2hex(const uint16_t value);
std::string array2hex(const uint8_t* value, size_t length);
#ifndef KNX_NO_PRINT
void print(const char[]);
void print(char);
void print(unsigned char, int = DEC);
@ -103,6 +102,10 @@
#define print(...) do {} while(0)
#define println(...) do {} while(0)
#define printHex(...) do {} while(0)
#define byte2hex(...) ""
#define word2hex(...) ""
#define array2hex(...) ""
#define enum_name(...) ""
#endif
#ifdef KNX_ACTIVITYCALLBACK
@ -130,14 +133,6 @@ uint64_t sixBytesToUInt64(uint8_t* data);
uint16_t crc16Ccitt(uint8_t* input, uint16_t length);
uint16_t crc16Dnp(uint8_t* input, uint16_t length);
enum ParameterFloatEncodings
{
Float_Enc_DPT9 = 0, // 2 Byte. See Chapter 3.7.2 section 3.10 (Datapoint Types 2-Octet Float Value)
Float_Enc_IEEE754Single = 1, // 4 Byte. C++ float
Float_Enc_IEEE754Double = 2, // 8 Byte. C++ double
};
#if defined(ARDUINO_ARCH_SAMD)
// temporary undef until framework-arduino-samd > 1.8.9 is released. See https://github.com/arduino/ArduinoCore-samd/pull/399 for a PR should will probably address this
#undef max

View File

@ -402,6 +402,7 @@ bool CemiFrame::valid() const
std::string CemiFrame::toString() const
{
#ifndef KNX_NO_PRINT
std::string value = "DPDU:" + enum_name(frameType()) + " ";
value += enum_name(systemBroadcast()) + " ";
value += enum_name(ack()) + " ";
@ -416,4 +417,7 @@ std::string CemiFrame::toString() const
value += format_ga(destinationAddress());
return value;
#else
return "";
#endif
}

View File

@ -1,11 +1,11 @@
#include "data_link_layer.h"
#include "bits.h"
#include "platform.h"
#include "device_object.h"
#include "cemi_server.h"
#include "cemi_frame.h"
#include "util/logger.h"
#include "bits.h"
#define LOGGER Logger::logger("DataLinkLayer")

View File

@ -1,8 +1,8 @@
#include "group_object.h"
#include "bits.h"
#include "string.h"
#include "datapoint_types.h"
#include "group_object_table_object.h"
#include "bits.h"
#ifdef SMALL_GROUPOBJECT
GroupObjectUpdatedHandler GroupObject::_updateHandlerStatic = 0;

View File

@ -2,9 +2,9 @@
#include "group_object_table_object.h"
#include "group_object.h"
#include "bits.h"
#include "data_property.h"
#include "util/logger.h"
#include "bits.h"
#define LOGGER Logger::logger("GroupObjectTableObject")

View File

@ -2,6 +2,7 @@
#include "interface_object.h"
#include "data_property.h"
#include "bits.h"
InterfaceObject::~InterfaceObject()
{

View File

@ -4,7 +4,6 @@
#include "property.h"
#include "save_restore.h"
#include "knx_types.h"
#include "bits.h"
/** Enum for the type of an interface object. See Section 2.2 of knx:3/7/3 */
enum ObjectType

View File

@ -1,4 +1,5 @@
#include "knx_ip_config_dib.h"
#include "../bits.h"
KnxIpConfigDIB::KnxIpConfigDIB(uint8_t* data, bool isCurrent) : KnxIpDIB(data)
{

View File

@ -1,6 +1,5 @@
#pragma once
#include "knx_ip_dib.h"
#include "../bits.h"
#define LEN_IP_CONFIG_DIB 16
#define LEN_IP_CURRENT_CONFIG_DIB 20

View File

@ -1,4 +1,5 @@
#include "knx_ip_knx_addresses_dib.h"
#include "../bits.h"
KnxIpKnxAddressesDIB::KnxIpKnxAddressesDIB(uint8_t* data) : KnxIpDIB(data)
{

View File

@ -1,6 +1,5 @@
#pragma once
#include "knx_ip_dib.h"
#include "../bits.h"
class KnxIpKnxAddressesDIB : public KnxIpDIB
{

View File

@ -1,6 +1,8 @@
#include "knx_ip_search_response_extended.h"
#include "service_families.h"
#include "../bits.h"
#define LEN_SERVICE_FAMILIES 2
#if MASK_VERSION == 0x091A
#ifdef KNX_TUNNELING

View File

@ -1,6 +1,5 @@
#pragma once
#include "../platform.h"
#include "../bits.h"
class KnxIpTunnelConnection
{

View File

@ -1,6 +1,8 @@
#include "knx_ip_tunneling_info_dib.h"
#include "service_families.h"
#include "../bits.h"
KnxIpTunnelingInfoDIB::KnxIpTunnelingInfoDIB(uint8_t* data) : KnxIpDIB(data)
{
currentPos = data + 4;

View File

@ -1,6 +1,5 @@
#pragma once
#include "knx_ip_dib.h"
#include "../bits.h"
#include "service_families.h"
class KnxIpTunnelingInfoDIB : public KnxIpDIB

View File

@ -1,5 +1,5 @@
#include "knx_types.h"
#ifndef KNX_NO_PRINT
const string enum_name(const LCCONFIG enum_val)
{
switch (enum_val)
@ -700,3 +700,4 @@ const string format_ga(uint16_t ga)
{
return to_string(ga & 0xF800 >> 23) + "/" + to_string(ga & 0x70 >> 16) + "/" + to_string(ga & 0x00FF);
}
#endif

View File

@ -2,8 +2,8 @@
#include "device_object.h"
#include "tpdu.h"
#include "cemi_frame.h"
#include "bits.h"
#include "util/logger.h"
#include "bits.h"
#define LOGGER Logger::logger("NetworkLayerDevice")

View File

@ -390,6 +390,11 @@ void println(unsigned int num, int base)
println();
}
void print(double num)
{
printf("%f", num);
}
void println(long num, int base)
{
print(num, base);
@ -527,7 +532,7 @@ uint8_t* CC1310Platform::getEepromBuffer(uint32_t size)
NVS_read(nvsHandle, 0, (void*) NVS_buffer, size);
for (int i = 0; i < size; i++)
for (uint32_t i = 0; i < size; i++)
{
if (NVS_buffer[i] != 0)
{

View File

@ -244,7 +244,7 @@ void Property::state(uint8_t* data, uint8_t length, uint8_t* resultData, uint8_t
(void)resultData;
resultLength = 0;
}
#ifndef KNX_NO_PRINT
const string enum_name(const PropertyDataType enum_val)
{
switch (enum_val)
@ -863,3 +863,4 @@ const string enum_name(const AccessLevel enum_val)
return to_string(enum_val);
}
#endif

View File

@ -4,7 +4,6 @@
#include <stdint.h>
#include "knx_types.h"
#include "apdu.h"
#include "bits.h"
#include "util/simple_map.h"
class DeviceObject;
@ -74,7 +73,6 @@ class SecureApplicationLayer : public ApplicationLayer
{
if ((cmpAddr.addrType == AddrType::unknown) || (addrType == AddrType::unknown))
{
println("Unknown address type detected!");
return false;
}

View File

@ -120,6 +120,7 @@ CemiFrame& TPDU::frame()
const std::string TPDU::toString() const
{
#ifndef KNX_NO_PRINT
std::string value = std::string("TPDU: ") + enum_name(type()) + " ";
if (control())
@ -129,4 +130,7 @@ const std::string TPDU::toString() const
value += "numbered sequence: " + to_string(sequenceNumber());
return value;
#else
return "";
#endif
}

View File

@ -4,9 +4,9 @@
#include "network_layer.h"
#include "application_layer.h"
#include "platform.h"
#include "bits.h"
#include "util/logger.h"
#include <stdio.h>
#include "bits.h"
#define LOGGER Logger::logger("TransportLayer")

View File

@ -1,5 +1,7 @@
#include "logger.h"
#include "../bits.h"
Map<std::string, Logger::LogType, 64> Logger::_loggers;
Logger Logger::_logger;
@ -123,7 +125,7 @@ void Logger::log(LogType type, const char* format, va_list args)
println();
#endif
}
#ifndef KNX_NO_PRINT
const std::string Logger::enum_name(LogType type)
{
switch (type)
@ -149,3 +151,4 @@ const std::string Logger::enum_name(LogType type)
return std::to_string(type);
}
#endif

View File

@ -1,4 +1,3 @@
#include "../bits.h"
#include <stdarg.h>
#include <string>
#include "simple_map.h"
@ -17,7 +16,7 @@ class Logger
void exception(const std::string message, ...);
protected:
Logger() {}
virtual void log(LogType type, const char* format, va_list args);
void log(LogType type, const char* format, va_list args);
void name(std::string value) { _name = value; }
private:
const std::string enum_name(LogType type);

View File

@ -1,5 +1,7 @@
#pragma once
#include <stdint.h>
// Provides a simple unordered map which is based on two arrays of different data types, namely K and V.
// One array is used for the keys, the other array is used for the values.
// Tracking of free/occupied slots in the arrays is realized by a bitmask of size uint64_t.

View File

@ -1,6 +1,5 @@
#pragma once
#include "knx/bits.h"
#include "knx/util/logger.h"
#include "knx/config.h"
#include "knx/bau.h"
@ -10,6 +9,8 @@
#include "knx/bau2920.h"
#include "knx/bau57B0.h"
#include "knx/bits.h"
#ifndef USERDATA_SAVE_SIZE
#define USERDATA_SAVE_SIZE 0
#endif