c#: Receiving OSC/TUIO Data works not after build

Hi Community,
I am trying to receive raw TUIO data, underlying structure is as known OSC. It works when I am testing it in the unity development environment but fails when i am trying to run my builded exe file.

I am scipting with c# and I am using the c# reference implementation which can be found here:
http://sourceforge.net/projects/reactivision/files/TUIO%201.1/TUIO-Clients%201.1.5/TUIO11_NET-1.1.5.zip/download?use_mirror=netix&download=
From here:
http://tuio.org/?software

What I did was to copy the folder TUIO and OSC.NET to my Assets folder. From there I can use them in my scripts.

Hmm so its working fine when running the project within the unity development environment… After build and starting the exe no reaction when sending TUIO data. Looking into the output_log.txt file that was created by the .exe, I see an excepion that comes up with the first TUIO message sent, saying this:

An exception was thrown by the type initializer for OSC.NET.OSCPacket
null packet
This seems to come up with every TUIO data that was sent.

The class OSCPacket is abstact:
abstract public class OSCPacket

Could this cause the problem?
Not sure as its running fine when not starting the exe, so i was thinking it might be some missing ressources or sth?

Maybe someone else has a smart idea?

Thanks & Cheers,
Tobi

Hi There,
so I did change to another, more simple, Tuio C# implementation:
https://github.com/valyard/TUIOsharp

It needed a bit more programming on my side but now its working fine also after building the exe file.

Still I don’t know why it did not work with the other implementation.

Cheers,
Tobi

@TobiTobsenL Do you have any explanation/tutorial how to use your library.
Very interested in testing out TUIO using unity!

1 Like

Hi Surg,
so like I wrote, the standard TUIO C# implentation did crash after buidling the exe file and trying to run this.

So I was using this more simple implementation:
https://github.com/valyard/TUIOsharp

I added the folders OSCsharp and TUIOsharp to my Assets.
TUIO uses the OSC implementation, so you need both although you will only talk to TUIOsharp.
I wrote a class called TuioHandling() that does the TUIO handling and attached this one to the MainCamera.

In this skrip you have to create a TuioServer:
TuioServer tuioserver;

Now this is not the nicest programming design but was ok for my purpose: The TuioServer needs to know who to call when there are new TUIO data - this is why I added a TuioHandling() object to the TuioServer() class. This TuioHandling() object is called when there are new data available, this happens in TuioServer():

private void handlerOscMessageReceived(object sender, OscMessageReceivedEventArgs oscMessageReceivedEventArgs)
{
parseOscMessage(oscMessageReceivedEventArgs.Message);
this.tuioMain.callMeOnNewCursors(this.updatedCursors, this.addedCursors, this.removedCursors);
}

the method callMeOnNewCursors() is in my TuioHandling class and this is where I process the Tuio data.

Now you have to create the TuioServer, I did init this in the Start() method in TuioHandling:
tuioServer = new TuioServer(this);
tuioServer.Connect();

You can see with (this) the TuioServer() gets the link to the TuioHandling().

OnApplicationQuit() you should disconnect:
tuioServer.Disconnect();

If I find time I will prepare a clean version of my implementation and upload it, this will make things easier.
But in the end you will only receive raw TUIO data, thats pretty low level data that need to be processed somehow.

Best regards
Tobi

For my case, the Encoding.GetEncoding(1252) function at static OSCPacket() in class OSC.NET.OSCPacket caused the problem above.
Log all exception would show that the builded exe file could not find the specified code page 1252.
Just change to ASCIIEncoding8Bit = Encoding.Default would fixed the problem.

3 Likes

Saved my day, thank you!

I had similar issues, but I ended up using this library : TouchScript | Input Management | Unity Asset Store