From 922d2a0cbd1406c0b437c0a062a8c04129d7dda4 Mon Sep 17 00:00:00 2001 From: xengineering Date: Thu, 30 May 2024 20:00:44 +0200 Subject: software: communication: Implement unslip() This implements to decode the Serial Line Internet Protocol (SLIP). It splits the continuous byte stream into frames. Based on these frames the rest of the data link layer and upper layers can be implemented. --- software/communication/interface.go | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'software/communication/interface.go') diff --git a/software/communication/interface.go b/software/communication/interface.go index d124a48..df089f2 100644 --- a/software/communication/interface.go +++ b/software/communication/interface.go @@ -1,11 +1,12 @@ package communication import ( - "fmt" + "log" ) type SerialInterface struct { phy physical + dl dataLink } func NewSerialInterface() (SerialInterface, error) { @@ -17,16 +18,19 @@ func NewSerialInterface() (SerialInterface, error) { return iface, err } + iface.dl = newDataLink() + return iface, nil } func (i *SerialInterface) Start() { i.phy.start() + i.dl.start(i.phy.rx) } func (i *SerialInterface) Cat() { for { - data := <-i.phy.rx - fmt.Printf("%s", string(data)) + data := <-i.dl.rx + log.Printf("RX: '%v'\n", data) } } -- cgit v1.2.3-70-g09d2