bugst / go-serial

A cross-platform serial library for go-lang.
BSD 3-Clause "New" or "Revised" License
617 stars 188 forks source link

Allow setting RTS and DTR on `Open` #140

Closed cmaglie closed 1 year ago

cmaglie commented 1 year ago

Based on #47, the API is slightly different to allow DTR and RTS to default to true if not specified:

    port, err := serial.Open("/dev/ttyUSB0", &serial.Mode{BaudRate: 9600})

this is the full initialization:

    port, err := serial.Open("/dev/ttyUSB0", &serial.Mode{
        BaudRate: 9600,
        DataBits: 8,
        Parity:   serial.NoParity,
        StopBits: serial.OneStopBit,
        InitialStatusBits: &serial.ModemOutputBits{
            RTS: true,
            DTR: false,
        },
    })