Compare commits

..

33 Commits

Author SHA1 Message Date
Joel Wetzell d7c6da5c5b support OSC 1.0 TCP format if SLIP is not enabled 2026-01-28 14:37:23 -06:00
Joel Wetzell 6f3a65322b rework send string 2026-01-28 14:36:59 -06:00
Joel Wetzell e34a589c5f prevent parsing empty byte slice 2026-01-28 14:34:52 -06:00
Joel Wetzell 41112d583b Merge pull request #13 from jwetzell/dependabot/go_modules/github.com/urfave/cli/v3-3.6.2
Bump github.com/urfave/cli/v3 from 3.6.1 to 3.6.2
2026-01-28 14:26:26 -06:00
dependabot[bot] 24a0501a4d Bump github.com/urfave/cli/v3 from 3.6.1 to 3.6.2
Bumps [github.com/urfave/cli/v3](https://github.com/urfave/cli) from 3.6.1 to 3.6.2.
- [Release notes](https://github.com/urfave/cli/releases)
- [Changelog](https://github.com/urfave/cli/blob/main/docs/CHANGELOG.md)
- [Commits](https://github.com/urfave/cli/compare/v3.6.1...v3.6.2)

---
updated-dependencies:
- dependency-name: github.com/urfave/cli/v3
  dependency-version: 3.6.2
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-01-19 03:08:19 +00:00
Joel Wetzell e06a0a2776 fix slip encoding 2025-12-24 18:46:39 -06:00
Joel Wetzell d1696baa31 Merge pull request #12 from jwetzell/dependabot/github_actions/actions/checkout-6
Bump actions/checkout from 5 to 6
2025-12-11 15:19:19 -06:00
dependabot[bot] c0304bf7a6 Bump actions/checkout from 5 to 6
Bumps [actions/checkout](https://github.com/actions/checkout) from 5 to 6.
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](https://github.com/actions/checkout/compare/v5...v6)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-version: '6'
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-11-24 02:31:39 +00:00
Joel Wetzell d62d65c386 Merge pull request #10 from jwetzell/dependabot/go_modules/github.com/urfave/cli/v3-3.6.1
Bump github.com/urfave/cli/v3 from 3.6.0 to 3.6.1
2025-11-20 09:32:02 -06:00
dependabot[bot] f2888cc038 Bump github.com/urfave/cli/v3 from 3.6.0 to 3.6.1
Bumps [github.com/urfave/cli/v3](https://github.com/urfave/cli) from 3.6.0 to 3.6.1.
- [Release notes](https://github.com/urfave/cli/releases)
- [Changelog](https://github.com/urfave/cli/blob/main/docs/CHANGELOG.md)
- [Commits](https://github.com/urfave/cli/compare/v3.6.0...v3.6.1)

---
updated-dependencies:
- dependency-name: github.com/urfave/cli/v3
  dependency-version: 3.6.1
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-11-17 02:22:46 +00:00
jwetzell 24077a77d6 Merge pull request #9 from jwetzell/dependabot/go_modules/github.com/urfave/cli/v3-3.6.0
Bump github.com/urfave/cli/v3 from 3.4.1 to 3.6.0
2025-11-14 14:36:32 -06:00
dependabot[bot] 9e515cc28e Bump github.com/urfave/cli/v3 from 3.4.1 to 3.6.0
Bumps [github.com/urfave/cli/v3](https://github.com/urfave/cli) from 3.4.1 to 3.6.0.
- [Release notes](https://github.com/urfave/cli/releases)
- [Changelog](https://github.com/urfave/cli/blob/main/docs/CHANGELOG.md)
- [Commits](https://github.com/urfave/cli/compare/v3.4.1...v3.6.0)

---
updated-dependencies:
- dependency-name: github.com/urfave/cli/v3
  dependency-version: 3.6.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-11-10 02:27:40 +00:00
jwetzell 1ad942e489 fix cmd name and description 2025-10-01 13:07:00 -05:00
jwetzell e748adfa1c Merge pull request #7 from jwetzell/json-support
add json output to receiveosc
2025-10-01 13:03:26 -05:00
jwetzell 74a62f6287 add support for json output to receiveosc 2025-09-30 12:54:38 -05:00
jwetzell a1a550b4bb add json struct tags 2025-09-30 12:54:13 -05:00
jwetzell c039245298 update names of workflows 2025-09-27 10:28:58 -05:00
jwetzell 085bd082b4 Merge pull request #4 from jwetzell/dependabot/github_actions/actions/checkout-5
Bump actions/checkout from 4 to 5
2025-09-27 10:27:30 -05:00
jwetzell 0a4eff30b3 update go version 2025-09-27 10:22:45 -05:00
jwetzell 6482158fd6 Merge pull request #6 from jwetzell/urfave-cli
convert from cobra to urfave/cli
2025-09-27 10:20:21 -05:00
jwetzell 6808c36e88 remove cobra 2025-09-27 10:19:46 -05:00
jwetzell 257465d216 convert receiveosc to urfave/cli 2025-09-27 10:19:40 -05:00
jwetzell ce5e65e8f8 switch makeosc to urfave/cli 2025-09-27 09:55:09 -05:00
jwetzell e519f2d53c switch sendosc to urfave/cli 2025-09-27 09:54:58 -05:00
dependabot[bot] 048eb57d5a Bump actions/checkout from 4 to 5
Bumps [actions/checkout](https://github.com/actions/checkout) from 4 to 5.
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](https://github.com/actions/checkout/compare/v4...v5)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-version: '5'
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-08-18 03:36:57 +00:00
jwetzell 039d4e6f1a explicitly discard opening END when SLIP decoding 2025-05-19 09:23:57 -05:00
jwetzell 87853b8ccb SLIP encoding should be double END-ed 2025-05-19 09:23:06 -05:00
jwetzell d03f032e72 SLIP encoding should be double END-ed 2025-05-19 09:22:39 -05:00
jwetzell 2f4b90fc16 fix name of cmd in makeosc 2025-05-19 09:08:24 -05:00
jwetzell 278435e066 fix name of utility 2025-05-19 09:03:05 -05:00
jwetzell b50dc9969f add github actions to dependabot 2025-05-18 20:13:33 -05:00
jwetzell 30ffe3a965 Merge pull request #3 from jwetzell/dependabot/go_modules/github.com/spf13/cobra-1.9.1
Bump github.com/spf13/cobra from 1.8.1 to 1.9.1
2025-05-18 20:11:59 -05:00
dependabot[bot] 06e8ca7da3 Bump github.com/spf13/cobra from 1.8.1 to 1.9.1
Bumps [github.com/spf13/cobra](https://github.com/spf13/cobra) from 1.8.1 to 1.9.1.
- [Release notes](https://github.com/spf13/cobra/releases)
- [Commits](https://github.com/spf13/cobra/compare/v1.8.1...v1.9.1)

---
updated-dependencies:
- dependency-name: github.com/spf13/cobra
  dependency-version: 1.9.1
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-05-19 00:33:19 +00:00
12 changed files with 227 additions and 96 deletions
+4
View File
@@ -1,5 +1,9 @@
version: 2 version: 2
updates: updates:
- package-ecosystem: 'github-actions'
directory: '/'
schedule:
interval: 'weekly'
- package-ecosystem: gomod - package-ecosystem: gomod
directory: / directory: /
schedule: schedule:
+3 -3
View File
@@ -1,4 +1,4 @@
name: "release go binaries for multiple os/arch" name: "release go binaries for makeosc"
on: on:
push: push:
@@ -36,13 +36,13 @@ jobs:
- goarch: "386" - goarch: "386"
goos: darwin goos: darwin
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v6
- uses: wangyoucao577/go-release-action@v1 - uses: wangyoucao577/go-release-action@v1
with: with:
github_token: ${{ secrets.GITHUB_TOKEN }} github_token: ${{ secrets.GITHUB_TOKEN }}
goos: ${{ matrix.goos }} goos: ${{ matrix.goos }}
goarch: ${{ matrix.goarch }} goarch: ${{ matrix.goarch }}
goversion: "1.23.1" goversion: "1.25.1"
project_path: "./cmd/makeosc" project_path: "./cmd/makeosc"
binary_name: "makeosc" binary_name: "makeosc"
asset_name: makeosc-${{ matrix.goos }}-${{ matrix.goarch }} asset_name: makeosc-${{ matrix.goos }}-${{ matrix.goarch }}
+3 -3
View File
@@ -1,4 +1,4 @@
name: "release go binaries for multiple os/arch" name: "release go binaries for receiveosc"
on: on:
push: push:
@@ -36,13 +36,13 @@ jobs:
- goarch: "386" - goarch: "386"
goos: darwin goos: darwin
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v6
- uses: wangyoucao577/go-release-action@v1 - uses: wangyoucao577/go-release-action@v1
with: with:
github_token: ${{ secrets.GITHUB_TOKEN }} github_token: ${{ secrets.GITHUB_TOKEN }}
goos: ${{ matrix.goos }} goos: ${{ matrix.goos }}
goarch: ${{ matrix.goarch }} goarch: ${{ matrix.goarch }}
goversion: "1.23.1" goversion: "1.25.1"
project_path: "./cmd/receiveosc" project_path: "./cmd/receiveosc"
binary_name: "receiveosc" binary_name: "receiveosc"
asset_name: receiveosc-${{ matrix.goos }}-${{ matrix.goarch }} asset_name: receiveosc-${{ matrix.goos }}-${{ matrix.goarch }}
+3 -3
View File
@@ -1,4 +1,4 @@
name: "release go binaries for multiple os/arch" name: "release go binaries for sendosc"
on: on:
push: push:
@@ -36,13 +36,13 @@ jobs:
- goarch: "386" - goarch: "386"
goos: darwin goos: darwin
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v6
- uses: wangyoucao577/go-release-action@v1 - uses: wangyoucao577/go-release-action@v1
with: with:
github_token: ${{ secrets.GITHUB_TOKEN }} github_token: ${{ secrets.GITHUB_TOKEN }}
goos: ${{ matrix.goos }} goos: ${{ matrix.goos }}
goarch: ${{ matrix.goarch }} goarch: ${{ matrix.goarch }}
goversion: "1.23.1" goversion: "1.25.1"
project_path: "./cmd/sendosc" project_path: "./cmd/sendosc"
binary_name: "sendosc" binary_name: "sendosc"
asset_name: sendosc-${{ matrix.goos }}-${{ matrix.goarch }} asset_name: sendosc-${{ matrix.goos }}-${{ matrix.goarch }}
+39 -13
View File
@@ -1,13 +1,14 @@
package main package main
import ( import (
"context"
"encoding/hex" "encoding/hex"
"fmt" "fmt"
"os" "os"
"strconv" "strconv"
osc "github.com/jwetzell/osc-go" osc "github.com/jwetzell/osc-go"
"github.com/spf13/cobra" "github.com/urfave/cli/v3"
) )
func main() { func main() {
@@ -16,18 +17,43 @@ func main() {
var Types []string var Types []string
var Slip bool var Slip bool
var rootCmd = &cobra.Command{ cmd := &cli.Command{
Use: "sendosc", Name: "makeosc",
Run: func(cmd *cobra.Command, args []string) { Usage: "make osc bytes",
Flags: []cli.Flag{
&cli.StringFlag{
Name: "address",
Value: "",
Usage: "OSC address",
Destination: &Address,
Required: true,
},
&cli.StringSliceFlag{
Name: "arg",
Usage: "OSC args",
Destination: &Args,
},
&cli.StringSliceFlag{
Name: "type",
Usage: "OSC types",
Destination: &Types,
},
&cli.BoolFlag{
Name: "slip",
Value: false,
Usage: "whether to slip encode the OSC Message bytes",
Destination: &Slip,
},
},
Action: func(ctx context.Context, cmd *cli.Command) error {
make(Address, Args, Types, Slip) make(Address, Args, Types, Slip)
return nil
}, },
} }
rootCmd.Flags().StringVar(&Address, "address", "", "OSC address")
rootCmd.Flags().StringArrayVar(&Args, "arg", []string{}, "OSC args") if err := cmd.Run(context.Background(), os.Args); err != nil {
rootCmd.Flags().StringArrayVar(&Types, "type", []string{}, "OSC types") panic(err)
rootCmd.Flags().BoolVar(&Slip, "slip", false, "whether to slip encode the OSC Message bytes") }
rootCmd.MarkFlagRequired("address")
rootCmd.Execute()
} }
func argToTypedArg(rawArg string, oscType string) osc.OSCArg { func argToTypedArg(rawArg string, oscType string) osc.OSCArg {
@@ -117,13 +143,13 @@ func slipEncode(bytes []byte) []byte {
ESC_END := byte(0xdc) ESC_END := byte(0xdc)
ESC_ESC := byte(0xdd) ESC_ESC := byte(0xdd)
var encodedBytes = []byte{} var encodedBytes = []byte{END}
for _, byteToEncode := range bytes { for _, byteToEncode := range bytes {
if byteToEncode == END { if byteToEncode == END {
encodedBytes = append(encodedBytes, ESC_END) encodedBytes = append(encodedBytes, ESC, ESC_END)
} else if byteToEncode == ESC { } else if byteToEncode == ESC {
encodedBytes = append(encodedBytes, ESC_ESC) encodedBytes = append(encodedBytes, ESC, ESC_ESC)
} else { } else {
encodedBytes = append(encodedBytes, byteToEncode) encodedBytes = append(encodedBytes, byteToEncode)
} }
+77 -25
View File
@@ -1,36 +1,80 @@
package main package main
import ( import (
"context"
"encoding/json"
"fmt" "fmt"
"net" "net"
"os"
osc "github.com/jwetzell/osc-go" osc "github.com/jwetzell/osc-go"
"github.com/spf13/cobra" "github.com/urfave/cli/v3"
) )
func main() { func main() {
var Host string var Host string
var Port string var Port int32
var Protocol string var Protocol string
var Format string
var rootCmd = &cobra.Command{ cmd := &cli.Command{
Use: "sendosc", Name: "receiveosc",
Run: func(cmd *cobra.Command, args []string) { Usage: "receive OSC messages via UDP or TCP",
netAddress := Host + ":" + Port Flags: []cli.Flag{
&cli.StringFlag{
Name: "host",
Usage: "host to send OSC message to",
Value: "127.0.0.1",
Destination: &Host,
},
&cli.Int32Flag{
Name: "port",
Usage: "port to send OSC message to",
Destination: &Port,
Value: 8888,
},
&cli.StringFlag{
Name: "protocol",
Usage: "protocol to use to send (tcp or udp)",
Value: "udp",
Destination: &Protocol,
Validator: func(flag string) error {
if flag != "udp" && flag != "tcp" {
return fmt.Errorf("protocol must be either 'udp' or 'tcp'")
}
return nil
},
},
&cli.StringFlag{
Name: "format",
Usage: "format for messages to be output in ('json')",
Value: "json",
Destination: &Format,
Validator: func(flag string) error {
if flag != "json" {
return fmt.Errorf("format must be 'json'")
}
return nil
},
},
},
Action: func(ctx context.Context, cmd *cli.Command) error {
netAddress := fmt.Sprintf("%s:%d", Host, Port)
if Protocol == "udp" { if Protocol == "udp" {
listenUDP(netAddress) listenUDP(netAddress, Format)
} else if Protocol == "tcp" { } else if Protocol == "tcp" {
listenTCP(netAddress) listenTCP(netAddress, Format)
} }
return nil
}, },
} }
rootCmd.Flags().StringVar(&Host, "host", "127.0.0.1", "host to send OSC message to")
rootCmd.Flags().StringVar(&Port, "port", "8888", "port to send OSC message to") if err := cmd.Run(context.Background(), os.Args); err != nil {
rootCmd.Flags().StringVar(&Protocol, "protocol", "udp", "protocol to use to send (tcp or udp)") panic(err)
rootCmd.Execute() }
} }
func listenTCP(netAddress string) { func listenTCP(netAddress string, format string) {
socket, err := net.Listen("tcp4", netAddress) socket, err := net.Listen("tcp4", netAddress)
if err != nil { if err != nil {
fmt.Println(err) fmt.Println(err)
@@ -39,15 +83,13 @@ func listenTCP(netAddress string) {
defer socket.Close() defer socket.Close()
fmt.Printf("listening on %s (tcp w/ SLIP)\n", netAddress)
for { for {
conn, err := socket.Accept() conn, err := socket.Accept()
if err != nil { if err != nil {
fmt.Println(err) fmt.Println(err)
continue continue
} }
go handleConnection(conn) go handleConnection(conn, format)
} }
} }
@@ -78,7 +120,10 @@ func (s *SLIP) decode(bytes []byte) {
} }
escapeNext = false escapeNext = false
} else if packetByte == END { } else if packetByte == END {
if len(s.pendingBytes) > 0 { if len(s.pendingBytes) == 0 {
// opening END byte, can discard
continue
} else {
message, err := osc.MessageFromBytes(s.pendingBytes) message, err := osc.MessageFromBytes(s.pendingBytes)
if err != nil { if err != nil {
fmt.Println(err) fmt.Println(err)
@@ -94,18 +139,18 @@ func (s *SLIP) decode(bytes []byte) {
} }
func handleMessages(slip SLIP) { func handleSLIP(slip SLIP, format string) {
for message := range slip.Messages { for message := range slip.Messages {
fmt.Printf("%v\n", message) handleMessage(message, format)
} }
} }
func handleConnection(conn net.Conn) { func handleConnection(conn net.Conn, format string) {
slip := SLIP{ slip := SLIP{
pendingBytes: []byte{}, pendingBytes: []byte{},
Messages: make(chan osc.OSCMessage), Messages: make(chan osc.OSCMessage),
} }
go handleMessages(slip) go handleSLIP(slip, format)
defer conn.Close() defer conn.Close()
buffer := make([]byte, 1024) buffer := make([]byte, 1024)
@@ -121,7 +166,16 @@ func handleConnection(conn net.Conn) {
} }
} }
func listenUDP(netAddress string) { func handleMessage(message osc.OSCMessage, format string) {
if format == "json" {
jsonData, _ := json.Marshal(message)
fmt.Println(string(jsonData))
} else {
fmt.Printf("%v\n", message)
}
}
func listenUDP(netAddress string, format string) {
s, err := net.ResolveUDPAddr("udp4", netAddress) s, err := net.ResolveUDPAddr("udp4", netAddress)
if err != nil { if err != nil {
@@ -135,8 +189,6 @@ func listenUDP(netAddress string) {
return return
} }
fmt.Printf("listening on %s (udp)\n", netAddress)
defer connection.Close() defer connection.Close()
buffer := make([]byte, 1024) buffer := make([]byte, 1024)
@@ -152,6 +204,6 @@ func listenUDP(netAddress string) {
if err != nil { if err != nil {
panic(err) panic(err)
} }
fmt.Println(oscMessage) handleMessage(oscMessage, format)
} }
} }
+72 -18
View File
@@ -1,14 +1,17 @@
package main package main
import ( import (
"context"
"encoding/binary"
"encoding/hex" "encoding/hex"
"fmt" "fmt"
"net" "net"
"os"
"strconv" "strconv"
osc "github.com/jwetzell/osc-go" osc "github.com/jwetzell/osc-go"
"github.com/spf13/cobra" "github.com/urfave/cli/v3"
) )
func main() { func main() {
@@ -20,23 +23,68 @@ func main() {
var Types []string var Types []string
var Slip bool var Slip bool
var rootCmd = &cobra.Command{ cmd := &cli.Command{
Use: "sendosc", Name: "sendosc",
Run: func(cmd *cobra.Command, args []string) { Usage: "send OSC messages via UDP or TCP",
Flags: []cli.Flag{
&cli.StringFlag{
Name: "host",
Usage: "host to send OSC message to",
Destination: &Host,
Required: true,
},
&cli.Int32Flag{
Name: "port",
Usage: "port to send OSC message to",
Destination: &Port,
Required: true,
},
&cli.StringFlag{
Name: "protocol",
Usage: "protocol to use to send (tcp or udp)",
Value: "udp",
Destination: &Protocol,
Validator: func(flag string) error {
if flag != "udp" && flag != "tcp" {
return fmt.Errorf("protocol must be either 'udp' or 'tcp'")
}
return nil
},
},
&cli.StringFlag{
Name: "address",
Usage: "OSC address",
Destination: &Address,
Required: true,
},
&cli.StringSliceFlag{
Name: "arg",
Usage: "OSC args",
Value: []string{},
Destination: &Args,
},
&cli.StringSliceFlag{
Name: "type",
Usage: "OSC types",
Value: []string{},
Destination: &Types,
},
&cli.BoolFlag{
Name: "slip",
Value: false,
Usage: "whether to slip encode the OSC Message bytes",
Destination: &Slip,
},
},
Action: func(ctx context.Context, cmd *cli.Command) error {
send(Host, Port, Address, Args, Types, Protocol, Slip) send(Host, Port, Address, Args, Types, Protocol, Slip)
return nil
}, },
} }
rootCmd.Flags().StringVar(&Host, "host", "", "host to send OSC message to")
rootCmd.Flags().Int32Var(&Port, "port", 9999, "port to send OSC message to") if err := cmd.Run(context.Background(), os.Args); err != nil {
rootCmd.Flags().StringVar(&Address, "address", "", "OSC address") panic(err)
rootCmd.Flags().StringVar(&Protocol, "protocol", "udp", "protocol to use to send (tcp or udp)") }
rootCmd.Flags().StringArrayVar(&Args, "arg", []string{}, "OSC args")
rootCmd.Flags().StringArrayVar(&Types, "type", []string{}, "OSC types")
rootCmd.Flags().BoolVar(&Slip, "slip", false, "whether to slip encode the OSC Message bytes")
rootCmd.MarkFlagRequired("host")
rootCmd.MarkFlagRequired("port")
rootCmd.MarkFlagRequired("address")
rootCmd.Execute()
} }
func argToTypedArg(rawArg string, oscType string) osc.OSCArg { func argToTypedArg(rawArg string, oscType string) osc.OSCArg {
@@ -126,13 +174,13 @@ func slipEncode(bytes []byte) []byte {
ESC_END := byte(0xdc) ESC_END := byte(0xdc)
ESC_ESC := byte(0xdd) ESC_ESC := byte(0xdd)
var encodedBytes = []byte{} var encodedBytes = []byte{END}
for _, byteToEncode := range bytes { for _, byteToEncode := range bytes {
if byteToEncode == END { if byteToEncode == END {
encodedBytes = append(encodedBytes, ESC_END) encodedBytes = append(encodedBytes, ESC, ESC_END)
} else if byteToEncode == ESC { } else if byteToEncode == ESC {
encodedBytes = append(encodedBytes, ESC_ESC) encodedBytes = append(encodedBytes, ESC, ESC_ESC)
} else { } else {
encodedBytes = append(encodedBytes, byteToEncode) encodedBytes = append(encodedBytes, byteToEncode)
} }
@@ -164,6 +212,12 @@ func send(host string, port int32, address string, args []string, types []string
if slip { if slip {
oscMessageBuffer = slipEncode(oscMessageBuffer) oscMessageBuffer = slipEncode(oscMessageBuffer)
} else if protocol == "tcp" {
// OSC 1.0 prepends a 4 byte size header for non-SLIP TCP messages
size := uint32(len(oscMessageBuffer))
sizeBytes := make([]byte, 4)
binary.BigEndian.PutUint32(sizeBytes, size)
oscMessageBuffer = append(sizeBytes, oscMessageBuffer...)
} }
netAddress := fmt.Sprintf("%s:%d", host, port) netAddress := fmt.Sprintf("%s:%d", host, port)
+2 -7
View File
@@ -1,10 +1,5 @@
module github.com/jwetzell/osc-go module github.com/jwetzell/osc-go
go 1.23.1 go 1.25.1
require github.com/spf13/cobra v1.8.1 require github.com/urfave/cli/v3 v3.6.2
require (
github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
)
+9 -9
View File
@@ -1,10 +1,10 @@
github.com/cpuguy83/go-md2man/v2 v2.0.4/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/spf13/cobra v1.8.1 h1:e5/vxKd/rZsfSJMUX1agtjeTDf+qv1/JdBF8gg5k9ZM= github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U=
github.com/spf13/cobra v1.8.1/go.mod h1:wHxEcudfqmLYa8iTfL+OuZPbBZkmvliBWKIezN3kD9Y= github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U=
github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= github.com/urfave/cli/v3 v3.6.2 h1:lQuqiPrZ1cIz8hz+HcrG0TNZFxU70dPZ3Yl+pSrH9A8=
github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= github.com/urfave/cli/v3 v3.6.2/go.mod h1:ysVLtOEmg2tOy6PknnYVhDoouyC/6N42TMeoMzskhso=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
+4
View File
@@ -26,6 +26,10 @@ func (m *OSCMessage) ToBytes() []byte {
} }
func MessageFromBytes(bytes []byte) (OSCMessage, error) { func MessageFromBytes(bytes []byte) (OSCMessage, error) {
if len(bytes) == 0 {
return OSCMessage{}, errors.New("cannot create OSC Message from empty byte array")
}
address, typeAndArgBytes := readOSCString(bytes) address, typeAndArgBytes := readOSCString(bytes)
if address[0] != 47 { if address[0] != 47 {
+5 -9
View File
@@ -174,17 +174,13 @@ func argsToBuffer(args []OSCArg) []byte {
func readOSCString(bytes []byte) (string, []byte) { func readOSCString(bytes []byte) (string, []byte) {
//TODO(jwetzell): add error handling //TODO(jwetzell): add error handling
oscString := "" oscString := ""
stringFinished := false
stringEndIndex := 0 stringEndIndex := 0
remainingBytes := []byte{}
for index, byteIn := range bytes { for index, byteIn := range bytes {
if !stringFinished { if byteIn == 0 {
if byteIn == 0 { oscString = string(bytes[0:index])
oscString = string(bytes[0:index]) stringEndIndex = index + 1
stringEndIndex = index + 1 break
break
}
} }
} }
@@ -194,7 +190,7 @@ func readOSCString(bytes []byte) (string, []byte) {
stringEndIndex = stringEndIndex + stringPadding stringEndIndex = stringEndIndex + stringPadding
} }
remainingBytes = bytes[stringEndIndex:] remainingBytes := bytes[stringEndIndex:]
return oscString, remainingBytes return oscString, remainingBytes
} }
+6 -6
View File
@@ -5,18 +5,18 @@ type OSCPacket interface {
} }
type OSCBundle struct { type OSCBundle struct {
Contents []OSCPacket Contents []OSCPacket `json:"contents"`
TimeTag OSCTimeTag TimeTag OSCTimeTag `json:"timeTag"`
} }
type OSCArg struct { type OSCArg struct {
Value any Value any `json:"value"`
Type string Type string `json:"type"`
} }
type OSCMessage struct { type OSCMessage struct {
Address string Address string `json:"address"`
Args []OSCArg Args []OSCArg `json:"args"`
} }
type OSCColor struct { type OSCColor struct {