From 777a7600337030e6fc9d292d702ec6bbecea4dc2 Mon Sep 17 00:00:00 2001 From: saji Date: Wed, 10 May 2023 12:55:51 -0500 Subject: [PATCH] format session.go --- xbee/session.go | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/xbee/session.go b/xbee/session.go index 0a349b5..a6802b2 100644 --- a/xbee/session.go +++ b/xbee/session.go @@ -9,17 +9,17 @@ package xbee import ( "bufio" + "errors" "fmt" "io" - "sync" - "strings" - "errors" - "runtime" "net" + "runtime" "strconv" + "strings" + "sync" - "golang.org/x/exp/slog" "go.bug.st/serial" + "golang.org/x/exp/slog" ) // TODO: implement net.Conn for Session/Conn. We are missing LocalAddr, RemoteAddr, @@ -27,6 +27,8 @@ import ( // Session represents a connection to a locally-attached XBee. The connection can be through // serial/USB or TCP/IP depending on what is supported by the device. +// Session implements the net.Conn interface, so it can be used anywhere a net.Conn can be used. +// This also means that deadlines can be set. type Session struct { ioDev io.ReadWriteCloser ct connTrack @@ -239,14 +241,13 @@ func (c *Conn) Write(p []byte) (int, error) { return c.parent.writeAddr(p, c.addr) } +/* + Transport represents a connection that an XBee can use. + it's mostly a helper struct to parse URIs. It can parse the following formats: - -/* Transport represents a connection that an XBee can use. - it's mostly a helper struct to parse URIs. It can parse the following formats: - - tcp://192.168.4.5:8340 - COM1 - /dev/ttyUSB0:115200 + tcp://192.168.4.5:8340 + COM1 + /dev/ttyUSB0:115200 for network devices, a port is optional. If it is not specified it will default to 2616. The colon after a serial port sets the baud rate.