TCP to Serial forwarder

Community contributed apps

Posts: 13
Joined: Mon Mar 10, 2014 2:10 pm
PostPosted: Sat Mar 15, 2014 2:30 pm
So forgive me if this is something that's already available or not needed - I'm just excited I got it working so easily :)

I hacked together a very quick and dirty app that will accept traffic on TCP port 2000 and forward it to the COM3 port. The long and the short of it is I'm able to use the Android app to control my Reef Angel (including setting relay states) without the Wifi module (I just have the RA connected via the USB->TTL cord to my pc running the app I wrote).

Is there a need for something like this in the community? If so I'd be happy to clean this up a bit for use by others. Just a caveat, it's developed in .NET so this would be a windows only solution.

Posts: 12288
Joined: Fri Mar 18, 2011 6:47 pm
PostPosted: Sat Mar 15, 2014 3:40 pm
That would be really cool!!!
I would also like to request 2 things.
1. Host the source code on both github.
2. Permission to post your work in the contribution section of the website.
Roberto.

Posts: 13
Joined: Mon Mar 10, 2014 2:10 pm
PostPosted: Sat Mar 15, 2014 3:56 pm
Awesome, I have no problem with either of those. I'll put what I have on github tonight and post the link back on this thread.
User avatar
Posts: 5361
Joined: Fri Jul 20, 2012 9:42 am
PostPosted: Sat Mar 15, 2014 4:44 pm
You could probably do the same on the mac or linux by using nc (netcat) in a few lines as well. Just so we can cover all OSs
User avatar
Posts: 5361
Joined: Fri Jul 20, 2012 9:42 am
PostPosted: Sat Mar 15, 2014 4:48 pm
Found this

http://playwithmyled.com/internet-to-serial-proxy/

And a whole page of options including netcat but its page was empty..

http://playground.arduino.cc/Interfacin ... yTl8S-9LCQ

Posts: 13
Joined: Mon Mar 10, 2014 2:10 pm
PostPosted: Sat Mar 15, 2014 5:51 pm
lnevo - I agree there's really nothing to these things so I'd be surprised if there's not already multiple options out there on other OSes (or windows for that matter). It certainly shouldn't be hard to put something together if they're not.

At any rate - https://github.com/smande00/ReefAngelTcpToSerialRelay is the link to what hacked together (with some help from http://www.codeproject.com/Articles/463 ... -in-Csharp)

I'm git challenged so the solution file didn't make it up to git, but it's not really important. I'll move this to a windows service and include an installer as my next steps. In the interim you can run this as a console app - just update the config if your usb->ttl cable is not running on COM3 or you're not using port 2000 for the wifi module.

Posts: 12288
Joined: Fri Mar 18, 2011 6:47 pm
PostPosted: Mon Mar 17, 2014 9:29 am
May I ask for the installable version too?
Just so people can just download and install.
Roberto.

Posts: 13
Joined: Mon Mar 10, 2014 2:10 pm
PostPosted: Mon Mar 17, 2014 9:52 am
Sure - I have to actually write the installer still though :)

I should be able to get that put together tonight or tomorrow at the latest (along with moving the application to a service).

There's also some hardening of the code that needs to get done before I'd recommend anyone actually rely on this - things like gracefully handling errors (rather than ignoring them), reopening the serial port as necessary, etc.

I'll keep the thread updated as things progress.
User avatar
Posts: 5361
Joined: Fri Jul 20, 2012 9:42 am
PostPosted: Mon Mar 17, 2014 11:14 am
For the record, I was not trying to belittle your contribution. On the contrary, this will be very helpful for many people.

I finally managed to get some syntax for netcat to read/write from the serial port. This should work on MacOS and on Linux

Code: Select all
nc -l 2000 > /dev/ttyS0 < /dev/ttyS0


This should open up a tcp port listener for port 2000 on the computer and read/write the IO to /dev/ttyS0. You'd need to change this to whatever serial device your RA comes up as. You may also need to use stty or setserial to set the speed/modes for the serial port. I'm looking into the syntax for those as well, but the command above is the meat of the process.

This should be pretty helpful to those without a wifi adapter who can have a machine permenantly connected. In addition if you kill this off, you shoudl be able to upload new code and then restart the redirection again remotely :)

Posts: 13
Joined: Mon Mar 10, 2014 2:10 pm
PostPosted: Mon Mar 17, 2014 5:24 pm
Hah! No worries, that's not at all how I took it. I'm all for options, and I'm glad to see such a simple built in solution is available on the mac & linux platforms. Something tells me there's probably something similar floating around for windows as well.
Next

Return to Apps

Who is online

Users browsing this forum: No registered users and 1 guest

cron