Documentation
¶
Overview ¶
Package sources provides capture.Source implementations for serial ports, TCP connections, and local files.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var CommonBaudRates = []int{9600, 19200, 38400, 57600, 115200, 230400, 460800, 921600}
CommonBaudRates lists baud rates we routinely offer to users.
var DataBitsOptions = []int{5, 6, 7, 8}
DataBitsOptions enumerates supported data bit widths.
var FlowControlOptions = []SerialOption{
{Code: "none", Label: "None"},
{Code: "hardware", Label: "Hardware (RTS/CTS)"},
{Code: "software", Label: "Software (XON/XOFF)"},
}
FlowControlOptions enumerates supported flow control strategies.
var ParityOptions = []SerialOption{
{Code: "N", Label: "None"},
{Code: "O", Label: "Odd"},
{Code: "E", Label: "Even"},
{Code: "M", Label: "Mark"},
{Code: "S", Label: "Space"},
}
ParityOptions enumerates supported parity settings and their display labels.
var StopBitsOptions = []SerialOption{
{Code: "1", Label: "1"},
{Code: "1.5", Label: "1.5"},
{Code: "2", Label: "2"},
}
StopBitsOptions enumerates supported stop bit configurations.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
Port string
Baud int
Parity string // "N", "O", "E", "M", "S"
DataBits int // 5, 6, 7, 8
StopBits string // "1", "1.5", "2"
FlowControl string // "none", "hardware", "software"
}
Config captures the serial connection parameters that can be shared across UIs and sources.
func DefaultConfig ¶
func DefaultConfig() Config
DefaultConfig returns the standard serial defaults used throughout the application.
type File ¶
type File struct {
FileConfig
// contains filtered or unexported fields
}
File represents a file-based data source for ingesting existing data files.
func NewFileWithConfig ¶
func NewFileWithConfig(cfg FileConfig) (*File, error)
NewFileWithConfig constructs a File source from an explicit configuration.
func (*File) Meta ¶
func (f *File) Meta() core.SourceMeta
Meta returns source metadata for the file.
type FileConfig ¶
type FileConfig struct {
Path string
ChunkSize int // bytes per chunk (0 = line-by-line)
SkipLines int // skip N header lines
Follow bool // tail -f mode (future enhancement)
}
FileConfig captures file ingestion parameters.
func DefaultFileConfig ¶
func DefaultFileConfig() FileConfig
DefaultFileConfig returns standard file ingestion defaults.
type Serial ¶
type Serial struct {
Config
// contains filtered or unexported fields
}
Serial is a capture source that reads newline-delimited frames from a hardware serial port. It opens the port in a background goroutine and streams frames over the channel returned by Frames.
func NewSerialWithConfig ¶
NewSerialWithConfig constructs a Serial source from an explicit configuration.
func (*Serial) Frames ¶
Frames returns the channel on which raw byte frames are delivered. The channel is closed when the read loop exits.
func (*Serial) Meta ¶
func (s *Serial) Meta() core.SourceMeta
Meta returns the source metadata (kind, port, baud) for this serial source.
type SerialOption ¶
SerialOption exposes a code/label pair for presenting serial settings.
type TCP ¶
type TCP struct {
TCPConfig
// contains filtered or unexported fields
}
TCP represents a TCP socket data source for ingesting streaming data.
func NewTCPWithConfig ¶
NewTCPWithConfig constructs a TCP source from an explicit configuration.
func (*TCP) Meta ¶
func (t *TCP) Meta() core.SourceMeta
Meta returns source metadata for the TCP connection.
type TCPConfig ¶
type TCPConfig struct {
Host string // hostname or IP address
Port int // TCP port
ConnectTimeout time.Duration // connection timeout
ReadTimeout time.Duration // read timeout (0 = no timeout)
BufferSize int // read buffer size in bytes
}
TCPConfig captures the TCP connection parameters.
func DefaultTCPConfig ¶
func DefaultTCPConfig() TCPConfig
DefaultTCPConfig returns the standard TCP defaults.