FSR fun: Bit-banging HTTP POST

So, now that I have the Aurora LXC-200 RPC API figured out, I’m moving closer to my ultimate goal of having an FSR FLEX-LT use an LXC-200 as an expansion serial port. There’s just one problem: The FLEX doesn’t speak HTTP. It has the capability of communicating with IP devices, but just with raw bits – unlike the WACI, no protocol is implemented in it’s firmware. Well…. what’s a protocol, anyway, but a series of bits on the wire.

So, let’s come up with the most bare-bones version of an HTTP POST that we can. This technique is no stranger to anyone who’s ever used telnet to simulate an HTTP connection. We just want to make sure we make ours as stripped down as possible to preserve space in the FLEX’s memory; the FLEX is a small device compared to the WACI and every command we send to one of the LXC ports has to implement this POST inside it’s IP command. This is… unfortunate, but – hey – desperate times and all that.

We’ll start by using the ubiquitous ‘nc’ to test our series of bits. nc has the option to use ‘crlf’ to terminate lines, so that should work for our HTTP POST. We’ll create a file with our commands in it:

POST /rpc/ HTTP/1.1
Content-Type: application/x-www-form-urlencoded
method=Serial_Send&param1=1&param2=nc+test&param3=10

And tell netcat to send this to our LXC device:

$ cat lxptest.nc | nc -v -c a.b.c.d 80

And viola! Our lovely test string “nc test” is sent from the serial port. Watching the traffic with Wireshark, it doesn’t recognize the packets as proper HTTP, but the LXC is forgiving enough to honor the command.

Now, as I mentioned, every FSR command that sends data to an LXC port will need to implement this fake HTTP POST request. The easiest way to do this is to create a custom IP device with a single command “Serial send”. This command can be used via “Send Inline IP…” wherever we need it in our FLEX project; just replace the ‘param2’ bits with the data you want to send – properly URL encoded, of course.

Putting this all into an inline IP command looks like:

IP ‘Aurora_LXC-200_1_Addr’ INLINE “POST /rpc/ HTTP/1.1<0D 0A>Content-Type: application/x-www-form-urlencoded<0D 0A 0D 0A>method=Serial_Send&param1=1&param2=data&param3=10<0D 0A>”

…but running this command via a button press on the FLEX results in nothing but an empty TCP connection. The connection is started with a 3-way handshake and then torn down similarly, with no attempt at an HTTP command. *frowny* What’s going on here? Let’s change the device IP from the LXC to my desktop, run nc -l on port 8888 and press that button again. Same thing – an empty connection with no data sent. Let’s try something simpler. We’ll change the IP command to just

IP ‘Aurora_LXC-200_1_Addr’ INLINE “Hello world<0d>”

…and lo and behold, that works! We get “Hello world” spit out from our listening nc. So…. there’s something it doesn’t like about the HTTP data.

#include <swearword.h>

I guess I’ll have to keep increasing the complexity of the command until I find out what the problem is.

This entry was posted in Audiovisual. Bookmark the permalink.

Comments are closed.