Compare commits

...

19 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
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
11 changed files with 74 additions and 48 deletions
+2 -2
View File
@@ -1,4 +1,4 @@
name: "release go binaries for multiple os/arch"
name: "release go binaries for makeosc"
on:
push:
@@ -36,7 +36,7 @@ jobs:
- goarch: "386"
goos: darwin
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v6
- uses: wangyoucao577/go-release-action@v1
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
+2 -2
View File
@@ -1,4 +1,4 @@
name: "release go binaries for multiple os/arch"
name: "release go binaries for receiveosc"
on:
push:
@@ -36,7 +36,7 @@ jobs:
- goarch: "386"
goos: darwin
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v6
- uses: wangyoucao577/go-release-action@v1
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
+2 -2
View File
@@ -1,4 +1,4 @@
name: "release go binaries for multiple os/arch"
name: "release go binaries for sendosc"
on:
push:
@@ -36,7 +36,7 @@ jobs:
- goarch: "386"
goos: darwin
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v6
- uses: wangyoucao577/go-release-action@v1
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
+2 -2
View File
@@ -147,9 +147,9 @@ func slipEncode(bytes []byte) []byte {
for _, byteToEncode := range bytes {
if byteToEncode == END {
encodedBytes = append(encodedBytes, ESC_END)
encodedBytes = append(encodedBytes, ESC, ESC_END)
} else if byteToEncode == ESC {
encodedBytes = append(encodedBytes, ESC_ESC)
encodedBytes = append(encodedBytes, ESC, ESC_ESC)
} else {
encodedBytes = append(encodedBytes, byteToEncode)
}
+35 -16
View File
@@ -2,6 +2,7 @@ package main
import (
"context"
"encoding/json"
"fmt"
"net"
"os"
@@ -14,10 +15,11 @@ func main() {
var Host string
var Port int32
var Protocol string
var Format string
cmd := &cli.Command{
Name: "makeosc",
Usage: "make osc bytes",
Name: "receiveosc",
Usage: "receive OSC messages via UDP or TCP",
Flags: []cli.Flag{
&cli.StringFlag{
Name: "host",
@@ -43,13 +45,25 @@ func main() {
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" {
listenUDP(netAddress)
listenUDP(netAddress, Format)
} else if Protocol == "tcp" {
listenTCP(netAddress)
listenTCP(netAddress, Format)
}
return nil
},
@@ -60,7 +74,7 @@ func main() {
}
}
func listenTCP(netAddress string) {
func listenTCP(netAddress string, format string) {
socket, err := net.Listen("tcp4", netAddress)
if err != nil {
fmt.Println(err)
@@ -69,15 +83,13 @@ func listenTCP(netAddress string) {
defer socket.Close()
fmt.Printf("listening on %s (tcp w/ SLIP)\n", netAddress)
for {
conn, err := socket.Accept()
if err != nil {
fmt.Println(err)
continue
}
go handleConnection(conn)
go handleConnection(conn, format)
}
}
@@ -127,18 +139,18 @@ func (s *SLIP) decode(bytes []byte) {
}
func handleMessages(slip SLIP) {
func handleSLIP(slip SLIP, format string) {
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{
pendingBytes: []byte{},
Messages: make(chan osc.OSCMessage),
}
go handleMessages(slip)
go handleSLIP(slip, format)
defer conn.Close()
buffer := make([]byte, 1024)
@@ -154,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)
if err != nil {
@@ -168,8 +189,6 @@ func listenUDP(netAddress string) {
return
}
fmt.Printf("listening on %s (udp)\n", netAddress)
defer connection.Close()
buffer := make([]byte, 1024)
@@ -185,6 +204,6 @@ func listenUDP(netAddress string) {
if err != nil {
panic(err)
}
fmt.Println(oscMessage)
handleMessage(oscMessage, format)
}
}
+11 -4
View File
@@ -2,6 +2,7 @@ package main
import (
"context"
"encoding/binary"
"encoding/hex"
"fmt"
"net"
@@ -23,8 +24,8 @@ func main() {
var Slip bool
cmd := &cli.Command{
Name: "makeosc",
Usage: "make osc bytes",
Name: "sendosc",
Usage: "send OSC messages via UDP or TCP",
Flags: []cli.Flag{
&cli.StringFlag{
Name: "host",
@@ -177,9 +178,9 @@ func slipEncode(bytes []byte) []byte {
for _, byteToEncode := range bytes {
if byteToEncode == END {
encodedBytes = append(encodedBytes, ESC_END)
encodedBytes = append(encodedBytes, ESC, ESC_END)
} else if byteToEncode == ESC {
encodedBytes = append(encodedBytes, ESC_ESC)
encodedBytes = append(encodedBytes, ESC, ESC_ESC)
} else {
encodedBytes = append(encodedBytes, byteToEncode)
}
@@ -211,6 +212,12 @@ func send(host string, port int32, address string, args []string, types []string
if slip {
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)
+1 -1
View File
@@ -2,4 +2,4 @@ module github.com/jwetzell/osc-go
go 1.25.1
require github.com/urfave/cli/v3 v3.4.1
require github.com/urfave/cli/v3 v3.6.2
+4 -4
View File
@@ -2,9 +2,9 @@ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA=
github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
github.com/urfave/cli/v3 v3.4.1 h1:1M9UOCy5bLmGnuu1yn3t3CB4rG79Rtoxuv1sPhnm6qM=
github.com/urfave/cli/v3 v3.4.1/go.mod h1:FJSKtM/9AiiTOJL4fJ6TbMUkxBXn7GO9guZqoZtpYpo=
github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U=
github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U=
github.com/urfave/cli/v3 v3.6.2 h1:lQuqiPrZ1cIz8hz+HcrG0TNZFxU70dPZ3Yl+pSrH9A8=
github.com/urfave/cli/v3 v3.6.2/go.mod h1:ysVLtOEmg2tOy6PknnYVhDoouyC/6N42TMeoMzskhso=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
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) {
if len(bytes) == 0 {
return OSCMessage{}, errors.New("cannot create OSC Message from empty byte array")
}
address, typeAndArgBytes := readOSCString(bytes)
if address[0] != 47 {
+5 -9
View File
@@ -174,17 +174,13 @@ func argsToBuffer(args []OSCArg) []byte {
func readOSCString(bytes []byte) (string, []byte) {
//TODO(jwetzell): add error handling
oscString := ""
stringFinished := false
stringEndIndex := 0
remainingBytes := []byte{}
for index, byteIn := range bytes {
if !stringFinished {
if byteIn == 0 {
oscString = string(bytes[0:index])
stringEndIndex = index + 1
break
}
if byteIn == 0 {
oscString = string(bytes[0:index])
stringEndIndex = index + 1
break
}
}
@@ -194,7 +190,7 @@ func readOSCString(bytes []byte) (string, []byte) {
stringEndIndex = stringEndIndex + stringPadding
}
remainingBytes = bytes[stringEndIndex:]
remainingBytes := bytes[stringEndIndex:]
return oscString, remainingBytes
}
+6 -6
View File
@@ -5,18 +5,18 @@ type OSCPacket interface {
}
type OSCBundle struct {
Contents []OSCPacket
TimeTag OSCTimeTag
Contents []OSCPacket `json:"contents"`
TimeTag OSCTimeTag `json:"timeTag"`
}
type OSCArg struct {
Value any
Type string
Value any `json:"value"`
Type string `json:"type"`
}
type OSCMessage struct {
Address string
Args []OSCArg
Address string `json:"address"`
Args []OSCArg `json:"args"`
}
type OSCColor struct {