File tree Expand file tree Collapse file tree 2 files changed +20
-4
lines changed Expand file tree Collapse file tree 2 files changed +20
-4
lines changed Original file line number Diff line number Diff line change @@ -113,7 +113,7 @@ namespace serial {
113
113
}
114
114
115
115
/* *
116
- * Read multiple characters from the receive buffer.
116
+ * Read multiple characters from the receive buffer.
117
117
* If length is positive, pauses until enough characters are present.
118
118
* @param length default buffer length
119
119
*/
@@ -144,8 +144,8 @@ namespace serial {
144
144
case SerialPin::USB_TX: name = USBTX; return true ;
145
145
case SerialPin::USB_RX: name = USBRX; return true ;
146
146
#endif
147
- default :
148
- auto pin = getPin (p);
147
+ default :
148
+ auto pin = getPin (p);
149
149
if (NULL != pin) {
150
150
name = (PinName)pin->name ;
151
151
return true ;
@@ -185,6 +185,22 @@ namespace serial {
185
185
#endif
186
186
}
187
187
188
+ // %
189
+ int redirectWithStatus (SerialPin tx, SerialPin rx) {
190
+ #if MICROBIT_CODAL
191
+ if (getPin (tx) && getPin (rx)) {
192
+ is_redirected = 1 ;
193
+ return uBit.serial .redirect (*getPin (tx), *getPin (rx));
194
+ }
195
+ #else
196
+ PinName txn;
197
+ PinName rxn;
198
+ if (tryResolvePin (tx, txn) && tryResolvePin (rx, rxn))
199
+ return uBit.serial .redirect (txn, rxn);
200
+ #endif
201
+ return MICROBIT_INVALID_PARAMETER;
202
+ }
203
+
188
204
/* *
189
205
Set the baud rate of the serial port
190
206
*/
Original file line number Diff line number Diff line change @@ -1053,7 +1053,7 @@ declare namespace serial {
1053
1053
function writeBuffer ( buffer : Buffer ) : void ;
1054
1054
1055
1055
/**
1056
- * Read multiple characters from the receive buffer.
1056
+ * Read multiple characters from the receive buffer.
1057
1057
* If length is positive, pauses until enough characters are present.
1058
1058
* @param length default buffer length
1059
1059
*/
You can’t perform that action at this time.
0 commit comments