Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Flag ¶
type Flag interface {
StringVar(*string, string, string, string)
IntVar(*int, string, int, string)
}
See flag.FlagSet
type Mock ¶
Mock contains options and the serial port
func (*Mock) Start ¶
Start() executes StartSocat() and Read(), which starts a socat process and read data from the virtual serial port.
func (*Mock) StartSocat ¶
Kill previous socat process (if any) and then start a socat process and write process ID to the pid file.
type Options ¶
type Options struct {
InputFile string // device file for your program to open for read and write
OutputFile string // device file for this program to open for read and write
PidFile string // file to store the process id of socat, defaults to "socat.pid"
SocatPath string // path to the socat executable, defaults to "socat"
BaudRate int // baud rate (1200/2400/4800/9600/19200/38400/57600/115200)
ExtraOpts string // extra options of socat
Verbose bool // whether to print log to stderr
// Function is called to open serial port
Open func(path string, baudrate int) (Port, error)
// Function is called when new bytes is read. Return any
// unprocessed bytes for later use
Process func(*Mock, []byte) []byte
}
Mock options
func (*Options) SetFlagsPrefix ¶ added in v1.0.1
Helper method to set up flags (with prefix) for flag set.
func (*Options) SocatCommandArgs ¶
Return command line arguments of socat.
Click to show internal directories.
Click to hide internal directories.