Merge pull request #51 from jwetzell/fix/no-default-framing-method

don't default framing method
This commit is contained in:
Joel Wetzell
2026-02-03 22:28:47 -06:00
committed by GitHub
3 changed files with 30 additions and 33 deletions

View File

@@ -43,20 +43,19 @@ func init() {
return nil, errors.New("serial.client port must be a string") return nil, errors.New("serial.client port must be a string")
} }
framingMethod := "RAW" framingMethod, ok := params["framing"]
framingMethodRaw, ok := params["framing"] if !ok {
return nil, errors.New("serial.client requires a framing parameter")
}
if ok { framingMethodString, ok := framingMethod.(string)
framingMethodString, ok := framingMethodRaw.(string)
if !ok { if !ok {
return nil, errors.New("serial.client framing method must be a string") return nil, errors.New("serial.client framing method must be a string")
} }
framingMethod = framingMethodString
}
framer := framer.GetFramer(framingMethod) framer := framer.GetFramer(framingMethodString)
if framer == nil { if framer == nil {
return nil, fmt.Errorf("serial.client unknown framing method: %s", framingMethod) return nil, fmt.Errorf("serial.client unknown framing method: %s", framingMethod)

View File

@@ -56,20 +56,19 @@ func init() {
return nil, err return nil, err
} }
framingMethod := "RAW" framingMethod, ok := params["framing"]
framingMethodRaw, ok := params["framing"] if !ok {
return nil, errors.New("net.tcp.client requires a framing parameter")
}
if ok { framingMethodString, ok := framingMethod.(string)
framingMethodString, ok := framingMethodRaw.(string)
if !ok { if !ok {
return nil, errors.New("net.tcp.client framing method must be a string") return nil, errors.New("net.tcp.client framing method must be a string")
} }
framingMethod = framingMethodString
}
framer := framer.GetFramer(framingMethod) framer := framer.GetFramer(framingMethodString)
if framer == nil { if framer == nil {
return nil, fmt.Errorf("net.tcp.client unknown framing method: %s", framingMethod) return nil, fmt.Errorf("net.tcp.client unknown framing method: %s", framingMethod)

View File

@@ -45,20 +45,19 @@ func init() {
return nil, errors.New("net.tcp.server port must be a number") return nil, errors.New("net.tcp.server port must be a number")
} }
framingMethod := "RAW" framingMethod, ok := params["framing"]
framingMethodRaw, ok := params["framing"] if !ok {
return nil, errors.New("net.tcp.server requires a framing parameter")
}
if ok { framingMethodString, ok := framingMethod.(string)
framingMethodString, ok := framingMethodRaw.(string)
if !ok { if !ok {
return nil, errors.New("net.tcp.server framing method must be a string") return nil, errors.New("net.tcp.server framing method must be a string")
} }
framingMethod = framingMethodString
}
framer := framer.GetFramer(framingMethod) framer := framer.GetFramer(framingMethodString)
if framer == nil { if framer == nil {
return nil, fmt.Errorf("net.tcp.server unknown framing method: %s", framingMethod) return nil, fmt.Errorf("net.tcp.server unknown framing method: %s", framingMethod)