platformio_pre.py
This commit is contained in:
@@ -1,3 +0,0 @@
|
||||
Import("env")
|
||||
|
||||
env.Append(CCFLAGS=["-Ilib/pip/libs/main/core", "-Ilib/pip/libs/main/containers", "-Ilib/pip/libs/main/introspection"])
|
||||
10
library.json
10
library.json
@@ -13,17 +13,13 @@
|
||||
"dependencies": {"mike-matera/ArduinoSTL": "^1.3.2"},
|
||||
"build":
|
||||
{
|
||||
"srcDir": "libs/main",
|
||||
"srcFilter": [
|
||||
"+<core/*.cpp>",
|
||||
"+<core/*.h>",
|
||||
"+<containers/*.cpp>",
|
||||
"+<containers/*.h>"
|
||||
"+<libs/main/core/*.cpp>",
|
||||
"+<libs/main/containers/*.cpp>"
|
||||
],
|
||||
"flags": [
|
||||
"-std=c++11",
|
||||
"-DPIP_MICRO"
|
||||
],
|
||||
"extraScript": "include_pip.py"
|
||||
"extraScript": "platformio_pre.py"
|
||||
}
|
||||
}
|
||||
@@ -19,7 +19,7 @@
|
||||
|
||||
#include "picompress.h"
|
||||
#ifdef PIP_COMPRESS
|
||||
# ifdef FREERTOS
|
||||
# ifdef ESP_PLATFORM
|
||||
# include "esp32/rom/miniz.h"
|
||||
# define compress2 mz_compress2
|
||||
# define Z_OK MZ_OK
|
||||
|
||||
@@ -63,7 +63,7 @@ PIScreen::SystemConsole::SystemConsole() {
|
||||
GetConsoleMode(PRIVATE->hOut, &PRIVATE->smode);
|
||||
GetConsoleCursorInfo(PRIVATE->hOut, &PRIVATE->curinfo);
|
||||
#else
|
||||
# ifdef FREERTOS
|
||||
# ifdef MICRO_PIP
|
||||
w = 80;
|
||||
h = 24;
|
||||
# else
|
||||
@@ -115,7 +115,7 @@ void PIScreen::SystemConsole::prepare() {
|
||||
w = PRIVATE->csbi.srWindow.Right - PRIVATE->csbi.srWindow.Left + 1;
|
||||
h = PRIVATE->csbi.srWindow.Bottom - PRIVATE->csbi.srWindow.Top + 1;
|
||||
#else
|
||||
# ifndef FREERTOS
|
||||
# ifndef MICRO_PIP
|
||||
winsize ws;
|
||||
ioctl(0, TIOCGWINSZ, &ws);
|
||||
w = ws.ws_col;
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
#include "piincludes_p.h"
|
||||
#include "piterminal.h"
|
||||
#include "pisharedmemory.h"
|
||||
#ifndef FREERTOS
|
||||
#ifndef MICRO_PIP
|
||||
#ifdef WINDOWS
|
||||
# include <windows.h>
|
||||
# include <wingdi.h>
|
||||
@@ -918,4 +918,4 @@ bool PITerminal::resize(int cols, int rows) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
#endif // FREERTOS
|
||||
#endif // MICRO_PIP
|
||||
|
||||
@@ -28,13 +28,13 @@
|
||||
|
||||
#include "picout.h"
|
||||
#include "piintrospection_containers.h"
|
||||
#ifndef PIP_MICRO
|
||||
//#ifndef PIP_MICRO
|
||||
# ifdef MAC_OS
|
||||
# include <stdlib.h>
|
||||
# else
|
||||
# include <malloc.h>
|
||||
# endif
|
||||
#endif
|
||||
//#endif
|
||||
#include <initializer_list>
|
||||
#include <type_traits>
|
||||
#include <string.h>
|
||||
|
||||
@@ -124,6 +124,7 @@
|
||||
#include <cstddef>
|
||||
#include <cassert>
|
||||
#include <limits>
|
||||
#include <atomic>
|
||||
|
||||
#ifdef WINDOWS
|
||||
# ifdef CC_VC
|
||||
@@ -277,7 +278,7 @@
|
||||
} _PIP_ADD_COUNTER(_pip_initializer_);
|
||||
|
||||
|
||||
#ifdef FREERTOS
|
||||
#ifdef MICRO_PIP
|
||||
# define PIP_MIN_MSLEEP 10.
|
||||
#else
|
||||
# define PIP_MIN_MSLEEP 1.
|
||||
|
||||
@@ -29,7 +29,7 @@
|
||||
#include "pivector2d.h"
|
||||
#include <stdio.h>
|
||||
|
||||
#ifdef FREERTOS
|
||||
#ifdef MICRO_PIP
|
||||
# define _TYPENAME_(T) "?"
|
||||
#else
|
||||
# define _TYPENAME_(T) typeid(T).name()
|
||||
|
||||
@@ -26,9 +26,6 @@
|
||||
#ifdef PIP_STD_IOSTREAM
|
||||
# include <iostream>
|
||||
#endif
|
||||
#ifndef PIP_MICRO
|
||||
# include <atomic>
|
||||
#endif
|
||||
|
||||
class PIMutex;
|
||||
class PIMutexLocker;
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
#include "pisysteminfo.h"
|
||||
#include "piresourcesstorage.h"
|
||||
#include "pidir.h"
|
||||
#ifndef FREERTOS
|
||||
#ifndef MICRO_PIP
|
||||
# include "piprocess.h"
|
||||
#endif
|
||||
#ifdef ESP_PLATFORM
|
||||
@@ -49,7 +49,7 @@ void __PISetTimerResolution() {
|
||||
}
|
||||
#else
|
||||
# include <pwd.h>
|
||||
# ifndef FREERTOS
|
||||
# ifndef MICRO_PIP
|
||||
# include <sys/utsname.h>
|
||||
# endif
|
||||
# include <pthread.h>
|
||||
@@ -84,7 +84,7 @@ ULONG prev_res;
|
||||
bool delete_locs;
|
||||
PRIVATE_DEFINITION_END(PIInit)
|
||||
|
||||
#ifndef FREERTOS
|
||||
#ifndef MICRO_PIP
|
||||
void __sighandler__(PISignals::Signal s) {
|
||||
//piCout << Hex << int(s);
|
||||
if (s == PISignals::StopTTYInput || s == PISignals::StopTTYOutput)
|
||||
@@ -106,9 +106,9 @@ PIInit::PIInit() {
|
||||
file_charset = 0;
|
||||
PISystemInfo * sinfo = PISystemInfo::instance();
|
||||
sinfo->execDateTime = PIDateTime::current();
|
||||
#ifndef MICRO_PIP
|
||||
setFileCharset("UTF-8");
|
||||
#ifndef FREERTOS
|
||||
#ifndef ANDROID
|
||||
# ifndef ANDROID
|
||||
PISignals::setSlot(__sighandler__);
|
||||
PISignals::grabSignals(PISignals::UserDefined1);
|
||||
# ifndef WINDOWS
|
||||
@@ -128,7 +128,7 @@ PIInit::PIInit() {
|
||||
break;
|
||||
}
|
||||
}
|
||||
# else
|
||||
# else //WINDOWS
|
||||
// OS version
|
||||
DWORD dwVersion = GetVersion();
|
||||
DWORD dwMajorVersion = (DWORD)(LOBYTE(LOWORD(dwVersion)));
|
||||
@@ -154,7 +154,7 @@ PIInit::PIInit() {
|
||||
setTimerResolutionAddr = (PINtSetTimerResolution)GetProcAddress(PRIVATE->ntlib, "NtSetTimerResolution");
|
||||
__PISetTimerResolution();
|
||||
}
|
||||
# endif
|
||||
# endif //WINDOWS
|
||||
# ifdef HAS_LOCALE
|
||||
//cout << "has locale" << endl;
|
||||
if (currentLocale_t != 0) {
|
||||
@@ -162,22 +162,22 @@ PIInit::PIInit() {
|
||||
currentLocale_t = 0;
|
||||
}
|
||||
currentLocale_t = newlocale(LC_ALL, setlocale(LC_ALL, ""), 0);
|
||||
# else
|
||||
# else //HAS_LOCALE
|
||||
setlocale(LC_ALL, "");
|
||||
setlocale(LC_NUMERIC, "C");
|
||||
# endif
|
||||
#else
|
||||
# endif //HAS_LOCALE
|
||||
# else //ANDROID
|
||||
struct sigaction actions;
|
||||
memset(&actions, 0, sizeof(actions));
|
||||
sigemptyset(&actions.sa_mask);
|
||||
actions.sa_flags = 0;
|
||||
actions.sa_handler = android_thread_exit_handler;
|
||||
sigaction(SIGTERM, &actions, 0);
|
||||
#endif
|
||||
# endif //ANDROID
|
||||
PRIVATE->delete_locs = false;
|
||||
__syslocname__ = __sysoemname__ = 0;
|
||||
__utf8name__ = const_cast<char*>("UTF-8");
|
||||
#ifdef PIP_ICU
|
||||
# ifdef PIP_ICU
|
||||
UErrorCode e((UErrorCode)0);
|
||||
u_init(&e);
|
||||
# ifdef WINDOWS
|
||||
@@ -201,21 +201,21 @@ PIInit::PIInit() {
|
||||
# endif
|
||||
//piCout << __syslocname__;
|
||||
//piCout << __sysoemname__;
|
||||
#else
|
||||
# else //PIP_ICU
|
||||
# ifdef WINDOWS
|
||||
__syslocname__ = (char *)CP_ACP;
|
||||
__sysoemname__ = (char *)CP_OEMCP;
|
||||
__utf8name__ = (char *)CP_UTF8;
|
||||
# endif
|
||||
#endif
|
||||
#ifdef MAC_OS
|
||||
# endif //PIP_ICU
|
||||
# ifdef MAC_OS
|
||||
host_get_clock_service(mach_host_self(), CALENDAR_CLOCK, &__pi_mac_clock);
|
||||
#endif
|
||||
# endif
|
||||
char cbuff[1024];
|
||||
memset(cbuff, 0, 1024);
|
||||
if (gethostname(cbuff, 1023) == 0)
|
||||
sinfo->hostname = cbuff;
|
||||
#ifdef WINDOWS
|
||||
# ifdef WINDOWS
|
||||
SYSTEM_INFO sysinfo;
|
||||
GetSystemInfo(&sysinfo);
|
||||
sinfo->processorsCount = sysinfo.dwNumberOfProcessors;
|
||||
@@ -236,7 +236,7 @@ PIInit::PIInit() {
|
||||
ulong unlen = 1023;
|
||||
if (GetUserName(cbuff, &unlen) != 0)
|
||||
sinfo->user = cbuff;
|
||||
#else
|
||||
# else //WINDOWS
|
||||
sinfo->processorsCount = piMaxi(1, int(sysconf(_SC_NPROCESSORS_ONLN)));
|
||||
passwd * ps = getpwuid(getuid());
|
||||
if (ps)
|
||||
@@ -252,8 +252,9 @@ PIInit::PIInit() {
|
||||
sinfo->OS_version = uns.release;
|
||||
sinfo->architecture = uns.machine;
|
||||
}
|
||||
# endif
|
||||
#endif
|
||||
# endif //WINDOWS
|
||||
#endif // MICRO_PIP
|
||||
|
||||
#ifdef ESP_PLATFORM
|
||||
esp_chip_info_t chip_info;
|
||||
esp_chip_info(&chip_info);
|
||||
@@ -265,19 +266,21 @@ PIInit::PIInit() {
|
||||
sinfo->OS_name =
|
||||
#ifdef WINDOWS
|
||||
PIStringAscii("Windows");
|
||||
#elif defined(QNX)
|
||||
# elif defined(QNX)
|
||||
PIStringAscii("QNX");
|
||||
#elif defined(MAC_OS)
|
||||
# elif defined(MAC_OS)
|
||||
PIStringAscii("MacOS");
|
||||
#elif defined(ANDROID)
|
||||
# elif defined(ANDROID)
|
||||
PIStringAscii("Android");
|
||||
#elif defined(FREE_BSD)
|
||||
# elif defined(FREE_BSD)
|
||||
PIStringAscii("FreeBSD");
|
||||
#elif defined(FREERTOS)
|
||||
# elif defined(FREERTOS)
|
||||
PIStringAscii("FreeRTOS");
|
||||
#else
|
||||
# elif defined(MICRO_PIP)
|
||||
PIStringAscii("MicroPIP");
|
||||
# else
|
||||
uns.sysname;
|
||||
#endif
|
||||
# endif
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
#include "pisysteminfo.h"
|
||||
#include "pithread.h"
|
||||
#include "piconditionvar.h"
|
||||
#ifndef FREERTOS
|
||||
#ifndef MICRO_PIP
|
||||
# include "pifile.h"
|
||||
#endif
|
||||
|
||||
@@ -355,7 +355,7 @@ void PIObject::piDisconnect(PIObject * src, const PIString & sig) {
|
||||
src->connections.remove(i);
|
||||
i--;
|
||||
if (dest) {
|
||||
#if !defined(ANDROID) && !defined(MAC_OS) && !defined(FREERTOS)
|
||||
#if !defined(ANDROID) && !defined(MAC_OS) && !defined(MICRO_PIP)
|
||||
PIMutexLocker _mld(dest->mutex_connect, src != dest);
|
||||
#endif
|
||||
dest->updateConnectors();
|
||||
@@ -373,7 +373,7 @@ void PIObject::piDisconnectAll() {
|
||||
// piCout << "disconnect"<< src << o;
|
||||
if (!o || (o == this)) continue;
|
||||
if (!o->isPIObject()) continue;
|
||||
#if !defined(ANDROID) && !defined(MAC_OS) && !defined(FREERTOS)
|
||||
#if !defined(ANDROID) && !defined(MAC_OS) && !defined(MICRO_PIP)
|
||||
PIMutexLocker _mld(o->mutex_connect, this != o);
|
||||
#endif
|
||||
PIVector<Connection> & oc(o->connections);
|
||||
@@ -615,7 +615,7 @@ void dumpApplication() {
|
||||
}
|
||||
|
||||
|
||||
#ifndef FREERTOS
|
||||
#ifndef MICRO_PIP
|
||||
bool dumpApplicationToFile(const PIString & path) {
|
||||
PIFile f(path + "_tmp");
|
||||
f.setName("__S__DumpFile");
|
||||
|
||||
@@ -192,9 +192,9 @@ public:
|
||||
static PIObject::Connection piConnect(PIObject * src, const PIString & sig, PIObject * dest_o, void * dest, void * ev_h, void * e_h, int args, const char * loc);
|
||||
static PIObject::Connection piConnectU(PIObject * src, const PIString & sig, PIObject * dest_o, void * dest, const PIString & hname, const char * loc, PIObject * performer = 0);
|
||||
static PIObject::Connection piConnectLS(PIObject * src, const PIString & sig, std::function<void()> * f, const char * loc);
|
||||
template <typename INPUT, typename... TYPES>
|
||||
static std::function<void()> * __newFunctor(void(*stat_handler)(void*,TYPES...), INPUT functor) {
|
||||
return (std::function<void()>*)(new std::function<void(TYPES...)>(functor));
|
||||
template <typename PIINPUT, typename... PITYPES>
|
||||
static std::function<void()> * __newFunctor(void(*stat_handler)(void*,PITYPES...), PIINPUT functor) {
|
||||
return (std::function<void()>*)(new std::function<void(PITYPES...)>(functor));
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -35,6 +35,9 @@
|
||||
# include "freertos/FreeRTOS.h"
|
||||
# include "freertos/task.h"
|
||||
#endif
|
||||
#ifdef MICRO_PIP
|
||||
# include <sys/time.h>
|
||||
#endif
|
||||
|
||||
/*! \class PISystemTime
|
||||
* @brief System time
|
||||
@@ -252,12 +255,10 @@ PISystemTime PISystemTime::current(bool precise_but_not_system) {
|
||||
ullong lt = ullong(sft.dwHighDateTime) * 0x100000000U + ullong(sft.dwLowDateTime);
|
||||
return PISystemTime(lt / 10000000U, (lt % 10000000U) * 100U);
|
||||
}
|
||||
#else
|
||||
# ifdef MAC_OS
|
||||
#elif defined(MAC_OS)
|
||||
mach_timespec_t t_cur;
|
||||
clock_get_time(__pi_mac_clock, &t_cur);
|
||||
# else
|
||||
# ifdef FREERTOS
|
||||
#elif defined(MICRO_PIP)
|
||||
timespec t_cur;
|
||||
timeval tv;
|
||||
tv.tv_sec = 0;
|
||||
@@ -265,11 +266,11 @@ PISystemTime PISystemTime::current(bool precise_but_not_system) {
|
||||
gettimeofday(&tv, NULL);
|
||||
t_cur.tv_sec = tv.tv_sec;
|
||||
t_cur.tv_nsec = tv.tv_usec * 1000;
|
||||
# else
|
||||
#else
|
||||
timespec t_cur;
|
||||
clock_gettime(precise_but_not_system ? CLOCK_MONOTONIC : 0, &t_cur);
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
#ifndef WINDOWS
|
||||
return PISystemTime(t_cur.tv_sec, t_cur.tv_nsec);
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
|
||||
#include "pistring.h"
|
||||
#include <typeinfo>
|
||||
#ifdef PIP_FREERTOS
|
||||
#ifdef MICRO_PIP
|
||||
#include "pivariant.h"
|
||||
#endif
|
||||
|
||||
@@ -48,10 +48,10 @@ template<typename T>
|
||||
class __VariantFunctions__: public __VariantFunctionsBase__ {
|
||||
public:
|
||||
__VariantFunctionsBase__ * instance() final {static __VariantFunctions__<T> ret; return &ret;}
|
||||
#ifdef PIP_FREERTOS
|
||||
#ifdef MICRO_PIP
|
||||
PIString typeName() const final {static PIString ret(PIVariant(T()).typeName()); return ret;}
|
||||
#else
|
||||
PIString typeName() const final {static PIString ret(typeid(T).name()); return ret;}
|
||||
PIString typeName() const final {static PIString ret(_TYPENAME_(T)); return ret;}
|
||||
#endif
|
||||
uint hash() const final {static uint ret = typeName().hash(); return ret;}
|
||||
void newT(void *& ptr, const void * value) final {ptr = (void*)(new T(*(const T*)value));}
|
||||
|
||||
@@ -53,7 +53,7 @@ static const uchar binlog_sig[] = {'B','I','N','L','O','G'};
|
||||
REGISTER_DEVICE(PIBinaryLog)
|
||||
|
||||
PIBinaryLog::PIBinaryLog() {
|
||||
#ifdef FREERTOS
|
||||
#ifdef MICRO_PIP
|
||||
setThreadedReadBufferSize(512);
|
||||
#else
|
||||
setThreadedReadBufferSize(65536);
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
#include "pican.h"
|
||||
#include "pipropertystorage.h"
|
||||
#include "piincludes_p.h"
|
||||
#if !defined(WINDOWS) && !defined(MAC_OS) && !defined(FREERTOS)
|
||||
#if !defined(WINDOWS) && !defined(MAC_OS) && !defined(MICRO_PIP)
|
||||
# define PIP_CAN
|
||||
#endif
|
||||
#ifdef PIP_CAN
|
||||
|
||||
@@ -58,10 +58,10 @@
|
||||
# include <sys/socket.h>
|
||||
# include <netdb.h>
|
||||
# include <net/if.h>
|
||||
# if !defined(ANDROID) && !defined(FREERTOS)
|
||||
# if !defined(ANDROID) && !defined(LWIP)
|
||||
# include <ifaddrs.h>
|
||||
# endif
|
||||
# ifdef FREERTOS
|
||||
# ifdef LWIP
|
||||
# include <lwip/sockets.h>
|
||||
# endif
|
||||
# endif
|
||||
@@ -260,7 +260,7 @@ void PIEthernet::construct() {
|
||||
setMulticastTTL(1);
|
||||
server_thread_.setData(this);
|
||||
server_thread_.setName("__S__server_thread");
|
||||
#ifdef FREERTOS
|
||||
#ifdef MICRO_PIP
|
||||
setThreadedReadBufferSize(512);
|
||||
#else
|
||||
setThreadedReadBufferSize(65536);
|
||||
@@ -473,7 +473,7 @@ bool PIEthernet::joinMulticastGroup(const PIString & group) {
|
||||
}
|
||||
PIFlags<Parameters> params = parameters();
|
||||
addr_r.set(path());
|
||||
#ifndef FREERTOS
|
||||
#ifndef LWIP
|
||||
struct ip_mreqn mreq;
|
||||
#else
|
||||
struct ip_mreq mreq;
|
||||
@@ -486,13 +486,13 @@ bool PIEthernet::joinMulticastGroup(const PIString & group) {
|
||||
if (ci != 0) mreq.imr_ifindex = ci->index;*/
|
||||
#endif
|
||||
if (params[PIEthernet::Broadcast])
|
||||
#ifndef FREERTOS
|
||||
#ifndef LWIP
|
||||
mreq.imr_address.s_addr = INADDR_ANY;
|
||||
#else
|
||||
mreq.imr_interface.s_addr = INADDR_ANY;
|
||||
#endif
|
||||
else
|
||||
#ifndef FREERTOS
|
||||
#ifndef LWIP
|
||||
mreq.imr_address.s_addr = addr_r.ip();
|
||||
#else
|
||||
mreq.imr_interface.s_addr = addr_r.ip();
|
||||
@@ -520,20 +520,20 @@ bool PIEthernet::leaveMulticastGroup(const PIString & group) {
|
||||
}
|
||||
PIFlags<Parameters> params = parameters();
|
||||
addr_r.set(path());
|
||||
#ifndef FREERTOS
|
||||
#ifndef LWIP
|
||||
struct ip_mreqn mreq;
|
||||
#else
|
||||
struct ip_mreq mreq;
|
||||
#endif
|
||||
memset(&mreq, 0, sizeof(mreq));
|
||||
if (params[PIEthernet::Broadcast])
|
||||
#ifndef FREERTOS
|
||||
#ifndef LWIP
|
||||
mreq.imr_address.s_addr = INADDR_ANY;
|
||||
#else
|
||||
mreq.imr_interface.s_addr = INADDR_ANY;
|
||||
#endif
|
||||
else
|
||||
#ifndef FREERTOS
|
||||
#ifndef LWIP
|
||||
mreq.imr_address.s_addr = addr_r.ip();
|
||||
#else
|
||||
mreq.imr_interface.s_addr = addr_r.ip();
|
||||
@@ -1053,7 +1053,7 @@ PIEthernet::InterfaceList PIEthernet::interfaces() {
|
||||
if (pAdapterInfo)
|
||||
HeapFree(GetProcessHeap(), 0, (pAdapterInfo));
|
||||
#else
|
||||
#ifdef FREERTOS
|
||||
#ifdef MICRO_PIP
|
||||
#else
|
||||
# ifdef ANDROID
|
||||
struct ifconf ifc;
|
||||
@@ -1165,7 +1165,7 @@ PIEthernet::InterfaceList PIEthernet::interfaces() {
|
||||
|
||||
|
||||
PIEthernet::Address PIEthernet::interfaceAddress(const PIString & interface_) {
|
||||
#if defined(WINDOWS) || defined(FREERTOS)
|
||||
#if defined(WINDOWS) || defined(MICRO_PIP)
|
||||
piCout << "[PIEthernet] Not implemented, use \"PIEthernet::allAddresses\" or \"PIEthernet::interfaces\" instead";
|
||||
return Address();
|
||||
#else
|
||||
|
||||
@@ -711,7 +711,7 @@ PIFile::FileInfo PIFile::fileInfo(const PIString & path) {
|
||||
ret.time_modification = PIDateTime::fromSystemTime(PISystemTime(fs.MTIME.tv_sec, fs.MTIME.tv_nsec));
|
||||
# endif
|
||||
#endif
|
||||
#ifndef FREERTOS
|
||||
#ifndef MICRO_PIP
|
||||
ret.perm_user = FileInfo::Permissions((mode & S_IRUSR) == S_IRUSR, (mode & S_IWUSR) == S_IWUSR, (mode & S_IXUSR) == S_IXUSR);
|
||||
ret.perm_group = FileInfo::Permissions((mode & S_IRGRP) == S_IRGRP, (mode & S_IWGRP) == S_IWGRP, (mode & S_IXGRP) == S_IXGRP);
|
||||
ret.perm_other = FileInfo::Permissions((mode & S_IROTH) == S_IROTH, (mode & S_IWOTH) == S_IWOTH, (mode & S_IXOTH) == S_IXOTH);
|
||||
|
||||
@@ -155,7 +155,7 @@ bool PIIODevice::setOption(PIIODevice::DeviceOption o, bool yes) {
|
||||
|
||||
|
||||
bool stopThread(PIThread * t, bool hard) {
|
||||
#ifdef FREERTOS
|
||||
#ifdef MICRO_PIP
|
||||
t->stop(true);
|
||||
#else
|
||||
if (hard) {
|
||||
@@ -222,7 +222,7 @@ void PIIODevice::_init() {
|
||||
setOptions(0);
|
||||
setReopenEnabled(true);
|
||||
setReopenTimeout(1000);
|
||||
#ifdef FREERTOS
|
||||
#ifdef MICRO_PIP
|
||||
threaded_read_buffer_size = 512;
|
||||
//setThreadedReadBufferSize(512);
|
||||
#else
|
||||
@@ -276,7 +276,7 @@ void PIIODevice::terminate() {
|
||||
thread_started_ = false;
|
||||
if (!init_) return;
|
||||
if (isRunning()) {
|
||||
#ifdef FREERTOS
|
||||
#ifdef MICRO_PIP
|
||||
stop(true);
|
||||
#else
|
||||
stop();
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
#include "pipropertystorage.h"
|
||||
#include <errno.h>
|
||||
|
||||
#if defined(FREERTOS)
|
||||
#if defined(MICRO_PIP)
|
||||
# define PISERIAL_NO_PINS
|
||||
#endif
|
||||
#if defined(PISERIAL_NO_PINS) || defined(WINDOWS)
|
||||
|
||||
@@ -42,7 +42,7 @@ REGISTER_DEVICE(PISPI)
|
||||
|
||||
|
||||
PISPI::PISPI(const PIString & path, uint speed, PIIODevice::DeviceMode mode) : PIIODevice(path, mode) {
|
||||
#ifdef FREERTOS
|
||||
#ifdef MICRO_PIP
|
||||
setThreadedReadBufferSize(512);
|
||||
#else
|
||||
setThreadedReadBufferSize(1024);
|
||||
|
||||
@@ -37,7 +37,7 @@ PIBaseTransfer::PIBaseTransfer(): crc(standardCRC_16()), diag(false) {
|
||||
diag.setName("PIBaseTransfer");
|
||||
diag.start(50);
|
||||
packets_count = 10;
|
||||
#ifdef FREERTOS
|
||||
#ifdef MICRO_PIP
|
||||
setPacketSize(512);
|
||||
#else
|
||||
setPacketSize(4096);
|
||||
|
||||
@@ -94,7 +94,7 @@ void PIPacketExtractor::construct() {
|
||||
ret_func_header = ret_func_footer = 0;
|
||||
setPayloadSize(0);
|
||||
setTimeout(100);
|
||||
#ifdef FREERTOS
|
||||
#ifdef MICRO_PIP
|
||||
setBufferSize(512);
|
||||
#else
|
||||
setBufferSize(65536);
|
||||
|
||||
@@ -51,13 +51,16 @@
|
||||
#ifdef PIP_FREERTOS
|
||||
# define FREERTOS
|
||||
#endif
|
||||
#if defined(FREERTOS) || defined(PLATFORMIO)
|
||||
# define MICRO_PIP
|
||||
#endif
|
||||
#ifndef WINDOWS
|
||||
# ifndef QNX
|
||||
# ifndef FREE_BSD
|
||||
# ifndef MAC_OS
|
||||
# ifndef ANDROID
|
||||
# ifndef BLACKBERRY
|
||||
# ifndef FREERTOS
|
||||
# ifndef MICRO_PIP
|
||||
# define LINUX
|
||||
# endif
|
||||
# endif
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef PIP_FREERTOS
|
||||
#ifndef MICRO_PIP
|
||||
|
||||
#include "pilibrary.h"
|
||||
#include "piincludes_p.h"
|
||||
@@ -110,4 +110,4 @@ void PILibrary::getLastError() {
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif // PIP_FREERTOS
|
||||
#endif // MICRO_PIP
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
#ifndef PILIBRARY_H
|
||||
#define PILIBRARY_H
|
||||
|
||||
#ifndef PIP_FREERTOS
|
||||
#ifndef MICRO_PIP
|
||||
|
||||
#include "pistring.h"
|
||||
|
||||
@@ -50,5 +50,5 @@ private:
|
||||
|
||||
};
|
||||
|
||||
#endif // PIP_FREERTOS
|
||||
#endif // MICRO_PIP
|
||||
#endif // PILIBRARY_H
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef PIP_FREERTOS
|
||||
#ifndef MICRO_PIP
|
||||
|
||||
#include "piplugin.h"
|
||||
#include "pifile.h"
|
||||
@@ -408,4 +408,4 @@ PIString PIPluginLoader::libExtension() {
|
||||
}
|
||||
|
||||
|
||||
#endif // PIP_FREERTOS
|
||||
#endif // MICRO_PIP
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
#ifndef PIPLUGIN_H
|
||||
#define PIPLUGIN_H
|
||||
|
||||
#ifndef PIP_FREERTOS
|
||||
#ifndef MICRO_PIP
|
||||
|
||||
#include "pilibrary.h"
|
||||
#include "pistringlist.h"
|
||||
@@ -212,5 +212,5 @@ private:
|
||||
};
|
||||
|
||||
|
||||
#endif // PIP_FREERTOS
|
||||
#endif // MICRO_PIP
|
||||
#endif // PIPLUGIN_H
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef PIP_FREERTOS
|
||||
#ifndef MICRO_PIP
|
||||
|
||||
#include "piincludes_p.h"
|
||||
#include "piprocess.h"
|
||||
@@ -290,5 +290,5 @@ PIString PIProcess::getEnvironmentVariable(const PIString & variable) {
|
||||
return PIString();
|
||||
}
|
||||
|
||||
#endif // PIP_FREERTOS
|
||||
#endif // MICRO_PIP
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
#ifndef PIPROCESS_H
|
||||
#define PIPROCESS_H
|
||||
|
||||
#ifndef PIP_FREERTOS
|
||||
#ifndef MICRO_PIP
|
||||
|
||||
#include "pithread.h"
|
||||
#include "pifile.h"
|
||||
@@ -104,5 +104,5 @@ private:
|
||||
|
||||
};
|
||||
|
||||
#endif // PIP_FREERTOS
|
||||
#endif // MICRO_PIP
|
||||
#endif // PIPROCESS_H
|
||||
|
||||
@@ -59,7 +59,7 @@ PISystemMonitor::ThreadStatsFixed::ThreadStatsFixed() {
|
||||
}
|
||||
|
||||
|
||||
#ifndef FREERTOS
|
||||
#ifndef MICRO_PIP
|
||||
PRIVATE_DEFINITION_START(PISystemMonitor)
|
||||
#ifndef WINDOWS
|
||||
# ifdef MAC_OS
|
||||
@@ -83,7 +83,7 @@ PRIVATE_DEFINITION_END(PISystemMonitor)
|
||||
PISystemMonitor::PISystemMonitor(): PIThread() {
|
||||
pID_ = cycle = 0;
|
||||
cpu_count = PISystemInfo::instance()->processorsCount;
|
||||
#ifndef FREERTOS
|
||||
#ifndef MICRO_PIP
|
||||
#ifndef WINDOWS
|
||||
# ifdef QNX
|
||||
page_size = 4096;
|
||||
@@ -104,7 +104,7 @@ PISystemMonitor::~PISystemMonitor() {
|
||||
}
|
||||
|
||||
|
||||
#ifndef FREERTOS
|
||||
#ifndef MICRO_PIP
|
||||
bool PISystemMonitor::startOnProcess(int pID, int interval_ms) {
|
||||
stop();
|
||||
pID_ = pID;
|
||||
@@ -134,7 +134,7 @@ bool PISystemMonitor::startOnProcess(int pID, int interval_ms) {
|
||||
|
||||
|
||||
bool PISystemMonitor::startOnSelf(int interval_ms) {
|
||||
#ifndef FREERTOS
|
||||
#ifndef MICRO_PIP
|
||||
bool ret = startOnProcess(PIProcess::currentPID(), interval_ms);
|
||||
cycle = -1;
|
||||
#else
|
||||
@@ -196,7 +196,7 @@ void PISystemMonitor::run() {
|
||||
//piCout << tbid.keys().toType<uint>();
|
||||
ProcessStats tstat;
|
||||
tstat.ID = pID_;
|
||||
#ifdef FREERTOS
|
||||
#ifdef MICRO_PIP
|
||||
piForeach (PIThread * t, tv)
|
||||
if (t->isPIObject())
|
||||
gatherThread(t->tid());
|
||||
@@ -357,7 +357,7 @@ void PISystemMonitor::run() {
|
||||
void PISystemMonitor::gatherThread(llong id) {
|
||||
PISystemMonitor::ThreadStats ts;
|
||||
ts.id = id;
|
||||
#ifdef FREERTOS
|
||||
#ifdef MICRO_PIP
|
||||
ts.name = tbid.value(id, "<PIThread>");
|
||||
#else
|
||||
ts.name = tbid.value(id, "<non-PIThread>");
|
||||
|
||||
@@ -79,7 +79,7 @@ public:
|
||||
PIString name;
|
||||
};
|
||||
|
||||
#ifndef FREERTOS
|
||||
#ifndef MICRO_PIP
|
||||
bool startOnProcess(int pID, int interval_ms = 1000);
|
||||
#endif
|
||||
bool startOnSelf(int interval_ms = 1000);
|
||||
@@ -106,7 +106,7 @@ private:
|
||||
PIMap<llong, PIString> tbid;
|
||||
mutable PIMutex stat_mutex;
|
||||
int pID_, page_size, cpu_count, cycle;
|
||||
#ifndef FREERTOS
|
||||
#ifndef MICRO_PIP
|
||||
PRIVATE_DECLARATION(PIP_EXPORT)
|
||||
#endif
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
|
||||
#include "pisystemtests.h"
|
||||
|
||||
#ifndef PIP_FREERTOS
|
||||
#ifndef MICRO_PIP
|
||||
# include "piconfig.h"
|
||||
#endif
|
||||
|
||||
@@ -35,7 +35,7 @@ namespace PISystemTests {
|
||||
|
||||
|
||||
PISystemTests::PISystemTestReader::PISystemTestReader() {
|
||||
#if !defined(WINDOWS) && !defined(FREERTOS)
|
||||
#if !defined(WINDOWS) && !defined(MICRO_PIP)
|
||||
PIConfig conf(PIStringAscii("/etc/pip.conf"), PIIODevice::ReadOnly);
|
||||
time_resolution_ns = conf.getValue(PIStringAscii("time_resolution_ns"), 1).toLong();
|
||||
time_elapsed_ns = conf.getValue(PIStringAscii("time_elapsed_ns"), 0).toLong();
|
||||
|
||||
85
platformio_pre.py
Normal file
85
platformio_pre.py
Normal file
@@ -0,0 +1,85 @@
|
||||
import os
|
||||
import glob
|
||||
import shutil
|
||||
import re
|
||||
|
||||
# The list of items
|
||||
files = glob.glob('libs/main/*/*.h', recursive=True)
|
||||
files += glob.glob('libs/main/*.h', recursive=True)
|
||||
|
||||
tdir = './include/'
|
||||
|
||||
if os.path.exists(tdir):
|
||||
shutil.rmtree(tdir)
|
||||
|
||||
os.mkdir(tdir)
|
||||
|
||||
for filename in files:
|
||||
shutil.copy(filename, tdir)
|
||||
|
||||
with open(tdir+'pip_defs.h', 'w') as f:
|
||||
f.write('// This file was generated by PlatformIO, don`t edit it!')
|
||||
|
||||
with open(tdir+'pip_export.h', 'w') as f:
|
||||
f.write('''
|
||||
#ifndef PIP_EXPORT_H
|
||||
#define PIP_EXPORT_H
|
||||
|
||||
# define PIP_EXPORT
|
||||
# define PIP_NO_EXPORT
|
||||
|
||||
|
||||
#ifndef PIP_DEPRECATED
|
||||
# define PIP_DEPRECATED __attribute__ ((__deprecated__))
|
||||
#endif
|
||||
|
||||
#ifndef PIP_DEPRECATED_EXPORT
|
||||
# define PIP_DEPRECATED_EXPORT PIP_EXPORT PIP_DEPRECATED
|
||||
#endif
|
||||
|
||||
#ifndef PIP_DEPRECATED_NO_EXPORT
|
||||
# define PIP_DEPRECATED_NO_EXPORT PIP_NO_EXPORT PIP_DEPRECATED
|
||||
#endif
|
||||
|
||||
#endif /* PIP_EXPORT_H */
|
||||
''')
|
||||
|
||||
version_h = '''
|
||||
#ifndef PIP_VERSION_H
|
||||
#define PIP_VERSION_H
|
||||
|
||||
|
||||
// Project
|
||||
|
||||
#define PIP_VERSION_MAJOR ${VERSION_MAJOR}
|
||||
#define PIP_VERSION_MINOR ${VERSION_MINOR}
|
||||
#define PIP_VERSION_REVISION ${VERSION_REVISION}
|
||||
#define PIP_VERSION_BUILD 0
|
||||
#define PIP_VERSION_SUFFIX \"${VERSION_SUFFIX}\"
|
||||
#define PIP_VERSION_NAME \"${VERSION}\"
|
||||
#define PIP_MAKE_VERSION(major, minor, revision) ((major << 16) | (minor << 8) | revision)
|
||||
#define PIP_VERSION PIP_MAKE_VERSION(PIP_VERSION_MAJOR, PIP_VERSION_MINOR, PIP_VERSION_REVISION)
|
||||
|
||||
#endif // PIP_VERSION_H
|
||||
'''
|
||||
|
||||
with open('CMakeLists.txt') as cm:
|
||||
str = cm.read()
|
||||
v_major = re.findall(r'pip_MAJOR\s+(\d+)\)', str)
|
||||
v_minor = re.findall(r'pip_MINOR\s+(\d+)\)', str)
|
||||
v_rev = re.findall(r'pip_REVISION\s+(\d+)\)', str)
|
||||
v_suffix = re.findall(r'pip_SUFFIX\s+(\w+)\)', str)
|
||||
ver = ''
|
||||
ver = v_major[0]+'.'+v_minor[0]+'.'+v_rev[0]
|
||||
version_h.replace('${VERSION_MAJOR}', v_major[0])
|
||||
version_h.replace('${VERSION_MINOR}', v_minor[0])
|
||||
version_h.replace('${VERSION_REVISION}', v_rev[0])
|
||||
if len(v_suffix):
|
||||
ver += v_suffix[0]
|
||||
version_h.replace('${VERSION_SUFFIX}', v_suffix[0])
|
||||
else:
|
||||
version_h.replace('${VERSION_SUFFIX}', '')
|
||||
print('PIP version = '+ver)
|
||||
with open(tdir+'pip_version.h', 'w') as f:
|
||||
f.write(version_h)
|
||||
|
||||
Reference in New Issue
Block a user