Question RasPi serial port server?

Zatnikitelman

Addon Developer
Addon Developer
Joined
Jan 13, 2008
Messages
2,302
Reaction score
6
Points
38
Location
Atlanta, GA, USA, North America
So I have an unusual application for a Raspberry Pi. Basically, what I need is for it to connect to a device via serial port, then send that data over a network, then have a Windows computer be able to receive that data, but as a serial port. In other words, if I'm in a program that requires serial data, I want to be able to select that COM port just as if it were attached to the local computer. I've done some Googling and it looks like Ser2Net has some promise, but it's largely undocumented, and I'm lost on what to look for on the Windows side of things. Does anyone understand what I'm getting at?

Thanks!
 

jedidia

shoemaker without legs
Addon Developer
Joined
Mar 19, 2008
Messages
10,882
Reaction score
2,133
Points
203
Location
between the planets
Well, basically you'll have to make a virtual comport that connects to a socket... How difficult that is depends mostly on how easily available code for a virtual comport is, I guess.

Getting the data from the hardware part on the Pi and then sending it over the network shouldn't be too big of a deal. I'd recommend an MQTT implementation.
 

kamaz

Unicorn hunter
Addon Developer
Joined
Mar 31, 2012
Messages
2,298
Reaction score
4
Points
0
So I have an unusual application for a Raspberry Pi. Basically, what I need is for it to connect to a device via serial port, then send that data over a network, then have a Windows computer be able to receive that data, but as a serial port. In other words, if I'm in a program that requires serial data, I want to be able to select that COM port just as if it were attached to the local computer. I've done some Googling and it looks like Ser2Net has some promise, but it's largely undocumented, and I'm lost on what to look for on the Windows side of things. Does anyone understand what I'm getting at?

Thanks!

1. The Raspi has no standard serial port (only LVTTL UART), get an FT232 dongle. Not any cheap USB-to-serial converter, but an FT232 (FTDI) one. These are more expensive, but you will thank me later. Plug that into Raspi's USB port.

1A. Actually, since Raspi is known to have an underpowered +5V rail and the smallest voltage drop will reboot the CPU, get a powered USB hub and plug all your peripherials (including the dongle) into that, not into Raspi directly. You will thank me later for that also.

2. After plugging the dongle in run

dmesg

In the last line of the output you should see a report that an FTDI device is plugged in. Then run

ls /dev/ttyUSB*

this should show what device name the FTDI device uses (/dev/ttyUSB0, /dev/ttyUSB1 and so on).

3. You need a serial-to-tcp bridge on raspi. The manual for ser2net is here:

http://linux.die.net/man/8/ser2net

and this is a good tutorial:

https://mellowd.co.uk/ccie/?tag=ser2net

(I'd disable the banner though, see the manual how to do that)

4. Verify that you can connect to ser2net from Windows machine via putty. (The tutorial uses telnet, but you're better off if you use putty with connection type Raw. You will thank me later). This is a critical step. Verify that you can talk to the serial device from windows.

5. You need a serial port redirector for Windows. This one:

http://www.hw-group.com/products/hw_vsp/index_en.html

worked fine for me and it's free if you need only one port. This creates a new COM port in windows which sends data over the TCP socket to raspi.

6. Launch putty and connect to the newly created COM port. Verify that you can talk to the device.

7. Profit!

Alternatively, if you want something which is more bulletproof (*) than raspi and you have money get one of these:

http://www.moxa.com/product/Serial_Device_Servers.htm

you can configure them simply via a web browser and there is a windows software included (though HW VSP will work also).

(*) Literally:

https://www.youtube.com/watch?v=o9daC24kUHY
https://www.youtube.com/watch?v=pCf6yZPcEGs
 
Last edited:
Top