Request ServerDescription via UDP
Posted: Sun Jan 11, 2015 5:26 pm
For various reasons I have not been using the NatNet SDK .dll to interface with Motive, but I have been able to successfully read and unpack the data stream from Motive.
I'd like to dynamically retrieve the NatNet version used by Motive. I see that there is an interface in NAT_PING to request the server description which would be returned by a NAT_PINGRESPONSE.
I've been trying to create a NAT_PING request in C#, but it doesn't seem to be generating any sort of response. I'm making the request on the same UDP Data Port as I'm receiving the frame packets.
This is my C# code to generate the packet. I believe that I'm successfully sending the request to the multicast group because I can see the request echoed back by my own listener.
Does this request packet look correct? Is this general approach correct? workable?
Thanks in advance!
I'd like to dynamically retrieve the NatNet version used by Motive. I see that there is an interface in NAT_PING to request the server description which would be returned by a NAT_PINGRESPONSE.
I've been trying to create a NAT_PING request in C#, but it doesn't seem to be generating any sort of response. I'm making the request on the same UDP Data Port as I'm receiving the frame packets.
This is my C# code to generate the packet. I believe that I'm successfully sending the request to the multicast group because I can see the request echoed back by my own listener.
Does this request packet look correct? Is this general approach correct? workable?
Thanks in advance!
Code: Select all
short shortValue = 225;
byte[] tempBytes = BitConverter.GetBytes(shortValue);
//if (BitConverter.IsLittleEndian)
// Array.Reverse(tempBytes);
byte[] intBytes = tempBytes;
byte [] clientAppNameBytes = new byte [256];
string clientName = "MyAppName";
System.Buffer.BlockCopy( Encoding.ASCII.GetBytes (clientName), 0, clientAppNameBytes, 0, Encoding.ASCII.GetBytes (clientName).Length );
byte [] clientVersionBytes = Encoding.ASCII.GetBytes(new char[]{'0', '0', '0', '0'}); // it's an array of 4 chars, a char is 2 bytes
byte [] clientNatNetVersionBytes = Encoding.ASCII.GetBytes(new char[]{'0', '0', '0', '0'});
byte[] messageToSend = new byte[ intBytes.Length + clientAppNameBytes.Length + clientVersionBytes.Length + clientNatNetVersionBytes.Length ];
System.Buffer.BlockCopy( intBytes, 0, messageToSend, 0, intBytes.Length );
System.Buffer.BlockCopy( clientAppNameBytes, 0, messageToSend, intBytes.Length, clientAppNameBytes.Length );
System.Buffer.BlockCopy( clientVersionBytes, 0, messageToSend, intBytes.Length + clientAppNameBytes.Length, clientVersionBytes.Length );
System.Buffer.BlockCopy( clientNatNetVersionBytes, 0, messageToSend, intBytes.Length + clientAppNameBytes.Length + clientVersionBytes.Length, clientNatNetVersionBytes.Length );
listener.Send (messageToSend, messageToSend.Length, groupEP);