|
@@ -61,7 +61,7 @@ struct ConditionalSerial : public SerialBase< ConditionalSerial<SerialT> > {
|
61
|
61
|
|
62
|
62
|
bool & condition;
|
63
|
63
|
SerialT & out;
|
64
|
|
- size_t write(uint8_t c) { if (condition) return out.write(c); return 0; }
|
|
64
|
+ NO_INLINE size_t write(uint8_t c) { if (condition) return out.write(c); return 0; }
|
65
|
65
|
void flush() { if (condition) out.flush(); }
|
66
|
66
|
void begin(long br) { out.begin(br); }
|
67
|
67
|
void end() { out.end(); }
|
|
@@ -83,7 +83,7 @@ struct ForwardSerial : public SerialBase< ForwardSerial<SerialT> > {
|
83
|
83
|
typedef SerialBase< ForwardSerial<SerialT> > BaseClassT;
|
84
|
84
|
|
85
|
85
|
SerialT & out;
|
86
|
|
- size_t write(uint8_t c) { return out.write(c); }
|
|
86
|
+ NO_INLINE size_t write(uint8_t c) { return out.write(c); }
|
87
|
87
|
void flush() { out.flush(); }
|
88
|
88
|
void begin(long br) { out.begin(br); }
|
89
|
89
|
void end() { out.end(); }
|
|
@@ -111,12 +111,12 @@ struct RuntimeSerial : public SerialBase< RuntimeSerial<SerialT> >, public Seria
|
111
|
111
|
EndOfMessageHook eofHook;
|
112
|
112
|
void * userPointer;
|
113
|
113
|
|
114
|
|
- size_t write(uint8_t c) {
|
|
114
|
+ NO_INLINE size_t write(uint8_t c) {
|
115
|
115
|
if (writeHook) writeHook(userPointer, c);
|
116
|
116
|
return SerialT::write(c);
|
117
|
117
|
}
|
118
|
118
|
|
119
|
|
- void msgDone() {
|
|
119
|
+ NO_INLINE void msgDone() {
|
120
|
120
|
if (eofHook) eofHook(userPointer);
|
121
|
121
|
}
|
122
|
122
|
|
|
@@ -130,7 +130,11 @@ struct RuntimeSerial : public SerialBase< RuntimeSerial<SerialT> >, public Seria
|
130
|
130
|
|
131
|
131
|
using BaseClassT::print;
|
132
|
132
|
using BaseClassT::println;
|
133
|
|
-
|
|
133
|
+
|
|
134
|
+ // Underlying implementation might use Arduino's bool operator
|
|
135
|
+ bool connected() {
|
|
136
|
+ return Private::HasMember_connected<SerialT>::value ? CALL_IF_EXISTS(bool, static_cast<SerialT*>(this), connected) : static_cast<SerialT*>(this)->operator bool();
|
|
137
|
+ }
|
134
|
138
|
|
135
|
139
|
void setHook(WriteHook writeHook = 0, EndOfMessageHook eofHook = 0, void * userPointer = 0) {
|
136
|
140
|
// Order is important here as serial code can be called inside interrupts
|
|
@@ -165,13 +169,13 @@ struct MultiSerial : public SerialBase< MultiSerial<Serial0T, Serial1T, offset>
|
165
|
169
|
AllMask = FirstOutputMask | SecondOutputMask,
|
166
|
170
|
};
|
167
|
171
|
|
168
|
|
- size_t write(uint8_t c) {
|
|
172
|
+ NO_INLINE size_t write(uint8_t c) {
|
169
|
173
|
size_t ret = 0;
|
170
|
174
|
if (portMask & FirstOutputMask) ret = serial0.write(c);
|
171
|
175
|
if (portMask & SecondOutputMask) ret = serial1.write(c) | ret;
|
172
|
176
|
return ret;
|
173
|
177
|
}
|
174
|
|
- void msgDone() {
|
|
178
|
+ NO_INLINE void msgDone() {
|
175
|
179
|
if (portMask & FirstOutputMask) serial0.msgDone();
|
176
|
180
|
if (portMask & SecondOutputMask) serial1.msgDone();
|
177
|
181
|
}
|
|
@@ -182,7 +186,7 @@ struct MultiSerial : public SerialBase< MultiSerial<Serial0T, Serial1T, offset>
|
182
|
186
|
default: return false;
|
183
|
187
|
}
|
184
|
188
|
}
|
185
|
|
- int read(uint8_t index) {
|
|
189
|
+ NO_INLINE int read(uint8_t index) {
|
186
|
190
|
switch(index) {
|
187
|
191
|
case 0 + offset: return serial0.read();
|
188
|
192
|
case 1 + offset: return serial1.read();
|
|
@@ -208,11 +212,11 @@ struct MultiSerial : public SerialBase< MultiSerial<Serial0T, Serial1T, offset>
|
208
|
212
|
using BaseClassT::read;
|
209
|
213
|
|
210
|
214
|
// Redirect flush
|
211
|
|
- void flush() {
|
|
215
|
+ NO_INLINE void flush() {
|
212
|
216
|
if (portMask & FirstOutputMask) serial0.flush();
|
213
|
217
|
if (portMask & SecondOutputMask) serial1.flush();
|
214
|
218
|
}
|
215
|
|
- void flushTX() {
|
|
219
|
+ NO_INLINE void flushTX() {
|
216
|
220
|
if (portMask & FirstOutputMask) CALL_IF_EXISTS(void, &serial0, flushTX);
|
217
|
221
|
if (portMask & SecondOutputMask) CALL_IF_EXISTS(void, &serial1, flushTX);
|
218
|
222
|
}
|