diff --git a/cmd/vbantxt/config.go b/cmd/vbantxt/config.go index b5cab06..748bd0d 100644 --- a/cmd/vbantxt/config.go +++ b/cmd/vbantxt/config.go @@ -1,3 +1,4 @@ +// Package main provides the configuration loading functionality for the vbantxt application. package main import ( diff --git a/cmd/vbantxt/config_internal_test.go b/cmd/vbantxt/config_internal_test.go index 6358bcf..7e99c37 100644 --- a/cmd/vbantxt/config_internal_test.go +++ b/cmd/vbantxt/config_internal_test.go @@ -35,5 +35,4 @@ func TestLoadConfig_Errors(t *testing.T) { assert.ErrorContains(t, err, tc.err) }) } - } diff --git a/errors.go b/errors.go index edb35d4..ad84e0c 100644 --- a/errors.go +++ b/errors.go @@ -1,3 +1,4 @@ +// Package vbantxt provides utilities for handling VBAN text errors. package vbantxt // Error is used to define sentinel errors. diff --git a/option.go b/option.go index 2191ee6..55ca723 100644 --- a/option.go +++ b/option.go @@ -9,14 +9,14 @@ import ( // Option is a functional option type that allows us to configure the VbanTxt. type Option func(*VbanTxt) -// WithRateLimit is a functional option to set the ratelimit for requests +// WithRateLimit is a functional option to set the ratelimit for requests. func WithRateLimit(ratelimit time.Duration) Option { return func(vt *VbanTxt) { vt.ratelimit = ratelimit } } -// WithBPSOpt is a functional option to set the bps index for {VbanTxt}.packet +// WithBPSOpt is a functional option to set the bps index for {VbanTxt}.packet. func WithBPSOpt(bps int) Option { return func(vt *VbanTxt) { bpsIndex := indexOf(BpsOpts, bps) @@ -28,7 +28,7 @@ func WithBPSOpt(bps int) Option { } } -// WithChannel is a functional option to set the channel for {VbanTxt}.packet +// WithChannel is a functional option to set the channel for {VbanTxt}.packet. func WithChannel(channel int) Option { return func(vt *VbanTxt) { vt.packet.channel = channel diff --git a/packet.go b/packet.go index 66f4a1c..380172f 100644 --- a/packet.go +++ b/packet.go @@ -13,9 +13,12 @@ const ( headerSz = 4 + 1 + 1 + 1 + 1 + 16 + 4 ) -var BpsOpts = []int{0, 110, 150, 300, 600, 1200, 2400, 4800, 9600, 14400, 19200, 31250, +// BpsOpts defines the available baud rate options. +var BpsOpts = []int{ + 0, 110, 150, 300, 600, 1200, 2400, 4800, 9600, 14400, 19200, 31250, 38400, 57600, 115200, 128000, 230400, 250000, 256000, 460800, 921600, - 1000000, 1500000, 2000000, 3000000} + 1000000, 1500000, 2000000, 3000000, +} type packet struct { streamname []byte @@ -39,17 +42,17 @@ func newPacket(streamname string) packet { } } -// sr defines the samplerate for the request +// sr defines the samplerate for the request. func (p *packet) sr() byte { return byte(vbanProtocolTxt + p.bpsIndex) } -// nbc defines the channel of the request +// nbc defines the channel of the request. func (p *packet) nbc() byte { return byte(p.channel) } -// header returns a fully formed packet header +// header returns a fully formed packet header. func (p *packet) header() []byte { p.hbuf.Reset() p.hbuf.WriteString("VBAN") @@ -62,7 +65,7 @@ func (p *packet) header() []byte { return p.hbuf.Bytes() } -// bumpFrameCounter increments the frame counter by 1 +// bumpFrameCounter increments the frame counter by 1. func (p *packet) bumpFrameCounter() { x := binary.LittleEndian.Uint32(p.framecounter) binary.LittleEndian.PutUint32(p.framecounter, x+1) diff --git a/udpconn.go b/udpconn.go index 4a41ce3..81ed490 100644 --- a/udpconn.go +++ b/udpconn.go @@ -7,12 +7,12 @@ import ( log "github.com/sirupsen/logrus" ) -// udpConn represents the UDP client +// udpConn represents the UDP client. type udpConn struct { conn *net.UDPConn } -// newUDPConn returns a UDP client +// newUDPConn returns a UDP client. func newUDPConn(host string, port int) (udpConn, error) { udpAddr, err := net.ResolveUDPAddr("udp4", fmt.Sprintf("%s:%d", host, port)) if err != nil { @@ -27,7 +27,7 @@ func newUDPConn(host string, port int) (udpConn, error) { return udpConn{conn: conn}, nil } -// Write implements the io.WriteCloser interface +// Write implements the io.WriteCloser interface. func (u udpConn) Write(buf []byte) (int, error) { n, err := u.conn.Write(buf) if err != nil { @@ -38,7 +38,7 @@ func (u udpConn) Write(buf []byte) (int, error) { return n, nil } -// Close implements the io.WriteCloser interface +// Close implements the io.WriteCloser interface. func (u udpConn) Close() error { err := u.conn.Close() if err != nil { diff --git a/vbantxt.go b/vbantxt.go index a20ad7f..e0fe34e 100644 --- a/vbantxt.go +++ b/vbantxt.go @@ -49,7 +49,7 @@ func (vt VbanTxt) Send(cmd string) error { return nil } -// Close is responsible for closing the UDP Client connection +// Close is responsible for closing the UDP Client connection. func (vt VbanTxt) Close() error { err := vt.udpConn.Close() if err != nil {