LINQ to Robots by way of REST

So I wanted a general way to control my .Net Micro Framework (NETMF) device (e.g. FEZ board) from a web service. So that I could define one interface and use any type of client to call the interface (such as Console, WinForms, Silverlight, etc).  It turns out WCF Data Services (i.e. Astoria) worked nicely.  Once you have the REST part working, you can then use LINQ and clients such as LinqPad 4.x to not only query your devices data, but also drive your motors and sensors.  Basic setup:

1) Fez has serial listener loop running.  I used the CDC virtual Comm port and USB connection.  You could also use XBEE or other.

2) PC has WinForms app with a client proxy that talks sends simple string commands using a command pattern.  It also waits for reply.

3) WinForms app also Hosts the REST DataService and exposes the REST endpoint.

4) The DataService exposes some Service Methods such as Drive(360, 360).  This means you can not only Query your objects using LINQ, but can also Invoke commands to do things on your NETMF device such as move motors.  In this case, I am driving two Stepper motors and some LEDs.

So the client calls the DataService via REST.  The DataService methods call the Fez Client Proxy with sends serial commands to the Fez.  The returned data and send back as normal REST reply.

This was just a proof of concept, but soon will get everything put together in a moving robot controlled via LINQ and REST service.

Advertisements
This entry was posted in Uncategorized. Bookmark the permalink.