OSC streaming not working as expected

Post Reply
jeffpeck
Posts: 3
Joined: Mon Feb 15, 2021 10:30 pm

OSC streaming not working as expected

Post by jeffpeck »

I have OSC Stream Target IP set to "192.168.0.157", which is the IP address of my Mac Mini on the local network.

I am doing this:

Code: Select all

from pythonosc import dispatcher
from pythonosc import osc_server


def eeg_handler(unused_addr, args, ch1, ch2, ch3, ch4):
    print("EEG per channel: ", ch1, ch2, ch3, ch4)


if __name__ == "__main__":
    dispatcher = dispatcher.Dispatcher()
    dispatcher.map("/debug", print)
    dispatcher.map("/Muse/eeg", eeg_handler, "EEG")

    server = osc_server.ThreadingOSCUDPServer(("192.168.0.157", 5000), dispatcher)
    server.serve_forever()
But, nothing is happening when I run this script.

I would expect it to print something.

What am I missing here? And is there a guide for getting started with this?

Thanks!
Attachments
IMG_5FD6E7A62D8A-1.jpeg
IMG_5FD6E7A62D8A-1.jpeg (143.32 KiB) Viewed 1187 times
jeffpeck
Posts: 3
Joined: Mon Feb 15, 2021 10:30 pm

Re: OSC streaming not working as expected

Post by jeffpeck »

Hrm, it seems to be working now. Here is the slightly updated code in case anyone finds this.

from pythonosc import dispatcher, osc_server

Code: Select all

def eeg_handler(unused_addr, args, ch1, ch2, ch3, ch4, ch5):
    print("EEG per channel: ", ch1, ch2, ch3, ch4, ch5)


if __name__ == "__main__":
    dispatcher = dispatcher.Dispatcher()
    dispatcher.map("/debug", print)
    dispatcher.map("/muse/eeg", eeg_handler, "eeg")

    server = osc_server.ThreadingOSCUDPServer(("192.168.0.157", 5000), dispatcher)
    server.serve_forever()
jeffpeck
Posts: 3
Joined: Mon Feb 15, 2021 10:30 pm

Re: OSC streaming not working as expected

Post by jeffpeck »

Oh, gotit. It originally was listening for endpoint "/Muse/eeg", whereas it should be "/muse/eeg".

I actually copy/pasted that from somewhere, I think on this forum, so watch out for that.

Is there a guide anywhere that explains what the different endpoints are and what their outputs are?
muriloborges
Posts: 6
Joined: Tue Apr 28, 2020 11:39 pm

Re: OSC streaming not working as expected

Post by muriloborges »

Hello!
Let me see if I can help you
In my code I use this in python:

Code: Select all

from pythonosc import dispatcher
from pythonosc import osc_server

def __init__(self, api_collector_controller, api_eegdata, api_collector_screen, namecollect, datetimetrain):
        Thread.__init__(self)
        self.ip = "192.168.0.113"
        self.port = 8000
        self.dispatcher = dispatcher.Dispatcher()
        self.dispatcher.map("/debug", print)
        self.dispatcher.map("/muse/eeg", self.eeg_handler, "EEG")
 def run(self):
        print(" Run do ReadEEG ")
        self.server = osc_server.ThreadingOSCUDPServer((self.ip, self.port), self.dispatcher)
        print("Serving on {}".format(self.server.server_address))
        self.server.serve_forever()

def eeg_handler(self, unused_addr, args, ch1, ch2, ch3, ch4, aux):
        print(ch1)
        print(ch2)
        print(ch3)
        print(ch4)
       print(aux) # if it is Muse 2
       
 
for other parameters, see at this link https://mind-monitor.com/FAQ.php#oscspec
Post Reply