-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
move from pico_rec package to a separate repo spp-picoadc
- Loading branch information
Showing
44 changed files
with
3,229 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
tar: . |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
srcdir = spp-picoadc | ||
|
||
all: | ||
make -C ${srcdir} | ||
|
||
|
||
DESTDIR ?= | ||
prefix ?= $(DESTDIR)/usr | ||
bindir ?= $(prefix)/bin | ||
|
||
install: all | ||
install -D -m755 ${srcdir}/pico_adc -t ${bindir} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
*.deps | ||
*.o | ||
*.a | ||
*.test | ||
*.test.passed |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
all: | ||
sh -e -c 'for i in */Makefile; do make -C $${i%/Makefile}; done' | ||
|
||
clean: | ||
sh -e -c 'for i in */Makefile; do make -C $${i%/Makefile} clean; done' | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,149 @@ | ||
# module subdirs. | ||
# | ||
# Module name equals to the subdir name. Module h-file should | ||
# have the same name (with .h extension) | ||
# | ||
# Before using define following variables: | ||
# MODDIR -- directory where all modiles are located | ||
# MOD_HEADERS -- list of module headers (*.h) | ||
# MOD_SOURCES -- list of module sources (*.cpp) | ||
# PROGRAMS -- programs to be build | ||
# SHARED_LIB -- shared library to build (collect all MOD_SOURCES + dependencies) | ||
# SIMPLE_TESTS -- Programs returning 0/1. | ||
# For each <name> should be a source <name>.test.cpp. | ||
# SCRIPT_TESTS -- Programs with testing scripts. | ||
# For each <name> should be a source <name>.test.cpp and | ||
# a script <name>.test.script | ||
# OTHER_TESTS -- Any programs or scripts which should be run after building | ||
# PKG_CONFIG -- external libraries used in this module, controlled by pkg-config | ||
# PROG_DEPS -- External programs needed for building the module. | ||
# LDLIBS, LDFLAGS, CXXFLAGS, etc. -- standard Makefile variables | ||
# MOD_LOCAL -- do not find dependencies, use only local information, | ||
# do not expand PKG_CONFIG options (used in get_deps) | ||
###################################################### | ||
|
||
###################################################### | ||
# Main building rules | ||
all: make_deps make_nodeps | ||
clean: | ||
rm -f *.o *.a *.so *.test *.passed Makefile.deps $(PROGRAMS) | ||
|
||
|
||
MODDIR ?= .. | ||
|
||
MOD_NAME := | ||
MOD_STATIC := | ||
MOD_OBJECTS := | ||
|
||
ifdef MOD_HEADERS | ||
MOD_NAME := $(notdir $(shell pwd)) | ||
MOD_STATIC := $(MOD_NAME).a | ||
endif | ||
ifdef MOD_SOURCES | ||
MOD_OBJECTS := $(patsubst %.cpp, %.o, $(MOD_SOURCES)) | ||
MOD_OBJECTS := $(patsubst %.c, %.o, $(MOD_OBJECTS)) | ||
endif | ||
|
||
SHARED_LIB_SO := $(patsubst %, %.so, $(SHARED_LIB)) | ||
|
||
|
||
###################################################### | ||
# Build and include dependency file (using get_deps script). | ||
|
||
# .SHELLSTATUS variable appears in make 4.2. We set it to 0 for earlier | ||
# versions of make and skip error detection in the get_deps script: | ||
|
||
ifndef MOD_LOCAL | ||
|
||
$(shell true) | ||
ifneq (${.SHELLSTATUS},0) | ||
.SHELLSTATUS := 0 | ||
endif | ||
|
||
$(shell $(MODDIR)/get_deps $(MODDIR) . > Makefile.deps) | ||
ifneq (${.SHELLSTATUS},0) | ||
$(error "get_deps failed: ${.SHELLSTATUS}") | ||
endif | ||
-include Makefile.deps | ||
|
||
###################################################### | ||
# Building flags | ||
# user-defined flags are added _after_ this | ||
|
||
override CFLAGS_ = $(shell [ "$(PKG_CONFIG)" = "" ] ||\ | ||
pkg-config --cflags '$(PKG_CONFIG)') | ||
override LDLIBS_ = $(shell [ "$(PKG_CONFIG)" = "" ] ||\ | ||
pkg-config --libs '$(PKG_CONFIG)') | ||
|
||
override CFLAGS_ += -Werror=return-type -O2 -fPIC -g -I$(MODDIR) | ||
|
||
override CFLAGS := $(CFLAGS_) $(CFLAGS) | ||
override CXXFLAGS := -std=gnu++11 $(CFLAGS_) $(CXXFLAGS) | ||
override LDLIBS := $(LDLIBS_) $(LDLIBS) | ||
|
||
endif # MOD_LOCAL | ||
|
||
###################################################### | ||
# make_deps/make_nodeps building rules: | ||
make_deps: | ||
@echo "## Building dependencies: [$(MDEPS)]" | ||
@sh -e -c 'for i in $(MDEPS); do $(MAKE) -C $(MODDIR)/$$i make_nodeps; done' | ||
@echo "## Finish building dependencies" | ||
|
||
make_nodeps: $(MOD_STATIC) $(PROGRAMS) $(SHARED_LIB_SO) make_tests | ||
|
||
###################################################### | ||
# Building rules for tests | ||
SIMPLE_TEST_PROGS := $(patsubst %, %.test, $(SIMPLE_TESTS)) | ||
SCRIPT_TEST_PROGS := $(patsubst %, %.test, $(SCRIPT_TESTS)) | ||
SIMPLE_TEST_RES := $(patsubst %, %.test.passed, $(SIMPLE_TESTS)) | ||
SCRIPT_TEST_RES := $(patsubst %, %.test.passed, $(SCRIPT_TESTS)) | ||
|
||
$(SIMPLE_TEST_RES): TEST_DEP := '' | ||
$(SCRIPT_TEST_RES): TEST_DEP := %.test.script | ||
$(SIMPLE_TEST_RES): TEST_CMD = ./$< && > $<.passed | ||
$(SCRIPT_TEST_RES): TEST_CMD = ./$<.script && > $<.passed | ||
|
||
TEST_OBJECTS := $(patsubst %,%.test.o, $(SIMPLE_TESTS) $(SCRIPT_TESTS)) | ||
$(SIMPLE_TEST_PROGS) $(SCRIPT_TEST_PROGS): CC:=$(CXX) | ||
$(SIMPLE_TEST_PROGS) $(SCRIPT_TEST_PROGS): %: %.o $(MOD_OBJECTS) $(ADEPS) | ||
$(TEST_OBJECTS): %.o: %.cpp | ||
|
||
%.test.passed: %.test $(TEST_DEP) | ||
@echo "## Running test: $<" | ||
@$(TEST_CMD) | ||
|
||
make_tests: $(SIMPLE_TEST_RES) $(SCRIPT_TEST_RES) | ||
@sh -e -c 'for i in $(OTHER_TESTS); do echo "## Running test: $$i"; ./$$i; done' | ||
|
||
###################################################### | ||
# building rules for programs and shared lib | ||
PROG_OBJECTS := $(patsubst %,%.o, $(PROGRAMS)) | ||
$(PROGRAMS): CC:=$(CXX) | ||
$(PROGRAMS): %: %.o $(MOD_OBJECTS) $(ADEPS) | ||
$(PROG_OBJECTS): %.o: %.cpp | ||
|
||
$(SHARED_LIB_SO): %.so: $(MOD_OBJECTS) $(ADEPS) | ||
$(CXX) -shared $(LDFLAGS) $+ $(LDLIBS) -o $@ | ||
###################################################### | ||
# Building rules for module static library | ||
|
||
$(MOD_STATIC): $(MOD_OBJECTS) | ||
ar crs $@ $+ | ||
|
||
###################################################### | ||
info: | ||
@echo "MOD_NAME: $(MOD_NAME)" | ||
@echo "MOD_STATIC: $(MOD_STATIC)" | ||
@echo "MOD_SOURCES: $(MOD_SOURCES)" | ||
@echo "MOD_HEADERS: $(MOD_HEADERS)" | ||
@echo "PKG_CONFIG: $(PKG_CONFIG)" | ||
@echo "PROG_DEPS: $(PROG_DEPS)" | ||
@echo "MDEPS: $(MDEPS)" | ||
@echo "ADEPS: $(ADEPS)" | ||
@echo "LDEPS: $(LDEPS)" | ||
@echo "SIMPLE_TESTS: $(SIMPLE_TESTS)" | ||
@echo "SCRIPT_TESTS: $(SCRIPT_TESTS)" | ||
@echo "PROGRAMS: $(PROGRAMS)" | ||
@echo "LDLIBS: $(LDLIBS)" | ||
@echo "CXXFLAGS: $(CXXFLAGS)" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
This folder contains some modules from mapsoft2-libs source code library: | ||
https://github.com/slazav/mapsoft2-libs | ||
|
||
Modules are copied locally by update_moddir script. | ||
Update time: 2024-01-25 15:05:33 | ||
Commit: 36262eb25595b3306b37d45ef9cf73b9e7bf6626 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
MOD_HEADERS := err.h assert_err.h | ||
SIMPLE_TESTS := err assert_err | ||
|
||
include ../Makefile.inc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
## Err class | ||
|
||
Human-readable text exceptions (with optional error codes) | ||
|
||
- Throwing an error: | ||
```c | ||
throw Err() << "some message"; | ||
``` | ||
|
||
- Catching and printing error: | ||
```c | ||
catch (Err E){ cerr << "Error: " << E.str() << "\n"; } | ||
``` | ||
- Integer error code can be set as an optional constructor parameter | ||
and extracted by `code` method: `E.code()`. Default code is -1. | ||
```c | ||
try {throw Err(1); } catch (Err E) {int code=E.code();} | ||
``` | ||
|
||
## assert_err macro | ||
|
||
``` | ||
#include "err/assert_err.h" | ||
assert_err(<code>, <expected error>) | ||
``` | ||
|
||
|
||
------------------ | ||
## Changelog: | ||
2020.09.18 V.Zavjalov 1.3: | ||
- Add Err::operator= | ||
|
||
2020.08.13 V.Zavjalov 1.2.5: | ||
- err: add std::exception interface | ||
|
||
2019.10.10 V.Zavjalov 1.2: | ||
- Add assert_eq, assert_deq, and assert_feq macro | ||
- Print more information in assert_* | ||
|
||
2019.08.16 V.Zavjalov 1.1: | ||
- Add assert_err macro | ||
|
||
2019.05.02 V.Zavjalov 1.0: | ||
- First version (used widely in many of my projects) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
#ifndef ASSERT_ERR_H | ||
#define ASSERT_ERR_H | ||
|
||
///\addtogroup libmapsoft | ||
///@{ | ||
|
||
#include <cmath> // fabs | ||
#include "err.h" | ||
|
||
// assert_err macro | ||
|
||
#define assert_err(cmd,ret)\ | ||
{try{\ | ||
cmd;\ | ||
throw Err(-9999)\ | ||
<< "assert_err: " << __FILE__ << ":" << __LINE__ << ": error is not thrown:\n"\ | ||
<< "command: " << #cmd << "\n"\ | ||
<< "expected error: " << (ret)<< "\n";\ | ||
} catch (Err & e) {\ | ||
if (e.code()==-9999) throw;\ | ||
if (e.str()!=(ret)){\ | ||
throw Err()\ | ||
<< "assert_err: " << __FILE__ << ":" << __LINE__ << ": wrong error message:\n"\ | ||
<< "command: " << #cmd << "\n"\ | ||
<< "expected error: " << (ret) << "\n"\ | ||
<< "actual error: " << e.str()<< "\n";\ | ||
}\ | ||
}} | ||
|
||
// catch an error and check it | ||
#define assert_eq(v1,v2)\ | ||
{if ((v1) != (v2)){\ | ||
throw Err()\ | ||
<< "assert_eq: " << __FILE__ << ":" << __LINE__ << ": arguments are not equal:\n"\ | ||
<< "v1: " << #v1 << "\n"\ | ||
<< " " << (v1) << "\n"\ | ||
<< "v2: " << #v2 << "\n"\ | ||
<< " " << (v2) << "\n";\ | ||
}} | ||
|
||
// compare two double values and check that difference is less then e | ||
#define assert_feq(v1,v2,e)\ | ||
{if (fabs((v1) - (v2)) > e){\ | ||
throw Err()\ | ||
<< "assert_feq: " << __FILE__ << ":" << __LINE__ << ": arguments are not equal:\n"\ | ||
<< "v1: " << #v1 << "\n"\ | ||
<< " " << (v1) << "\n"\ | ||
<< "v2: " << #v2 << "\n"\ | ||
<< " " << (v2) << "\n";\ | ||
}} | ||
|
||
// compare two objects with a dist(a,b) function, check thet the result is less then e | ||
#define assert_deq(v1,v2,e)\ | ||
{if (dist((v1),(v2)) > e){\ | ||
throw Err()\ | ||
<< "assert_feq: " << __FILE__ << ":" << __LINE__ << ": arguments are not equal:\n"\ | ||
<< "v1: " << #v1 << "\n"\ | ||
<< " " << (v1) << "\n"\ | ||
<< "v2: " << #v2 << "\n"\ | ||
<< " " << (v2) << "\n";\ | ||
}} | ||
|
||
///@} | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
///\cond HIDDEN (do not show this in Doxyden) | ||
|
||
#include <cassert> | ||
#include "assert_err.h" | ||
|
||
void errorfunc(){ | ||
throw Err() << "some error"; | ||
} | ||
|
||
void nonerrorfunc(){} | ||
|
||
double dist(double v1, double v2){return fabs(v1-v2);} | ||
|
||
int | ||
main(){ | ||
try{ | ||
assert_err(errorfunc(), "some error"); | ||
|
||
// assert_err(errorfunc(), "some error1"); | ||
// assert_err(nonerrorfunc(), "some error"); | ||
|
||
assert_err(throw Err() << "eee", "eee"); | ||
|
||
assert_eq(10, 10); | ||
assert_eq(20-10, 10); | ||
assert_eq(10, 20-10); | ||
|
||
assert_feq(10.0, 10.0, 1e-6); | ||
assert_feq(10.1, 10.2, 0.2); | ||
assert_feq(10.2, 10.1, 0.2); | ||
|
||
assert_feq(1, 2-1, 1e-6); | ||
assert_feq(2-1, 1, 1e-6); | ||
|
||
// using dist() function | ||
assert_deq(10.0, 10.0, 1e-6); | ||
assert_deq(10.1, 10.2, 0.2); | ||
assert_deq(10.2, 10.1, 0.2); | ||
|
||
assert_deq(1, 2-1, 1e-6); | ||
assert_deq(2-1, 1, 1e-6); | ||
|
||
|
||
|
||
} | ||
catch (Err & e) { | ||
std::cerr << "Error: " << e.str() << "\n"; | ||
return 1; | ||
} | ||
return 0; | ||
} | ||
|
||
///\endcond |
Oops, something went wrong.