sending a json message on udp

Dalmazzo's icon

Hi All,
I need to read data from an EEG. Right now I'm just testing the protocol to activate the sensors.
The point is that I need to communicate with the EEG client using json messages:

C {"COMMAND":"start"}
S {"MSG":"","STATUS":"OK"}
C {"DATA":[{"ID":"start_clip","Timestamp":1469790507648,"Values":[]}]}

But I can`t send this messages on a normal message, it takes quotes as redundant and brakes json format.

The second question is then how to read the input signals with this format:

S {"DATA":[{"ID":"eeg_theta","Timestamp":1469790507678,"Values":[0.750152587890625,0.83721923828125,0.03131103515625,0.6588134765625,0.91973876953125,0.8878173828125,0.687652587890625,0.8065185546875,0.503570556640625,0.9246826171875,0.604644775390625,0.79486083984375,0.853607177734375,0.32977294921875,0.822540283203125,0.445159912109375,0.180206298828125,0.94915771484375,0.871978759765625,0.458953857421875,0.9984130859375,0.8787841796875,0.041717529296875,0.739837646484375,0.78729248046875,0.611572265625,0.562469482421875,0.9674072265625,0.8934326171875,0.4521484375,0.98773193359375,0.579193115234375]}]}
S {"DATA":[{"ID":"eeg_beta","Timestamp":1469790507678,"Values":[0.20965576171875,0.605224609375,0.55340576171875,0.81732177734375,0.66058349609375,0.844268798828125,0.79693603515625,0.99560546875,0.026031494140625,0.166412353515625,0.217742919921875,0.643707275390625,0.13336181640625,0.33990478515625,0.2596435546875,0.6845703125,0.9505615234375,0.750396728515625,0.39691162109375,0.30126953125,0.61065673828125,0.452423095703125,0.605194091796875,0.6494140625,0.899200439453125,0.83203125,0.998260498046875,0.07171630859375,0.23577880859375,0.787109375,0.9122314453125,0.970672607421875]}]}

Thanks for the help

Dalmazzo's icon

Sorry!
it is not udp of course, it is by url, I need to communicate with a server. So i might use [maxurl] but don't know yet how to send a request with this object.

Dalmazzo's icon

Now I have something like this:
It start downloading data, but I need to stream while downloading, becouse it is the data from the sensor:

Max Patch
Copy patch and select New From Clipboard in Max.

Matthew Mosher's icon

Hey Dalmazzo, did you ever get this working? I am looking to do something similar. Was this for the OpenBCI headset?

Dalmazzo's icon

Hey
Yes it was for something very similar than OpenBCI, a EEG system. Actually this idea of sending JSON like a network protocol was a horrible idea. If you can find a solution using just normal OSC, better. I end up implementing a micro translator program in Openframeworks to receive that data in a network socket, check JSON packages and then send OSC to Max. Bad memories about this project, the only and unique memory I would like to erase from my brain cortex.

Dalmazzo's icon

I think node.js send OSC messages. Why not to try read using node.js and translate the relevant info into a UDP message to Max?

Dalmazzo's icon


max-nodejs-maxurl-json-example.zip
application/zip 12.71 KB

Dalmazzo's icon

or second option is to read it using the Python library, from there is easy to send OSC to Max
https://github.com/OpenBCI/OpenBCI_Python