Read OSC data with ConnectionReader

Return to Scripting Issues

Read OSC data with ConnectionReader

Postby zakharm » Mon Feb 27, 2012 2:43 pm

I'm having trouble with OSC on OSX, trying to figure it out on this post, but in the meantime I'm looking at other options.

Is it possible to receive OSC data via the ConnectionReader?

I have a C++ program that is not tied into Panda and it sends via OSC. Is there a different way that I can configure the data sending in C++ to be accepted by ConnectionReader?

My data is just an array of floats.


I get this error when I try to read / print raw OSC data from the iterator
Code: Select all
AssertionError: _current_index + s_len <= _datagram->get_length() at line 30 of panda/src/express/datagramIterator.cxx



Code: Select all
from panda3d.core import QueuedConnectionManager, QueuedConnectionListener, QueuedConnectionReader, ConnectionWriter, PointerToConnection, NetAddress, NetDatagram
from direct.distributed.PyDatagram import PyDatagram
from direct.distributed.PyDatagramIterator import PyDatagramIterator

from direct.directbase.DirectStart import *

class SN:
    def __init__(self):
        self.cManager = QueuedConnectionManager()
        self.cReader = QueuedConnectionReader(self.cManager, 0)
        self.cReader.setRawMode(True)
        #self.cWriter = ConnectionWriter(self.cManager,0)
        self.port_address=7000
        self.udpSocket = self.cManager.openUDPConnection(self.port_address)
        self.cReader.addConnection(self.udpSocket)       
        taskMgr.add(self.tskReaderPolling,"Poll the connection reader",-40)
   
    def tskReaderPolling(self, taskdata):
        if self.cReader.dataAvailable():
            datagram=NetDatagram()  # catch the incoming data in this instance
            # Check the return value; if we were threaded, someone else could have
            # snagged this data before we did           
            if self.cReader.getData(datagram):
                self.myProcessDataFunction(datagram)                   
        return taskdata.cont

    def myProcessDataFunction(self, netDatagram):
        myIterator = PyDatagramIterator(netDatagram)
        msgID = myIterator.getUint8()
        #if msgID == PRINT_MESSAGE:
        messageToPrint = myIterator.getString()  ### this causes the above error
        print messageToPrint   

 
sn = SN()
run()
zakharm
 
Posts: 64
Joined: Thu Jul 29, 2010 10:07 am

Postby zakharm » Fri Mar 02, 2012 9:22 am

Any thoughts on alternatives to OSC for communication from a C++ app to Panda?
zakharm
 
Posts: 64
Joined: Thu Jul 29, 2010 10:07 am

Postby zakharm » Tue Mar 06, 2012 8:22 am

This will return the raw string from netDatagram:
Code: Select all
rawString = netDatagram.getMessage()

You can then decode the binary OSC message from rawString.
zakharm
 
Posts: 64
Joined: Thu Jul 29, 2010 10:07 am


Return to Scripting Issues

Who is online

Users browsing this forum: No registered users and 0 guests