File tree 3 files changed +34
-22
lines changed
3 files changed +34
-22
lines changed Original file line number Diff line number Diff line change @@ -115,6 +115,7 @@ extern analogin_config_t adcCurrentConfig;
115
115
#if defined(RPC_SERIAL)
116
116
#undef Serial
117
117
#if __has_include("RPC.h")
118
+ #include " SerialRPC.h"
118
119
#define Serial SerialRPC
119
120
#else
120
121
extern ErrorSerialClass ErrorSerial;
Original file line number Diff line number Diff line change 1
1
#include " SerialRPC.h"
2
+ #include " RPC.h"
3
+
4
+ size_t arduino::SerialRPCClass::write (uint8_t * buf, size_t len) {
5
+ tx_buffer.clear ();
6
+ for (size_t i=0 ; i < len; i++) {
7
+ tx_buffer.push_back (buf[i]);
8
+ }
9
+ RPC.send (" tty" , tx_buffer);
10
+ return len;
11
+ }
12
+
13
+ int arduino::SerialRPCClass::begin (long unsigned int , uint16_t ) {
14
+ if (RPC.begin () == 0 ) {
15
+ return 0 ;
16
+ }
17
+ RPC.bind (" tty" , mbed::callback (this , &SerialRPCClass::onWrite));
18
+ return 1 ;
19
+ }
20
+
21
+ arduino::SerialRPCClass::operator bool () {
22
+ return RPC;
23
+ }
2
24
3
25
arduino::SerialRPCClass SerialRPC;
Original file line number Diff line number Diff line change 1
- #include " RPC.h"
1
+ #ifndef __SERIAL_RPC__
2
+ #define __SERIAL_RPC__
3
+
2
4
#include " Arduino.h"
5
+ #include < vector>
3
6
4
7
namespace arduino {
5
8
@@ -29,6 +32,9 @@ class SerialRPCClass : public Stream {
29
32
}
30
33
}
31
34
35
+ int begin (long unsigned int = 0 , uint16_t = 0 );
36
+ size_t write (uint8_t * buf, size_t len);
37
+
32
38
size_t write (uint8_t c) {
33
39
return write (&c, 1 );
34
40
}
@@ -43,28 +49,9 @@ class SerialRPCClass : public Stream {
43
49
return write ((uint8_t *)buf, len);
44
50
}
45
51
46
- size_t write (uint8_t * buf, size_t len) {
47
- tx_buffer.clear ();
48
- for (size_t i=0 ; i < len; i++) {
49
- tx_buffer.push_back (buf[i]);
50
- }
51
- RPC.send (" tty" , tx_buffer);
52
- return len;
53
- }
54
-
55
52
using Print::write;
56
53
57
- int begin (long unsigned int = 0 , uint16_t = 0 ) {
58
- if (RPC.begin () == 0 ) {
59
- return 0 ;
60
- }
61
- RPC.bind (" tty" , mbed::callback (this , &SerialRPCClass::onWrite));
62
- return 1 ;
63
- }
64
-
65
- operator bool () {
66
- return RPC;
67
- }
54
+ operator bool ();
68
55
69
56
void attach (void (*fptr)(void ))
70
57
{
@@ -80,4 +67,6 @@ class SerialRPCClass : public Stream {
80
67
};
81
68
}
82
69
83
- extern arduino::SerialRPCClass SerialRPC;
70
+ extern arduino::SerialRPCClass SerialRPC;
71
+
72
+ #endif
You can’t perform that action at this time.
0 commit comments