Skip to content

Commit c5bb605

Browse files
committed
Fixed ESP32/8266 compile errors
1 parent 209c7e3 commit c5bb605

File tree

3 files changed

+21
-1
lines changed

3 files changed

+21
-1
lines changed

library.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name=OpenMV Arduino RPC
2-
version=1.0.1
2+
version=1.0.2
33
author=OpenMV
44
maintainer=OpenMV
55
sentence=OpenMV Arduino RPC Interface Library

src/openmvrpc.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,14 @@
2727
// Master <-- Slave magic DATA ack, n-byte payload, CRC
2828
//
2929

30+
#ifndef min
31+
#define min(a,b) ((a)<(b)?(a):(b))
32+
#endif
33+
34+
#ifndef max
35+
#define max(a,b) ((a)>(b)?(a):(b))
36+
#endif
37+
3038
using namespace openmv;
3139

3240
uint8_t *openmv::__buff = NULL;
@@ -669,6 +677,7 @@ bool rpc_slave::loop(unsigned long recv_timeout, unsigned long send_timeout)
669677
return false;
670678
}
671679

680+
#ifndef ARDUINO_ARCH_ESP8266
672681
void rpc_can_master::_flush()
673682
{
674683
for (int i = 0, ii = CAN.parsePacket(); i < ii; i++) CAN.read();
@@ -740,6 +749,7 @@ bool rpc_can_slave::put_bytes(uint8_t *data, size_t size, unsigned long timeout)
740749

741750
return i == size;
742751
}
752+
#endif
743753

744754
void rpc_i2c_master::_flush()
745755
{
@@ -763,7 +773,9 @@ bool rpc_i2c_master::get_bytes(uint8_t *buff, size_t size, unsigned long timeout
763773
for (size_t j = 0; j < request_size; j++) buff[i+j] = Wire.read();
764774
}
765775

776+
#if (!defined(ARDUINO_ARCH_ESP32)) && (!defined(ARDUINO_ARCH_ESP8266))
766777
Wire.end();
778+
#endif
767779
if (ok) ok = ok && (!_same(buff, size));
768780
if (!ok) delay(_get_short_timeout);
769781
return ok;
@@ -786,7 +798,9 @@ bool rpc_i2c_master::put_bytes(uint8_t *data, size_t size, unsigned long timeout
786798
if ((Wire.write(data + i, request_size) != request_size) || Wire.endTransmission(request_stop)) { ok = false; break; }
787799
}
788800

801+
#if (!defined(ARDUINO_ARCH_ESP32)) && (!defined(ARDUINO_ARCH_ESP8266))
789802
Wire.end();
803+
#endif
790804
return ok;
791805
}
792806

src/openmvrpc.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@
88
#define __OPENMVRPC__
99

1010
#include <Arduino.h>
11+
#ifndef ARDUINO_ARCH_ESP8266
1112
#include <CAN.h>
13+
#endif
1214
#ifdef ARDUINO_ARCH_AVR
1315
#include <SoftwareSerial.h>
1416
#endif // ARDUINO_ARCH_AVR
@@ -215,6 +217,7 @@ class rpc_slave : public rpc
215217
bool __register_callback(uint32_t hash, rpc_callback_type_t type, void *value);
216218
};
217219

220+
#ifndef ARDUINO_ARCH_ESP8266
218221
class rpc_can_master : public rpc_master
219222
{
220223
public:
@@ -248,6 +251,7 @@ class rpc_can_slave : public rpc_slave
248251
long __bit_rate;
249252
rpc_can_slave(const rpc_can_slave &);
250253
};
254+
#endif
251255

252256
class rpc_i2c_master : public rpc_master
253257
{
@@ -276,7 +280,9 @@ class rpc_i2c_slave : public rpc_slave
276280
virtual bool get_bytes(uint8_t *buff, size_t size, unsigned long timeout) override;
277281
virtual bool put_bytes(uint8_t *data, size_t size, unsigned long timeout) override;
278282
virtual void begin() override { Wire.onReceive(onReceiveHandler); Wire.onRequest(onRequestHandler); Wire.begin(__slave_addr); }
283+
#if (!defined(ARDUINO_ARCH_ESP32)) && (!defined(ARDUINO_ARCH_ESP8266))
279284
virtual void end() override { Wire.end(); }
285+
#endif
280286
protected:
281287
virtual uint32_t _stream_writer_queue_depth_max() override { return 1; }
282288
private:

0 commit comments

Comments
 (0)