node-serialport
node-serialport copied to clipboard
Update to a higher baudrate(460800 or 921600) is impossible on MacOS
SerialPort Version
11.x.x
Node Version
v14.18.0
Electron Version
No response
Platform
Darwin xxx 21.6.0 Darwin Kernel Version 21.6.0: Thu Mar 9 20:08:59 PST 2023; root:xnu-8020.240.18.700.8~1/RELEASE_X86_64 x86_64
Architecture
No response
Hardware or chipset of serialport
No response
What steps will reproduce the bug?
const serialPort = new SerialPort({path:'xxx', baudRate:230400});
serialPort.update({baudRate:460800}, (err)=>{console.log(err)});
What happens?
Received error in callback, the detailed information is:
Error: Error: Invalid argument calling ioctl(.., IOSSIOSPEED, -1 )
What should have happened?
I have read the source code, I think it is due to the ToBaudConstant method in bindings-cpp/src/serialport_unix.cpp. It will convert the baudrate passed by user. For baudrate higher than 230400, it will convert to -1 on MacOS.
I have also tested on windows, no such issue.
Additional information
No response