Windows Phone 7

wp7 record your own accelerometer data for testing

In the recent Mango developer tools for Windows Phone the device emulator has been updated to include an accelerometer simulation screen.

 

acc1

 

This enables passing data in real time to your application via the Accelerometer. Also, you can play back some recorded data, of which there is some sample ‘Shake’ data. So pressing Play will play back the recorded data.

The shake data is stored as xml from this location ‘<PROGRAM FILES>Microsoft XDE1.0sensordataacc’ in a file called ‘Shake’.  The format is very simple as can be seen from the screenshot below;

 

acc2

 

Now, the next bit happened by accident as I was trying to think of something simple to implement with sockets just so I could become familiar with the socket support on Mango. Anyway, I started by writing the obligatory client / server socket code. The server being a console app which listens for client connections on a tcp port.

Once connected, the client sends  accelerometer reading data over the connection to the server which saves it to xml in the required format.

 

acc3

 

So to record a file, start the server console app, then run the mango app on the emulator. Start the accelerometer tools…

acc4

 

…manipulate the input data using the pink blob on the tools in the required motion. The data will be sent via the Accelerometer interface in the phone app, across the socket connection to the console app which will save it to an xml file when the recording ends.

The resulting file will subsequently end up in the drop-down on the Accelerometer Tools ui;

 

acc5

 

Probably not the best way to record the data but it allowed me to play around with the socket api’s

Smile

Source code is here http://cid-4f1b7368284539e5.office.live.com/self.aspx/.Public/AccelerometerRecorder/AccelerometerRecorderServer.zip

Technorati Tags: ,,,,,,,,,,,,,,,
Windows Live Tags: wp7dev,Mango,tools,simulation,Shake,location,Microsoft,socket,client,server,code,port,connection,AccelerometerRecorder,sockets,emulator
WordPress Tags: wp7dev,Mango,tools,simulation,Shake,location,Microsoft,socket,client,server,code,port,connection,AccelerometerRecorder,sockets,emulator

1 thought on “wp7 record your own accelerometer data for testing

Leave a Reply

Your email address will not be published. Required fields are marked *