invented the bicycle)) Simple fork of goburrow/serial to use setterm() from termios lib AND use non-standart (non-posix) termios.Cflag 0x40000000, to manipulate 9 bit's MARK and SPACE states. Changes (after original goburrow/serial):
- serial_posix.go: newTermios(&config) => NewTermios(&config) (now it is public)
- serial.go: add SetTermios(termios) to Port interface (not need to reopen port to apply new termios settings)
- serial_posix.go: add 0x40000000 bit ops, non-posix. tested linux only (new debian 9.8 and ti arm embed with old kernel 2.6.x)
package main
import (
"log"
"github.com/adenis78/serial"
)
func main() {
port, err := serial.Open(&serial.Config{Address: "/dev/ttyUSB0"})
if err != nil {
log.Fatal(err)
}
defer port.Close()
_, err = port.Write([]byte("serial"))
if err != nil {
log.Fatal(err)
}
config.Parity = "M"
config.StopBits = 1
termios, _ := serial.NewTermios(&config)
err = port.SetTermios(termios)
if err != nil {
log.Fatal(err)
}
config.Parity = "S"
termios, _ := serial.NewTermios(&config)
err = port.SetTermios(termios)
if err != nil {
log.Fatal(err)
}
}
socat -d -d pty,raw,echo=0 pty,raw,echo=0
- on Mac OS, the socat command can be installed using homebrew:
brew install socat