Class SerialPort
- Namespace
- CSharpToJavaScript.APIs.JS
- Assembly
- CSharpToJavaScript.dll
NOTE
ExperimentalSerialPort interface of the Web Serial API provides access to a serial port on the host device.
[Value("SerialPort")]
public class SerialPort : EventTarget
- Inheritance
-
SerialPort
- Inherited Members
Remarks
Constructors
SerialPort()
public SerialPort()
Properties
Connected
NOTE
Experimentalconnected read-only property of the SerialPort interface returns a boolean value that indicates whether the port is logically connected to the device.
[Value("connected")]
public bool Connected { get; }
Property Value
- bool
A boolean —
trueif the port is logically connected, andfalseif not.
Remarks
Onconnect
[Value("onconnect")]
public EventHandlerNonNull Onconnect { get; set; }
Property Value
Ondisconnect
[Value("ondisconnect")]
public EventHandlerNonNull Ondisconnect { get; set; }
Property Value
Readable
NOTE
Experimentalreadable read-only property of the SerialPort interface returns a ReadableStream for receiving data from the device connected to the port. Chunks read from this stream are instances of {{jsxref("Uint8Array")}}. This property is non-null as long as the port is open and has not encountered a fatal error.
[Value("readable")]
public ReadableStream Readable { get; }
Property Value
Remarks
Writable
NOTE
Experimentalwritable read-only property of the SerialPort interface returns a WritableStream for sending data to the device connected to the port. Chunks written to this stream must be instances of {{jsxref("ArrayBuffer")}}, {{jsxref("TypedArray")}}, or {{jsxref("DataView")}}. This property is non-null as long as the port is open and has not encountered a fatal error.
[Value("writable")]
public WritableStream Writable { get; }
Property Value
Remarks
Methods
Close()
NOTE
ExperimentalSerialPort.close() method of the SerialPort interface returns a {{jsxref("Promise")}} that resolves when the port closes.
[Value("close")]
public Task<GlobalObject.Undefined> Close()
Returns
Remarks
Forget()
NOTE
ExperimentalSerialPort.forget() method of the SerialPort interface returns a {{jsxref("Promise")}} that resolves when access to the serial port is revoked.
[Value("forget")]
public Task<GlobalObject.Undefined> Forget()
Returns
- Task<GlobalObject.Undefined>
A Promise that resolves with
undefinedonce the connection is revoked.
Remarks
GetInfo()
NOTE
ExperimentalgetInfo() method of the SerialPort interface returns an object containing identifying information for the device available via the port.
[Value("getInfo")]
public SerialPortInfo GetInfo()
Returns
- SerialPortInfo
An object containing the following properties:
Remarks
GetSignals()
NOTE
ExperimentalSerialPort.getSignals() method of the SerialPort interface returns a {{jsxref("Promise")}} that resolves with an object containing the current state of the port's control signals.
[Value("getSignals")]
public Task<SerialInputSignals> GetSignals()
Returns
- Task<SerialInputSignals>
Returns a Promise that resolves with an object containing the following members:
Remarks
Open(SerialOptions)
NOTE
Experimentalopen() method of the SerialPort interface returns a {{jsxref("Promise")}} that resolves when the port is opened. By default the port is opened with 8 data bits, 1 stop bit and no parity checking. The baudRate parameter is required.
[Value("open")]
public Task<GlobalObject.Undefined> Open(SerialOptions options)
Parameters
optionsSerialOptions
Returns
Remarks
SetSignals(SerialOutputSignals)
NOTE
ExperimentalsetSignals() method of the SerialPort interface sets control signals on the port and returns a {{jsxref("Promise")}} that resolves when they are set.
[Value("setSignals")]
public Task<GlobalObject.Undefined> SetSignals(SerialOutputSignals signals = null)
Parameters
signalsSerialOutputSignals