Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot read SerialPort data within a Worker Thread #2974

Open
FergusCoulter opened this issue Jan 2, 2025 · 0 comments
Open

Cannot read SerialPort data within a Worker Thread #2974

FergusCoulter opened this issue Jan 2, 2025 · 0 comments

Comments

@FergusCoulter
Copy link

SerialPort Version

12.0.0

Node Version

22.12.0

Electron Version

No response

Platform

Linux pulse 6.6.63-v8+ #1824 SMP PREEMPT Tue Dec 3 12:59:39 GMT 2024 aarch64 GNU/Linux

Architecture

ARM

Hardware or chipset of serialport

No response

What steps will reproduce the bug?

This file calls the worker...

console.log("starting worker")
const gpsWorker = new Worker('./WorkerTest.js');

gpsWorker.on('message', (dt) =>{
    console.log("received message from worker to main thread")
    console.log(dt)
});
gpsWorker.on("error", (msg) => {
    console.log(msg);
});

Worker.js:

console.log("starting GPS worker service")
const gps = new GPSSetup();
// gps.SetupGPS();
// gps.ChangeUpdateRateAndLog();

const port = new SerialPort({
    path:'/dev/serial0',
    baudRate:115200
});
const parser = port.pipe(new ReadlineParser({ delimiter: '\r\n' }));

parser.on('data', (data) => {
    parentPort.postMessage(data)
});

What happens?

Trying to run SerialPort in a worker thread results in an error

2025-01-02T21:20:21.003Z serialport/bindings-cpp/unixRead read error [Error: EAGAIN: resource temporarily unavailable, read] {
  errno: -11,
  code: 'EAGAIN',
  syscall: 'read'
}
2025-01-02T21:20:21.004Z serialport/bindings-cpp/unixRead waiting for readable because of code: EAGAIN
2025-01-02T21:20:21.005Z serialport/bindings-cpp/poller Polling for "readable"
Segmentation fault

What should have happened?

I would expect the console to output the serial data

Additional information

No response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant