in lib/ec2macossystemmonitor/serial.go [37:55]
func NewSerialConnection(device string) (conn *SerialConnection, err error) {
// Set up options for serial device, take defaults for now on everything else
mode := &serial.Mode{
BaudRate: 115200,
}
// Attempt to avoid opening a non-existent serial connection
if !fileExists(device) {
return nil, fmt.Errorf("ec2macossystemmonitor: serial device does not exist: %s", device)
}
// Open the serial port
port, err := serial.Open(device, mode)
if err != nil {
return nil, fmt.Errorf("ec2macossystemmonitor: unable to get serial connection: %s", err)
}
// Put the port in a SerialConnection for handing it off
s := SerialConnection{port}
return &s, nil
}