mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-06 07:49:52 +03:00
test on Windows
This commit is contained in:
@@ -17,7 +17,6 @@
|
||||
|
||||
#ifdef EMSESP_STANDALONE
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
#include <iostream>
|
||||
@@ -57,8 +56,11 @@ void ClientLoop(void * arg) {
|
||||
}
|
||||
}
|
||||
|
||||
#ifndef UNITY_INCLUDE_CONFIG_H
|
||||
// we have another main that overrides this when using Unity in test_api.cpp
|
||||
int main(int argc __attribute__((unused)), char * argv[] __attribute__((unused))) {
|
||||
setup();
|
||||
|
||||
std::thread t = std::thread(ClientLoop, nullptr);
|
||||
// while (millis() <= 10 * 1000) {
|
||||
while (1) {
|
||||
@@ -69,10 +71,7 @@ int main(int argc __attribute__((unused)), char * argv[] __attribute__((unused))
|
||||
t.join();
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
// unsigned long millis() {
|
||||
// return __millis;
|
||||
// }
|
||||
#endif
|
||||
|
||||
int64_t esp_timer_get_time() {
|
||||
return __millis;
|
||||
@@ -139,13 +138,13 @@ uint32_t analogReadMilliVolts(uint8_t pin) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
void analogSetPinAttenuation(uint8_t pin, adc_attenuation_t attenuation){};
|
||||
void analogSetAttenuation(adc_attenuation_t attenuation){};
|
||||
void dacWrite(uint8_t pin, uint8_t value){};
|
||||
void analogSetPinAttenuation(uint8_t pin, adc_attenuation_t attenuation) {};
|
||||
void analogSetAttenuation(adc_attenuation_t attenuation) {};
|
||||
void dacWrite(uint8_t pin, uint8_t value) {};
|
||||
double ledcSetup(uint8_t chan, double freq, uint8_t bit_num) {
|
||||
return 0;
|
||||
};
|
||||
void ledcAttachPin(uint8_t pin, uint8_t chan){};
|
||||
void ledcWrite(uint8_t chan, uint32_t duty){};
|
||||
void ledcAttachPin(uint8_t pin, uint8_t chan) {};
|
||||
void ledcWrite(uint8_t chan, uint32_t duty) {};
|
||||
|
||||
#endif
|
||||
@@ -32,6 +32,10 @@
|
||||
#include <iostream>
|
||||
|
||||
#include "WString.h"
|
||||
#include "Network.h"
|
||||
|
||||
extern ETHClass ETH;
|
||||
extern WiFiClass WiFi;
|
||||
|
||||
typedef double double_t;
|
||||
|
||||
@@ -86,6 +90,21 @@ int vsnprintf_P(char * str, size_t size, const char * format, va_list ap);
|
||||
#define pgm_read_float(addr) (*(const float *)(addr))
|
||||
#define pgm_read_ptr(addr) (*(const void **)(addr))
|
||||
|
||||
// #if defined(__linux__)
|
||||
#include <chrono> // NOLINT [build/c++11]
|
||||
#include <thread> // NOLINT [build/c++11] for yield()
|
||||
#define millis() std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::steady_clock::now().time_since_epoch()).count()
|
||||
// #endif
|
||||
|
||||
int64_t esp_timer_get_time();
|
||||
|
||||
void delay(unsigned long millis);
|
||||
|
||||
void yield(void);
|
||||
|
||||
void setup(void);
|
||||
void loop(void);
|
||||
|
||||
class Print;
|
||||
|
||||
class NativeConsole : public Stream {
|
||||
@@ -94,6 +113,11 @@ class NativeConsole : public Stream {
|
||||
}
|
||||
|
||||
int available() override {
|
||||
#if defined(_WIN32)
|
||||
// added for EMS-ESP
|
||||
return 1;
|
||||
#else
|
||||
|
||||
if (peek_ != -1)
|
||||
return 1;
|
||||
|
||||
@@ -107,6 +131,7 @@ class NativeConsole : public Stream {
|
||||
timeout.tv_usec = 1000;
|
||||
|
||||
return ::select(STDIN_FILENO + 1, &rfds, NULL, NULL, &timeout) > 0 ? 1 : 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
int read() override {
|
||||
@@ -163,27 +188,6 @@ class NativeConsole : public Stream {
|
||||
int peek_ = -1;
|
||||
};
|
||||
|
||||
#include "Network.h"
|
||||
|
||||
extern NativeConsole Serial;
|
||||
extern ETHClass ETH;
|
||||
extern WiFiClass WiFi;
|
||||
|
||||
// unsigned long millis();
|
||||
|
||||
#if defined(__linux__)
|
||||
#include <chrono> // NOLINT [build/c++11]
|
||||
#include <thread> // NOLINT [build/c++11] for yield()
|
||||
#define millis() std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::steady_clock::now().time_since_epoch()).count()
|
||||
#endif
|
||||
|
||||
int64_t esp_timer_get_time();
|
||||
|
||||
void delay(unsigned long millis);
|
||||
|
||||
void yield(void);
|
||||
|
||||
void setup(void);
|
||||
void loop(void);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -86,7 +86,12 @@ class Print {
|
||||
return print(str);
|
||||
}
|
||||
size_t println() {
|
||||
// added for EMS-ESP
|
||||
#if defined(_WIN32)
|
||||
return print("\n");
|
||||
#else
|
||||
return print("\r\n");
|
||||
#endif
|
||||
}
|
||||
size_t println(const char * data) {
|
||||
return print(data) + println();
|
||||
@@ -106,7 +111,7 @@ class Print {
|
||||
size_t println(unsigned long value) {
|
||||
return print(std::to_string(value).c_str()) + println();
|
||||
}
|
||||
virtual void flush(){};
|
||||
virtual void flush() {};
|
||||
|
||||
private:
|
||||
int err_{0};
|
||||
|
||||
Reference in New Issue
Block a user