Recieving UDP from iphone
4 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Hi
I have an iphone application called Accel Pro which can stream data via UPD (see here http://www.wavefrontlabs.com/Wavefront_Labs/Accelerometer_Data.html)
the app gives me an address and port and continuously streams acceleration data from the iphones accelerometers. My question is how do i read this on Matlab???? I have been trying for hours.
Im haven't used matlab for this kind of thing ever before!!
2 comentarios
Amir
el 30 de Jul. de 2012
Hi,
Were you able to resolve your question? I'm stuck with the exact same problem. I can read those packets just fine using python, but no luck with the instrument control toolbox.
Kiat Nern Yeo
el 18 de Jun. de 2019
Hello, does this work for the android tcp/ip block ?
I am not sure whether set it to the "server" or "client" mode.
I want to make the android phone the receipient of a wifi signal.
Another device will be the one emiting the wifi signal.
Cheers !
Respuestas (4)
Ankit Desai
el 29 de Jul. de 2011
u = udp('localhost',<port>,'localport',<port>);
u.InputBufferSize = 1000;
u.DatagramReceivedFcn = @localReadDatagram;
fopen(u);
The code above creates a UDP object and listens to port port. Depending on the packet size of the datagram you are receiving update the InputBufferSize property of the object. You want to make sure that input buffer size is greater than the packet length. The iPhone app that I used was sending packets of size lower than 1000, so the code above worked fine for me.
The DatagramReceivedFcn is the property you can set to point to a function that will be called everytime a datagram arrives. It is in this function that you can parse the incoming data and get the raw accelerometer values. Parsing will depend on the format in which you get the data from the iPhone.
The app that I used sent the data in string format and I ended up using the textscan. Here's the code I used to parse the incoming packet, inside the localReadDatagram function:
function localReadDatagram(obj,event)
rawString = fscanf(obj);
values = textscan(rawString,'%*s %*s %f %f %f','Delimiter',',');
x = values{1};
y = values{2};
z = values{3};
Hope this helps
-Ankit
2 comentarios
Amir
el 30 de Jul. de 2012
The above solution does not seems to work for me (I have matlab and the instrumentation control toolbox). I'm trying to stream data from an application called 'sensor data' (by the same publisher, wavefrontlabs). Using the code above, the datagramRecieverFcn is never called, as no bytes are recived on the port.
Ankit Desai
el 21 de Ag. de 2012
That appears to be a configuration issue.
You might want to check the network settings and buffer size of the UDP object. Make sure you have your buffer size big enough to accommodate at least one datagram packet.
Walter Roberson
el 24 de Jun. de 2011
You either need the Instrument Control Toolbox, or the MATLAB File Exchange contribution named "tcpudpip"
And you have to hope that your ISP isn't blocking incoming data on that port. And if you have a home or lab firewall, you have to hope that isn't blocking the data. And if you are running Windows, you probably have to work in the Security control panel to open the port.
0 comentarios
Farhaan SHaikh
el 24 de Jun. de 2011
1 comentario
Walter Roberson
el 24 de Jun. de 2011
which udp
and see where it says the routine is. Basic MATLAB doesn't have a "udp" routine, so if the one you find is not one you wrote yourself, it is probably an appropriate one.
I suggest you read the Solution at http://www.mathworks.com/support/solutions/en/data/1-OUCYT/?solution=1-OUCYT
Ver también
Categorías
Más información sobre MATLAB Mobile en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!