move framing creation into shared place

This commit is contained in:
Joel Wetzell
2025-12-06 16:02:35 -06:00
parent 04103cc6ca
commit 4c0f7c1723
4 changed files with 35 additions and 40 deletions

View File

@@ -49,19 +49,10 @@ func init() {
return nil, fmt.Errorf("misc.serial.client framing method must be a string")
}
var framer framing.Framer
framer, err := framing.GetFramer(framingMethodString)
switch framingMethodString {
case "CR":
framer = framing.NewByteSeparatorFramer([]byte{'\r'})
case "LF":
framer = framing.NewByteSeparatorFramer([]byte{'\n'})
case "CRLF":
framer = framing.NewByteSeparatorFramer([]byte{'\r', '\n'})
case "SLIP":
framer = framing.NewSlipFramer()
default:
return nil, fmt.Errorf("unknown framing method: %s", framingMethodString)
if err != nil {
return nil, err
}
buadRate, ok := params["baudRate"]