mirror of
https://github.com/odin-lang/Odin.git
synced 2025-12-30 01:44:36 +00:00
These are the procedures for configuring a serial port.
You simply open the port with CreateFile (os.open), followed by a call to GetCommState,
setting the DCB as desired, followed by a SetCommState call.
The DCB structure uses C bitfields, so a configuration struct is provided along with a helper procedure to make it easier
to initialize in Odin code.
This makes it possible to initialize a DCB structure with one call to the helper:
```
dcb: DCB
windows.init_dcb_with_config(&dcb, {
BaudRate = 115200,
ByteSize = 8,
Parity = .None,
StopBits = .One,
})
```
(The parity and the stopbits are actually optional in this example, as their zero-values are None and One, respectively.)