Send/ recieve TCP ASCII commands

Hi

I know Open Stage Control is focused on OSC but...

It would be great to be able to send/ recieve simple ascii code from to open stage control. Is this maybe possible with a python script?

Thx and greetings

Christian

This won't be implemented in open stage control. It is possible to implement one your self with a custom module written in javascript. Here is a an incomplete example to get started.

var net = require('net'),
    port = 12345,
    tcpServer = net.createServer()


tcpServer.listen(port, function() {
    console.log(`TCP server listening for connection requests on socket localhost:${port}`.);
})

tcpServer.on('connection', function(socket){
    // follow some "node tcp server" "tutorials to complete this part
})


module.exports = {
    // read custom module documentation & examples to complete this part
}

Thx a lot!!

Hello guys

Is there a finished script that you can share? I started adding some code but not confident at all. I want to press a button in o-s-c and pass a string to send. This is what I have so for:

see next post

Thanks in advance from a complete newbie!

I have figured it out, this is the custom module:

const net = nativeRequire('net');
const port = 50000;
const host = '127.0.0.1';//'192.168.0.222';
const socket = new net.Socket;

socket.connect(port,host,function(){
  console.log('>>> TCP SOCKET CONNECTED');
})

module.exports = {
  oscInFilter:function(data){
    var {address, args, host, port} = data
    if (address === '/rawtcp') {
      socket.write(data.args[0].value);
      console.log('>>> RAW TCP:  ' + data.args[0].value);
    }
    return {address, args, host, port}
  },
}

And you can call it from a button:

  {
    "type": "button",
    "mode": "momentary",
    "address": "/rawtcp",
    "preArgs": "JS{{ return ("hello\x0a\x0d") }}",
    "typeTags": "s",
    "target": "127.0.0.1:12000",
  }

So now I can send out TCP commands to control the non-OSC devices that I have. Thanks all :slight_smile:

@JonnyTech, I'm getting the following error in the Console. Any ideas?

(ERROR) A JavaScript error occurred in the main process:
Error: connect ECONNREFUSED 192.168.68.89:50000
    at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1142:16)

My firewall is off. I'm not sure why the connection would be refused.

Also, how would one send modifier keys in MacOS? (Command, Option, Control, Shift, etc.)

Thanks! :slightly_smiling_face:

Error: connect ECONNREFUSED 192.168.68.89:50000

Can you telnet to the device? I Terminal try: telnet 192.168.68.89

Also, how would one send modifier keys in MacOS? (Command, Option, Control, Shift, etc.)

That is not how it works, you need to know the hex code for what you are sending. Do you have a protocol manual for the device?

The OSC server and client are running on the same MacMini (Ventura 13.5.1). Terminal responds:

eric@macmini ~ % telnet 192.168.68.89
zsh: command not found: telnet

What is supposed to be running on ports 50000 and 12000?

I'm trying to send keyboard commands from OSC to Logic Pro. (⌘+H for example) Perhaps I misunderstood the purpose of your custom module? :upside_down_face:

The OSC server and client are running on the same MacMini (Ventura 13.5.1).

You can then use the localhost IP address of 127.0.0.1

zsh: command not found: telnet

Seems that MacOS does not have telnet installed. Use netcat instead:

nc 127.0.0.1 50000

Where 127.0.0.1 is the IP of the device to control and 50000 is the port number.

What is supposed to be running on ports 50000 and 12000?

12000 is the OSC port of O-S-C, 50000 is the TCP port of the device to control.

But I thought that Logic Pro accepted OSC commands. Do you have any documentation stating that Logic Pro can be controlled by TCP?

I'm trying to send keyboard commands from OSC to Logic Pro. (⌘+H for example) Perhaps I misunderstood the purpose of your custom module? :upside_down_face:

Indeed you have misunderstood. The device/software must support TCP commands. They are usually documented in the (protocol) manual.

As an example, in Terminal enter: nc -l 50000 then run my script and you should see a response.

Logic Pro accepts OSC commands. I thought I could string together multiple keyboard shortcut commands and trigger them thru OSC. My bad. MIDI Translator Pro is probably what I'm looking for. Thank you for the further explanations. :slightly_smiling_face:

...or you can do it via applescript in a custom module, it has been done before