(fd int, fn string)
| 31 | } |
| 32 | |
| 33 | func 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. |