move main.cpp, document SaveRestore

This commit is contained in:
Thomas Kunze 2019-05-15 21:25:04 +02:00
parent 7b6a62bbc1
commit 3a58ca8534
9 changed files with 139 additions and 146 deletions

View File

@ -791,7 +791,8 @@ WARN_LOGFILE =
# Note: If this tag is empty the current directory is searched.
INPUT = ../src \
../README.md
../README.md \
example_list.h
# This tag can be used to specify the character encoding of the source files
# that doxygen parses. Internally doxygen uses the UTF-8 encoding. Doxygen uses
@ -874,7 +875,7 @@ RECURSIVE = YES
# Note that relative paths are relative to the directory from which doxygen is
# run.
EXCLUDE = .
EXCLUDE =
# The EXCLUDE_SYMLINKS tag can be used to select whether or not files or
# directories that are symbolic links (a Unix file system feature) are excluded
@ -890,15 +891,7 @@ EXCLUDE_SYMLINKS = NO
# Note that the wildcards are matched against the file with absolute path, so to
# exclude all test directories for example use the pattern */test/*
EXCLUDE_PATTERNS = VisualGDB \
VisualGDBCache \
pybind11 \
visualstudio \
main.cpp \
*.py \
Debug \
gcc_Debug.h \
gcc_Release.h
EXCLUDE_PATTERNS =
# The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names
# (namespaces, classes, functions, etc.) that should be excluded from the
@ -915,7 +908,8 @@ EXCLUDE_SYMBOLS =
# that contain example code fragments that are included (see the \include
# command).
EXAMPLE_PATH =
EXAMPLE_PATH = ../examples \
../knx-linux
# If the value of the EXAMPLE_PATH tag contains directories, you can use the
# EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp and
@ -929,7 +923,7 @@ EXAMPLE_PATTERNS = *
# irrespective of the value of the RECURSIVE tag.
# The default value is: NO.
EXAMPLE_RECURSIVE = NO
EXAMPLE_RECURSIVE = YES
# The IMAGE_PATH tag can be used to specify one or more files or directories
# that contain images that are to be included in the documentation (see the
@ -991,7 +985,7 @@ FILTER_SOURCE_PATTERNS =
# (index.html). This can be useful if you have a project on for instance GitHub
# and want to reuse the introduction page also for the doxygen output.
USE_MDFILE_AS_MAINPAGE =
USE_MDFILE_AS_MAINPAGE = ../README.md
#---------------------------------------------------------------------------
# Configuration options related to source browsing
@ -2244,7 +2238,7 @@ HIDE_UNDOC_RELATIONS = YES
# set to NO
# The default value is: NO.
HAVE_DOT = YES
HAVE_DOT = NO
# The DOT_NUM_THREADS specifies the number of dot invocations doxygen is allowed
# to run in parallel. When set to 0 doxygen will base this on the number of

7
doc/example_list.h Normal file
View File

@ -0,0 +1,7 @@
/**
* @example main.cpp
* @example knx-demo.ino
* @example knx-hdc1008.ino
* @example knx-bme680.ino
*
**/

View File

@ -6,16 +6,9 @@
HDC100X HDC1(0x43);
// declare array of all groupobjects with their sizes in byte
GroupObject groupObjects[]
{
GroupObject(2),
GroupObject(2)
};
// create named references for easy access to group objects
GroupObject& goTemperature = groupObjects[0];
GroupObject& goHumidity = groupObjects[1];
// create macros easy access to group objects
#define goTemperature knx.getGroupObject(1)
#define goHumidity knx.getGroupObject(2)
long lastsend = 0;
@ -39,8 +32,6 @@ void setup(void)
knx.ledPin(5);
// Programming button on digital pin D7
knx.buttonPin(7);
// register group objects
knx.registerGroupObjects(groupObjects, 2);
// read adress table, association table, groupobject table and parameters from eeprom
knx.readMemory();

View File

@ -4,7 +4,7 @@
cmake_minimum_required(VERSION 2.7)
project(knx-linux)
set(LIBRARIES_FROM_REFERENCES "")
add_executable(knx-linux ../src/knx/address_table_object.cpp ../src/knx/apdu.cpp ../src/knx/application_layer.cpp ../src/knx/application_program_object.cpp ../src/knx/association_table_object.cpp ../src/knx/bau.cpp ../src/knx/bau07B0.cpp ../src/knx/bau57B0.cpp ../src/knx/bau_systemB.cpp ../src/knx/bits.cpp ../src/knx/cemi_frame.cpp ../src/knx/data_link_layer.cpp ../src/knx/datapoint_types.cpp ../src/knx/device_object.cpp ../src/knx/group_object.cpp ../src/knx/group_object_table_object.cpp ../src/knx/interface_object.cpp ../src/knx/ip_data_link_layer.cpp ../src/knx/ip_parameter_object.cpp ../src/knx/memory.cpp ../src/knx/network_layer.cpp ../src/knx/npdu.cpp ../src/knx/table_object.cpp ../src/knx/tpdu.cpp ../src/knx/tpuart_data_link_layer.cpp ../src/knx/transport_layer.cpp ../src/knx/platform.cpp ../src/main.cpp ../src/linux_platform.cpp)
add_executable(knx-linux ../src/knx/address_table_object.cpp ../src/knx/apdu.cpp ../src/knx/application_layer.cpp ../src/knx/application_program_object.cpp ../src/knx/association_table_object.cpp ../src/knx/bau.cpp ../src/knx/bau07B0.cpp ../src/knx/bau57B0.cpp ../src/knx/bau_systemB.cpp ../src/knx/bits.cpp ../src/knx/cemi_frame.cpp ../src/knx/data_link_layer.cpp ../src/knx/datapoint_types.cpp ../src/knx/device_object.cpp ../src/knx/group_object.cpp ../src/knx/group_object_table_object.cpp ../src/knx/interface_object.cpp ../src/knx/ip_data_link_layer.cpp ../src/knx/ip_parameter_object.cpp ../src/knx/memory.cpp ../src/knx/network_layer.cpp ../src/knx/npdu.cpp ../src/knx/table_object.cpp ../src/knx/tpdu.cpp ../src/knx/tpuart_data_link_layer.cpp ../src/knx/transport_layer.cpp ../src/knx/platform.cpp main.cpp ../src/linux_platform.cpp)
target_link_libraries(knx-linux "${LIBRARIES_FROM_REFERENCES}")
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -Wall -Wno-unknown-pragmas -Wno-switch -g -O0")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -Wall -Wno-unknown-pragmas -Wno-switch -g -O0")

View File

@ -1,12 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<ClassDiagram MajorVersion="1" MinorVersion="1">
<Class Name="AddressTableObject" Collapsed="true">
<Position X="2.25" Y="4.25" Width="1.5" />
<TypeIdentifier>
<HashCode>IBAAAAEAQACAEAIAABAAAAgAAAAAAAgAAAAAAABAAEA=</HashCode>
<FileName>C:\Users\tkunze\Source\knx\src\knx\address_table_object.h</FileName>
</TypeIdentifier>
</Class>
<Class Name="ApplicationProgramObject" Collapsed="true">
<Position X="4" Y="4.25" Width="1.5" />
<TypeIdentifier>
@ -77,13 +70,6 @@
<FileName>C:\Users\tkunze\Source\knx\src\linux_platform.h</FileName>
</TypeIdentifier>
</Class>
<Class Name="SaveRestore" Collapsed="true">
<Position X="0.5" Y="0.5" Width="1.5" />
<TypeIdentifier>
<HashCode>AAAAAAAAAACAAAIAAAAAAAAAAAAAAAAAAAAAAAAAAAA=</HashCode>
<FileName>C:\Users\tkunze\Source\knx\src\knx\save_restore.h</FileName>
</TypeIdentifier>
</Class>
<Class Name="Platform" Collapsed="true">
<Position X="9.75" Y="0.5" Width="1.5" />
<TypeIdentifier>

View File

@ -140,6 +140,6 @@
<ClCompile Include="..\src\knx\tpuart_data_link_layer.cpp" />
<ClCompile Include="..\src\knx\transport_layer.cpp" />
<ClCompile Include="..\src\linux_platform.cpp" />
<ClCompile Include="..\src\main.cpp" />
<ClCompile Include="main.cpp" />
</ItemGroup>
</Project>

View File

@ -212,10 +212,10 @@
<ClCompile Include="..\src\knx\transport_layer.cpp">
<Filter>Source files\knx</Filter>
</ClCompile>
<ClCompile Include="..\src\main.cpp">
<ClCompile Include="..\src\linux_platform.cpp">
<Filter>Source files</Filter>
</ClCompile>
<ClCompile Include="..\src\linux_platform.cpp">
<ClCompile Include="main.cpp">
<Filter>Source files</Filter>
</ClCompile>
</ItemGroup>

View File

@ -1,100 +1,97 @@
#ifdef __linux__
#include "linux_platform.h"
#include "knx/bau57B0.h"
#include "knx/group_object_table_object.h"
#include <time.h>
#include <stdlib.h>
#include <stdio.h>
LinuxPlatform platfrom;
Bau57B0 bau(platfrom);
float currentValue = 0;
float maxValue = 0;
float minValue = RAND_MAX;
long lastsend = 0;
#define CURR bau.groupObjectTable().get(1)
#define MAX bau.groupObjectTable().get(2)
#define MIN bau.groupObjectTable().get(3)
#define RESET bau.groupObjectTable().get(4)
void measureTemp()
{
long now = platfrom.millis();
if ((now - lastsend) < 2000)
return;
lastsend = now;
int r = rand();
currentValue = (r * 1.0) / (RAND_MAX * 1.0);
currentValue *= 100 * 100;
CURR.objectWrite(currentValue);
if (currentValue > maxValue)
{
maxValue = currentValue;
MAX.objectWrite(maxValue);
}
if (currentValue < minValue)
{
minValue = currentValue;
MIN.objectWrite(minValue);
}
}
void resetCallback(GroupObject& go)
{
if (go.objectReadBool())
{
maxValue = 0;
minValue = 10000;
}
}
void appLoop()
{
if (!bau.configured())
return;
measureTemp();
}
void setup()
{
srand((unsigned int)time(NULL));
bau.readMemory();
if (bau.configured())
RESET.callback(resetCallback);
if (bau.deviceObject().induvidualAddress() == 0)
bau.deviceObject().progMode(true);
if (bau.parameters().loadState() == LS_LOADED)
{
printf("Timeout: %d\n", bau.parameters().getWord(0));
printf("Zykl. senden: %d\n", bau.parameters().getByte(2));
printf("Min/Max senden: %d\n", bau.parameters().getByte(3));
printf("Aenderung senden: %d\n", bau.parameters().getByte(4));
printf("Abgleich %d\n", bau.parameters().getByte(5));
}
bau.enabled(true);
}
int main(int argc, char **argv)
{
setup();
while (1)
{
bau.loop();
appLoop();
platfrom.mdelay(100);
}
}
#endif
#include "linux_platform.h"
#include "knx/bau57B0.h"
#include "knx/group_object_table_object.h"
#include <time.h>
#include <stdlib.h>
#include <stdio.h>
LinuxPlatform platfrom;
Bau57B0 bau(platfrom);
float currentValue = 0;
float maxValue = 0;
float minValue = RAND_MAX;
long lastsend = 0;
#define CURR bau.groupObjectTable().get(1)
#define MAX bau.groupObjectTable().get(2)
#define MIN bau.groupObjectTable().get(3)
#define RESET bau.groupObjectTable().get(4)
void measureTemp()
{
long now = platfrom.millis();
if ((now - lastsend) < 2000)
return;
lastsend = now;
int r = rand();
currentValue = (r * 1.0) / (RAND_MAX * 1.0);
currentValue *= 100 * 100;
CURR.objectWrite(currentValue);
if (currentValue > maxValue)
{
maxValue = currentValue;
MAX.objectWrite(maxValue);
}
if (currentValue < minValue)
{
minValue = currentValue;
MIN.objectWrite(minValue);
}
}
void resetCallback(GroupObject& go)
{
if (go.objectReadBool())
{
maxValue = 0;
minValue = 10000;
}
}
void appLoop()
{
if (!bau.configured())
return;
measureTemp();
}
void setup()
{
srand((unsigned int)time(NULL));
bau.readMemory();
if (bau.configured())
RESET.callback(resetCallback);
if (bau.deviceObject().induvidualAddress() == 0)
bau.deviceObject().progMode(true);
if (bau.parameters().loadState() == LS_LOADED)
{
printf("Timeout: %d\n", bau.parameters().getWord(0));
printf("Zykl. senden: %d\n", bau.parameters().getByte(2));
printf("Min/Max senden: %d\n", bau.parameters().getByte(3));
printf("Aenderung senden: %d\n", bau.parameters().getByte(4));
printf("Abgleich %d\n", bau.parameters().getByte(5));
}
bau.enabled(true);
}
int main(int argc, char **argv)
{
setup();
while (1)
{
bau.loop();
appLoop();
platfrom.mdelay(100);
}
}

View File

@ -1,10 +1,28 @@
#pragma once
#include <stdint.h>
/**
*@brief Interface for classes that can save and restore data from a buffer.
*/
class SaveRestore
{
public:
/**
* @brief This method is called when the object should save its state to the buffer.
*
* @param buffer The buffer the object should save its state to.
*
* @return The buffer plus the size of the object state. The next object will use this value as
* the start of its buffer.
*/
virtual uint8_t* save(uint8_t* buffer) = 0;
/**
* @brief This method is called when the object should restore its state from the buffer.
*
* @param buffer The buffer the object should restore its state from.
*
* @return The buffer plus the size of the object state. The next object will use this value as
* the start of its buffer.
*/
virtual uint8_t* restore(uint8_t* buffer) = 0;
};