WIP: Pi Pico support #193
@@ -0,0 +1,165 @@
|
||||
# PIP Codebase Guide for AGENTS
|
||||
|
||||
## Build Commands
|
||||
|
||||
### Basic Build
|
||||
```bash
|
||||
# Configure with CMake (release build)
|
||||
cmake -B build -j16
|
||||
|
||||
# Build the project
|
||||
cmake --build build -j16
|
||||
|
||||
# Install (default system location)
|
||||
cmake --build build --target install -j16
|
||||
|
||||
# Local install (bin/lib/include in build directory)
|
||||
cmake -B build -DLOCAL=ON -j16
|
||||
```
|
||||
|
||||
### With Tests
|
||||
```bash
|
||||
cmake -B build -DTESTS=ON -j16
|
||||
cmake --build build -j16
|
||||
cd build && ctest
|
||||
```
|
||||
|
||||
### Build Only
|
||||
```bash
|
||||
cmake --build build -j16
|
||||
```
|
||||
|
||||
### Run Single Test
|
||||
```bash
|
||||
# After building with TESTS=ON
|
||||
./build/tests/math/pip_math_test --gtest_filter="Vector2DTest.defaultConstructor*"
|
||||
# Or use ctest
|
||||
ctest -R math -V
|
||||
# List all tests
|
||||
ctest -N
|
||||
```
|
||||
|
||||
### Build Options
|
||||
- `TESTS=ON` - Build tests (requires Google Test)
|
||||
- `COVERAGE=ON` - Build with coverage instrumentation
|
||||
- `ICU=ON` - Enable ICU support for string conversion
|
||||
- `STD_IOSTREAM=ON` - Enable std::iostream operators
|
||||
- `INTROSPECTION=ON` - Build with introspection support
|
||||
- `PIP_BUILD_*` - Enable/disable modules (e.g., `PIP_BUILD_CRYPT=OFF`)
|
||||
|
||||
### Code Generation Tools
|
||||
- `pip_cmg` - Code model generator (auto-generates code from comments)
|
||||
- `pip_rc` - Resources compiler (embeds resources into C++ code)
|
||||
- `pip_tr` - Translation tool (compiles .btf translation files)
|
||||
|
||||
### Linting & Formatting
|
||||
- **clang-format**: Run `clang-format -i <file>` or `find . -name "*.cpp" -o -name "*.h" | xargs clang-format -i`
|
||||
- **Format config**: `.clang-format` (ColumnLimit: 140, IndentWidth: 4, BraceWrapping: Attach)
|
||||
- **Includes sorting**: Enabled (CaseSensitive, SortIncludes: true)
|
||||
- **Macro blocks**: `PRIVATE_DEFINITION_START/END`, `STATIC_INITIALIZER_BEGIN/END`, `DECLARE_UNIT_CLASS_BEGIN/END`
|
||||
- **No Cursor/Copilot rules** found in this repository
|
||||
|
||||
## Code Style Guidelines
|
||||
|
||||
### General
|
||||
- **Language Standard**: C++11 (CMAKE_CXX_STANDARD 11)
|
||||
- **File Encoding**: UTF-8
|
||||
- **Line Endings**: Unix (LF)
|
||||
- **Column Limit**: 140 characters
|
||||
|
||||
### Naming Conventions
|
||||
- **Classes**: `PascalCase` (e.g., `PIObject`, `PIString`)
|
||||
- **Functions/Methods**: `camelCase` (e.g., `toString()`, `isEmpty()`)
|
||||
- **Variables**: `camelCase` (e.g., `rowCount`, `isReady`)
|
||||
- **Constants**: `kPrefixCamelCase` (e.g., `kMaxSize`)
|
||||
- **Macros**: `UPPER_CASE` (e.g., `PIP_EXPORT`, `NO_COPY_CLASS`)
|
||||
- **Types**: `PascalCase` with `p` prefix for internal/private (e.g., `PIString_p.h`)
|
||||
|
||||
### File Naming
|
||||
- Headers: `pi<name>.h` (e.g., `piobject.h`, `pistring.h`)
|
||||
- Private headers: `pi<name>_p.h` (e.g., `piobject_p.h`)
|
||||
- Test files: `test<name>.cpp` (e.g., `testpivector2d.cpp`)
|
||||
|
||||
### Comments & Documentation
|
||||
- Use Doxygen-style comments for all public APIs
|
||||
- Include `\~english` and `\~russian` translations
|
||||
- Group related classes/modules with `//! \defgroup`
|
||||
- Use `\ingroup` to assign files to groups
|
||||
- Example:
|
||||
```cpp
|
||||
//! \file piobject.h
|
||||
//! \ingroup Core
|
||||
//! \~\brief
|
||||
//! \~english Base object
|
||||
//! \~russian Базовый класс
|
||||
```
|
||||
|
||||
### Includes
|
||||
- Order: System headers → PIP headers → Local headers
|
||||
- Sort alphabetically within groups
|
||||
- Use `#pragma once` or include guards
|
||||
- PIP includes use `#include "pi<name>.h"`
|
||||
|
||||
### Formatting (clang-format)
|
||||
- **Indentation**: 4 spaces (no tabs for code)
|
||||
- **Braces**: Attach style (`if (x) {`)
|
||||
- **Pointers/References**: `Type* ptr`, `Type& ref`
|
||||
- **Templates**: Always break before `>` in nested templates
|
||||
- **Empty Lines**: Max 2 consecutive empty lines
|
||||
- **Namespace**: No indentation (`Namespace { ... }`)
|
||||
|
||||
### Error Handling
|
||||
- Use `PIString` for error messages
|
||||
- Return bool for success/failure
|
||||
- Use `assert()` for debug-only checks
|
||||
- Avoid exceptions (RTTI disabled in some builds)
|
||||
|
||||
### Memory Management
|
||||
- Prefer stack allocation
|
||||
- Use `NO_COPY_CLASS(MyClass)` to disable copy
|
||||
- Implement proper move semantics when needed
|
||||
- Use `std::unique_ptr`/`std::shared_ptr` sparingly
|
||||
|
||||
### Macros
|
||||
- PIMETA(...) - Add metadata for code model generator
|
||||
- PIP_EXPORT - Export/import symbols for DLLs
|
||||
- NO_COPY_CLASS - Disable copy constructor and operator=
|
||||
- PRIVATE_DECLARATION - Private implementation macro
|
||||
|
||||
## Testing
|
||||
- Framework: Google Test (fetched automatically when TESTS=ON)
|
||||
- Test files: `tests/<module>/test<name>.cpp`
|
||||
- Use `pip_test(module)` macro in `tests/CMakeLists.txt`
|
||||
- Test discovery via `gtest_discover_tests()`
|
||||
|
||||
### Running Tests
|
||||
```bash
|
||||
# Run all tests
|
||||
ctest
|
||||
|
||||
# Run specific test suite
|
||||
ctest -R math -V
|
||||
|
||||
# List all available tests
|
||||
ctest -N
|
||||
|
||||
# Run single test with gtest filter
|
||||
./build/tests/math/pip_math_test --gtest_filter="Vector2DTest.defaultConstructor*"
|
||||
```
|
||||
|
||||
## Module Structure
|
||||
```
|
||||
libs/
|
||||
├── main/ # Core modules
|
||||
│ ├── core/ # Base types, PIObject, PIString
|
||||
│ ├── thread/ # Threading primitives
|
||||
│ ├── math/ # Math functions, vectors, matrices
|
||||
│ └── ...
|
||||
└── <module>/ # Feature modules (fftw, crypt, compress, etc.)
|
||||
```
|
||||
|
||||
## Additional Notes
|
||||
- Project uses custom CMake macros from `cmake/` directory
|
||||
- Version format: `MAJOR.MINOR.REVISION` (e.g., 5.6.0)
|
||||
- All files have LGPL license header
|
||||
- Support for multiple platforms: Windows, Linux, QNX, Android, Apple
|
||||
+34
-14
@@ -70,6 +70,8 @@ option(INTROSPECTION "Build with introspection" OFF)
|
||||
option(TESTS "Build tests" OFF)
|
||||
option(TESTS_RUN "Run tests before install step" OFF)
|
||||
option(COVERAGE "Build project with coverage info" OFF)
|
||||
option(PIP_NO_FILESYSTEM "Disable filesystem support" OFF)
|
||||
option(PIP_NO_THREADS "Disable threading support" OFF)
|
||||
option(PIP_FFTW_F "Support fftw module for float" ON)
|
||||
option(PIP_FFTW_L "Support fftw module for long double" ON)
|
||||
option(PIP_FFTW_Q "Support fftw module for quad double" OFF)
|
||||
@@ -223,11 +225,26 @@ if (TESTS)
|
||||
add_subdirectory(tests)
|
||||
endif()
|
||||
|
||||
if(PIP_FREERTOS)
|
||||
add_definitions(-DPIP_FREERTOS)
|
||||
if(PIP_MICRO)
|
||||
add_definitions(-DMICRO_PIP)
|
||||
set(ICU OFF)
|
||||
set(LOCAL ON)
|
||||
endif()
|
||||
if(PIP_FREERTOS)
|
||||
add_definitions(-DPIP_FREERTOS)
|
||||
endif()
|
||||
if(DEFINED PICO_BOARD)
|
||||
add_definitions(-DPICO_SDK)
|
||||
set(PIP_NO_FILESYSTEM ON CACHE BOOL "" FORCE)
|
||||
message(STATUS "Building PIP for Pi Pico SDK ${PICO_SDK_VERSION_STRING}")
|
||||
endif()
|
||||
|
||||
if(PIP_NO_FILESYSTEM)
|
||||
add_definitions(-DPIP_NO_FILESYSTEM)
|
||||
endif()
|
||||
if(PIP_NO_THREADS)
|
||||
add_definitions(-DPIP_NO_THREADS)
|
||||
endif()
|
||||
|
||||
# Check Bessel functions
|
||||
set(CMAKE_REQUIRED_INCLUDES math.h)
|
||||
@@ -331,7 +348,7 @@ if ((NOT DEFINED SHSTKPROJECT) AND (DEFINED ANDROID_PLATFORM))
|
||||
#message("${ANDROID_NDK}/sysroot/usr/include")
|
||||
endif()
|
||||
|
||||
if(NOT PIP_FREERTOS)
|
||||
if(NOT PIP_MICRO)
|
||||
if(WIN32)
|
||||
if(${C_COMPILER} STREQUAL "cl.exe")
|
||||
else()
|
||||
@@ -352,7 +369,7 @@ if(NOT PIP_FREERTOS)
|
||||
endif()
|
||||
endif()
|
||||
set(PIP_LIBS)
|
||||
if(PIP_FREERTOS)
|
||||
if(PIP_MICRO)
|
||||
set(PIP_LIBS ${LIBS_MAIN})
|
||||
else()
|
||||
foreach(LIB_ ${LIBS_MAIN})
|
||||
@@ -369,11 +386,11 @@ else()
|
||||
if (NOT DEFINED ANDROID_PLATFORM)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-exceptions")
|
||||
endif()
|
||||
if(DEFINED ENV{QNX_HOST} OR PIP_FREERTOS)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -ftemplate-depth-32")
|
||||
endif()
|
||||
endif()
|
||||
set(CMAKE_C_FLAGS "${CMAKE_CXX_FLAGS}")
|
||||
if(DEFINED ENV{QNX_HOST} OR PIP_MICRO)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -ftemplate-depth-32")
|
||||
endif()
|
||||
|
||||
set(PCRE2_BUILD_PCRE2_8 OFF CACHE BOOL "" FORCE)
|
||||
set(PCRE2_BUILD_PCRE2_16 ON CACHE BOOL "" FORCE)
|
||||
@@ -411,7 +428,7 @@ endif()
|
||||
|
||||
|
||||
if (NOT CROSSTOOLS)
|
||||
if (NOT PIP_FREERTOS)
|
||||
if (NOT PIP_MICRO)
|
||||
|
||||
if (PIP_BUILD_CONSOLE)
|
||||
pip_module(console "" "PIP console support" "" "" "")
|
||||
@@ -649,9 +666,12 @@ if (NOT CROSSTOOLS)
|
||||
endif()
|
||||
|
||||
if (PIP_BUILD_IO_UTILS)
|
||||
if(PIP_BUILD_CRYPT)
|
||||
pip_module(io_utils "pip_crypt" "PIP I/O support" "" "" " (+crypt)")
|
||||
else()
|
||||
pip_module(io_utils "" "PIP I/O support" "" "" "")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
endif()
|
||||
endif()
|
||||
|
||||
@@ -659,7 +679,7 @@ string(REPLACE ";" "," PIP_EXPORTS_STR "${PIP_EXPORTS}")
|
||||
target_compile_definitions(pip PRIVATE "PICODE_DEFINES=\"${PIP_EXPORTS_STR}\"")
|
||||
|
||||
|
||||
if(NOT PIP_FREERTOS)
|
||||
if(NOT PIP_MICRO)
|
||||
|
||||
# Auxiliary
|
||||
if (NOT CROSSTOOLS)
|
||||
@@ -736,7 +756,7 @@ if(NOT LOCAL)
|
||||
install(TARGETS ${PIP_MODULES} DESTINATION ${CMAKE_INSTALL_PREFIX}/lib)
|
||||
endif()
|
||||
else()
|
||||
if(NOT PIP_FREERTOS)
|
||||
if(NOT PIP_MICRO)
|
||||
if(WIN32)
|
||||
install(TARGETS ${PIP_MODULES} RUNTIME DESTINATION bin)
|
||||
install(TARGETS ${PIP_MODULES} ARCHIVE DESTINATION lib)
|
||||
@@ -764,7 +784,7 @@ endif()
|
||||
#
|
||||
# Build Documentation
|
||||
#
|
||||
if ((NOT PIP_FREERTOS) AND (NOT CROSSTOOLS))
|
||||
if ((NOT PIP_MICRO) AND (NOT CROSSTOOLS))
|
||||
include(PIPDocumentation)
|
||||
find_package(Doxygen)
|
||||
if(DOXYGEN_FOUND)
|
||||
@@ -833,7 +853,7 @@ message(" Type : ${CMAKE_BUILD_TYPE}")
|
||||
if (NOT LOCAL)
|
||||
message(" Install: \"${CMAKE_INSTALL_PREFIX}\"")
|
||||
else()
|
||||
if(NOT PIP_FREERTOS)
|
||||
if(NOT PIP_MICRO)
|
||||
message(" Install: local \"bin\", \"lib\" and \"include\"")
|
||||
endif()
|
||||
endif()
|
||||
@@ -869,7 +889,7 @@ message(" Utilites:")
|
||||
foreach(_util ${PIP_UTILS_LIST})
|
||||
message(" * ${_util}")
|
||||
endforeach()
|
||||
if(NOT PIP_FREERTOS)
|
||||
if(NOT PIP_MICRO)
|
||||
message("")
|
||||
message(" Using libraries:")
|
||||
foreach(LIB_ ${LIBS_STATUS})
|
||||
|
||||
+1
-1
@@ -72,7 +72,7 @@ if (NOT BUILDING_PIP)
|
||||
find_library(PTHREAD_LIBRARY pthread)
|
||||
find_library(UTIL_LIBRARY util)
|
||||
set(_PIP_ADD_LIBS_ ${PTHREAD_LIBRARY} ${UTIL_LIBRARY})
|
||||
if((NOT DEFINED ENV{QNX_HOST}) AND (NOT APPLE) AND (NOT PIP_FREERTOS))
|
||||
if((NOT DEFINED ENV{QNX_HOST}) AND (NOT APPLE) AND (NOT PIP_MICRO))
|
||||
find_library(RT_LIBRARY rt)
|
||||
list(APPEND _PIP_ADD_LIBS_ ${RT_LIBRARY})
|
||||
endif()
|
||||
|
||||
@@ -17,6 +17,7 @@ list(APPEND COMPONENT_ADD_INCLUDEDIRS "../libs/main/thread")
|
||||
set(COMPONENT_PRIV_REQUIRES pthread lwip freertos vfs spi_flash libsodium)
|
||||
register_component()
|
||||
set(PIP_FREERTOS ON)
|
||||
set(PIP_MICRO ON)
|
||||
set(LIB OFF)
|
||||
set(INCLUDE_DIRS ${IDF_INCLUDE_DIRECTORIES})
|
||||
list(APPEND INCLUDE_DIRS $ENV{IDF_PATH}/components/newlib/platform_include)
|
||||
|
||||
@@ -178,6 +178,9 @@ PISystemTime uint64toST(uint64_t v) {
|
||||
void PISystemMonitor::run() {
|
||||
cur_tm.clear();
|
||||
tbid.clear();
|
||||
ProcessStats tstat;
|
||||
tstat.ID = pID_;
|
||||
#ifndef PIP_NO_THREADS
|
||||
__PIThreadCollection * pitc = __PIThreadCollection::instance();
|
||||
pitc->lock();
|
||||
PIVector<PIThread *> tv = pitc->threads();
|
||||
@@ -185,12 +188,10 @@ void PISystemMonitor::run() {
|
||||
if (t->isPIObject()) tbid[t->tid()] = t->name();
|
||||
pitc->unlock();
|
||||
// piCout << tbid.keys().toType<uint>();
|
||||
ProcessStats tstat;
|
||||
tstat.ID = pID_;
|
||||
#ifdef MICRO_PIP
|
||||
# ifdef FREERTOS
|
||||
for (auto * t: tv)
|
||||
if (t->isPIObject()) gatherThread(t->tid());
|
||||
#else
|
||||
# else // FREERTOS
|
||||
# ifndef WINDOWS
|
||||
double delay_ms = delay_.toMilliseconds();
|
||||
tbid[pID_] = "main";
|
||||
@@ -210,7 +211,7 @@ void PISystemMonitor::run() {
|
||||
tstat.cpu_load_user = 100.f * (PRIVATE->cpu_u_cur - PRIVATE->cpu_u_prev).toMilliseconds() / delay_ms;
|
||||
cycle = 0;
|
||||
// piCout << (PRIVATE->cpu_u_cur - PRIVATE->cpu_u_prev).toMilliseconds() / delay_ms;
|
||||
# else
|
||||
# else // MAC_OS
|
||||
PRIVATE->file.seekToBegin();
|
||||
PIString str = PIString::fromAscii(PRIVATE->file.readAll());
|
||||
int si = str.find('(') + 1, fi = 0, cc = 1;
|
||||
@@ -264,8 +265,8 @@ void PISystemMonitor::run() {
|
||||
if (i.flags[PIFile::FileInfo::Dot] || i.flags[PIFile::FileInfo::DotDot]) continue;
|
||||
gatherThread(i.name().toInt());
|
||||
}
|
||||
# endif
|
||||
# else
|
||||
# endif // MAC_OS
|
||||
# else // WINDOWS
|
||||
if (GetProcessMemoryInfo(PRIVATE->hProc, &PRIVATE->mem_cnt, sizeof(PRIVATE->mem_cnt)) != 0) {
|
||||
tstat.physical_memsize = PRIVATE->mem_cnt.WorkingSetSize;
|
||||
}
|
||||
@@ -315,8 +316,9 @@ void PISystemMonitor::run() {
|
||||
tstat.cpu_load_user = 0.f;
|
||||
}
|
||||
PRIVATE->tm.reset();
|
||||
# endif
|
||||
#endif
|
||||
# endif // WINDOWS
|
||||
# endif // FREERTOS
|
||||
#endif // PIP_NO_THREADS
|
||||
|
||||
tstat.cpu_load_system = piClampf(tstat.cpu_load_system, 0.f, 100.f);
|
||||
tstat.cpu_load_user = piClampf(tstat.cpu_load_user, 0.f, 100.f);
|
||||
|
||||
@@ -18,6 +18,8 @@
|
||||
*/
|
||||
#include "pikbdlistener.h"
|
||||
|
||||
#ifndef MICRO_PIP
|
||||
|
||||
# include "piincludes_p.h"
|
||||
# include "piliterals.h"
|
||||
# include "piwaitevent_p.h"
|
||||
@@ -587,3 +589,5 @@ void PIKbdListener::setActive(bool yes) {
|
||||
# endif
|
||||
}
|
||||
}
|
||||
|
||||
#endif // MICRO_PIP
|
||||
|
||||
@@ -25,6 +25,10 @@
|
||||
#ifndef PIKBDLISTENER_H
|
||||
#define PIKBDLISTENER_H
|
||||
|
||||
#include "pibase.h"
|
||||
|
||||
#ifndef MICRO_PIP
|
||||
|
||||
# include "pithread.h"
|
||||
# include "pitime.h"
|
||||
|
||||
@@ -377,4 +381,5 @@ REGISTER_PIVARIANTSIMPLE(PIKbdListener::KeyEvent)
|
||||
REGISTER_PIVARIANTSIMPLE(PIKbdListener::MouseEvent)
|
||||
REGISTER_PIVARIANTSIMPLE(PIKbdListener::WheelEvent)
|
||||
|
||||
#endif // MICRO_PIP
|
||||
#endif // PIKBDLISTENER_H
|
||||
|
||||
@@ -225,8 +225,10 @@ extern char ** environ;
|
||||
|
||||
# ifdef MICRO_PIP
|
||||
# define __PIP_TYPENAME__(T) "?"
|
||||
# else
|
||||
# elif defined(__GXX_RTTI__) || defined(__RTTI__)
|
||||
# define __PIP_TYPENAME__(T) typeid(T).name()
|
||||
# else
|
||||
# define __PIP_TYPENAME__(T) "?"
|
||||
# endif
|
||||
|
||||
# ifdef CC_GCC
|
||||
|
||||
+28
-2
@@ -31,13 +31,14 @@
|
||||
|
||||
#include "pibase.h"
|
||||
|
||||
#ifndef MICRO_PIP
|
||||
#ifndef PIP_NO_THREADS
|
||||
|
||||
# include "piincludes.h"
|
||||
|
||||
|
||||
class PIFile;
|
||||
class PIStringList;
|
||||
class PIInit;
|
||||
|
||||
class PIP_EXPORT __PIInit_Initializer__ {
|
||||
public:
|
||||
@@ -49,6 +50,31 @@ public:
|
||||
|
||||
static __PIInit_Initializer__ __piinit_initializer__;
|
||||
|
||||
#ifdef MICRO_PIP
|
||||
#ifndef PIINIT_MICRO_STUB_DEFINED
|
||||
#define PIINIT_MICRO_STUB_DEFINED
|
||||
|
||||
int __PIInit_Initializer__::count_ = 0;
|
||||
PIInit * __PIInit_Initializer__::__instance__ = nullptr;
|
||||
|
||||
__PIInit_Initializer__::__PIInit_Initializer__() {
|
||||
count_++;
|
||||
if (count_ > 1) return;
|
||||
__instance__ = nullptr;
|
||||
}
|
||||
|
||||
__PIInit_Initializer__::~__PIInit_Initializer__() {
|
||||
count_--;
|
||||
if (count_ > 0) return;
|
||||
if (__instance__ != nullptr) {
|
||||
__instance__ = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
//! \~\ingroup Core
|
||||
//! \~\brief
|
||||
//! \~english Library initialization singleton and build information access point.
|
||||
@@ -96,5 +122,5 @@ private:
|
||||
};
|
||||
|
||||
|
||||
#endif // MICRO_PIP
|
||||
#endif // PIP_NO_THREADS
|
||||
#endif // PIINIT_H
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
|
||||
#include "piconditionvar.h"
|
||||
#include "pithread.h"
|
||||
#include "pitime.h"
|
||||
#ifndef MICRO_PIP
|
||||
# include "pifile.h"
|
||||
# include "piiostream.h"
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
*/
|
||||
|
||||
#include "piwaitevent_p.h"
|
||||
#ifndef MICRO_PIP
|
||||
# ifdef WINDOWS
|
||||
// # ifdef _WIN32_WINNT
|
||||
// # undef _WIN32_WINNT
|
||||
@@ -151,3 +152,5 @@ void * PIWaitEvent::getEvent() const {
|
||||
return nullptr;
|
||||
# endif
|
||||
}
|
||||
|
||||
#endif // MICRO_PIP
|
||||
|
||||
@@ -20,6 +20,8 @@
|
||||
#ifndef PIWAITEVENT_P_H
|
||||
#define PIWAITEVENT_P_H
|
||||
|
||||
#ifndef MICRO_PIP
|
||||
|
||||
# include "pibase.h"
|
||||
// clang-format off
|
||||
#ifdef WINDOWS
|
||||
@@ -65,4 +67,5 @@ private:
|
||||
};
|
||||
|
||||
|
||||
#endif // MICRO_PIP
|
||||
#endif // PIWAITEVENT_P_H
|
||||
|
||||
@@ -19,6 +19,8 @@
|
||||
|
||||
#include "piintrospection_server_p.h"
|
||||
|
||||
#if defined(PIP_INTROSPECTION) && !defined(PIP_FORCE_NO_PIINTROSPECTION)
|
||||
|
||||
# include "pichunkstream.h"
|
||||
# include "piinit.h"
|
||||
# include "piobject.h"
|
||||
@@ -170,3 +172,5 @@ void PIIntrospection::unpackObjects(PIByteArray & ba, PIVector<PIIntrospection::
|
||||
objects.clear();
|
||||
ba >> objects;
|
||||
}
|
||||
|
||||
#endif // #if defined(PIP_INTROSPECTION) && !defined(PIP_FORCE_NO_PIINTROSPECTION)
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
#include "piintrospection_threads_p.h"
|
||||
#include "pisystemmonitor.h"
|
||||
|
||||
#if defined(PIP_INTROSPECTION) && !defined(PIP_FORCE_NO_PIINTROSPECTION)
|
||||
|
||||
class PIP_EXPORT PIIntrospection {
|
||||
public:
|
||||
@@ -168,4 +169,5 @@ BINARY_STREAM_READ(PIIntrospection::ObjectInfo) {
|
||||
return s;
|
||||
}
|
||||
|
||||
#endif // #if defined(PIP_INTROSPECTION) && !defined(PIP_FORCE_NO_PIINTROSPECTION)
|
||||
#endif // PIINTROSPECTION_SERVER_P_H
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
|
||||
#include "piintrospection_threads_p.h"
|
||||
|
||||
#if defined(PIP_INTROSPECTION) && !defined(PIP_FORCE_NO_PIINTROSPECTION)
|
||||
|
||||
PIIntrospectionThreads::ThreadInfo::ThreadInfo() {
|
||||
id = delay = 0;
|
||||
@@ -78,3 +79,5 @@ void PIIntrospectionThreads::threadRunDone(PIThread * t, ullong us) {
|
||||
ThreadInfo & ti(threads[t]);
|
||||
ti.run_us = (ti.run_us * 0.8) + (us * 0.2); /// WARNING
|
||||
}
|
||||
|
||||
#endif // #if defined(PIP_INTROSPECTION) && !defined(PIP_FORCE_NO_PIINTROSPECTION)
|
||||
|
||||
@@ -20,6 +20,10 @@
|
||||
#ifndef PIINTROSPECTION_THREADS_P_H
|
||||
#define PIINTROSPECTION_THREADS_P_H
|
||||
|
||||
#include "pibase.h"
|
||||
|
||||
#if defined(PIP_INTROSPECTION) && !defined(PIP_FORCE_NO_PIINTROSPECTION)
|
||||
|
||||
#include "pimap.h"
|
||||
#include "pithread.h"
|
||||
|
||||
@@ -68,4 +72,5 @@ BINARY_STREAM_READ(PIIntrospectionThreads::ThreadInfo) {
|
||||
return s;
|
||||
}
|
||||
|
||||
#endif // #if defined(PIP_INTROSPECTION) && !defined(PIP_FORCE_NO_PIINTROSPECTION)
|
||||
#endif // PIINTROSPECTION_THREADS_P_H
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
|
||||
#include "pipropertystorage.h"
|
||||
#include "piwaitevent_p.h"
|
||||
#if !defined(WINDOWS) && !defined(MAC_OS) && !defined(MICRO_PIP)
|
||||
#if !defined(WINDOWS) && !defined(MAC_OS) && !defined(PIP_NO_SOCKET)
|
||||
# define PIP_CAN
|
||||
#endif
|
||||
#ifdef PIP_CAN
|
||||
@@ -39,25 +39,29 @@
|
||||
|
||||
REGISTER_DEVICE(PICAN)
|
||||
|
||||
|
||||
#ifdef PIP_CAN
|
||||
PRIVATE_DEFINITION_START(PICAN)
|
||||
PIWaitEvent event;
|
||||
PRIVATE_DEFINITION_END(PICAN)
|
||||
|
||||
#endif
|
||||
|
||||
PICAN::PICAN(const PIString & path, PIIODevice::DeviceMode mode): PIIODevice(path, mode) {
|
||||
setThreadedReadBufferSize(256);
|
||||
setPath(path);
|
||||
#ifdef PIP_CAN
|
||||
can_id = 0;
|
||||
sock = 0;
|
||||
PRIVATE->event.create();
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
PICAN::~PICAN() {
|
||||
stopAndWait();
|
||||
close();
|
||||
#ifdef PIP_CAN
|
||||
PRIVATE->event.destroy();
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@@ -164,7 +168,9 @@ int PICAN::readedCANID() const {
|
||||
|
||||
|
||||
void PICAN::interrupt() {
|
||||
#ifdef PIP_CAN
|
||||
PRIVATE->event.interrupt();
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#ifndef PIP_NO_FILESYSTEM
|
||||
#include "pidir.h"
|
||||
|
||||
#include "piincludes_p.h"
|
||||
@@ -610,3 +611,4 @@ void PIDir::CurrentDirOverrider::save(const PIFile::FileInfo & info) {
|
||||
else
|
||||
PIDir::setCurrent(PIDir::current().path() + PIDir::separator + p);
|
||||
}
|
||||
#endif // PIP_NO_FILESYSTEM
|
||||
|
||||
@@ -30,6 +30,7 @@
|
||||
#include "piregularexpression.h"
|
||||
|
||||
|
||||
#ifndef PIP_NO_FILESYSTEM
|
||||
//! \~\ingroup IO
|
||||
//! \~\brief
|
||||
//! \~english Local directory.
|
||||
@@ -217,8 +218,10 @@ private:
|
||||
|
||||
PIString path_, scan_;
|
||||
};
|
||||
#endif // PIP_NO_FILESYSTEM
|
||||
|
||||
|
||||
#ifndef PIP_NO_FILESYSTEM
|
||||
inline bool operator<(const PIFile::FileInfo & v0, const PIFile::FileInfo & v1) {
|
||||
return (v0.path < v1.path);
|
||||
}
|
||||
@@ -242,6 +245,7 @@ inline PICout operator<<(PICout s, const PIDir & v) {
|
||||
s.restoreControls();
|
||||
return s;
|
||||
}
|
||||
#endif // PIP_NO_FILESYSTEM
|
||||
|
||||
|
||||
#endif // PIDIR_H
|
||||
|
||||
@@ -18,6 +18,8 @@
|
||||
*/
|
||||
#include "piethernet.h"
|
||||
|
||||
#ifndef PIP_NO_SOCKET
|
||||
|
||||
# include "piconfig.h"
|
||||
# include "piconstchars.h"
|
||||
# include "piincludes_p.h"
|
||||
@@ -25,7 +27,7 @@
|
||||
# include "pipropertystorage.h"
|
||||
# include "pisysteminfo.h"
|
||||
# include "pitranslator.h"
|
||||
// clang-format off
|
||||
|
||||
# ifdef QNX
|
||||
# include <arpa/inet.h>
|
||||
# include <fcntl.h>
|
||||
@@ -49,21 +51,21 @@
|
||||
# else
|
||||
# ifdef WINDOWS
|
||||
# include <io.h>
|
||||
# include <winsock2.h>
|
||||
# include <iphlpapi.h>
|
||||
# include <psapi.h>
|
||||
# include <winsock2.h>
|
||||
# include <ws2tcpip.h>
|
||||
# define ip_mreqn ip_mreq
|
||||
# define imr_address imr_interface
|
||||
# else
|
||||
# include <arpa/inet.h>
|
||||
# include <fcntl.h>
|
||||
# include <sys/ioctl.h>
|
||||
# include <net/if.h>
|
||||
# include <netdb.h>
|
||||
# include <netinet/in.h>
|
||||
# include <netinet/tcp.h>
|
||||
# include <arpa/inet.h>
|
||||
# include <sys/ioctl.h>
|
||||
# include <sys/socket.h>
|
||||
# include <netdb.h>
|
||||
# include <net/if.h>
|
||||
# if !defined(ANDROID) && !defined(LWIP)
|
||||
# include <ifaddrs.h>
|
||||
# endif
|
||||
@@ -72,7 +74,6 @@
|
||||
# endif
|
||||
# endif
|
||||
# endif
|
||||
// clang-format on
|
||||
# include "piwaitevent_p.h"
|
||||
|
||||
# include <errno.h>
|
||||
@@ -196,7 +197,7 @@ void PIEthernet::construct() {
|
||||
setMulticastTTL(1);
|
||||
server_thread_.setData(this);
|
||||
server_thread_.setName("_S.tcpserver"_a);
|
||||
#ifdef MICRO_PIP
|
||||
# ifdef LWIP
|
||||
setThreadedReadBufferSize(512);
|
||||
# else
|
||||
setThreadedReadBufferSize(64_KiB);
|
||||
@@ -1171,7 +1172,7 @@ PIEthernet::InterfaceList PIEthernet::interfaces() {
|
||||
}
|
||||
if (pAdapterInfo) HeapFree(GetProcessHeap(), 0, pAdapterInfo);
|
||||
# else
|
||||
# ifdef MICRO_PIP
|
||||
# ifdef LWIP
|
||||
# else
|
||||
# ifdef ANDROID
|
||||
struct ifconf ifc;
|
||||
@@ -1283,7 +1284,7 @@ PIEthernet::InterfaceList PIEthernet::interfaces() {
|
||||
|
||||
|
||||
PINetworkAddress PIEthernet::interfaceAddress(const PIString & interface_) {
|
||||
#if defined(WINDOWS) || defined(MICRO_PIP)
|
||||
# if defined(WINDOWS) || defined(LWIP)
|
||||
piCout << "[PIEthernet] Not implemented, use \"PIEthernet::allAddresses\" or \"PIEthernet::interfaces\" instead";
|
||||
return PINetworkAddress();
|
||||
# else
|
||||
@@ -1487,3 +1488,5 @@ bool PIEthernet::ethIsWriteable(int sock) {
|
||||
return ret == 0;
|
||||
# endif
|
||||
}
|
||||
|
||||
#endif // PIP_NO_SOCKET
|
||||
|
||||
@@ -25,9 +25,12 @@
|
||||
#ifndef PIETHERNET_H
|
||||
#define PIETHERNET_H
|
||||
|
||||
|
||||
#include "piiodevice.h"
|
||||
#include "pinetworkaddress.h"
|
||||
|
||||
#ifndef PIP_NO_SOCKET
|
||||
|
||||
# ifdef ANDROID
|
||||
struct
|
||||
# else
|
||||
@@ -703,4 +706,5 @@ inline bool operator!=(const PIEthernet::Interface & v0, const PIEthernet::Inter
|
||||
return (v0.name != v1.name || v0.address != v1.address || v0.netmask != v1.netmask);
|
||||
}
|
||||
|
||||
#endif // PIP_NO_SOCKET
|
||||
#endif // PIETHERNET_H
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef PIP_NO_FILESYSTEM
|
||||
#include "pifile.h"
|
||||
|
||||
#include "pidir.h"
|
||||
@@ -45,7 +46,7 @@
|
||||
# include <utime.h>
|
||||
#endif
|
||||
#define S_IFHDN 0x40
|
||||
#if defined(QNX) || defined(ANDROID) || defined(FREERTOS)
|
||||
#if defined(QNX) || defined(ANDROID) || defined(MICRO_PIP)
|
||||
# define _fopen_call_ fopen
|
||||
# define _fseek_call_ fseek
|
||||
# define _ftell_call_ ftell
|
||||
@@ -635,3 +636,4 @@ int PIFile::writeAll(const PIString & path, const PIByteArray & data) {
|
||||
f.clear();
|
||||
return f.write(data.data(), data.size_s());
|
||||
}
|
||||
#endif // PIP_NO_FILESYSTEM
|
||||
|
||||
@@ -31,6 +31,7 @@
|
||||
#include "pipropertystorage.h"
|
||||
|
||||
|
||||
#ifndef PIP_NO_FILESYSTEM
|
||||
//! \~\ingroup IO
|
||||
//! \~\brief
|
||||
//! \~english Local file.
|
||||
@@ -361,8 +362,10 @@ private:
|
||||
llong _size = -1;
|
||||
PIString prec_str;
|
||||
};
|
||||
#endif // PIP_NO_FILESYSTEM
|
||||
|
||||
|
||||
#ifndef PIP_NO_FILESYSTEM
|
||||
//! \relatesalso PICout
|
||||
//! \~english Output operator to \a PICout.
|
||||
//! \~russian Оператор вывода в \a PICout.
|
||||
@@ -395,5 +398,6 @@ BINARY_STREAM_READ(PIFile::FileInfo) {
|
||||
v.perm_group.raw >> v.perm_other.raw;
|
||||
return s;
|
||||
}
|
||||
#endif // PIP_NO_FILESYSTEM
|
||||
|
||||
#endif // PIFILE_H
|
||||
|
||||
@@ -19,6 +19,8 @@
|
||||
|
||||
#include "piserial.h"
|
||||
|
||||
#ifndef MICRO_PIP
|
||||
|
||||
# include "piconfig.h"
|
||||
# include "pidir.h"
|
||||
# include "piincludes_p.h"
|
||||
@@ -29,9 +31,6 @@
|
||||
|
||||
# include <errno.h>
|
||||
|
||||
#if defined(MICRO_PIP)
|
||||
# define PISERIAL_NO_PINS
|
||||
#endif
|
||||
# if defined(PISERIAL_NO_PINS) || defined(WINDOWS)
|
||||
# define TIOCM_LE 1
|
||||
# define TIOCM_DTR 4
|
||||
@@ -1318,3 +1317,5 @@ void PISerial::threadedReadBufferSizeChanged() {
|
||||
// piCoutObj << "a" << ss.xmit_fifo_size;
|
||||
# endif
|
||||
}
|
||||
|
||||
#endif // MICRO_PIP
|
||||
|
||||
@@ -153,8 +153,14 @@
|
||||
#ifdef PIP_FREERTOS
|
||||
# define FREERTOS
|
||||
#endif
|
||||
#if defined(FREERTOS) || defined(PLATFORMIO)
|
||||
# define MICRO_PIP
|
||||
#ifdef MICRO_PIP
|
||||
# ifndef FREERTOS
|
||||
# define PIP_NO_THREADS
|
||||
# endif
|
||||
# ifndef LWIP
|
||||
# define PIP_NO_SOCKET
|
||||
# endif
|
||||
# define PISERIAL_NO_PINS
|
||||
#endif
|
||||
#ifndef WINDOWS
|
||||
# ifndef QNX
|
||||
|
||||
@@ -41,7 +41,11 @@ template<typename... Args>
|
||||
class Function: public FunctionBase {
|
||||
public:
|
||||
uint formatHash() override {
|
||||
#if defined(__GXX_RTTI__) || defined(__RTTI__)
|
||||
static uint ret = PIConstChars(typeid(std::function<void(Args...)>).name()).hash();
|
||||
#else
|
||||
static uint ret = 0;
|
||||
#endif
|
||||
return ret;
|
||||
}
|
||||
std::function<bool(Args...)> func;
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
# include "pifile.h"
|
||||
# include "piiostream.h"
|
||||
|
||||
# ifdef LINUX
|
||||
# include <fcntl.h>
|
||||
# include <linux/input-event-codes.h>
|
||||
# include <linux/input.h>
|
||||
@@ -14,6 +15,14 @@
|
||||
# include <sys/time.h>
|
||||
# include <unistd.h>
|
||||
# else
|
||||
// Stubs for embedded/non-Linux builds
|
||||
# define EV_SYN 0
|
||||
# define EV_KEY 1
|
||||
# define EV_REL 2
|
||||
# define EV_ABS 3
|
||||
# define EVIOCGABS(_v) 0
|
||||
# endif
|
||||
#else
|
||||
// clang-format off
|
||||
# undef _WIN32_WINNT
|
||||
# define _WIN32_WINNT 0x0600
|
||||
@@ -399,6 +408,7 @@ PIVector<PIHIDeviceInfo> PIHIDevice::allDevices(bool try_open) {
|
||||
ullong bits = readFile(hd_i.path + file).toULLong(16);
|
||||
// piCout<< PICoutManipulators::Bin << abs;
|
||||
if (bits > 0) {
|
||||
#ifdef LINUX
|
||||
int fd = ::open(dev.path.dataAscii(), O_RDONLY);
|
||||
if (fd < 0) {
|
||||
// piCout << "Warning: can`t open" << dev.path << errorString();
|
||||
@@ -423,6 +433,19 @@ PIVector<PIHIDeviceInfo> PIHIDevice::allDevices(bool try_open) {
|
||||
}
|
||||
}
|
||||
if (fd >= 0) ::close(fd);
|
||||
#else
|
||||
// Stub implementation for non-Linux builds
|
||||
PIHIDeviceInfo::AxisInfo ai;
|
||||
ai.is_relative = is_relative;
|
||||
ai.min = 0;
|
||||
ai.max = 1024;
|
||||
for (int bit = 0; bit < 64; ++bit) {
|
||||
if (checkBit(bits, bit, PIString::fromNumber(bit))) {
|
||||
ai.data_index = bit;
|
||||
ret << ai;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
return ret;
|
||||
};
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
# define _WIN32_WINNT 0x0600
|
||||
#endif
|
||||
|
||||
#ifndef PIP_NO_THREADS
|
||||
#include "piconditionvar.h"
|
||||
#include "piincludes_p.h"
|
||||
#ifdef WINDOWS
|
||||
@@ -175,3 +176,4 @@ void PIConditionVariable::notifyAll() {
|
||||
pthread_cond_broadcast(&PRIVATE->nativeHandle);
|
||||
#endif
|
||||
}
|
||||
#endif // PIP_NO_THREADS
|
||||
|
||||
@@ -28,6 +28,8 @@
|
||||
#include "pimutex.h"
|
||||
#include "pisystemtime.h"
|
||||
|
||||
|
||||
#ifndef PIP_NO_THREADS
|
||||
//! \~\ingroup Thread
|
||||
//! \~\brief
|
||||
//! \~english Condition variable used together with external %PIMutex.
|
||||
@@ -173,5 +175,5 @@ private:
|
||||
PRIVATE_DECLARATION(PIP_EXPORT)
|
||||
};
|
||||
|
||||
|
||||
#endif // PIP_NO_THREADS
|
||||
#endif // PICONDITIONVAR_H
|
||||
|
||||
@@ -107,6 +107,7 @@
|
||||
//! \}
|
||||
|
||||
|
||||
#ifndef PIP_NO_THREADS
|
||||
#include "pimutex.h"
|
||||
|
||||
#include "piincludes_p.h"
|
||||
@@ -228,3 +229,4 @@ void PIMutex::destroy() {
|
||||
pthread_mutex_destroy(&(PRIVATE->mutex));
|
||||
#endif
|
||||
}
|
||||
#endif // PIP_NO_THREADS
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
|
||||
#include "piinit.h"
|
||||
|
||||
#ifndef PIP_NO_THREADS
|
||||
//! \~\ingroup Thread
|
||||
//! \~\brief
|
||||
//! \~english Mutex for mutual exclusion between threads.
|
||||
@@ -93,5 +94,5 @@ private:
|
||||
bool cond;
|
||||
};
|
||||
|
||||
|
||||
#endif // PIP_NO_THREADS
|
||||
#endif // PIMUTEX_H
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef PIP_NO_THREADS
|
||||
#include "pithread.h"
|
||||
|
||||
#include "piincludes_p.h"
|
||||
@@ -1086,3 +1087,4 @@ bool PIThread::_waitForFinish(PISystemTime max_tm) {
|
||||
#endif
|
||||
return false;
|
||||
}
|
||||
#endif // PIP_NO_THREADS
|
||||
|
||||
@@ -43,6 +43,7 @@
|
||||
|
||||
class PIThread;
|
||||
|
||||
#ifndef PIP_NO_THREADS
|
||||
#ifndef MICRO_PIP
|
||||
class PIIntrospectionThreads;
|
||||
|
||||
@@ -339,5 +340,5 @@ private:
|
||||
void setThreadName();
|
||||
};
|
||||
|
||||
|
||||
#endif // PIP_NO_THREADS
|
||||
#endif // PITHREAD_H
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef PIP_NO_THREADS
|
||||
#include "pitimer.h"
|
||||
|
||||
#include "piconditionvar.h"
|
||||
@@ -315,3 +316,4 @@ void PITimer::stop() {
|
||||
thread->stop();
|
||||
event.notifyAll();
|
||||
}
|
||||
#endif // PIP_NO_THREADS
|
||||
|
||||
@@ -44,6 +44,7 @@
|
||||
|
||||
class PIThread;
|
||||
|
||||
#ifndef PIP_NO_THREADS
|
||||
//! \~\ingroup Thread
|
||||
//! \~\brief
|
||||
//! \~english Periodic timer that emits ticks from an internal worker thread.
|
||||
@@ -246,5 +247,5 @@ protected:
|
||||
PIConditionVariable event;
|
||||
};
|
||||
|
||||
|
||||
#endif // PIP_NO_THREADS
|
||||
#endif // PITIMER_H
|
||||
|
||||
@@ -26,6 +26,8 @@
|
||||
# include "pisystemtests.h"
|
||||
#elif defined(ARDUINO)
|
||||
# include <Arduino.h>
|
||||
#elif defined(PICO_SDK)
|
||||
# include "hardware/time.h"
|
||||
#endif
|
||||
#ifdef MICRO_PIP
|
||||
# include <sys/time.h>
|
||||
@@ -48,15 +50,13 @@
|
||||
void piUSleep(int usecs) {
|
||||
if (usecs <= 0) return;
|
||||
#ifdef WINDOWS
|
||||
// printf("Sleep %d\n", usecs / 1000);
|
||||
if (usecs > 0) Sleep(usecs / 1000);
|
||||
// printf("Sleep end");
|
||||
#else
|
||||
# ifdef FREERTOS
|
||||
Sleep(usecs / 1000);
|
||||
#elif defined(FREERTOS)
|
||||
vTaskDelay(usecs / 1000 / portTICK_PERIOD_MS);
|
||||
#elif defined(PICO_SDK)
|
||||
sleep_us(usecs);
|
||||
#else
|
||||
usecs -= PISystemTests::usleep_offset_us;
|
||||
if (usecs > 0) usleep(usecs);
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -54,12 +54,16 @@ public:
|
||||
}
|
||||
#ifdef MICRO_PIP
|
||||
PIString typeName() const final {
|
||||
static PIString ret(PIVariant(T()).typeName());
|
||||
static PIString ret(PIVariant::fromValue<T>(T()).typeName());
|
||||
return ret;
|
||||
}
|
||||
#else
|
||||
PIString typeName() const final {
|
||||
#if defined(__GXX_RTTI__) || defined(__RTTI__)
|
||||
static PIString ret(typeid(T).name());
|
||||
#else
|
||||
static PIString ret("unknown");
|
||||
#endif
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user