Skip to content

Commit 16ba350

Browse files
authored
Merge pull request #31 from constructive-io/feat/osc-debug-logging
feat(osc): DEBUG_OSC logging flag + default BEYOND port to 7001
2 parents df7eb41 + 76ea6c9 commit 16ba350

5 files changed

Lines changed: 24 additions & 4 deletions

File tree

packages/osc/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ const receiver = new Receiver({
3030
input: new WebSocketInput({ url: 'ws://192.168.1.50:3000' }),
3131
output: new BeyondOscOutput({
3232
host: '192.168.50.10',
33-
port: 9000,
33+
port: 7001,
3434
projectorMap: { 0: 0, 1: 1, 2: 2 }
3535
})
3636
});
@@ -59,7 +59,7 @@ receiver.start();
5959
```json
6060
{
6161
"targets": {
62-
"beyond-a": { "type": "beyond", "host": "192.168.50.10", "port": 9000 },
62+
"beyond-a": { "type": "beyond", "host": "192.168.50.10", "port": 7001 },
6363
"fb4-b": { "type": "fb4", "host": "192.168.50.20", "port": 8000 }
6464
},
6565
"flushHz": 30,

packages/osc/src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ export type {
1313
} from './osc-adapters';
1414
export {
1515
BeyondOscOutput,
16+
DEBUG_OSC,
1617
FB4OscOutput,
1718
RoutedOscOutput,
1819
createRoutedOutput,

packages/osc/src/osc-adapters.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ import { CannonState, OutputAdapter } from 'wavegrid';
1616

1717
import { hsbToRgb100, hsbToRgb255 } from './color';
1818

19+
/** When true, log every OSC message sent. Set via DEBUG_OSC=1 env var. */
20+
export const DEBUG_OSC = !!process.env.DEBUG_OSC;
21+
1922
// ═══════════════════════════════════════════════════
2023
// Types
2124
// ═══════════════════════════════════════════════════
@@ -103,6 +106,13 @@ export class BeyondOscOutput implements OutputAdapter {
103106
if (!this.client) return;
104107

105108
const messages = encodeBeyondMessages(grid, this.config.projectorMap);
109+
if (DEBUG_OSC && messages.length > 0) {
110+
const sample = messages.slice(0, 4);
111+
const lines = sample.map(m => ` ${m.address} = ${m.value}`);
112+
console.log(` [OSC→BEYOND] frame ${this.frameCount} | ${messages.length} msgs to ${this.config.host}:${this.config.port}`);
113+
for (const line of lines) console.log(line);
114+
if (messages.length > 4) console.log(` ... +${messages.length - 4} more`);
115+
}
106116
for (const msg of messages) {
107117
this.client.send(msg.address, msg.value);
108118
}
@@ -188,6 +198,13 @@ export class FB4OscOutput implements OutputAdapter {
188198
if (!this.client) return;
189199

190200
const messages = encodeFB4Messages(grid, this.config.serialMap);
201+
if (DEBUG_OSC && messages.length > 0) {
202+
const sample = messages.slice(0, 3);
203+
const lines = sample.map(m => ` ${m.address} = ${m.value}`);
204+
console.log(` [OSC→FB4] frame ${this.frameCount} | ${messages.length} msgs to ${this.config.host}:${this.config.port}`);
205+
for (const line of lines) console.log(line);
206+
if (messages.length > 3) console.log(` ... +${messages.length - 3} more`);
207+
}
191208
for (const msg of messages) {
192209
this.client.send(msg.address, msg.value);
193210
}

packages/receiver/README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,8 @@ receiver.start();
7272
| `GRID_COLUMNS` | `7` | Number of columns in the grid |
7373
| `ROUTING_CONFIG` || Path to JSON routing config (enables OSC) |
7474
| `BEYOND_HOST` || Quick single-target BEYOND OSC host |
75-
| `BEYOND_PORT` | `9000` | BEYOND OSC port |
75+
| `BEYOND_PORT` | `7001` | BEYOND OSC port |
76+
| `DEBUG_OSC` || Set to `1` to log all OSC messages |
7677
| `FB4_HOST` || Quick single-target FB4 OSC host |
7778
| `FB4_PORT` | `8000` | FB4 OSC port |
7879

packages/receiver/src/main.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ if (hasOscConfig) {
6161

6262
if (process.env.BEYOND_HOST) {
6363
const host = process.env.BEYOND_HOST;
64-
const port = parseInt(process.env.BEYOND_PORT || '9000', 10);
64+
const port = parseInt(process.env.BEYOND_PORT || '7001', 10);
6565
const projectorMap: Record<number, number> = {};
6666
for (let i = 0; i < NUM_CANNONS; i++) projectorMap[i] = i;
6767
const beyond = new osc.BeyondOscOutput({ host, port, projectorMap });
@@ -116,6 +116,7 @@ console.log(` → Output: ${outputLabels.join(' + ')}`);
116116
console.log(` → Alpha: ${ALPHA} Fallback delay: ${FALLBACK_DELAY}ms`);
117117
console.log(` → Grid: ${NUM_CANNONS} cannons (${GRID_COLUMNS} columns)`);
118118
console.log(` → Shard: ${shard ? `cannons ${shard.start}${shard.end} (${shard.end - shard.start + 1} of ${NUM_CANNONS})` : `all cannons (no shard)`}`);
119+
if (process.env.DEBUG_OSC) console.log(' → DEBUG_OSC: enabled (logging all OSC messages)');
119120
console.log('');
120121

121122
receiver.start();

0 commit comments

Comments
 (0)