-
Notifications
You must be signed in to change notification settings - Fork 0
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
New Web Serial API #1
Labels
Comments
frank-dspeed
added
documentation
Improvements or additions to documentation
enhancement
New feature or request
labels
Apr 21, 2021
This was referenced Apr 21, 2021
serialport-webserial.js //https://unpkg.com/browse/[email protected]/dist/ponyfill.es2018.mjs
/**
* Complet interfaces
* interface EventTarget {
constructor();
undefined addEventListener(DOMString type, EventListener? callback, optional (AddEventListenerOptions or boolean) options = {});
undefined removeEventListener(DOMString type, EventListener? callback, optional (EventListenerOptions or boolean) options = {});
boolean dispatchEvent(Event event);
};
callback interface EventListener {
undefined handleEvent(Event event);
};
dictionary EventListenerOptions {
boolean capture = false;
};
dictionary AddEventListenerOptions : EventListenerOptions {
boolean passive = false;
boolean once = false;
AbortSignal signal;
};
interface SerialPort : EventTarget {
attribute EventHandler onconnect;
attribute EventHandler ondisconnect;
readonly attribute ReadableStream readable;
readonly attribute WritableStream writable;
SerialPortInfo getInfo();
Promise<undefined> open(SerialOptions options);
Promise<undefined> setSignals(optional SerialOutputSignals signals = {});
Promise<SerialInputSignals> getSignals();
Promise<undefined> close();
};
// serialOptions
required [EnforceRange] unsigned long baudRate;
[EnforceRange] octet dataBits = 8;
[EnforceRange] octet stopBits = 1;
ParityType parity = "none";
[EnforceRange] unsigned long bufferSize = 255;
FlowControlType flowControl = "none";
* @param {*} SerialPort
* @param {*} errorHandler
*/
function WebSerialPort(SerialPort,serialOptions,errorHandler) {
const onconnect, ondisconnect
const SerialPort = {
//https://unpkg.com/browse/[email protected]/dist/ponyfill.es2018.mjs
readable: {
getReader(){
return {
read() {}
}
}
},
writeable: {
getWriter(){
return {
write() {}
}
}
},
open(serialOptions) {
_internalPort = new SerialPort();
},
getPorts(){},
requestPort() {},
closed() {},
ready() {},
onconnect() {},
ondisconnect() {}
}
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
Deprecated Example in both Locations as using the port Path or Address Directly is not Possible with the WebSerialApi
and it is also not usefull for Linux in Software that gets Shipped also the productId vendorId pattern is the new successor
the old functionality does not need to get removed but examples should show how to use find() alternatives ,getPort, requestPort()
Introducing Web Streams to NodeJS
Accepting Callbacks and register them
Error Handling for connections on the port
Auto Open#
If you disable the autoOpen option, you'll need to open the port on your own.
Reading Data#
Get updates about new data arriving through the serial port as follows:
Enjoy and do cool things with this code.
The text was updated successfully, but these errors were encountered: