diff --git a/.gitignore b/.gitignore index 6371d65..ed2b6e6 100644 --- a/.gitignore +++ b/.gitignore @@ -20,3 +20,4 @@ # Go workspace file go.work +.vscode/ diff --git a/internal/can/frame.go b/can/frame.go similarity index 100% rename from internal/can/frame.go rename to can/frame.go diff --git a/internal/can/frame_kind.go b/can/frame_kind.go similarity index 100% rename from internal/can/frame_kind.go rename to can/frame_kind.go diff --git a/cmd/root.go b/cmd/root.go index c9fefcb..f26c0a8 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -13,6 +13,7 @@ func Execute() { Usage: "see everything", Commands: []*cli.Command{ serveCmd, + xbeeCmd, }, } diff --git a/cmd/server.go b/cmd/server.go index 636cb38..4152c33 100644 --- a/cmd/server.go +++ b/cmd/server.go @@ -5,10 +5,9 @@ import ( "net" "time" - "github.com/kschamplin/gotelem/internal/can" - "github.com/kschamplin/gotelem/internal/gotelem" - "github.com/kschamplin/gotelem/internal/socketcan" - "github.com/kschamplin/gotelem/internal/xbee" + "github.com/kschamplin/gotelem/can" + "github.com/kschamplin/gotelem/socketcan" + "github.com/kschamplin/gotelem/xbee" "github.com/tinylib/msgp/msgp" "github.com/urfave/cli/v2" "go.bug.st/serial" diff --git a/cmd/xbee.go b/cmd/xbee.go new file mode 100644 index 0000000..1097604 --- /dev/null +++ b/cmd/xbee.go @@ -0,0 +1,45 @@ +package cmd + +// this file contains xbee utilities. +// we can do network discovery and netcat-like things. + +import ( + "github.com/urfave/cli/v2" +) + +var xbeeCmd = &cli.Command{ + Name: "xbee", + Aliases: []string{"x"}, + Usage: "Utilities for XBee", + Description: ` +Allows for testing and debugging XBee networks and devices. +The "device" parameter is not optional, and can be any of the following formats: + tcp://192.168.4.5:8430 + COM1 + /dev/ttyUSB0:115200 +For serial devices (COM1 and /dev/ttyUSB0), you can specify the baud rate +using a ':'. If excluded the baud rate will default to 9600. Note that +if using the native USB of the XLR Pro, the baud rate setting has no effect. + +TCP/UDP connections require a port. + `, + Flags: []cli.Flag{ + &cli.StringFlag{ + Name: "device", + Aliases: []string{"d"}, + Usage: "The XBee to connect to", + }, + }, + Subcommands: []*cli.Command{ + { + Name: "info", + Usage: "get information about an xbee device", + }, + { + Name: "netcat", + Aliases: []string{"nc"}, + ArgsUsage: "[addr]", + Usage: "send data from stdio over the xbee", + }, + }, +} diff --git a/internal/db/can_adapter.go b/db/can_adapter.go similarity index 96% rename from internal/db/can_adapter.go rename to db/can_adapter.go index 7802473..01b22f4 100644 --- a/internal/db/can_adapter.go +++ b/db/can_adapter.go @@ -1,11 +1,9 @@ package db import ( - "database/sql" - "github.com/jmoiron/sqlx" - _ "github.com/mattn/go-sqlite3" "github.com/kschamplin/gotelem/internal/can" + _ "github.com/mattn/go-sqlite3" ) // this file implements a CAN adapter for the sqlite db. @@ -21,3 +19,5 @@ func (cdb *CanDB) Send(_ *can.Frame) error { func (cdb *CanDB) Recv() (*can.Frame, error) { panic("not implemented") // TODO: Implement } + +func NewCanDB() diff --git a/internal/mprpc/rpc.go b/mprpc/rpc.go similarity index 100% rename from internal/mprpc/rpc.go rename to mprpc/rpc.go diff --git a/internal/mprpc/rpc_msg.go b/mprpc/rpc_msg.go similarity index 100% rename from internal/mprpc/rpc_msg.go rename to mprpc/rpc_msg.go diff --git a/internal/mprpc/rpc_msg_gen.go b/mprpc/rpc_msg_gen.go similarity index 100% rename from internal/mprpc/rpc_msg_gen.go rename to mprpc/rpc_msg_gen.go diff --git a/internal/mprpc/rpc_msg_gen_test.go b/mprpc/rpc_msg_gen_test.go similarity index 100% rename from internal/mprpc/rpc_msg_gen_test.go rename to mprpc/rpc_msg_gen_test.go diff --git a/internal/mprpc/rpcconntrack.go b/mprpc/rpcconntrack.go similarity index 100% rename from internal/mprpc/rpcconntrack.go rename to mprpc/rpcconntrack.go diff --git a/internal/socketcan/socketcan.go b/socketcan/socketcan.go similarity index 100% rename from internal/socketcan/socketcan.go rename to socketcan/socketcan.go diff --git a/internal/socketcan/socketcan_test.go b/socketcan/socketcan_test.go similarity index 100% rename from internal/socketcan/socketcan_test.go rename to socketcan/socketcan_test.go diff --git a/internal/xbee/api_frame.go b/xbee/api_frame.go similarity index 100% rename from internal/xbee/api_frame.go rename to xbee/api_frame.go diff --git a/internal/xbee/api_frame_test.go b/xbee/api_frame_test.go similarity index 100% rename from internal/xbee/api_frame_test.go rename to xbee/api_frame_test.go diff --git a/internal/xbee/at.go b/xbee/at.go similarity index 100% rename from internal/xbee/at.go rename to xbee/at.go diff --git a/internal/xbee/at_test.go b/xbee/at_test.go similarity index 100% rename from internal/xbee/at_test.go rename to xbee/at_test.go diff --git a/internal/xbee/conntrack.go b/xbee/conntrack.go similarity index 100% rename from internal/xbee/conntrack.go rename to xbee/conntrack.go diff --git a/internal/xbee/rxframe.go b/xbee/rxframe.go similarity index 100% rename from internal/xbee/rxframe.go rename to xbee/rxframe.go diff --git a/internal/xbee/rxframe_test.go b/xbee/rxframe_test.go similarity index 100% rename from internal/xbee/rxframe_test.go rename to xbee/rxframe_test.go diff --git a/internal/xbee/session.go b/xbee/session.go similarity index 99% rename from internal/xbee/session.go rename to xbee/session.go index ecddd58..fb41c4a 100644 --- a/internal/xbee/session.go +++ b/xbee/session.go @@ -236,5 +236,5 @@ func (sess *SerialSession) Close() error { } func (sess *SerialSession) DiscoverNodes() { - + panic("TODO: implement") } diff --git a/internal/xbee/txframe.go b/xbee/txframe.go similarity index 100% rename from internal/xbee/txframe.go rename to xbee/txframe.go diff --git a/internal/xbee/txframe_test.go b/xbee/txframe_test.go similarity index 100% rename from internal/xbee/txframe_test.go rename to xbee/txframe_test.go