FreeRTOS console and io devices support for compile
git-svn-id: svn://db.shs.com.ru/pip@688 12ceb7fc-bf1f-11e4-8940-5bc7170c53b5
This commit is contained in:
@@ -120,10 +120,8 @@ endif()
|
|||||||
# Main lib
|
# Main lib
|
||||||
set(PIP_FOLDERS "." "core" "containers" "thread" "system" "io_devices" "io_utils" "console" "math" "code" "geo" "resources" "opencl" "crypt")
|
set(PIP_FOLDERS "." "core" "containers" "thread" "system" "io_devices" "io_utils" "console" "math" "code" "geo" "resources" "opencl" "crypt")
|
||||||
if(PIP_FREERTOS)
|
if(PIP_FREERTOS)
|
||||||
list(REMOVE_ITEM PIP_FOLDERS "io_devices")
|
#list(REMOVE_ITEM PIP_FOLDERS "console")
|
||||||
include_directories("${PIP_SRC_MAIN}/io_devices")
|
#include_directories("${PIP_SRC_MAIN}/console")
|
||||||
list(REMOVE_ITEM PIP_FOLDERS "console")
|
|
||||||
include_directories("${PIP_SRC_MAIN}/console")
|
|
||||||
endif()
|
endif()
|
||||||
include_directories("${PIP_SRC_MAIN}")
|
include_directories("${PIP_SRC_MAIN}")
|
||||||
set(PIP_MAIN_FOLDERS)
|
set(PIP_MAIN_FOLDERS)
|
||||||
@@ -132,7 +130,6 @@ foreach(F ${PIP_FOLDERS})
|
|||||||
include_directories("${PIP_SRC_MAIN}/${F}")
|
include_directories("${PIP_SRC_MAIN}/${F}")
|
||||||
gather_src("${PIP_SRC_MAIN}/${F}" CPP_LIB_MAIN HDRS PHDRS)
|
gather_src("${PIP_SRC_MAIN}/${F}" CPP_LIB_MAIN HDRS PHDRS)
|
||||||
endforeach(F)
|
endforeach(F)
|
||||||
|
|
||||||
# Crypt lib
|
# Crypt lib
|
||||||
gather_src("${PIP_SRC_CRYPT}" CPP_LIB_CRYPT HDRS PHDRS)
|
gather_src("${PIP_SRC_CRYPT}" CPP_LIB_CRYPT HDRS PHDRS)
|
||||||
|
|
||||||
@@ -234,7 +231,7 @@ if(ICU)
|
|||||||
add_definitions(-DPIP_ICU)
|
add_definitions(-DPIP_ICU)
|
||||||
list(APPEND LIBS_MAIN icuuc)
|
list(APPEND LIBS_MAIN icuuc)
|
||||||
else()
|
else()
|
||||||
message(STATUS "Building PIP without ICU, attention!")
|
message(STATUS "Building PIP without ICU")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
|
||||||
@@ -465,9 +462,19 @@ else(NOT PIP_FREERTOS)
|
|||||||
message(STATUS "Building PIP with crypt support")
|
message(STATUS "Building PIP with crypt support")
|
||||||
add_definitions(-DPIP_CRYPT)
|
add_definitions(-DPIP_CRYPT)
|
||||||
add_library(pip_crypt ${PIP_LIB_TYPE} ${CPP_LIB_CRYPT})
|
add_library(pip_crypt ${PIP_LIB_TYPE} ${CPP_LIB_CRYPT})
|
||||||
target_link_libraries(pip_crypt pip ${sodium_FOUND})
|
target_link_libraries(pip_crypt pip)
|
||||||
list(APPEND LIBS_STATUS sodium)
|
|
||||||
list(APPEND PIP_LIBS_TARGETS pip_crypt)
|
list(APPEND PIP_LIBS_TARGETS pip_crypt)
|
||||||
|
set(IO_UTILS_LIBS pip)
|
||||||
|
add_library(pip_io_utils ${PIP_LIB_TYPE} ${CPP_LIB_IO_UTILS})
|
||||||
|
message(STATUS "Building PIP IO Utils library with crypt support")
|
||||||
|
list(APPEND IO_UTILS_LIBS pip_crypt)
|
||||||
|
target_link_libraries(pip_io_utils ${IO_UTILS_LIBS})
|
||||||
|
list(APPEND PIP_LIBS_TARGETS pip_io_utils)
|
||||||
|
message(STATUS "Building PIP with zlib compress support")
|
||||||
|
add_definitions(-DPIP_COMPRESS)
|
||||||
|
add_library(pip_compress ${PIP_LIB_TYPE} ${CPP_LIB_COMPRESS})
|
||||||
|
target_link_libraries(pip_compress pip)
|
||||||
|
list(APPEND PIP_LIBS_TARGETS pip_compress)
|
||||||
endif(NOT PIP_FREERTOS)
|
endif(NOT PIP_FREERTOS)
|
||||||
|
|
||||||
# Install
|
# Install
|
||||||
|
|||||||
@@ -1,24 +1,41 @@
|
|||||||
set(COMPONENT_SRCS "main.cpp" "pip/src_main/io_devices/piiodevice.cpp")
|
set(COMPONENT_SRCS "main.cpp")
|
||||||
set(COMPONENT_ADD_INCLUDEDIRS pip/src_main)
|
set(COMPONENT_ADD_INCLUDEDIRS "pip/src_main")
|
||||||
list(APPEND COMPONENT_ADD_INCLUDEDIRS pip/src_main/auxiliary)
|
list(APPEND COMPONENT_ADD_INCLUDEDIRS "pip/src_main/auxiliary")
|
||||||
list(APPEND COMPONENT_ADD_INCLUDEDIRS pip/src_main/code)
|
list(APPEND COMPONENT_ADD_INCLUDEDIRS "pip/src_main/code")
|
||||||
list(APPEND COMPONENT_ADD_INCLUDEDIRS pip/src_main/console)
|
list(APPEND COMPONENT_ADD_INCLUDEDIRS "pip/src_main/console")
|
||||||
list(APPEND COMPONENT_ADD_INCLUDEDIRS pip/src_main/containers)
|
list(APPEND COMPONENT_ADD_INCLUDEDIRS "pip/src_main/containers")
|
||||||
list(APPEND COMPONENT_ADD_INCLUDEDIRS pip/src_main/core)
|
list(APPEND COMPONENT_ADD_INCLUDEDIRS "pip/src_main/core")
|
||||||
list(APPEND COMPONENT_ADD_INCLUDEDIRS pip/src_main/crypt)
|
list(APPEND COMPONENT_ADD_INCLUDEDIRS "pip/src_main/crypt")
|
||||||
list(APPEND COMPONENT_ADD_INCLUDEDIRS pip/src_main/geo)
|
list(APPEND COMPONENT_ADD_INCLUDEDIRS "pip/src_main/geo")
|
||||||
list(APPEND COMPONENT_ADD_INCLUDEDIRS pip/src_main/io_devices)
|
list(APPEND COMPONENT_ADD_INCLUDEDIRS "pip/src_main/io_devices")
|
||||||
list(APPEND COMPONENT_ADD_INCLUDEDIRS pip/src_main/io_utils)
|
list(APPEND COMPONENT_ADD_INCLUDEDIRS "pip/src_main/io_utils")
|
||||||
list(APPEND COMPONENT_ADD_INCLUDEDIRS pip/src_main/math)
|
list(APPEND COMPONENT_ADD_INCLUDEDIRS "pip/src_main/math")
|
||||||
list(APPEND COMPONENT_ADD_INCLUDEDIRS pip/src_main/opencl)
|
list(APPEND COMPONENT_ADD_INCLUDEDIRS "pip/src_main/opencl")
|
||||||
list(APPEND COMPONENT_ADD_INCLUDEDIRS pip/src_main/resources)
|
list(APPEND COMPONENT_ADD_INCLUDEDIRS "pip/src_main/resources")
|
||||||
list(APPEND COMPONENT_ADD_INCLUDEDIRS pip/src_main/system)
|
list(APPEND COMPONENT_ADD_INCLUDEDIRS "pip/src_main/system")
|
||||||
list(APPEND COMPONENT_ADD_INCLUDEDIRS pip/src_main/thread)
|
list(APPEND COMPONENT_ADD_INCLUDEDIRS "pip/src_main/thread")
|
||||||
set(COMPONENT_PRIV_REQUIRES pthread)
|
set(COMPONENT_PRIV_REQUIRES pthread lwip freertos vfs spiffs)
|
||||||
|
set(COMPONENT_ADD_LDFRAGMENTS linker.lf)
|
||||||
register_component()
|
register_component()
|
||||||
set(PIP_FREERTOS ON)
|
set(PIP_FREERTOS ON)
|
||||||
set(LIB OFF)
|
set(LIB OFF)
|
||||||
include_directories(${IDF_INCLUDE_DIRECTORIES} ../newlib/platform_include ../libsodium/libsodium/src/libsodium/include ../libsodium/port_include ../heap/include ../esp32/include ../spi_flash/include ../driver/include ../soc/include ../soc/esp32/include ../freertos/include)
|
set(INCLUDE_DIRS ${IDF_INCLUDE_DIRECTORIES})
|
||||||
|
list(APPEND INCLUDE_DIRS "../newlib/platform_include")
|
||||||
|
list(APPEND INCLUDE_DIRS "../newlib/include")
|
||||||
|
list(APPEND INCLUDE_DIRS "../libsodium/libsodium/src/libsodium/include")
|
||||||
|
list(APPEND INCLUDE_DIRS "../libsodium/port_include")
|
||||||
|
list(APPEND INCLUDE_DIRS "../heap/include")
|
||||||
|
list(APPEND INCLUDE_DIRS "../esp32/include")
|
||||||
|
list(APPEND INCLUDE_DIRS "../driver/include")
|
||||||
|
list(APPEND INCLUDE_DIRS "../spi_flash/include")
|
||||||
|
list(APPEND INCLUDE_DIRS "../spiffs/include")
|
||||||
|
list(APPEND INCLUDE_DIRS "../soc/include")
|
||||||
|
list(APPEND INCLUDE_DIRS "../soc/esp32/include")
|
||||||
|
list(APPEND INCLUDE_DIRS "../freertos/include")
|
||||||
|
list(APPEND INCLUDE_DIRS "../lwip/lwip/src/include")
|
||||||
|
list(APPEND INCLUDE_DIRS "../lwip/port/esp32/include")
|
||||||
|
list(APPEND INCLUDE_DIRS "../vfs/include")
|
||||||
|
include_directories(${INCLUDE_DIRS})
|
||||||
#message("IDF_COMPILE_DEFINITIONS = ${IDF_COMPILE_DEFINITIONS}")
|
#message("IDF_COMPILE_DEFINITIONS = ${IDF_COMPILE_DEFINITIONS}")
|
||||||
#message("IDF_INCLUDE_DIRECTORIES = ${IDF_INCLUDE_DIRECTORIES}")
|
#message("IDF_INCLUDE_DIRECTORIES = ${IDF_INCLUDE_DIRECTORIES}")
|
||||||
add_compile_options(${IDF_COMPILE_OPTIONS})
|
add_compile_options(${IDF_COMPILE_OPTIONS})
|
||||||
@@ -28,4 +45,4 @@ add_definitions(-DGCC_NOT_5_2_0=0)
|
|||||||
add_definitions(-DHAVE_CONFIG_H)
|
add_definitions(-DHAVE_CONFIG_H)
|
||||||
add_subdirectory(pip)
|
add_subdirectory(pip)
|
||||||
|
|
||||||
target_link_libraries(${COMPONENT_TARGET} pip)
|
target_link_libraries(${COMPONENT_TARGET} pip pip_crypt pip_io_utils pip_compress)
|
||||||
|
|||||||
@@ -19,8 +19,15 @@
|
|||||||
|
|
||||||
#include "picompress.h"
|
#include "picompress.h"
|
||||||
#ifdef PIP_COMPRESS
|
#ifdef PIP_COMPRESS
|
||||||
|
# ifdef FREERTOS
|
||||||
|
# include "rom/miniz.h"
|
||||||
|
# define compress2 mz_compress2
|
||||||
|
# define Z_OK MZ_OK
|
||||||
|
# define uncompress mz_uncompress
|
||||||
|
# else
|
||||||
# include <zlib.h>
|
# include <zlib.h>
|
||||||
# endif
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
PIByteArray piCompress(const PIByteArray & ba, int level) {
|
PIByteArray piCompress(const PIByteArray & ba, int level) {
|
||||||
|
|||||||
@@ -90,13 +90,17 @@ PIConsole::PIConsole(bool startNow, PIKbdListener::KBFunc slot): PIThread() {
|
|||||||
PRIVATE->ulcoord.Y = PRIVATE->sbi.srWindow.Top;
|
PRIVATE->ulcoord.Y = PRIVATE->sbi.srWindow.Top;
|
||||||
GetConsoleMode(PRIVATE->hOut, &PRIVATE->smode);
|
GetConsoleMode(PRIVATE->hOut, &PRIVATE->smode);
|
||||||
GetConsoleCursorInfo(PRIVATE->hOut, &PRIVATE->curinfo);
|
GetConsoleCursorInfo(PRIVATE->hOut, &PRIVATE->curinfo);
|
||||||
|
#else
|
||||||
|
# ifdef FREERTOS
|
||||||
|
width = 80;
|
||||||
|
height = 24;
|
||||||
# else
|
# else
|
||||||
winsize ws;
|
winsize ws;
|
||||||
ioctl(0, TIOCGWINSZ, &ws);
|
ioctl(0, TIOCGWINSZ, &ws);
|
||||||
width = ws.ws_col;
|
width = ws.ws_col;
|
||||||
height = ws.ws_row;
|
height = ws.ws_row;
|
||||||
# endif
|
# endif
|
||||||
tabs.reserve(16);
|
#endif
|
||||||
addTab("main");
|
addTab("main");
|
||||||
listener = new PIKbdListener(key_event, this);
|
listener = new PIKbdListener(key_event, this);
|
||||||
peer_timer = new PITimer();
|
peer_timer = new PITimer();
|
||||||
@@ -543,11 +547,16 @@ void PIConsole::run() {
|
|||||||
GetConsoleScreenBufferInfo(PRIVATE->hOut, &PRIVATE->sbi);
|
GetConsoleScreenBufferInfo(PRIVATE->hOut, &PRIVATE->sbi);
|
||||||
width = PRIVATE->sbi.srWindow.Right - PRIVATE->sbi.srWindow.Left;
|
width = PRIVATE->sbi.srWindow.Right - PRIVATE->sbi.srWindow.Left;
|
||||||
height = PRIVATE->sbi.srWindow.Bottom - PRIVATE->sbi.srWindow.Top;
|
height = PRIVATE->sbi.srWindow.Bottom - PRIVATE->sbi.srWindow.Top;
|
||||||
|
#else
|
||||||
|
# ifdef FREERTOS
|
||||||
|
width = 80;
|
||||||
|
height = 24;
|
||||||
# else
|
# else
|
||||||
winsize ws;
|
winsize ws;
|
||||||
ioctl(0, TIOCGWINSZ, &ws);
|
ioctl(0, TIOCGWINSZ, &ws);
|
||||||
width = ws.ws_col;
|
width = ws.ws_col;
|
||||||
height = ws.ws_row;
|
height = ws.ws_row;
|
||||||
|
# endif
|
||||||
#endif
|
#endif
|
||||||
//fflush(0); return;
|
//fflush(0); return;
|
||||||
PICout::__mutex__().lock();
|
PICout::__mutex__().lock();
|
||||||
@@ -633,11 +642,16 @@ void PIConsole::fillLabels() {
|
|||||||
GetConsoleScreenBufferInfo(PRIVATE->hOut, &PRIVATE->sbi);
|
GetConsoleScreenBufferInfo(PRIVATE->hOut, &PRIVATE->sbi);
|
||||||
width = PRIVATE->sbi.srWindow.Right - PRIVATE->sbi.srWindow.Left;
|
width = PRIVATE->sbi.srWindow.Right - PRIVATE->sbi.srWindow.Left;
|
||||||
height = PRIVATE->sbi.srWindow.Bottom - PRIVATE->sbi.srWindow.Top;
|
height = PRIVATE->sbi.srWindow.Bottom - PRIVATE->sbi.srWindow.Top;
|
||||||
|
#else
|
||||||
|
# ifdef FREERTOS
|
||||||
|
width = 80;
|
||||||
|
height = 24;
|
||||||
# else
|
# else
|
||||||
winsize ws;
|
winsize ws;
|
||||||
ioctl(0, TIOCGWINSZ, &ws);
|
ioctl(0, TIOCGWINSZ, &ws);
|
||||||
width = ws.ws_col;
|
width = ws.ws_col;
|
||||||
height = ws.ws_row;
|
height = ws.ws_row;
|
||||||
|
# endif
|
||||||
#endif
|
#endif
|
||||||
max_y = 0;
|
max_y = 0;
|
||||||
col_cnt = columns().size();
|
col_cnt = columns().size();
|
||||||
|
|||||||
@@ -61,11 +61,16 @@ PIScreen::SystemConsole::SystemConsole() {
|
|||||||
PRIVATE->ulcoord.Y = PRIVATE->sbi.srWindow.Top;
|
PRIVATE->ulcoord.Y = PRIVATE->sbi.srWindow.Top;
|
||||||
GetConsoleMode(PRIVATE->hOut, &PRIVATE->smode);
|
GetConsoleMode(PRIVATE->hOut, &PRIVATE->smode);
|
||||||
GetConsoleCursorInfo(PRIVATE->hOut, &PRIVATE->curinfo);
|
GetConsoleCursorInfo(PRIVATE->hOut, &PRIVATE->curinfo);
|
||||||
|
#else
|
||||||
|
# ifdef FREERTOS
|
||||||
|
w = 80;
|
||||||
|
h = 24;
|
||||||
# else
|
# else
|
||||||
winsize ws;
|
winsize ws;
|
||||||
ioctl(0, TIOCGWINSZ, &ws);
|
ioctl(0, TIOCGWINSZ, &ws);
|
||||||
w = ws.ws_col;
|
w = ws.ws_col;
|
||||||
h = ws.ws_row;
|
h = ws.ws_row;
|
||||||
|
# endif
|
||||||
#endif
|
#endif
|
||||||
resize(w, h);
|
resize(w, h);
|
||||||
}
|
}
|
||||||
@@ -108,11 +113,16 @@ void PIScreen::SystemConsole::prepare() {
|
|||||||
GetConsoleScreenBufferInfo(PRIVATE->hOut, &PRIVATE->csbi);
|
GetConsoleScreenBufferInfo(PRIVATE->hOut, &PRIVATE->csbi);
|
||||||
w = PRIVATE->csbi.srWindow.Right - PRIVATE->csbi.srWindow.Left + 1;
|
w = PRIVATE->csbi.srWindow.Right - PRIVATE->csbi.srWindow.Left + 1;
|
||||||
h = PRIVATE->csbi.srWindow.Bottom - PRIVATE->csbi.srWindow.Top + 1;
|
h = PRIVATE->csbi.srWindow.Bottom - PRIVATE->csbi.srWindow.Top + 1;
|
||||||
|
#else
|
||||||
|
# ifdef FREERTOS
|
||||||
|
w = 80;
|
||||||
|
h = 24;
|
||||||
# else
|
# else
|
||||||
winsize ws;
|
winsize ws;
|
||||||
ioctl(0, TIOCGWINSZ, &ws);
|
ioctl(0, TIOCGWINSZ, &ws);
|
||||||
w = ws.ws_col;
|
w = ws.ws_col;
|
||||||
h = ws.ws_row;
|
h = ws.ws_row;
|
||||||
|
# endif
|
||||||
#endif
|
#endif
|
||||||
resize(w, h);
|
resize(w, h);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -189,7 +189,7 @@ void PIScreenTile::layout() {
|
|||||||
}
|
}
|
||||||
if (as <= ts) {
|
if (as <= ts) {
|
||||||
int acnt(0);
|
int acnt(0);
|
||||||
SizePolicy pol;
|
SizePolicy pol = Fixed;
|
||||||
if (ecnt > 0) {
|
if (ecnt > 0) {
|
||||||
acnt = ecnt;
|
acnt = ecnt;
|
||||||
pol = Expanding;
|
pol = Expanding;
|
||||||
|
|||||||
@@ -19,6 +19,7 @@
|
|||||||
#include "piincludes_p.h"
|
#include "piincludes_p.h"
|
||||||
#include "piterminal.h"
|
#include "piterminal.h"
|
||||||
#include "pisharedmemory.h"
|
#include "pisharedmemory.h"
|
||||||
|
#ifndef FREERTOS
|
||||||
#ifdef WINDOWS
|
#ifdef WINDOWS
|
||||||
# include <windows.h>
|
# include <windows.h>
|
||||||
# include <wincon.h>
|
# include <wincon.h>
|
||||||
@@ -911,3 +912,5 @@ bool PITerminal::resize(int cols, int rows) {
|
|||||||
cells[i].resize(size_x);
|
cells[i].resize(size_x);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif // FREERTOS
|
||||||
|
|||||||
@@ -24,8 +24,8 @@
|
|||||||
#include "piobject.h"
|
#include "piobject.h"
|
||||||
#include "pisysteminfo.h"
|
#include "pisysteminfo.h"
|
||||||
#include "piresourcesstorage.h"
|
#include "piresourcesstorage.h"
|
||||||
#ifndef FREERTOS
|
|
||||||
#include "pidir.h"
|
#include "pidir.h"
|
||||||
|
#ifndef FREERTOS
|
||||||
# include "piprocess.h"
|
# include "piprocess.h"
|
||||||
#endif
|
#endif
|
||||||
#ifdef ESP_PLATFORM
|
#ifdef ESP_PLATFORM
|
||||||
|
|||||||
@@ -19,7 +19,12 @@
|
|||||||
#include "piincludes_p.h"
|
#include "piincludes_p.h"
|
||||||
#include "pidir.h"
|
#include "pidir.h"
|
||||||
|
|
||||||
//#if !defined(ANDROID)
|
#ifdef ESP_PLATFORM
|
||||||
|
extern "C" {
|
||||||
|
# include "esp_spiffs.h"
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
const PIChar PIDir::separator = '/';
|
const PIChar PIDir::separator = '/';
|
||||||
#ifdef QNX
|
#ifdef QNX
|
||||||
# define _stat_struct_ struct stat
|
# define _stat_struct_ struct stat
|
||||||
@@ -34,8 +39,12 @@ const PIChar PIDir::separator = '/';
|
|||||||
# ifdef ANDROID
|
# ifdef ANDROID
|
||||||
# include <dirent.h>
|
# include <dirent.h>
|
||||||
# else
|
# else
|
||||||
|
# ifdef FREERTOS
|
||||||
|
# include <sys/dirent.h>
|
||||||
|
# else
|
||||||
# include <sys/dir.h>
|
# include <sys/dir.h>
|
||||||
# endif
|
# endif
|
||||||
|
# endif
|
||||||
# include <sys/stat.h>
|
# include <sys/stat.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -284,7 +293,7 @@ PIVector<PIFile::FileInfo> PIDir::entries() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#else
|
#else
|
||||||
# ifdef QNX
|
# if defined(QNX) || defined(FREERTOS)
|
||||||
struct dirent * de = 0;
|
struct dirent * de = 0;
|
||||||
DIR * dir = 0;
|
DIR * dir = 0;
|
||||||
dir = opendir(p.data());
|
dir = opendir(p.data());
|
||||||
@@ -299,7 +308,7 @@ PIVector<PIFile::FileInfo> PIDir::entries() {
|
|||||||
# else
|
# else
|
||||||
dirent ** list;
|
dirent ** list;
|
||||||
int cnt = scandir(p.data(), &list, 0,
|
int cnt = scandir(p.data(), &list, 0,
|
||||||
# if defined(MAC_OS) || defined(ANDROID) || defined(BLACKBERRY) || defined(QNX)
|
# if defined(MAC_OS) || defined(ANDROID) || defined(BLACKBERRY)
|
||||||
alphasort);
|
alphasort);
|
||||||
# else
|
# else
|
||||||
versionsort);
|
versionsort);
|
||||||
@@ -349,9 +358,11 @@ bool PIDir::isExists(const PIString & path) {
|
|||||||
DWORD ret = GetFileAttributes((LPCTSTR)(path.data()));
|
DWORD ret = GetFileAttributes((LPCTSTR)(path.data()));
|
||||||
return (ret != 0xFFFFFFFF) && (ret & FILE_ATTRIBUTE_DIRECTORY);
|
return (ret != 0xFFFFFFFF) && (ret & FILE_ATTRIBUTE_DIRECTORY);
|
||||||
#else
|
#else
|
||||||
|
#ifndef ESP_PLATFORM
|
||||||
DIR * dir_ = opendir(path.data());
|
DIR * dir_ = opendir(path.data());
|
||||||
if (dir_ == 0) return false;
|
if (dir_ == 0) return false;
|
||||||
closedir(dir_);
|
closedir(dir_);
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -367,7 +378,9 @@ PIDir PIDir::current() {
|
|||||||
ret.prepend(separator);
|
ret.prepend(separator);
|
||||||
return PIDir(ret);
|
return PIDir(ret);
|
||||||
#else
|
#else
|
||||||
|
#ifndef ESP_PLATFORM
|
||||||
if (getcwd(rc, 1024) == 0) return PIString();
|
if (getcwd(rc, 1024) == 0) return PIString();
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
return PIDir(rc);
|
return PIDir(rc);
|
||||||
}
|
}
|
||||||
@@ -471,4 +484,3 @@ bool PIDir::renameDir(const PIString & path, const PIString & new_name) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//#endif
|
|
||||||
|
|||||||
@@ -24,7 +24,7 @@
|
|||||||
#define PIDIR_H
|
#define PIDIR_H
|
||||||
|
|
||||||
#include "pifile.h"
|
#include "pifile.h"
|
||||||
//#if !defined(ANDROID)
|
|
||||||
|
|
||||||
class PIP_EXPORT PIDir
|
class PIP_EXPORT PIDir
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -56,11 +56,14 @@
|
|||||||
# include <netinet/in.h>
|
# include <netinet/in.h>
|
||||||
# include <arpa/inet.h>
|
# include <arpa/inet.h>
|
||||||
# include <sys/socket.h>
|
# include <sys/socket.h>
|
||||||
# include <net/if.h>
|
|
||||||
# include <netdb.h>
|
# include <netdb.h>
|
||||||
# ifndef ANDROID
|
# include <net/if.h>
|
||||||
|
# if !defined(ANDROID) && !defined(FREERTOS)
|
||||||
# include <ifaddrs.h>
|
# include <ifaddrs.h>
|
||||||
# endif
|
# endif
|
||||||
|
# ifdef FREERTOS
|
||||||
|
# include <lwip/sockets.h>
|
||||||
|
# endif
|
||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
@@ -478,7 +481,11 @@ bool PIEthernet::joinMulticastGroup(const PIString & group) {
|
|||||||
//if (!params[Broadcast])
|
//if (!params[Broadcast])
|
||||||
//;piCoutObj << "Warning: \"Broadcast\" parameter not set, \"joinMulticastGroup(\"" << group << "\")\" may be useless!";
|
//;piCoutObj << "Warning: \"Broadcast\" parameter not set, \"joinMulticastGroup(\"" << group << "\")\" may be useless!";
|
||||||
addr_r.set(path());
|
addr_r.set(path());
|
||||||
|
#ifndef FREERTOS
|
||||||
struct ip_mreqn mreq;
|
struct ip_mreqn mreq;
|
||||||
|
#else
|
||||||
|
struct ip_mreq mreq;
|
||||||
|
#endif
|
||||||
memset(&mreq, 0, sizeof(mreq));
|
memset(&mreq, 0, sizeof(mreq));
|
||||||
#ifdef LINUX
|
#ifdef LINUX
|
||||||
//mreq.imr_address.s_addr = INADDR_ANY;
|
//mreq.imr_address.s_addr = INADDR_ANY;
|
||||||
@@ -486,8 +493,19 @@ bool PIEthernet::joinMulticastGroup(const PIString & group) {
|
|||||||
const PIEthernet::Interface * ci = il.getByAddress(addr_r.ipString());
|
const PIEthernet::Interface * ci = il.getByAddress(addr_r.ipString());
|
||||||
if (ci != 0) mreq.imr_ifindex = ci->index;*/
|
if (ci != 0) mreq.imr_ifindex = ci->index;*/
|
||||||
#endif
|
#endif
|
||||||
if (params[PIEthernet::Broadcast]) mreq.imr_address.s_addr = INADDR_ANY;
|
if (params[PIEthernet::Broadcast])
|
||||||
else mreq.imr_address.s_addr = addr_r.ip();
|
#ifndef FREERTOS
|
||||||
|
mreq.imr_address.s_addr = INADDR_ANY;
|
||||||
|
#else
|
||||||
|
mreq.imr_interface.s_addr = INADDR_ANY;
|
||||||
|
#endif
|
||||||
|
else
|
||||||
|
#ifndef FREERTOS
|
||||||
|
mreq.imr_address.s_addr = addr_r.ip();
|
||||||
|
#else
|
||||||
|
mreq.imr_interface.s_addr = addr_r.ip();
|
||||||
|
#endif
|
||||||
|
|
||||||
/*#ifndef WINDOWS
|
/*#ifndef WINDOWS
|
||||||
PIEthernet::InterfaceList il = interfaces();
|
PIEthernet::InterfaceList il = interfaces();
|
||||||
const PIEthernet::Interface * ci = il.getByAddress(ip_);
|
const PIEthernet::Interface * ci = il.getByAddress(ip_);
|
||||||
@@ -529,10 +547,24 @@ bool PIEthernet::leaveMulticastGroup(const PIString & group) {
|
|||||||
}
|
}
|
||||||
PIFlags<Parameters> params = parameters();
|
PIFlags<Parameters> params = parameters();
|
||||||
addr_r.set(path());
|
addr_r.set(path());
|
||||||
|
#ifndef FREERTOS
|
||||||
struct ip_mreqn mreq;
|
struct ip_mreqn mreq;
|
||||||
|
#else
|
||||||
|
struct ip_mreq mreq;
|
||||||
|
#endif
|
||||||
memset(&mreq, 0, sizeof(mreq));
|
memset(&mreq, 0, sizeof(mreq));
|
||||||
if (params[PIEthernet::Broadcast]) mreq.imr_address.s_addr = INADDR_ANY;
|
if (params[PIEthernet::Broadcast])
|
||||||
else mreq.imr_address.s_addr = addr_r.ip();
|
#ifndef FREERTOS
|
||||||
|
mreq.imr_address.s_addr = INADDR_ANY;
|
||||||
|
#else
|
||||||
|
mreq.imr_interface.s_addr = INADDR_ANY;
|
||||||
|
#endif
|
||||||
|
else
|
||||||
|
#ifndef FREERTOS
|
||||||
|
mreq.imr_address.s_addr = addr_r.ip();
|
||||||
|
#else
|
||||||
|
mreq.imr_interface.s_addr = addr_r.ip();
|
||||||
|
#endif
|
||||||
mreq.imr_multiaddr.s_addr = inet_addr(group.dataAscii());
|
mreq.imr_multiaddr.s_addr = inet_addr(group.dataAscii());
|
||||||
if (ethSetsockopt(sock, IPPROTO_IP, IP_DROP_MEMBERSHIP, &mreq, sizeof(mreq)) == -1) {
|
if (ethSetsockopt(sock, IPPROTO_IP, IP_DROP_MEMBERSHIP, &mreq, sizeof(mreq)) == -1) {
|
||||||
piCoutObj << "Can`t leave multicast group" << group << "," << ethErrorString();
|
piCoutObj << "Can`t leave multicast group" << group << "," << ethErrorString();
|
||||||
@@ -1023,6 +1055,8 @@ PIEthernet::InterfaceList PIEthernet::interfaces() {
|
|||||||
if (pAdapterInfo)
|
if (pAdapterInfo)
|
||||||
HeapFree(GetProcessHeap(), 0, (pAdapterInfo));
|
HeapFree(GetProcessHeap(), 0, (pAdapterInfo));
|
||||||
#else
|
#else
|
||||||
|
#ifdef FREERTOS
|
||||||
|
#else
|
||||||
/*# ifdef QNX
|
/*# ifdef QNX
|
||||||
PIStringList il, sl;
|
PIStringList il, sl;
|
||||||
PIProcess proc;
|
PIProcess proc;
|
||||||
@@ -1157,14 +1191,15 @@ PIEthernet::InterfaceList PIEthernet::interfaces() {
|
|||||||
piCout << "[PIEthernet] Can`t get interfaces:" << errorString();
|
piCout << "[PIEthernet] Can`t get interfaces:" << errorString();
|
||||||
if (s != -1) ::close(s);
|
if (s != -1) ::close(s);
|
||||||
# endif
|
# endif
|
||||||
|
# endif
|
||||||
#endif
|
#endif
|
||||||
return il;
|
return il;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
PIEthernet::Address PIEthernet::interfaceAddress(const PIString & interface_) {
|
PIEthernet::Address PIEthernet::interfaceAddress(const PIString & interface_) {
|
||||||
#ifdef WINDOWS
|
#if defined(WINDOWS) || defined(FREERTOS)
|
||||||
piCout << "[PIEthernet] Not implemented on Windows, use \"PIEthernet::allAddresses\" or \"PIEthernet::interfaces\" instead";
|
piCout << "[PIEthernet] Not implemented, use \"PIEthernet::allAddresses\" or \"PIEthernet::interfaces\" instead";
|
||||||
return Address();
|
return Address();
|
||||||
#else
|
#else
|
||||||
struct ifreq ifr;
|
struct ifreq ifr;
|
||||||
|
|||||||
@@ -20,6 +20,11 @@
|
|||||||
#include "pifile.h"
|
#include "pifile.h"
|
||||||
#include "pidir.h"
|
#include "pidir.h"
|
||||||
#include "pitime_win.h"
|
#include "pitime_win.h"
|
||||||
|
#ifdef ESP_PLATFORM
|
||||||
|
extern "C" {
|
||||||
|
# include "esp_spiffs.h"
|
||||||
|
}
|
||||||
|
#endif
|
||||||
#ifdef WINDOWS
|
#ifdef WINDOWS
|
||||||
# undef S_IFDIR
|
# undef S_IFDIR
|
||||||
# undef S_IFREG
|
# undef S_IFREG
|
||||||
@@ -40,7 +45,7 @@
|
|||||||
# include <utime.h>
|
# include <utime.h>
|
||||||
#endif
|
#endif
|
||||||
#define S_IFHDN 0x40
|
#define S_IFHDN 0x40
|
||||||
#if defined(QNX) || defined(ANDROID)
|
#if defined(QNX) || defined(ANDROID) || defined(FREERTOS)
|
||||||
# define _fopen_call_ fopen
|
# define _fopen_call_ fopen
|
||||||
# define _fseek_call_ fseek
|
# define _fseek_call_ fseek
|
||||||
# define _ftell_call_ ftell
|
# define _ftell_call_ ftell
|
||||||
@@ -68,7 +73,6 @@
|
|||||||
# define _stat_link_ lstat64
|
# define _stat_link_ lstat64
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
/*! \class PIFile
|
/*! \class PIFile
|
||||||
* \brief Local file
|
* \brief Local file
|
||||||
*
|
*
|
||||||
@@ -661,7 +665,7 @@ PIFile::FileInfo PIFile::fileInfo(const PIString & path) {
|
|||||||
ret.time_access = PIDateTime::fromSystemTime(PISystemTime(fs.st_atime, fs.st_atime_nsec));
|
ret.time_access = PIDateTime::fromSystemTime(PISystemTime(fs.st_atime, fs.st_atime_nsec));
|
||||||
ret.time_modification = PIDateTime::fromSystemTime(PISystemTime(fs.st_mtime, fs.st_mtime_nsec));
|
ret.time_modification = PIDateTime::fromSystemTime(PISystemTime(fs.st_mtime, fs.st_mtime_nsec));
|
||||||
#else
|
#else
|
||||||
# ifdef QNX
|
# if defined(QNX) || defined(FREERTOS)
|
||||||
ret.time_access = PIDateTime::fromSecondSinceEpoch(fs.st_atime);
|
ret.time_access = PIDateTime::fromSecondSinceEpoch(fs.st_atime);
|
||||||
ret.time_modification = PIDateTime::fromSecondSinceEpoch(fs.st_mtime);
|
ret.time_modification = PIDateTime::fromSecondSinceEpoch(fs.st_mtime);
|
||||||
# else
|
# else
|
||||||
@@ -676,6 +680,7 @@ PIFile::FileInfo PIFile::fileInfo(const PIString & path) {
|
|||||||
ret.time_modification = PIDateTime::fromSystemTime(PISystemTime(fs.MTIME.tv_sec, fs.MTIME.tv_nsec));
|
ret.time_modification = PIDateTime::fromSystemTime(PISystemTime(fs.MTIME.tv_sec, fs.MTIME.tv_nsec));
|
||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
#ifndef FREERTOS
|
||||||
ret.perm_user = FileInfo::Permissions((mode & S_IRUSR) == S_IRUSR, (mode & S_IWUSR) == S_IWUSR, (mode & S_IXUSR) == S_IXUSR);
|
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_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);
|
ret.perm_other = FileInfo::Permissions((mode & S_IROTH) == S_IROTH, (mode & S_IWOTH) == S_IWOTH, (mode & S_IXOTH) == S_IXOTH);
|
||||||
@@ -688,6 +693,7 @@ PIFile::FileInfo PIFile::fileInfo(const PIString & path) {
|
|||||||
if ((mode & S_IFREG) == S_IFREG) ret.flags |= FileInfo::File;
|
if ((mode & S_IFREG) == S_IFREG) ret.flags |= FileInfo::File;
|
||||||
if ((mode & S_IFLNK) == S_IFLNK) ret.flags |= FileInfo::SymbolicLink;
|
if ((mode & S_IFLNK) == S_IFLNK) ret.flags |= FileInfo::SymbolicLink;
|
||||||
if ((mode & S_IFHDN) == S_IFHDN) ret.flags |= FileInfo::Hidden;
|
if ((mode & S_IFHDN) == S_IFHDN) ret.flags |= FileInfo::Hidden;
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
if (n == ".") ret.flags = FileInfo::Dir | FileInfo::Dot;
|
if (n == ".") ret.flags = FileInfo::Dir | FileInfo::Dot;
|
||||||
if (n == "..") ret.flags = FileInfo::Dir | FileInfo::DotDot;
|
if (n == "..") ret.flags = FileInfo::Dir | FileInfo::DotDot;
|
||||||
@@ -723,6 +729,7 @@ bool PIFile::applyFileInfo(const PIString & path, const PIFile::FileInfo & info)
|
|||||||
}
|
}
|
||||||
CloseHandle(hFile);
|
CloseHandle(hFile);
|
||||||
#else
|
#else
|
||||||
|
#ifndef ESP_PLATFORM
|
||||||
int mode(0);
|
int mode(0);
|
||||||
if (info.perm_user.read) mode |= S_IRUSR;
|
if (info.perm_user.read) mode |= S_IRUSR;
|
||||||
if (info.perm_user.write) mode |= S_IWUSR;
|
if (info.perm_user.write) mode |= S_IWUSR;
|
||||||
@@ -752,6 +759,7 @@ bool PIFile::applyFileInfo(const PIString & path, const PIFile::FileInfo & info)
|
|||||||
piCout << "[PIFile] applyFileInfo: \"utimes\" error:" << errorString();
|
piCout << "[PIFile] applyFileInfo: \"utimes\" error:" << errorString();
|
||||||
//return false;
|
//return false;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,8 +22,11 @@
|
|||||||
#include "pidir.h"
|
#include "pidir.h"
|
||||||
#include "pipropertystorage.h"
|
#include "pipropertystorage.h"
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#ifdef WINDOWS
|
|
||||||
# include <winreg.h>
|
#if defined(WINDOWS) || defined(FREERTOS)
|
||||||
|
# define PISERIAL_NO_PINS
|
||||||
|
#endif
|
||||||
|
#ifdef PISERIAL_NO_PINS
|
||||||
# define TIOCM_LE 1
|
# define TIOCM_LE 1
|
||||||
# define TIOCM_DTR 4
|
# define TIOCM_DTR 4
|
||||||
# define TIOCM_RTS 7
|
# define TIOCM_RTS 7
|
||||||
@@ -33,6 +36,9 @@
|
|||||||
# define TIOCM_CAR 1
|
# define TIOCM_CAR 1
|
||||||
# define TIOCM_RNG 9
|
# define TIOCM_RNG 9
|
||||||
# define TIOCM_DSR 6
|
# define TIOCM_DSR 6
|
||||||
|
#endif
|
||||||
|
#ifdef WINDOWS
|
||||||
|
# include <winreg.h>
|
||||||
# define B50 50
|
# define B50 50
|
||||||
# define B75 75
|
# define B75 75
|
||||||
# define B110 110
|
# define B110 110
|
||||||
@@ -113,7 +119,7 @@
|
|||||||
#ifndef CRTSCTS
|
#ifndef CRTSCTS
|
||||||
# define CRTSCTS 020000000000
|
# define CRTSCTS 020000000000
|
||||||
#endif
|
#endif
|
||||||
#if defined(LINUX)
|
#ifdef LINUX
|
||||||
# include <linux/serial.h>
|
# include <linux/serial.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -251,7 +257,7 @@ bool PISerial::isDSR() const {return isBit(TIOCM_DSR, "DSR");}
|
|||||||
|
|
||||||
|
|
||||||
bool PISerial::setBit(int bit, bool on, const PIString & bname) {
|
bool PISerial::setBit(int bit, bool on, const PIString & bname) {
|
||||||
#ifndef WINDOWS
|
#ifndef PISERIAL_NO_PINS
|
||||||
if (fd < 0) {
|
if (fd < 0) {
|
||||||
piCoutObj << "setBit" << bname << " error: \"" << path() << "\" is not opened!";
|
piCoutObj << "setBit" << bname << " error: \"" << path() << "\" is not opened!";
|
||||||
return false;
|
return false;
|
||||||
@@ -262,14 +268,14 @@ bool PISerial::setBit(int bit, bool on, const PIString & bname) {
|
|||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
#else
|
#else
|
||||||
piCoutObj << "setBit" << bname << " doesn`t implemented on Windows, sorry :-(";
|
piCoutObj << "setBit" << bname << " doesn`t implemented, sorry :-(";
|
||||||
return false;
|
return false;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool PISerial::isBit(int bit, const PIString & bname) const {
|
bool PISerial::isBit(int bit, const PIString & bname) const {
|
||||||
#ifndef WINDOWS
|
#ifndef PISERIAL_NO_PINS
|
||||||
if (fd < 0) {
|
if (fd < 0) {
|
||||||
piCoutObj << "isBit" << bname << " error: \"" << path() << "\" is not opened!";
|
piCoutObj << "isBit" << bname << " error: \"" << path() << "\" is not opened!";
|
||||||
return false;
|
return false;
|
||||||
@@ -279,7 +285,7 @@ bool PISerial::isBit(int bit, const PIString & bname) const {
|
|||||||
piCoutObj << "isBit" << bname << " error: " << errorString();
|
piCoutObj << "isBit" << bname << " error: " << errorString();
|
||||||
return ret & bit;
|
return ret & bit;
|
||||||
#else
|
#else
|
||||||
piCoutObj << "isBit" << bname << " doesn`t implemented on Windows, sorry :-(";
|
piCoutObj << "isBit" << bname << " doesn`t implemented, sorry :-(";
|
||||||
return false;
|
return false;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#include "pispi.h"
|
#include "pispi.h"
|
||||||
#include "pipropertystorage.h"
|
#include "pipropertystorage.h"
|
||||||
#include "piincludes_p.h"
|
#include "piincludes_p.h"
|
||||||
#if !defined(WINDOWS) && !defined(MAC_OS)
|
#ifdef LINUX
|
||||||
# define PIP_SPI
|
# define PIP_SPI
|
||||||
#endif
|
#endif
|
||||||
#ifdef PIP_SPI
|
#ifdef PIP_SPI
|
||||||
|
|||||||
@@ -40,11 +40,6 @@ __THREAD_FUNC_RET__ thread_function_once(void * t) {PIThread::__thread_func_once
|
|||||||
#define REGISTER_THREAD(t) __PIThreadCollection::instance()->registerThread(t)
|
#define REGISTER_THREAD(t) __PIThreadCollection::instance()->registerThread(t)
|
||||||
#define UNREGISTER_THREAD(t) __PIThreadCollection::instance()->unregisterThread(t)
|
#define UNREGISTER_THREAD(t) __PIThreadCollection::instance()->unregisterThread(t)
|
||||||
|
|
||||||
#ifdef FREERTOS
|
|
||||||
# define PTHREAD_MIN_MSLEEP 10.
|
|
||||||
#else
|
|
||||||
# define PTHREAD_MIN_MSLEEP 1.
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*! \class PIThread
|
/*! \class PIThread
|
||||||
* \brief Thread class
|
* \brief Thread class
|
||||||
|
|||||||
@@ -29,6 +29,12 @@
|
|||||||
#include "pimutex.h"
|
#include "pimutex.h"
|
||||||
#include "piobject.h"
|
#include "piobject.h"
|
||||||
|
|
||||||
|
#ifdef FREERTOS
|
||||||
|
# define PTHREAD_MIN_MSLEEP 10.
|
||||||
|
#else
|
||||||
|
# define PTHREAD_MIN_MSLEEP 1.
|
||||||
|
#endif
|
||||||
|
|
||||||
class PIThread;
|
class PIThread;
|
||||||
|
|
||||||
class PIP_EXPORT __PIThreadCollection {
|
class PIP_EXPORT __PIThreadCollection {
|
||||||
|
|||||||
@@ -368,8 +368,10 @@ _PITimerImp_Pool::_PITimerImp_Pool(): _PITimerImp_Thread() {
|
|||||||
_PITimerImp_Pool::Pool::Pool(): PIThread() {
|
_PITimerImp_Pool::Pool::Pool(): PIThread() {
|
||||||
setName("__S__PITimerImp_Pool::Pool");
|
setName("__S__PITimerImp_Pool::Pool");
|
||||||
needLockRun(true);
|
needLockRun(true);
|
||||||
|
#ifndef FREERTOS
|
||||||
timers.reserve(64);
|
timers.reserve(64);
|
||||||
start(2);
|
#endif
|
||||||
|
start(PTHREAD_MIN_MSLEEP);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user