Compare commits

...

7 Commits

Author SHA1 Message Date
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
6 changed files with 49 additions and 30 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@v5
- 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@v5
- 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@v5
- uses: wangyoucao577/go-release-action@v1
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
+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)
}
}
+2 -2
View File
@@ -23,8 +23,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",
+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 {