MCPcopy Create free account
hub / github.com/distributed/sers / takeOverFD

Function takeOverFD

sers_termios.go:33–53  ·  view source on GitHub ↗
(fd int, fn string)

Source from the content-addressed store, hash-verified

31}
32
33func takeOverFD(fd int, fn string) (SerialPort, error) {
34 bp := &baseport{
35 fd: fd,
36 }
37
38 tio, err := bp.getattr()
39 if err != nil {
40 return nil, &Error{"putting fd in non-canonical mode", err}
41 }
42
43 C.cfmakeraw(tio)
44
45 err = bp.setattr(tio)
46 if err != nil {
47 return nil, &Error{"putting fd in non-canonical mode", err}
48 }
49
50 bp.f = os.NewFile(uintptr(fd), fn)
51
52 return bp, nil
53}
54
55// TakeOver accepts an open *os.File and returns a SerialPort representing the
56// open file.

Callers 1

OpenFunction · 0.85

Calls 2

getattrMethod · 0.95
setattrMethod · 0.95

Tested by

no test coverage detected