2025-04-28 23:15:37 +03:00
|
|
|
### The "STTY" package
|
2025-04-28 22:57:43 +03:00
|
|
|
|
2025-04-28 23:15:37 +03:00
|
|
|
This package provides simplified way to invoke **stty** utility to perform some
|
|
|
|
tasks by means of it. For now the only a few number of functions are implemented:
|
|
|
|
set tty baudrate, check tty baudrate and test if selected baudrate is available
|
|
|
|
for some tty.
|
2025-04-28 22:57:43 +03:00
|
|
|
|
|
|
|
-------------
|
|
|
|
|
|
|
|
### Usage
|
|
|
|
1. Download the package by **go get** command:
|
|
|
|
```shell
|
2025-04-28 23:15:37 +03:00
|
|
|
go get code.foilhatguy.casa/pub/stty
|
2025-04-28 22:57:43 +03:00
|
|
|
```
|
2025-04-28 23:15:37 +03:00
|
|
|
|
2025-04-28 22:57:43 +03:00
|
|
|
2. Import package to your golang code:
|
|
|
|
```go
|
|
|
|
import (
|
2025-04-28 23:15:37 +03:00
|
|
|
"code.foilhatguy.casa/pub/stty"
|
2025-04-28 22:57:43 +03:00
|
|
|
)
|
|
|
|
```
|
|
|
|
|
2025-04-28 23:15:37 +03:00
|
|
|
3. Create new stty object by means of **Get()** function:
|
|
|
|
```go
|
|
|
|
sttyControl, err := stty.Get()
|
|
|
|
```
|
|
|
|
|
|
|
|
If **stty** is unavailable at the current system this function will
|
|
|
|
return an error.
|
|
|
|
|
|
|
|
4. Use stty object to perform some tasks. For instance, test if baudrate of 9600
|
|
|
|
is available at **/dev/ttyUSB0**:
|
2025-04-28 22:57:43 +03:00
|
|
|
```go
|
2025-04-28 23:15:37 +03:00
|
|
|
ok, err := sttyControl.TestBaudRate("/dev/ttyUSB0", 9600)
|
2025-04-28 22:57:43 +03:00
|
|
|
```
|