8000 Allow test framework to use cores/esp8266/Arduino.h directly by mcspr · Pull Request #7377 · esp8266/Arduino · GitHub
[go: up one dir, main page]

Skip to content

Allow test framework to use cores/esp8266/Arduino.h directly #7377

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 23 commits into from
Oct 6, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
84d8866
Allow test framework to use cores/esp8266/Arduino.h directly
mcspr Jun 14, 2020
c89d0f6
fix wps debugging
mcspr Jun 14, 2020
0e0849d
some more missing debug.h
mcspr Jun 14, 2020
65fab13
Merge remote-tracking branch 'origin/master' into tests/sync-arduino-h
mcspr Jul 17, 2020
555c272
Hunt down debug.h and roll-back
mcspr Jul 17, 2020
6b36f6e
Move abs+round checks to test/device/test_sw
mcspr Jul 17, 2020
ffc3744
Restore macros for C code
mcspr Jul 17, 2020
8000
6db24f8
fixup! Move abs+round checks to test/device/test_sw
mcspr Jul 18, 2020
e59f926
Fix bad c/p, actually try round with ints
mcspr Jul 18, 2020
0c8c7ab
Merge branch 'master' into tests/sync-arduino-h
d-a-v Jul 28, 2020
1f14878
tweak c macros per review
mcspr Aug 16, 2020
9e1b019
Merge remote-tracking branch 'origin/master' into tests/sync-arduino-h
mcspr Aug 17, 2020
247c6c3
fix gcc-10 missing cerrno include
mcspr Aug 17, 2020
685c25f
amend 555c272, again
mcspr Aug 17, 2020
60de322
fixup! Merge remote-tracking branch 'origin/master' into tests/sync-a…
mcspr Aug 17, 2020
1a2fd27
fixup! amend 555c272, again
mcspr Aug 17, 2020
8c89d90
switch to the current -std=... opts
mcspr Aug 17, 2020
f48cd49
Revert "switch to the current -std=... opts"
mcspr Aug 17, 2020
481b351
trying to fix CI, clean-up configTime decl + def
mcspr Aug 17, 2020
b496509
Merge branch 'master' into tests/sync-arduino-h
mcspr Sep 9, 2020
8e7a003
Merge remote-tracking branch 'origin/master' into tests/sync-arduino-h
mcspr Oct 6, 2020
1fa62d4
Merge branch 'master' into tests/sync-arduino-h
mcspr Oct 6, 2020
3d7379f
Merge branch 'master' into tests/sync-arduino-h
d-a-v Oct 6, 2020
File filter

Filter by extension

Filter by extension


Deleted files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Merge remote-tracking branch 'origin/master' into tests/sync-arduino-h
  • Loading branch information
mcspr committed Oct 6, 2020
commit 8e7a00339809a5656488de579fafbb8a0d9b566d
12 changes: 8 additions & 4 deletions .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,8 @@ jobs:
mod: 42 # Picked at random to give 4-5 builds and exit.
rem: 13
run: |
sudo apt-get install python3-pip python3-setuptools
sudo apt update
sudo apt install python3-pip python3-setuptools
PATH=/home/runner/.local/bin:$PATH bash ./tests/platformio.sh


Expand All @@ -174,7 +175,8 @@ jobs:
TRAVIS_BUILD_DIR: ${{ github.workspace }}
TRAVIS_TAG: ${{ github.ref }}
run: |
sudo apt-get install valgrind lcov
sudo apt update
sudo apt install valgrind lcov
bash ./tests/ci/host_test.sh


Expand All @@ -194,7 +196,8 @@ jobs:
TRAVIS_BUILD_DIR: ${{ github.workspace }}
TRAVIS_TAG: ${{ github.ref }}
run: |
sudo apt-get install python3-pip python3-setuptools
sudo apt update
sudo apt install python3-pip python3-setuptools
# GitHub CI installs pip3 and setuptools outside the path.
# Update the path to include them and run.
PATH=/home/runner/.local/bin:$PATH pip3 install --user -r doc/requirements.txt
Expand All @@ -217,7 +220,8 @@ jobs:
TRAVIS_BUILD_DIR: ${{ github.workspace }}
TRAVIS_TAG: ${{ github.ref }}
run: |
sudo apt-get install astyle
sudo apt update
sudo apt install astyle
bash ./tests/ci/style_check.sh


Expand Down
8 changes: 3 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Arduino core for ESP8266 WiFi chip

# Quick links

- [Latest release documentation](https://arduino-esp8266.readthedocs.io/en/2.7.2/)
- [Latest release documentation](https://arduino-esp8266.readthedocs.io/en/2.7.4_a/)
- [Current "git version" documentation](https://arduino-esp8266.readthedocs.io/en/latest/)
- [Install git version](https://arduino-esp8266.readthedocs.io/en/latest/installing.html#using-git-version) ([sources](doc/installing.rst#using-git-version))

Expand Down Expand Up @@ -36,7 +36,7 @@ Starting with 1.6.4, Arduino allows installation of third-party platform package
#### Latest release [![Latest release](https://img.shields.io/github/release/esp8266/Arduino.svg)](https://github.com/esp8266/Arduino/releases/latest/)
Boards manager link: `https://arduino.esp8266.com/stable/package_esp8266com_index.json`

Documentation: [https://arduino-esp8266.readthedocs.io/en/2.7.2/](https://arduino-esp8266.readthedocs.io/en/2.7.2/)
Documentation: [https://arduino-esp8266.readthedocs.io/en/2.7.4_a/](https://arduino-esp8266.readthedocs.io/en/2.7.4_a/)

### Using git version
[![Linux build status](https://travis-ci.org/esp8266/Arduino.svg)](https://travis-ci.org/esp8266/Arduino)
Expand Down Expand Up @@ -108,7 +108,7 @@ ESP8266 core includes an xtensa gcc toolchain, which is also under GPL.

Esptool.py was initially created by Fredrik Ahlberg (@themadinventor, @kongo), and is currently maintained by Angus Gratton (@projectgus) under GPL 2.0 license.

Espressif SDK included in this build is under Espressif MIT License.
[Espressif's NONOS SDK](https://github.com/espressif/ESP8266_NONOS_SDK) included in this build is under Espressif MIT License.

ESP8266 core files are licensed under LGPL.

Expand All @@ -118,8 +118,6 @@ ESP8266 core files are licensed under LGPL.

[SoftwareSerial](https://github.com/plerup/espsoftwareserial) library and examples written by Peter Lerup. Distributed under LGPL 2.1.

[axTLS](http://axtls.sourceforge.net/) library written by Cameron Rich, built from https://github.com/igrr/axtls-8266, is used in this project. It is distributed under [BSD license](https://github.com/igrr/axtls-8266/blob/master/LICENSE).

[BearSSL](https://bearssl.org) library written by Thomas Pornin, built from https://github.com/earlephilhower/bearssl-esp8266, is used in this project. It is distributed under the [MIT License](https://bearssl.org/#legal-details).

[LittleFS](https://github.com/ARMmbed/littlefs) library written by ARM Limited and released under the [BSD 3-clause license](https://github.com/ARMmbed/littlefs/blob/master/LICENSE.md).
Expand Down
7 changes: 7 additions & 0 deletions cores/esp8266/IPAddress.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,13 @@
struct ip_addr: ipv4_addr { };
#endif // !LWIP_IPV6

// to display a netif id with printf:
#define NETIFID_STR "%c%c%u"
#define NETIFID_VAL(netif) \
((netif)? (netif)->name[0]: '-'), \
((netif)? (netif)->name[1]: '-'), \
((netif)? netif_get_index(netif): 42)

// A class to make it easier to handle and pass around IP addresses
// IPv6 update:
// IPAddress is now a decorator class for lwIP's ip_addr_t
Expand Down
26 changes: 26 additions & 0 deletions cores/esp8266/LwipIntf.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@

#ifndef _LWIPINTF_H
#define _LWIPINTF_H

#include <lwip/netif.h>

#include <functional>

class LwipIntf
{
public:

using CBType = std::function <void(netif*)>;

static bool stateUpCB (LwipIntf::CBType&& cb);

private:

LwipIntf () { } // private, cannot be directly allocated

protected:

static bool stateChangeSysCB (LwipIntf::CBType&& cb);
};

#endif // _LWIPINTF_H
42 changes: 42 additions & 0 deletions cores/esp8266/LwipIntfCB.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@

#include <LwipIntf.h>
#include <Schedule.h>
#include <debug.h>

#define NETIF_STATUS_CB_SIZE 3

static int netifStatusChangeListLength = 0;
LwipIntf::CBType netifStatusChangeList [NETIF_STATUS_CB_SIZE];

extern "C" void netif_status_changed (struct netif* netif)
{
// override the default empty weak function
for (int i = 0; i < netifStatusChangeListLength; i++)
netifStatusChangeList[i](netif);
}

bool LwipIntf::stateChangeSysCB (LwipIntf::CBType&& cb)
{
if (netifStatusChangeListLength >= NETIF_STATUS_CB_SIZE)
{
#if defined(DEBUG_ESP_CORE)
DEBUGV("NETIF_STATUS_CB_SIZE is too low\n");
#endif
return false;
}

netifStatusChangeList[netifStatusChangeListLength++] = cb;
return true;
}

bool LwipIntf::stateUpCB (LwipIntf::CBType&& cb)
{
return stateChangeSysCB([cb](netif* nif)
{
if (netif_is_up(nif))
schedule_function([cb, nif]()
{
cb(nif);
});
});
}
119 changes: 62 additions & 57 deletions cores/esp8266/Print.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -146,35 +146,39 @@ size_t Print::print(unsigned int n, int base) {
}

size_t Print::print(long n, int base) {
if(base == 0) {
return write(n);
} else if(base == 10) {
if(n < 0) {
int t = print('-');
n = -n;
return printNumber(n, 10) + t;
}
return printNumber(n, 10);
} else {
return printNumber(n, base);
int t = 0;
if (base == 10 && n < 0) {
t = print('-');
n = -n;
}
return printNumber(static_cast<unsigned long>(n), base) + t;
}

size_t Print::print(unsigned long n, int base) {
if(base == 0)
if (base == 0) {
return write(n);
else
return printNumber(n, base);
}
return printNumber(n, base);
}

size_t Print::print(double n, int digits) {
return printFloat(n, digits);
size_t Print::print(long long n, int base) {
int t = 0;
if (base == 10 && n < 0) {
t = print('-');
n = -n;
}
return printNumber(static_cast<unsigned long long>(n), base) + t;
}

size_t Print::println(const __FlashStringHelper *ifsh) {
size_t n = print(ifsh);
n += println();
return n;
size_t Print::print(unsigned long long n, int base) {
if (base == 0) {
return write(n);
}
return printNumber(n, base);
}

size_t Print::print(double n, int digits) {
return printNumber(n, digits);
}

size_t Print::print(const Printable& x) {
Expand All @@ -185,89 +189,90 @@ size_t Print::println(void) {
return print("\r\n");
}

size_t Print::println(const __FlashStringHelper* ifsh) {
return _println<const __FlashStringHelper*>(ifsh);
}

size_t Print::println(const String &s) {
size_t n = print(s);
n += println();
return n;
return _println(s);
}

size_t Print::println(const char c[]) {
size_t n = print(c);
n += println();
return n;
return _println(c);
}

size_t Print::println(char c) {
size_t n = print(c);
n += println();
return n;
return _println(c);
}

size_t Print::println(unsigned char b, int base) {
size_t n = print(b, base);
n += println();
return n;
return _println(b, base);
}

size_t Print::println(int num, int base) {
size_t n = print(num, base);
n += println();
return n;
return _println(num, base);
}

size_t Print::println(unsigned int num, int base) {
size_t n = print(num, base);
n += println();
return n;
return _println(num, base);
}

size_t Print::println(long num, int base) {
size_t n = print(num, base);
n += println();
return n;
return _println(num, base);
}

size_t Print::println(unsigned long num, int base) {
size_t n = print(num, base);
n += println();
return n;
return _println(num, base);
}

size_t Print::println(long long num, int base) {
return _println(num, base);
}

size_t Print::println(unsigned long long num, int base) {
return _println(num, base);
}

size_t Print::println(double num, int digits) {
size_t n = print(num, digits);
n += println();
return n;
return _println(num, digits);
}

size_t Print::println(const Printable& x) {
size_t n = print(x);
n += println();
return n;
return _println<const Printable&>(x);
}

// Private Methods /////////////////////////////////////////////////////////////

size_t Print::printNumber(unsigned long n, uint8_t base) {
char buf[8 * sizeof(long) + 1]; // Assumes 8-bit chars plus zero byte.
char *str = &buf[sizeof(buf) - 1];
template<typename T, typename... P> inline size_t Print::_println(T v, P... args)
{
size_t n = print(v, args...);
n += println();
return n;
};

template<typename T> size_t Print::printNumber(T n, uint8_t base) {
char buf[8 * sizeof(n) + 1]; // Assumes 8-bit chars plus zero byte.
char* str = &buf[sizeof(buf) - 1];

*str = '\0';

// prevent crash if called with base == 1
if(base < 2)
if (base < 2) {
base = 10;
}

do {
unsigned long m = n;
auto m = n;
n /= base;
char c = m - base * n;

*--str = c < 10 ? c + '0' : c + 'A' - 10;
} while(n);
} while (n);

return write(str);
}

size_t Print::printFloat(double number, uint8_t digits) {
template<> size_t Print::printNumber(double number, uint8_t digits) {
char buf[40];
return write(dtostrf(number, 0, digits, buf));
}
Loading
You are viewing a condensed version of this merge commit. You can view the full changes here.
0