Skip to content

Commit 15e7d35

Browse files
authored
emulation on host: minor updates (#8454)
* emulation on host: minor fixes merge MockDigital.cpp and HostWiring.cpp * emulation: share mockverbose between CI-on-host and emulation * mock: add missing recently overridden method * remove extern variable, use weak function
1 parent 7356cd1 commit 15e7d35

File tree

7 files changed

+51
-61
lines changed

7 files changed

+51
-61
lines changed

libraries/ESP8266HTTPUpdateServer/src/ESP8266HTTPUpdateServer-impl.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ void ESP8266HTTPUpdateServerTemplate<ServerType>::setup(ESP8266WebServerTemplate
111111
}
112112
} else if(_authenticated && upload.status == UPLOAD_FILE_END && !_updaterError.length()){
113113
if(Update.end(true)){ //true to set the size to the current progress
114-
if (_serial_output) Serial.printf("Update Success: %u\nRebooting...\n", upload.totalSize);
114+
if (_serial_output) Serial.printf("Update Success: %zu\nRebooting...\n", upload.totalSize);
115115
} else {
116116
_setUpdaterError();
117117
}

tests/host/Makefile

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ MOCK_CPP_FILES_COMMON := \
136136
MockUART.cpp \
137137
MockTools.cpp \
138138
MocklwIP.cpp \
139-
MockDigital.cpp \
139+
HostWiring.cpp \
140140
)
141141

142142
MOCK_CPP_FILES := $(MOCK_CPP_FILES_COMMON) \
@@ -356,7 +356,6 @@ MOCK_ARDUINO_LIBS := \
356356
MockWiFiServerSocket.cpp \
357357
MockWiFiServer.cpp \
358358
UdpContextSocket.cpp \
359-
HostWiring.cpp \
360359
MockEsp.cpp \
361360
MockEEPROM.cpp \
362361
MockSPI.cpp \

tests/host/common/Arduino.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,3 +111,11 @@ cont_t* g_pcont = NULL;
111111
extern "C" void cont_suspend(cont_t*)
112112
{
113113
}
114+
115+
extern "C" int __mockverbose (const char* fmt, ...)
116+
{
117+
(void)fmt;
118+
return 0;
119+
}
120+
121+
int mockverbose (const char* fmt, ...) __attribute__ ((weak, alias("__mockverbose"), format (printf, 1, 2)));

tests/host/common/HostWiring.cpp

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,11 @@
3737
#define VERBOSE(x...) mockverbose(x)
3838
#endif
3939

40+
#define GPIONUM 17
41+
42+
static uint8_t _mode[GPIONUM];
43+
static uint8_t _gpio[GPIONUM];
44+
4045
void pinMode (uint8_t pin, uint8_t mode)
4146
{
4247
#define xxx(mode) case mode: m=STRHELPER(mode); break
@@ -53,11 +58,19 @@ void pinMode (uint8_t pin, uint8_t mode)
5358
default: m="(special)";
5459
}
5560
VERBOSE("gpio%d: mode='%s'\n", pin, m);
61+
62+
if (pin < GPIONUM)
63+
{
64+
_mode[pin] = mode;
65+
}
5666
}
5767

5868
void digitalWrite(uint8_t pin, uint8_t val)
5969
{
6070
VERBOSE("digitalWrite(pin=%d val=%d)\n", pin, val);
71+
if (pin < GPIONUM) {
72+
_gpio[pin] = val;
73+
}
6174
}
6275

6376
void analogWrite(uint8_t pin, int val)
@@ -80,6 +93,9 @@ int digitalRead(uint8_t pin)
8093
{
8194
VERBOSE("digitalRead(%d)\n", pin);
8295

83-
// pin 0 is most likely a low active input
84-
return pin ? 0 : 1;
96+
if (pin < GPIONUM) {
97+
return _gpio[pin] != 0;
98+
} else {
99+
return 0;
100+
}
85101
}

tests/host/common/MockDigital.cpp

Lines changed: 0 additions & 56 deletions
This file was deleted.

tests/host/common/MockEsp.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,15 @@ void EspClass::getHeapStats(uint32_t* hfree, uint16_t* hmax, uint8_t* hfrag) {
142142
if (hfrag) *hfrag = 100 - (sqrt(hm) * 100) / hf;
143143
}
144144

145+
void EspClass::getHeapStats(uint32_t* hfree, uint32_t* hmax, uint8_t* hfrag) {
146+
uint32_t hf = 10 * 1024;
147+
float hm = 1 * 1024;
148+
149+
if (hfree) *hfree = hf;
150+
if (hmax) *hmax = hm;
151+
if (hfrag) *hfrag = 100 - (sqrt(hm) * 100) / hf;
152+
}
153+
145154
bool EspClass::flashEraseSector(uint32_t sector)
146155
{
147156
(void) sector;
@@ -263,3 +272,8 @@ void EspClass::setExternalHeap()
263272
void EspClass::resetHeap()
264273
{
265274
}
275+
276+
void EspClass::reset ()
277+
{
278+
abort();
279+
}

tests/host/common/MockTools.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,3 +78,12 @@ void configTime(int timezone, int daylightOffset_sec,
7878

7979
mockverbose("configTime: TODO (tz=%dH offset=%dS) (time will be host's)\n", timezone, daylightOffset_sec);
8080
}
81+
82+
void configTime(const char* tz, const char* server1, const char* server2, const char* server3)
83+
{
84+
(void)server1;
85+
(void)server2;
86+
(void)server3;
87+
88+
mockverbose("configTime: TODO (tz='%s') (time will be host's)\n", tz);
89+
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy