Building A ser2net (Serial to IP) Server

Hi

After seeing a number of posts on this forum and thanks to some advice from @futzle, I’m trying to convert a linux based NAS into a ser2net server so that some USB serial devices can be accessible via and IP and Port in the Vera UI, rather than having to physically attach all the devices directly to Vera.

http://ser2net.sourceforge.net/

If this is possible then this ‘server’ can then act as the hub and be addressable for any number of serial devices (usb, rs232 etc.) I have within my ‘node central’ set up. In doing this it will also allow Vera, with it’s z-wave antenna, to be free from restriction and location (other than a need for a power socket)

Currently I’ve stumbled my way through and installed it, and can seem to run it from the SSH window like the following.

/ cd /home/Public/ser2net-2.8-rc2/ ./ser2net

Plus with @futzle’s help I have the entry in ser2net.conf for my USB to serial adapter that is connected to an current cost enviR monitor.

Other than to share the journey (and to get some much needed help on the way) I’m curious to know if i am on the right path and also how I can test it, outside of installing a plugin. Is there a bit of code I can use to see if data is available on the IP and port ?

So while I’ve already started this quest, (even as a newbie to Linux) I’m very keen to hear from people who have installed ser2net before and/ or have such a set up already.

Pasted from a discussion i had with futzle … (To keep it all together)

That’s right.

I have seen a number of mentions on Ser2net in this forum and the website itself is sadly not the most explanatory I've seen. It sounds like it provides you with the ability to hold (host) all your phsyical serial devices USB, RS232 and then allow them to be reference-able via an IP and Port combo.

Indeed, that’s what ser2net does (and it’s the only thing ser2net does).

Also there are dedicated pieces of hardware that do the same TCP/Serial bridging. Here are a couple: http://www.wiznet.co.kr/Sub_Modules/en/product/Product_Detail.asp?cate1=5&cate2=8&cate3=0&pid=1040 Products

Do you use the plugin created by Guessed ?(http://forum.micasaverde.com/index.php/topic,2989.msg12655.html#msg12655)

I used to, but then MCV added the ability to connect to a host+port directly into the Luup extensions (luup.io.open()) so I use that instead now in all my plugins.[/quote]

$ cat /etc/ser2net.conf 49402:raw:0:/dev/tty.usbserial:57600,NONE,1STOPBIT,LOCAL

I picked the port number more or less at random. The server is a Mac and it names the serial device /dev/tty.usbserial. You’ll need to change these accordingly.

And here’s the configuration on the Vera.[/quote]

I think that you are mistaken in thinking that ttyS0 has anything to do with the NAS’s USB system. Its name looks more like a regular serial port, probably one that can only be reached by connecting to jumpers on the NAS’s motherboard. (This is very common on embedded hardware.)

How do I open up port 49402 in linux ?

It’s not clear what you mean by “open up”. If you mean, what causes the port to be listened to for incoming connections, then ser2net does that. If you are talking about a firewall on the Linux machine blocking incoming connections, assuming you have one, then you will need to find the firewall configuration and turn off the firewall (seriously, firewalls on Unix machines inside your LAN aren’t any kind of security, just turn them off).

How do I check and ensure that ser2net is running ? - [i](I tried 'ps aux | less' but could not see it) [/i]

That should show ser2net. If it isn’t then ser2net isn’t running. ser2net has some command-line options that will stop it detaching into the background when you run it; these are useful with debugging. You can use ctrl-C to kill a running program in Linux, just as you do in a DOS shell.

Also you can speak to ser2net over the LAN with telnet:

telnet the-nas 49402

For the CurrentCost you’ll see the long XML strings every few seconds.[/quote]

Seems like i am not having much luck with my old NAS, i keep trying to open ports or assign existing open ports to the usb connection, but nothing is being seen.

For this to work with the current cost EnviR plugin or any others I need to be able to see (test) if it is working?

As before all thoughts ideas welcome. What devices OS are people using if they have ser2net running.

“Assign existing ports” suggests a misunderstanding about TCP networking. You have to pick a port that no one else is using, in the range 1024 to 65535. Only one process can listen on any given port.

For this to work with the current cost EnviR plugin or any others I need to be able to see (test) if it is working?

Telnet. See above. Don’t involve Vera until you know you are running ser2net properly.

I’ve been running ser2net on a Raspberry Pi for several months now. My CurrentCost unit is plugged into the Pi and the Pi makes the data available on my network via ser2net. The Vera CurrentCost plug-in gets its data from the Pi. This has worked flawlessly for several months now.

@racarter - fantastic, tell me more ? (Please)

I have one myself, so i could change over and work on that , which Linux OS did you use? Some step by step help would be a huge help…

“Assign existing ports” suggests a misunderstanding about TCP networking. You have to pick a port that no one else is using, in the range 1024 to 65535. Only one process can listen on any given port.[/quote]

Agreed, what I meant to lead with was that I tried opening new ports using (the following command line), but they did not seem to register on the NAS, so I did a port scan and could see a number that suggested they might be unused, so as a last resort I tried some of those too.

iptables -I INPUT -p tcp --dport 12345 --syn -j ACCEPT

Telnet. See above. Don’t involve Vera until you know you are running ser2net properly.[/quote]

Thanks, totally agree and I tried to telnet, but that did not return anything in the terminal window.

Telnet 192.xxx.xx.xxx 49402

As my NAS is not a clean install it has a proprietary version on it, I might be limited in what I can do, so maybe the Pi is a good one to try next.

Definitely switch to your Raspberry Pi if you can. It is more likely to have a working ser2net than a homebrew NAS.

iptables? Just turn the firewall off.

Another useful command is netstat. Use this to see which ports are being listened to:

netstat -l -n

While running ser2net you should see an extra line in the netstat output corresponding to your configured port.

That’s ambiguous. When reporting errors, say what did happen rather than what didn’t. Did it return immediately to the prompt? Did it hang indefinitely while producing no output. Was there an error message?

I’m using Debian. Just installed ser2net and put the following in its config file:

10002:raw:0:/dev/ttyUSB0:57600,NONE,1STOPBIT,8DATABITS

Then start ser2net from the command line.

Put the IP address of the Pi and port 10002 (or whatever port you want to use) in the connection tab of the CurrentCost plug-in on Vera. Worked straight away. :slight_smile:

I have a splitter installed between the CurrentCost and its network interface so the data goes to the CurrentCost website as well as to Vera.

Ok, thanks @racarter

I’ve dusted the PI off and have just put on a fresh Wheezy image and have now done the following all of which seems to have gone through ok.

sudo apt-get install ser2net

I will have a play later today in-between entertaining the kids ! :wink:

Good luck!

Thanks @racarter & @futzle!!

I’m now up and running on a Raspberry Pi, with Ser2net installed and the Current Cost USB to serial cable is plugged in and Vera is now reading from the EnviR monitor . Wow… Telneting to the port and ip allowed me to see the data being sent by the monitor…

That was so much easier on the Pi, than it was on the antiquated NAS I was using in the first place.

Great news! The Pi is SO good for things like this!

It’s a little beauty !

It’s also allowed me to restart my RS232 over IP post which both you and @futzle commented on before. Therefore my next quest is to see what can be achieved with the Pi, ser2net, Vera and a USB to serial/RS232 cable :wink: - http://forum.micasaverde.com/index.php/topic,12559.0.html

Not a bad solution for 25 quid! ;D

How reliable is the Raspberry Pi?

Mine seems to crash every 48 hours or so?

The one running ser2net has been running for months without any restarts.

Interesting, thanks.

What OS are you running?

I have the very latest copy of Wheezy?

I’m on Debian 6.0.5. I haven’t liked to disturb anything since it’s running so well. ;D

Was the download for that version, from her → Raspberry Pi OS – Raspberry Pi