Use unsigned values for termios setting
This allows the last (most significant) bit to be set without overflow errors. The error becomes visible after adding the CRTSCTS constant on linux/386: const tcCRTSCTS uint = 0x80000000
This commit is contained in:
@@ -13,7 +13,7 @@ const regexFilter = "^(cu|tty)\\..*"
|
||||
|
||||
// termios manipulation functions
|
||||
|
||||
var baudrateMap = map[int]int{
|
||||
var baudrateMap = map[int]uint{
|
||||
0: syscall.B9600, // Default to 9600
|
||||
50: syscall.B50,
|
||||
75: syscall.B75,
|
||||
@@ -35,7 +35,7 @@ var baudrateMap = map[int]int{
|
||||
230400: syscall.B230400,
|
||||
}
|
||||
|
||||
var databitsMap = map[int]int{
|
||||
var databitsMap = map[int]uint{
|
||||
0: syscall.CS8, // Default to 8 bits
|
||||
5: syscall.CS5,
|
||||
6: syscall.CS6,
|
||||
@@ -43,13 +43,13 @@ var databitsMap = map[int]int{
|
||||
8: syscall.CS8,
|
||||
}
|
||||
|
||||
const tcCMSPAR int = 0 // may be CMSPAR or PAREXT
|
||||
const tcIUCLC int = 0
|
||||
const tcCMSPAR uint = 0 // may be CMSPAR or PAREXT
|
||||
const tcIUCLC uint = 0
|
||||
|
||||
const tcCCTS_OFLOW int = 0x00010000
|
||||
const tcCRTS_IFLOW int = 0x00020000
|
||||
const tcCCTS_OFLOW uint = 0x00010000
|
||||
const tcCRTS_IFLOW uint = 0x00020000
|
||||
|
||||
const tcCRTSCTS int = (tcCCTS_OFLOW | tcCRTS_IFLOW)
|
||||
const tcCRTSCTS uint = (tcCCTS_OFLOW | tcCRTS_IFLOW)
|
||||
|
||||
// syscall wrappers
|
||||
|
||||
|
||||
@@ -6,6 +6,6 @@
|
||||
|
||||
package serial // import "go.bug.st/serial.v1"
|
||||
|
||||
func termiosMask(data int) uint32 {
|
||||
func termiosMask(data uint) uint32 {
|
||||
return uint32(data)
|
||||
}
|
||||
|
||||
@@ -8,6 +8,6 @@ package serial // import "go.bug.st/serial.v1"
|
||||
|
||||
// termios manipulation functions
|
||||
|
||||
func termiosMask(data int) uint64 {
|
||||
func termiosMask(data uint) uint64 {
|
||||
return uint64(data)
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ const regexFilter = "^(cu|tty)\\..*"
|
||||
|
||||
// termios manipulation functions
|
||||
|
||||
var baudrateMap = map[int]int{
|
||||
var baudrateMap = map[int]uint{
|
||||
0: syscall.B9600, // Default to 9600
|
||||
50: syscall.B50,
|
||||
75: syscall.B75,
|
||||
@@ -37,7 +37,7 @@ var baudrateMap = map[int]int{
|
||||
921600: syscall.B921600,
|
||||
}
|
||||
|
||||
var databitsMap = map[int]int{
|
||||
var databitsMap = map[int]uint{
|
||||
0: syscall.CS8, // Default to 8 bits
|
||||
5: syscall.CS5,
|
||||
6: syscall.CS6,
|
||||
@@ -45,15 +45,15 @@ var databitsMap = map[int]int{
|
||||
8: syscall.CS8,
|
||||
}
|
||||
|
||||
const tcCMSPAR int = 0 // may be CMSPAR or PAREXT
|
||||
const tcIUCLC int = 0
|
||||
const tcCMSPAR uint = 0 // may be CMSPAR or PAREXT
|
||||
const tcIUCLC uint = 0
|
||||
|
||||
const tcCCTS_OFLOW int = 0x00010000
|
||||
const tcCRTS_IFLOW int = 0x00020000
|
||||
const tcCCTS_OFLOW uint = 0x00010000
|
||||
const tcCRTS_IFLOW uint = 0x00020000
|
||||
|
||||
const tcCRTSCTS int = tcCCTS_OFLOW
|
||||
const tcCRTSCTS uint = tcCCTS_OFLOW
|
||||
|
||||
func termiosMask(data int) uint32 {
|
||||
func termiosMask(data uint) uint32 {
|
||||
return uint32(data)
|
||||
}
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ const regexFilter = "(ttyS|ttyUSB|ttyACM|ttyAMA|rfcomm|ttyO)[0-9]{1,3}"
|
||||
|
||||
// termios manipulation functions
|
||||
|
||||
var baudrateMap = map[int]int{
|
||||
var baudrateMap = map[int]uint{
|
||||
0: syscall.B9600, // Default to 9600
|
||||
50: syscall.B50,
|
||||
75: syscall.B75,
|
||||
@@ -47,7 +47,7 @@ var baudrateMap = map[int]int{
|
||||
4000000: syscall.B4000000,
|
||||
}
|
||||
|
||||
var databitsMap = map[int]int{
|
||||
var databitsMap = map[int]uint{
|
||||
0: syscall.CS8, // Default to 8 bits
|
||||
5: syscall.CS5,
|
||||
6: syscall.CS6,
|
||||
@@ -55,12 +55,12 @@ var databitsMap = map[int]int{
|
||||
8: syscall.CS8,
|
||||
}
|
||||
|
||||
const tcCMSPAR int = 0 // may be CMSPAR or PAREXT
|
||||
const tcCMSPAR uint = 0 // may be CMSPAR or PAREXT
|
||||
const tcIUCLC = syscall.IUCLC
|
||||
|
||||
const tcCRTSCTS int = 0x80000000
|
||||
const tcCRTSCTS uint = 0x80000000
|
||||
|
||||
func termiosMask(data int) uint32 {
|
||||
func termiosMask(data uint) uint32 {
|
||||
return uint32(data)
|
||||
}
|
||||
|
||||
|
||||
@@ -143,7 +143,7 @@ func setTermSettingsBaudrate(speed int, settings *syscall.Termios) error {
|
||||
return &PortError{code: InvalidSpeed}
|
||||
}
|
||||
// revert old baudrate
|
||||
BAUDMASK := 0
|
||||
var BAUDMASK uint
|
||||
for _, rate := range baudrateMap {
|
||||
BAUDMASK |= rate
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user