lee_trieu
Posts: 23
Joined: Wed Dec 18, 2013 4:54 am
Contact: Yahoo Messenger

[Help] How to using Ser2net to send and read data

Sun Mar 09, 2014 4:38 am

Hi all !
I have an issue hope everybody help me !
I want to send and read data from Serial devices using UART(RS232).
I known ser2net may be do it but i don't known how to use it ???
Please help me !!!
Thanks all !!

User avatar
DeeJay
Posts: 2027
Joined: Tue Jan 01, 2013 9:33 pm
Location: East Midlands, UK

Re: [Help] How to using Ser2net to send and read data

Sun Mar 09, 2014 7:17 am

How To Ask Questions The Smart Way: http://www.catb.org/~esr/faqs/smart-questions.html
How to Report Bugs Effectively: http://www.chiark.greenend.org.uk/~sgtatham/bugs.html

lee_trieu
Posts: 23
Joined: Wed Dec 18, 2013 4:54 am
Contact: Yahoo Messenger

Re: [Help] How to using Ser2net to send and read data

Sun Mar 09, 2014 9:15 am

I'm already read all link but i still don't understand how can i use GPIO 14 and GPIO 15 for my COM Port ? in three link you gave, it use USB-RS232 cable, but i want to connect with UART Pin .
I did success with echo a character or string from terminal in Windows using GPIO 14 and GPIO 15.
Please guide me with ser2net !!
Thanks sir so much !!!

User avatar
DeeJay
Posts: 2027
Joined: Tue Jan 01, 2013 9:33 pm
Location: East Midlands, UK

Re: [Help] How to using Ser2net to send and read data

Sun Mar 09, 2014 9:52 am

I haven't done it, but is there any reason why you could not use the built-in GPIO uart device ( /dev/ttyAMA0 ) as the port to be controlled by the ser2net.conf file? (You will need to remove the default association with the system console first - that is well documented elsewhere.)

Please bear in mind that rs232 signal levels are NOT simple 0v and 3v levels as produced by the RPi GPIO pins - you will need an external level convertor before you can safely connect to another rs232 device.
How To Ask Questions The Smart Way: http://www.catb.org/~esr/faqs/smart-questions.html
How to Report Bugs Effectively: http://www.chiark.greenend.org.uk/~sgtatham/bugs.html

lee_trieu
Posts: 23
Joined: Wed Dec 18, 2013 4:54 am
Contact: Yahoo Messenger

Re: [Help] How to using Ser2net to send and read data

Sun Mar 09, 2014 10:02 am

DeeJay wrote:I haven't done it, but is there any reason why you could not use the built-in GPIO uart device ( /dev/ttyAMA0 ) as the port to be controlled by the ser2net.conf file? (You will need to remove the default association with the system console first - that is well documented elsewhere.)

Please bear in mind that rs232 signal levels are NOT simple 0v and 3v levels as produced by the RPi GPIO pins - you will need an external level convertor before you can safely connect to another rs232 device.
Sir, I'm using MAX3232 for level convertor and I sure it still working !!
I can't use UART pin with Ser2net, sir ?
If i can't using Ser2net for my application, How can you guide me send data from RS232 to Webserver (Show a string from UART over webpage) ???
I really thanks you, sir !

klricks
Posts: 7565
Joined: Sat Jan 12, 2013 3:01 am
Location: Grants Pass, OR, USA
Contact: Website

Re: [Help] How to using Ser2net to send and read data

Sun Mar 09, 2014 2:42 pm

lee_trieu wrote:Hi all !
I have an issue hope everybody help me !
I want to send and read data from Serial devices using UART(RS232).
I known ser2net may be do it but i don't known how to use it ???
Please help me !!!
Thanks all !!
Your post is a bit vague. Not clear what your are trying to do. No information about how you are set up and what you have tried....

To use ser2net here is what you need to do:
1. Configure your router to reserve an IP address for your RPi so it always gets the same IP address.
-OR- configure the RPi for a static IP address but the above is easier.
2. Configure your console to work as a generic serial port by editing /etc/inittab and /boot/cmdline.txt
3. Install ser2net: sudo apt-get install ser2net
4. Configure /etc/ser2net.conf (There are instructions of how to configure ser2net contained in the ser2net.conf file)

I have step by step examples of all the above on my web page:
http://home.budget.net/~klricks/Comp/RPi/Serial.html
If you are still having trouble then post your ser2net config file here
Unless specified otherwise my response is based on the latest and fully updated RPiOS Buster w/ Desktop OS.

lee_trieu
Posts: 23
Joined: Wed Dec 18, 2013 4:54 am
Contact: Yahoo Messenger

Re: [Help] How to using Ser2net to send and read data

Sun Mar 09, 2014 2:51 pm

klricks wrote:
lee_trieu wrote:Hi all !
I have an issue hope everybody help me !
I want to send and read data from Serial devices using UART(RS232).
I known ser2net may be do it but i don't known how to use it ???
Please help me !!!
Thanks all !!
Your post is a bit vague. Not clear what your are trying to do. No information about how you are set up and what you have tried....

To use ser2net here is what you need to do:
1. Configure your router to reserve an IP address for your RPi so it always gets the same IP address.
-OR- configure the RPi for a static IP address but the above is easier.
2. Configure your console to work as a generic serial port by editing /etc/inittab and /boot/cmdline.txt
3. Install ser2net: sudo apt-get install ser2net
4. Configure /etc/ser2net.conf (There are instructions of how to configure ser2net contained in the ser2net.conf file)

I have step by step examples of all the above on my web page:
http://home.budget.net/~klricks/Comp/RPi/Serial.html
If you are still having trouble then post your ser2net config file here
Thanks you so much !!
I onlly want to make a "Serial to IP Converters" like this
Image
Ser2net will do it, sir ???

klricks
Posts: 7565
Joined: Sat Jan 12, 2013 3:01 am
Location: Grants Pass, OR, USA
Contact: Website

Re: [Help] How to using Ser2net to send and read data

Sun Mar 09, 2014 3:23 pm

Yes the RPi with Max3232 converter module and ser2net software can do the same.
(Make sure the MAX3232 module is powered by the 3V3 and not 5V)

The RPi can also do serial to IP over WIFI network instead of wired if you put a WIFI adapter on the RPi.

FYI- Homeseer is the company selling the $200.00 Raspberry Pi
http://store.homeseer.com/store/Default.aspx
Unless specified otherwise my response is based on the latest and fully updated RPiOS Buster w/ Desktop OS.

lee_trieu
Posts: 23
Joined: Wed Dec 18, 2013 4:54 am
Contact: Yahoo Messenger

Re: [Help] How to using Ser2net to send and read data

Mon Mar 10, 2014 2:58 pm

klricks wrote:Yes the RPi with Max3232 converter module and ser2net software can do the same.
(Make sure the MAX3232 module is powered by the 3V3 and not 5V)

The RPi can also do serial to IP over WIFI network instead of wired if you put a WIFI adapter on the RPi.

FYI- Homeseer is the company selling the $200.00 Raspberry Pi
http://store.homeseer.com/store/Default.aspx
Hi sir ! I did like you on this link
http://home.budget.net/~klricks/Comp/RPi/Serial.html
and this is my config file: /etc/ser2net.conf

Code: Select all

BANNER:banner:\r\nser2net port \p device \d [\s] (Debian GNU/Linux)\r\n\r\n

# IP address must be reserved on router so RPi always gets the same IP.

192.168.1.108,2000:raw:0:/dev/ttyAMA0:9600 8DATABITS NONE 1STOPBIT banner

#2000:telnet:600:/dev/ttyS0:9600 8DATABITS NONE 1STOPBIT banner
#2001:telnet:600:/dev/ttyS1:9600 8DATABITS NONE 1STOPBIT banner
#3000:telnet:600:/dev/ttyS0:19200 8DATABITS NONE 1STOPBIT banner
#3001:telnet:600:/dev/ttyS1:19200 8DATABITS NONE 1STOPBIT banner
but when i using google chrome and enter addreess: 192.168.1.108:2000
Browser show "Port already in use"
I did it wrong, sir ??

klricks
Posts: 7565
Joined: Sat Jan 12, 2013 3:01 am
Location: Grants Pass, OR, USA
Contact: Website

Re: [Help] How to using Ser2net to send and read data

Tue Mar 11, 2014 12:32 am

lee_trieu wrote:
klricks wrote:Yes the RPi with Max3232 converter module and ser2net software can do the same.
(Make sure the MAX3232 module is powered by the 3V3 and not 5V)

The RPi can also do serial to IP over WIFI network instead of wired if you put a WIFI adapter on the RPi.

FYI- Homeseer is the company selling the $200.00 Raspberry Pi
http://store.homeseer.com/store/Default.aspx
Hi sir ! I did like you on this link
http://home.budget.net/~klricks/Comp/RPi/Serial.html
and this is my config file: /etc/ser2net.conf

Code: Select all

BANNER:banner:\r\nser2net port \p device \d [\s] (Debian GNU/Linux)\r\n\r\n

# IP address must be reserved on router so RPi always gets the same IP.

192.168.1.108,2000:raw:0:/dev/ttyAMA0:9600 8DATABITS NONE 1STOPBIT banner

#2000:telnet:600:/dev/ttyS0:9600 8DATABITS NONE 1STOPBIT banner
#2001:telnet:600:/dev/ttyS1:9600 8DATABITS NONE 1STOPBIT banner
#3000:telnet:600:/dev/ttyS0:19200 8DATABITS NONE 1STOPBIT banner
#3001:telnet:600:/dev/ttyS1:19200 8DATABITS NONE 1STOPBIT banner
but when i using google chrome and enter addreess: 192.168.1.108:2000
Browser show "Port already in use"
I did it wrong, sir ??
I get that error only when trying to view the same IP:port with 2 different applications at the same time. I was viewing with Realterm and could not open the same port in my browser (Firefox on Win8.1). When I closed down Realterm then it would work in the browser.

The port could be used for something else. Try a different port. 2001 or 3000 etc.

When I use Ser2net running on my Linux desktop (Fedora 20) I had to use a config line like this:
2000:raw:0:/dev/ttyAMA0:9600 8DATABITS NONE 1STOPBIT banner
(It would not work with the full IP address)

I will have to get my RPi back running ser2net and see if something has changed.
Unless specified otherwise my response is based on the latest and fully updated RPiOS Buster w/ Desktop OS.

lee_trieu
Posts: 23
Joined: Wed Dec 18, 2013 4:54 am
Contact: Yahoo Messenger

Re: [Help] How to using Ser2net to send and read data

Tue Mar 11, 2014 1:30 am

klricks wrote:
I get that error only when trying to view the same IP:port with 2 different applications at the same time. I was viewing with Realterm and could not open the same port in my browser (Firefox on Win8.1). When I closed down Realterm then it would work in the browser.

The port could be used for something else. Try a different port. 2001 or 3000 etc.

When I use Ser2net running on my Linux desktop (Fedora 20) I had to use a config line like this:
2000:raw:0:/dev/ttyAMA0:9600 8DATABITS NONE 1STOPBIT banner
(It would not work with the full IP address)

I will have to get my RPi back running ser2net and see if something has changed.
Sir !! Can you give me a picture when ser2net working?? I don't know how is it?
When you open it on Terminal and on Web browser?
Thanks you so much, sir !

klricks
Posts: 7565
Joined: Sat Jan 12, 2013 3:01 am
Location: Grants Pass, OR, USA
Contact: Website

Re: [Help] How to using Ser2net to send and read data

Tue Mar 11, 2014 1:55 am

The output shown in the Realterm terminal program is from a weather station datalogger.
The datalogger outputs a new line of data 1 per second.
Note this is not using a RPi. The datalogger is connected to my Fedora box running ser2net. Then viewed over the network on a Win8.1 computer.
Don't have a RPi running at the moment but it works just the same.

Running on web browser is no different looks very much the same:

Image
Unless specified otherwise my response is based on the latest and fully updated RPiOS Buster w/ Desktop OS.

lee_trieu
Posts: 23
Joined: Wed Dec 18, 2013 4:54 am
Contact: Yahoo Messenger

Re: [Help] How to using Ser2net to send and read data

Tue Mar 11, 2014 2:07 am

klricks wrote:The output shown in the Realterm terminal program is from a weather station datalogger.
The datalogger outputs a new line of data 1 per second.
Note this is not using a RPi. The datalogger is connected to my Fedora box. Then viewed over the network on a Win8.1 computer.
Don't have a RPi running at the moment but it works just the same.

Running on web browser is no different looks very much the same:

Image
Thanks Sir !
Do you have some code for your weather station ,sir???
I don't understand how to send and receive data from COM port with ser2net?

klricks
Posts: 7565
Joined: Sat Jan 12, 2013 3:01 am
Location: Grants Pass, OR, USA
Contact: Website

Re: [Help] How to using Ser2net to send and read data

Tue Mar 11, 2014 2:55 am

There is no custom code running at all... only ser2net on server computer and the terminal program on remote computer.
The datalogger is all self contained and just connected to the server computer via an RS232 cable.
It's just a serial device. Could be a GPS or any other serial device...... doesn't matter...
ser2net is capturing data from a com port on the server computer (RPi).
Then data from com port is converted to network IP:port and sent out on the local network. Don't confuse com ports with IP ports......

Any computer connected to the network can access the data at the IP:port
At the moment I am not using any com ports at the remote computer...... However the Realterm program can echo the data stream to a virtual for physical com port if you wish. This is useful if you want to run software that expects get data from a com port. The software will get data from the com port and not know the serial data source is really connected to a different computer over the network.

You can also use other software to create virtual com ports on your PC such as comOcom or COM2TCP

I'm sure of course you realize that the serial device must be actively outputting data else you won't see anything from ser2net.
Unless specified otherwise my response is based on the latest and fully updated RPiOS Buster w/ Desktop OS.

lee_trieu
Posts: 23
Joined: Wed Dec 18, 2013 4:54 am
Contact: Yahoo Messenger

Re: [Help] How to using Ser2net to send and read data

Wed Mar 12, 2014 3:48 pm

klricks wrote:There is no custom code running at all... only ser2net on server computer and the terminal program on remote computer.
The datalogger is all self contained and just connected to the server computer via an RS232 cable.
It's just a serial device. Could be a GPS or any other serial device...... doesn't matter...
ser2net is capturing data from a com port on the server computer (RPi).
Then data from com port is converted to network IP:port and sent out on the local network. Don't confuse com ports with IP ports......

Any computer connected to the network can access the data at the IP:port
At the moment I am not using any com ports at the remote computer...... However the Realterm program can echo the data stream to a virtual for physical com port if you wish. This is useful if you want to run software that expects get data from a com port. The software will get data from the com port and not know the serial data source is really connected to a different computer over the network.

You can also use other software to create virtual com ports on your PC such as comOcom or COM2TCP

I'm sure of course you realize that the serial device must be actively outputting data else you won't see anything from ser2net.
Thanks you so much !!
it still no working for me :( I tried open ser2net with web browser but chrome and firefoxe was display "connecting" very slow....and it display "try again".....On Realterm i can connect with 192.168.1.108:3221 but no data return eventhough i have send some char from an other terminal (hercules terminal)

klricks
Posts: 7565
Joined: Sat Jan 12, 2013 3:01 am
Location: Grants Pass, OR, USA
Contact: Website

Re: [Help] How to using Ser2net to send and read data

Wed Mar 12, 2014 5:21 pm

Try swapping TX & RX Between GPIO and the RS232 module.

Connecting through a browser is probably not the best way? I never tried that until you mentioned that.
For me the browser continuously shows status as ...Connecting... but the data does come through. It does take several seconds to start seeing the data for me.
I haven't tried bi-directional communication yet in a browser (only receive) but I will try that when I get a chance.
Unless specified otherwise my response is based on the latest and fully updated RPiOS Buster w/ Desktop OS.

lee_trieu
Posts: 23
Joined: Wed Dec 18, 2013 4:54 am
Contact: Yahoo Messenger

Re: [Help] How to using Ser2net to send and read data

Wed Mar 12, 2014 5:38 pm

klricks wrote:Try swapping TX & RX Between GPIO and the RS232 module.
Sir ! I was swap it but it still not working ! :( :( :( :(
Realterm display connected but no data return :( :( :(
Image
Large image:https://dl.dropboxusercontent.com/u/23155150/eor.png

klricks
Posts: 7565
Joined: Sat Jan 12, 2013 3:01 am
Location: Grants Pass, OR, USA
Contact: Website

Re: [Help] How to using Ser2net to send and read data

Wed Mar 12, 2014 6:11 pm

Does the baud rate and other parameters of the serial device match what you have put in the ser2net.conf?
Unless specified otherwise my response is based on the latest and fully updated RPiOS Buster w/ Desktop OS.

lee_trieu
Posts: 23
Joined: Wed Dec 18, 2013 4:54 am
Contact: Yahoo Messenger

Re: [Help] How to using Ser2net to send and read data

Wed Mar 12, 2014 6:22 pm

klricks wrote:Does the baud rate and other parameters of the serial device match what you have put in the ser2net.conf?
Yes i do ! I'm sure all of it were mathed !
Sir, this is my configure file:
Image
Large image: https://dl.dropboxusercontent.com/u/231 ... aurate.png

klricks
Posts: 7565
Joined: Sat Jan 12, 2013 3:01 am
Location: Grants Pass, OR, USA
Contact: Website

Re: [Help] How to using Ser2net to send and read data

Wed Mar 12, 2014 7:04 pm

Try this in ser2net.conf:

3211:raw:0:/dev/ttyAMA0:115200 8DATABITS NONE 1STOPBIT banner
Unless specified otherwise my response is based on the latest and fully updated RPiOS Buster w/ Desktop OS.

lee_trieu
Posts: 23
Joined: Wed Dec 18, 2013 4:54 am
Contact: Yahoo Messenger

Re: [Help] How to using Ser2net to send and read data

Thu Mar 13, 2014 4:04 am

klricks wrote:Try this in ser2net.conf:

3211:raw:0:/dev/ttyAMA0:115200 8DATABITS NONE 1STOPBIT banner
Sory sir ! I'm sad to say that it still not working :( :( :( :( :(
Can you guide me how to test UART ??? like echo a char, please sir !
I now i can't Puttty with UART pin :( :( :(
Thank you so much, sir !!!

klricks
Posts: 7565
Joined: Sat Jan 12, 2013 3:01 am
Location: Grants Pass, OR, USA
Contact: Website

Re: [Help] How to using Ser2net to send and read data

Thu Mar 13, 2014 1:00 pm

Note that the Hercules serial terminal / monitor needs to be configured for NO FLOW control (no RTS & CTS).
If flow control can't be turned off then you would need buy or make a Null handshake adapter:
http://www.lammertbies.nl/comm/info/RS- ... modem.html
Refer to the Null modem with loop back handshaking section. Note the handshaking loopback only needs to be on the serial terminal side.

Loopback tests:
Stop Ser2net with this command:
/etc/init.d/ser2net stop

Remove your Max3232 adapter and short the GPIO TX & RX together with a jumper wire.
Run a terminal program such as minicom or Cutecom (GUI) and type characters. Typed characters should echo with jumper on and not echo with jumper off.

Install the Max3232 adapter and short pin 2 & 3 on the 'D' connector.
Repeat echo test.
(If the adapter has LED's for TX & RX they should blink with data as well)

You could also test by connecting a serial port of a computer to the RPi via Max3232 and run Realterm, and type characters back and forth between RPi and computer.

Also try connecting your Hercules serial terminal monitor to the PC.
Unless specified otherwise my response is based on the latest and fully updated RPiOS Buster w/ Desktop OS.

lee_trieu
Posts: 23
Joined: Wed Dec 18, 2013 4:54 am
Contact: Yahoo Messenger

Re: [Help] How to using Ser2net to send and read data

Fri Mar 14, 2014 1:02 pm

klricks wrote:Note that the Hercules serial terminal / monitor needs to be configured for NO FLOW control (no RTS & CTS).
If flow control can't be turned off then you would need buy or make a Null handshake adapter:
http://www.lammertbies.nl/comm/info/RS- ... modem.html
Refer to the Null modem with loop back handshaking section. Note the handshaking loopback only needs to be on the serial terminal side.

Loopback tests:
Stop Ser2net with this command:
/etc/init.d/ser2net stop

Remove your Max3232 adapter and short the GPIO TX & RX together with a jumper wire.
Run a terminal program such as minicom or Cutecom (GUI) and type characters. Typed characters should echo with jumper on and not echo with jumper off.

Install the Max3232 adapter and short pin 2 & 3 on the 'D' connector.
Repeat echo test.
(If the adapter has LED's for TX & RX they should blink with data as well)

You could also test by connecting a serial port of a computer to the RPi via Max3232 and run Realterm, and type characters back and forth between RPi and computer.

Also try connecting your Hercules serial terminal monitor to the PC.
Sir ! I think it working now...
I'm really thank sir so much !
Image
Large image: https://dl.dropboxusercontent.com/u/231 ... orking.png
Sir,...but it only working on Realterm. On web browser it don't display :( :( :( :( :( :(
But when i connect on browser the Hercluse Terminal show some thing like that
Image
Large image: https://dl.dropboxusercontent.com/u/23155150/web.png
I don't understand why does it don't working on web browser !! :( :( :( :( :( :(

klricks
Posts: 7565
Joined: Sat Jan 12, 2013 3:01 am
Location: Grants Pass, OR, USA
Contact: Website

Re: [Help] How to using Ser2net to send and read data

Fri Mar 14, 2014 4:18 pm

Please tell what you did to get it working.....
Unless specified otherwise my response is based on the latest and fully updated RPiOS Buster w/ Desktop OS.

lee_trieu
Posts: 23
Joined: Wed Dec 18, 2013 4:54 am
Contact: Yahoo Messenger

Re: [Help] How to using Ser2net to send and read data

Fri Mar 14, 2014 4:39 pm

klricks wrote:Please tell what you did to get it working.....
Sir ! I tried using Msp430 launchpad Dev KIT to connect with my Pi and it working now !
I think my RS232 module have problem !
But on browser it can't display anything !! Please give me a idea, sir !
Thanks sir so much !

Return to “Advanced users”