Skip to content

Commit 81fc13f

Browse files
committed
Fix Serial port path regression on Linux, and add docs
1 parent 4f75809 commit 81fc13f

File tree

3 files changed

+7
-2
lines changed

3 files changed

+7
-2
lines changed

ChangeLog

+1
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@
111111
Ensure `Date.getTimezoneOffset()` returns the correct timezone offset (fix #1515)
112112
Search for and execute files '.boot0'/1/2/3 in Storage at boot time if they exist
113113
Pixl.js: reduce saved code area to 9 x 4kb to allow for extra features
114+
Fix Serial port path regression on Linux, and add docs
114115

115116
1v99 : Increase jslMatch error buffer size to handle "UNFINISHED TEMPLATE LITERAL" string (#1426)
116117
nRF5x: Make FlashWrite cope with flash writes > 4k

src/jsserial.c

+3-1
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,9 @@ bool jsserialPopulateUSARTInfo(
104104
{"cts", JSV_PIN, &inf->pinCTS},
105105
{"bytesize", JSV_INTEGER, &inf->bytesize},
106106
{"stopbits", JSV_INTEGER, &inf->stopbits},
107+
#ifdef LINUX
108+
{"path", JSV_STRING_0, 0}, // not used - just here to avoid errors
109+
#endif
107110
{"parity", JSV_OBJECT /* a variable */, &parity},
108111
{"flow", JSV_OBJECT /* a variable */, &flow},
109112
{"errors", JSV_BOOLEAN, &inf->errorHandling},
@@ -147,7 +150,6 @@ bool jsserialPopulateUSARTInfo(
147150
}
148151
jsvUnLock(parity);
149152
jsvUnLock(flow);
150-
151153
return ok;
152154
}
153155

src/jswrap_serial.c

+3-1
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,9 @@ storage in the queue. If you're intending to receive a lot of malformed
248248
data then the queue might overflow `E.getErrorFlags()` would return `FIFO_FULL`.
249249
However if you need to respond to `framing` or `parity` errors then
250250
you'll need to use `errors:true` when initialising serial.
251+
252+
On Linux builds there is no default Serial device, so you must specify
253+
a path to a device - for instance: `Serial1.setup(9600,{path:"/dev/ttyACM0"})`
251254
*/
252255
void jswrap_serial_setup(JsVar *parent, JsVar *baud, JsVar *options) {
253256
IOEventFlags device = jsiGetDeviceFromClass(parent);
@@ -259,7 +262,6 @@ void jswrap_serial_setup(JsVar *parent, JsVar *baud, JsVar *options) {
259262
jsvLockAgain(options);
260263

261264
bool ok = jsserialPopulateUSARTInfo(&inf, baud, options);
262-
263265
#ifdef LINUX
264266
if (ok && jsvIsObject(options))
265267
jsvObjectSetChildAndUnLock(parent, "path", jsvObjectGetChild(options, "path", 0));

0 commit comments

Comments
 (0)