Skip to content

Commit

Permalink
conform code fmt; limit CI triggers
Browse files Browse the repository at this point in the history
  • Loading branch information
2bndy5 committed Jun 12, 2021
1 parent 733177e commit 2ac9a46
Show file tree
Hide file tree
Showing 15 changed files with 220 additions and 180 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build_arduino.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Arduino CLI build

on:
pull_request:
types: [opened, synchronize, reopened]
types: [opened, reopened]
paths:
- ".github/workflows/build_arduino.yml"
- "examples/**"
Expand Down
18 changes: 18 additions & 0 deletions .github/workflows/doxygen.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,26 @@ on:
pull_request:
branches: [master]
types: [opened, reopened]
paths:
- '*.h'
- 'docs/**'
- '!docs/README.md'
- '*.md'
- 'images/**'
- '.github/workflows/doxygen.yml'
- 'Doxyfile'
- 'library.properties' # get lib version from here
push:
branches: [master]
paths:
- '*.h'
- 'docs/**'
- '!docs/README.md'
- '*.md'
- 'images/**'
- '.github/workflows/doxygen.yml'
- 'Doxyfile'
- 'library.properties' # get lib version from here
release:
branches: [master]
types: [published, edited]
Expand Down
51 changes: 42 additions & 9 deletions .github/workflows/linux_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,29 @@ name: Linux build
on:
pull_request:
types: [opened, reopened]
paths:
- '*.h'
- '*.cpp'
- 'CMakeLists.txt'
- 'cmake/**'
- 'library.properties' # CMake gets lib info from here
- 'Makefile'
- 'examples_RPi/**'
- '**pyRF24Network/setup.py'
- '**pyRF24Network/*.cpp'
- '.github/workflows/build_linux.yml'
push:
paths:
- '*.h'
- '*.cpp'
- 'CMakeLists.txt'
- 'cmake/**'
- 'library.properties' # CMake gets lib info from here
- 'Makefile'
- 'examples_RPi/**'
- '**pyRF24Network/setup.py'
- '**pyRF24Network/*.cpp'
- '.github/workflows/build_linux.yml'
release:
types: [published, edited]

Expand Down Expand Up @@ -32,9 +54,6 @@ jobs:
usr_dir: "local"

steps:
- name: install rpmbuild
run: sudo apt-get install rpm

# - name: provide toolchain (for x86_64)
# if: ${{ matrix.toolchain.compiler == 'x86_64' }}
# run: |
Expand Down Expand Up @@ -81,12 +100,6 @@ jobs:
run: cmake -E make_directory ${{ github.workspace }}/build

- name: configure lib
if: ${{ matrix.toolchain.compiler == 'default' }}
working-directory: ${{ github.workspace }}/build
run: cmake .. -D CMAKE_BUILD_TYPE=$BUILD_TYPE

- name: configure lib (with toolchain compilers)
if: ${{ matrix.toolchain.compiler != 'default' }}
working-directory: ${{ github.workspace }}/build
run: |
cmake .. -D CMAKE_BUILD_TYPE=$BUILD_TYPE \
Expand Down Expand Up @@ -135,3 +148,23 @@ jobs:
run: |
cmake --build .
file ./helloworld_tx
# cross-compiling a python C extension is better done with pypa/cibuildwheel action
- name: provide python wrapper prerequisites
if: ${{ matrix.toolchain.compiler == 'default' }}
# python3-rpi.gpio is only required for physical hardware (namely the IRQ example)
run: sudo apt-get install python3-dev libboost-python-dev python3-setuptools

- name: create alias symlink to libboost_python3*.so
if: ${{ matrix.toolchain.compiler == 'default' }}
run: sudo ln -s $(ls /usr/lib/$(ls /usr/lib/gcc | tail -1)/libboost_python3*.so | tail -1) /usr/lib/$(ls /usr/lib/gcc | tail -1)/libboost_python3.so

- name: build python wrapper
if: ${{ matrix.toolchain.compiler == 'default' }}
working-directory: ${{ github.workspace }}/RPi/pyRF24Network
run: python3 setup.py build

- name: install python wrapper
if: ${{ matrix.toolchain.compiler == 'default' }}
working-directory: ${{ github.workspace }}/RPi/pyRF24Network
run: sudo python3 setup.py install
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ PINS_*/
*.exe
build/
.vscode/
*CMakeUserPresets.json
*CMakeUserPresets*.json
14 changes: 7 additions & 7 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -56,39 +56,39 @@ message(STATUS "using RF24 library: ${RF24}")
###########################
add_library(${LibTargetName} SHARED
RF24Network.cpp
)
)
target_include_directories(${LibTargetName} PUBLIC
${CMAKE_CURRENT_LIST_DIR}
)
)

target_link_libraries(${LibTargetName} INTERFACE
project_options
project_warnings
SHARED ${RF24}
)
)

set_target_properties(
${LibTargetName}
PROPERTIES
SOVERSION ${${LibName}_VERSION_MAJOR}
VERSION ${${LibName}_VERSION_STRING}
)
)

###########################
# target install rules for the RF24Log lib
###########################
install(TARGETS ${LibTargetName}
DESTINATION lib
)
)

install(FILES
RF24Network.h
RF24Network_config.h
DESTINATION include/RF24Network
)
)

# CMAKE_CROSSCOMPILING is only TRUE when CMAKE_TOOLCHAIN_FILE is specified via CLI
if(CMAKE_HOST_UNIX AND "${CMAKE_CROSSCOMPILING}" STREQUAL "FALSE")
if("${CMAKE_CROSSCOMPILING}" STREQUAL "FALSE")
install(CODE "message(STATUS \"Updating ldconfig\")")
install(CODE "execute_process(COMMAND ldconfig)")
endif()
153 changes: 56 additions & 97 deletions RPi/pyRF24Network/pyRF24Network.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ namespace bp = boost::python;

// **************** expicit wrappers *****************
// where needed, especially where buffer is involved
//

void throw_ba_exception(void)
{
PyErr_SetString(PyExc_TypeError, "buf parameter must be bytes or bytearray");
Expand All @@ -23,6 +23,7 @@ char *get_bytes_or_bytearray_str(bp::object buf)
return PyBytes_AsString(py_ba);
else
throw_ba_exception();

return NULL;
}

Expand All @@ -36,144 +37,102 @@ int get_bytes_or_bytearray_ln(bp::object buf)
return PyBytes_Size(py_ba);
else
throw_ba_exception();

return 0;
}

bp::tuple read_wrap(RF24Network& ref, size_t maxlen)
bp::tuple read_wrap(RF24Network &ref, size_t maxlen)
{
char *buf = new char[maxlen+1];
RF24NetworkHeader header;
char *buf = new char[maxlen + 1];
RF24NetworkHeader header;

uint16_t len = ref.read(header, buf, maxlen);
uint16_t len = ref.read(header, buf, maxlen);
bp::object py_ba(bp::handle<>(PyByteArray_FromStringAndSize(buf, len)));
delete[] buf;

return bp::make_tuple(header, py_ba);
return bp::make_tuple(header, py_ba);
}

bp::tuple peek_read_wrap(RF24Network& ref, size_t maxlen)
bp::tuple peek_read_wrap(RF24Network &ref, size_t maxlen)
{
char *buf = new char[maxlen+1];
RF24NetworkHeader header;
char *buf = new char[maxlen + 1];
RF24NetworkHeader header;

ref.peek(header, buf, maxlen);
ref.peek(header, buf, maxlen);
uint16_t len = ref.peek(header);
bp::object py_ba(bp::handle<>(PyByteArray_FromStringAndSize(buf, len)));
delete[] buf;

return bp::make_tuple(header, py_ba);
return bp::make_tuple(header, py_ba);
}

bool write_wrap(RF24Network& ref, RF24NetworkHeader& header, bp::object buf)
bool write_wrap(RF24Network &ref, RF24NetworkHeader &header, bp::object buf)
{
return ref.write(header, get_bytes_or_bytearray_str(buf), get_bytes_or_bytearray_ln(buf));
return ref.write(header, get_bytes_or_bytearray_str(buf), get_bytes_or_bytearray_ln(buf));
}

std::string toString_wrap(RF24NetworkHeader& ref)
std::string toString_wrap(RF24NetworkHeader &ref)
{
return std::string(ref.toString());
return std::string(ref.toString());
}

BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(
peekvoid, RF24Network::peek, 1, 3)
BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(
peekint, RF24Network::peek, 1, 2)
BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(peekvoid, RF24Network::peek, 1, 3)
BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(peekint, RF24Network::peek, 1, 2)

// **************** RF24Network exposed *****************
//
BOOST_PYTHON_MODULE(RF24Network){
BOOST_PYTHON_MODULE(RF24Network)
{
{ //::RF24Network
typedef bp::class_< RF24Network > RF24Network_exposer_t;
RF24Network_exposer_t RF24Network_exposer = RF24Network_exposer_t( "RF24Network", bp::init< RF24 & >(( bp::arg("_radio") )) );
bp::scope RF24Network_scope( RF24Network_exposer );
bp::implicitly_convertible< RF24 &, RF24Network >();
typedef bp::class_<RF24Network> RF24Network_exposer_t;
RF24Network_exposer_t RF24Network_exposer = RF24Network_exposer_t("RF24Network", bp::init<RF24 &>((bp::arg("_radio"))));
bp::scope RF24Network_scope(RF24Network_exposer);
bp::implicitly_convertible<RF24 &, RF24Network>();
{ //::RF24Network::available

typedef bool ( ::RF24Network::*available_function_type )( ) ;

RF24Network_exposer.def(
"available"
, available_function_type( &::RF24Network::available ) );

typedef bool (::RF24Network::*available_function_type)();
RF24Network_exposer.def("available", available_function_type(&::RF24Network::available));
}
{ //::RF24Network::begin

typedef void ( ::RF24Network::*begin_function_type )( ::uint8_t,::uint16_t ) ;

RF24Network_exposer.def(
"begin"
, begin_function_type( &::RF24Network::begin )
, ( bp::arg("_channel"), bp::arg("_node_address") ) );

typedef void (::RF24Network::*begin_function_type)(::uint8_t, ::uint16_t);
RF24Network_exposer.def("begin", begin_function_type(&::RF24Network::begin), (bp::arg("_channel"), bp::arg("_node_address")));
}
{ //::RF24Network::parent

typedef ::uint16_t ( ::RF24Network::*parent_function_type )( ) const;

RF24Network_exposer.def(
"parent"
, parent_function_type( &::RF24Network::parent ) );

typedef ::uint16_t (::RF24Network::*parent_function_type)() const;
RF24Network_exposer.def("parent", parent_function_type(&::RF24Network::parent));
}
{ //::RF24Network::peek

typedef uint16_t ( ::RF24Network::*peekint )( ::RF24NetworkHeader & ) ;

RF24Network_exposer.def(
"peek"
, peekint( &::RF24Network::peek )
, ( bp::arg("header") ) );

typedef uint16_t (::RF24Network::*peekint)(::RF24NetworkHeader &);
RF24Network_exposer.def("peek", peekint(&::RF24Network::peek), (bp::arg("header")));
}
{ //::RF24Network::peek

typedef bp::tuple ( *peekvoid )( ::RF24Network& , size_t) ;

RF24Network_exposer.def(
"peek"
, peekvoid( &peek_read_wrap )
, (bp::arg("maxlen") ) );

typedef bp::tuple (*peekvoid)(::RF24Network &, size_t);
RF24Network_exposer.def("peek", peekvoid(&peek_read_wrap), (bp::arg("maxlen")));
}
{ //::RF24Network::read

typedef bp::tuple ( *read_function_type )(::RF24Network&, size_t ) ;

RF24Network_exposer.def(
"read"
//, read_function_type( &::RF24Network::read )
, read_function_type( &read_wrap )
, ( bp::arg("maxlen") ) );

typedef bp::tuple (*read_function_type)(::RF24Network &, size_t);
RF24Network_exposer.def(
"read",
// read_function_type( &::RF24Network::read ),
read_function_type(&read_wrap), (bp::arg("maxlen")));
}
{ //::RF24Network::update

typedef void ( ::RF24Network::*update_function_type )( ) ;

RF24Network_exposer.def(
"update"
, update_function_type( &::RF24Network::update ) );

typedef void (::RF24Network::*update_function_type)();
RF24Network_exposer.def("update", update_function_type(&::RF24Network::update));
}
{ //::RF24Network::write

typedef bool ( *write_function_type )( ::RF24Network&, ::RF24NetworkHeader&, bp::object ) ;

RF24Network_exposer.def("write", write_function_type( &write_wrap ), ( bp::arg("header"), bp::arg("buf") ) );

typedef bool (*write_function_type)(::RF24Network &, ::RF24NetworkHeader &, bp::object);
RF24Network_exposer.def("write", write_function_type(&write_wrap), (bp::arg("header"), bp::arg("buf")));
}
RF24Network_exposer.def_readwrite( "txTimeout", &RF24Network::txTimeout );
RF24Network_exposer.def_readwrite("txTimeout", &RF24Network::txTimeout);
}

// **************** RF24NetworkHeader exposed *****************
//
bp::class_< RF24NetworkHeader >( "RF24NetworkHeader", bp::init< >() )
.def( bp::init< uint16_t, bp::optional< unsigned char > >(( bp::arg("_to"), bp::arg("_type")=(unsigned char)(0) )) )
.def("toString", &toString_wrap )
.def_readwrite( "from_node", &RF24NetworkHeader::from_node )
.def_readwrite( "id", &RF24NetworkHeader::id )
.def_readwrite( "next_id", RF24NetworkHeader::next_id )
.def_readwrite( "reserved", &RF24NetworkHeader::reserved )
.def_readwrite( "to_node", &RF24NetworkHeader::to_node )
.def_readwrite( "type", &RF24NetworkHeader::type );
// **************** RF24NetworkHeader exposed *****************
bp::class_<RF24NetworkHeader>("RF24NetworkHeader", bp::init<>())
.def(bp::init<uint16_t, bp::optional<unsigned char>>((bp::arg("_to"), bp::arg("_type") = (unsigned char)(0))))
.def("toString", &toString_wrap)
.def_readwrite("from_node", &RF24NetworkHeader::from_node)
.def_readwrite("id", &RF24NetworkHeader::id)
.def_readwrite("next_id", RF24NetworkHeader::next_id)
.def_readwrite("reserved", &RF24NetworkHeader::reserved)
.def_readwrite("to_node", &RF24NetworkHeader::to_node)
.def_readwrite("type", &RF24NetworkHeader::type);
}

Loading

0 comments on commit 2ac9a46

Please sign in to comment.