Skip to content

Commit

Permalink
Allow 9600 baudrate too
Browse files Browse the repository at this point in the history
  • Loading branch information
Tarmigan Casebolt committed Mar 4, 2011
1 parent c4bd917 commit 246486e
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions serial_posix.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,23 @@ func OpenPort(name string, baud int) (f *os.File, err os.Error) {
f.Close()
return nil, err
}
_, err = C.cfsetispeed(&st, C.B115200)
var speed C.speed_t
switch baud {
case 115200:
speed = C.B115200
case 9600:
speed = C.B9600
default:
f.Close()
return nil, SError{fmt.Sprintf("Unknown baud rate %v", baud)}
}

_, err = C.cfsetispeed(&st, speed)
if err != nil {
f.Close()
return nil, err
}
_, err = C.cfsetospeed(&st, C.B115200)
_, err = C.cfsetospeed(&st, speed)
if err != nil {
f.Close()
return nil, err
Expand Down

0 comments on commit 246486e

Please sign in to comment.