Could use some help with networking, OSC and teensy!

Skester96

Member
Hello,

I have a Teensy 3.2, a wiz820io, and a FSR sensor (as a dial / just to try out data sending).
I want to send this value through UDP, OSC protocol (trying to receive it in Max Msp). This should be working according to other codes I've seen, but I'm not sure if my problems lies on the Networking settings (I'm a beginner with this) or in my code.

I noticed the void loop() just prints out the FSR value just once, so I'm guessing that the program just never finishes the sendOSCMessage() function. Any ideas?

Code:

#include <OSCMessage.h>
#include <Ethernet.h>
#include <EthernetUdp.h>
#include <SPI.h>
#include <OSCMessage.h>
#include <OSCBundle.h>
#include <OSCBoards.h>

#pragma GCC diagnostic ignored "-Wwrite-strings"
/*******************SETUP OSC********************/
EthernetUDP Udp;
//255.255.255.255 is the IP to broadcast to all devices in the network
IPAddress ip(10, 0, 1, 2);
IPAddress outIp(10, 0, 1, 1); //destination IP
IPAddress gateway(10,0,1,1);
IPAddress subnet(255,255,255,0);

const unsigned int outPort = 6789;
const unsigned int inPort = 8979;
byte mac[] = { 0x04, 0xE9, 0xE5, 0x04, 0xE5, 0xBA }; // you can find this written on the board of some Arduino Ethernets or shields

//04:E9:E5:04:E5:BA -> My Teensy Mac
//mac = media access control

//Get values from FSR
int PressurePin = A0;
int force;


void setup() {
Serial.begin(115200);
Ethernet.begin(mac,ip);
pinMode(PressurePin, INPUT);
Udp.begin(inPort);
}


void loop(){
//the message wants an OSC address as first argument

force = analogRead(PressurePin);
Serial.println("print");
Serial.println(force);

sendOSCMessage("/OSCADDRES", force, outIp, outPort);
//OSCMsgReceive();
}

void sendOSCMessage(char *addr_pattern, int force, IPAddress ip_, int port_){

OSCMessage msg_recv(addr_pattern);
msg_recv.add((int32_t)force);
msg_recv.add((int32_t)analogRead(A0));

Udp.beginPacket(ip_, port_);
msg_recv.send(Udp); // send the bytes to the SLIP stream
Udp.endPacket(); // mark the end of the OSC Packet
msg_recv.empty(); // free space occupied by message

}
 
Max msp receive.pngTeensyforum.jpgTeensyforum.pngwiringethernet.jpg
 
Back
Top