Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 4 of 4

Thread: Could use some help with networking, OSC and teensy!

  1. #1
    Junior Member
    Join Date
    Feb 2020
    Posts
    17

    Could use some help with networking, OSC and teensy!

    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

    }

  2. #2
    Junior Member
    Join Date
    Feb 2020
    Posts
    17
    Click image for larger version. 

Name:	Max msp receive.png 
Views:	11 
Size:	10.8 KB 
ID:	19057Click image for larger version. 

Name:	Teensyforum.jpg 
Views:	9 
Size:	121.5 KB 
ID:	19058Click image for larger version. 

Name:	Teensyforum.png 
Views:	9 
Size:	16.4 KB 
ID:	19056Click image for larger version. 

Name:	wiringethernet.jpg 
Views:	11 
Size:	86.9 KB 
ID:	19055

  3. #3
    Senior Member+ manitou's Avatar
    Join Date
    Jan 2013
    Posts
    2,534
    you might add some lines to setup() to reset the wiz820io, see end of https://www.pjrc.com/store/wiz820_sd_adaptor.html

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •