Help! RFlink dongle over ip-usb using ser2net socat

  • Platform information:
    • Hardware: Raspberry PI 4 -
    • OS: Strech
    • Java 11.0.5
    • openHAB version: 2.4

*RFlink on Wemos® Mega +WiFi R3 Module ATmega2560+ESP8266 32Mb Memory USB-TTL CH340G Compatible For Arduino Mega NodeMCU ESP8266

[https://imgaz2.staticbg.com/thumb/large/oaupload/banggood/images/24/9F/b6fc7357-fbe7-4c3e-9aee-862d0c1dd6cb.JPG.webp]

Everything works correctly when connected to USB

*** Items configuration related to the issue**

String RFLinkRaw	"RFLink raw data [%s]" <text> { serial="/dev/ttyAMA0@57600", autoupdate="false" }

*** Sitemap configuration related to the issue**

sitemap rflink label= "RFlink"
{
    Text item=RFLinkRaw 
}

But I can not find the configuration to use it in WIFI to deport to another location

I tested under telnet and I visualize the information sent by RFlink/ESP_Easy

I installed ser2net and socat on my RPI4 (IP:192.168.0.27)
my /etc/ser2net.conf

8000:raw:0:/dev/ttyAMA0:57600 8DATABITS NONE 1STOPBIT

my /etc/default/socat.conf

OPTIONS="pty,link=/dev/ttyUSB0,raw,user=openhab,group=dialout,mode=777 tcp:192.168.0.27:8000"

Service Verification for ser2net:

systemctl status ser2net
● ser2net.service - LSB: Allows network connections to serial ports
   Loaded: loaded (/etc/init.d/ser2net; generated)
   Active: active (running) since Sun 2019-11-24 20:10:27 CET; 11h ago
     Docs: man:systemd-sysv-generator(8)
  Process: 1976 ExecStart=/etc/init.d/ser2net start (code=exited, status=0/SUCCE
    Tasks: 1 (limit: 4915)
   Memory: 1.7M
   CGroup: /system.slice/ser2net.service
           └─1984 /usr/sbin/ser2net -c /etc/ser2net.conf -P /run/ser2net.pid

nov. 24 20:10:27 pi4 systemd[1]: Starting LSB: Allows network connections to ser
nov. 24 20:10:27 pi4 ser2net[1982]: ser2net startup
nov. 24 20:10:27 pi4 ser2net[1976]: Starting Serial port to network proxy: ser2n
nov. 24 20:10:27 pi4 systemd[1]: Started LSB: Allows network connections to seri
lines 1-14/14 (END)

Service Verification for socat:

systemctl status socat
● socat.service - LSB: Start/stop (socat a multipurpose relay)
   Loaded: loaded (/etc/init.d/socat; generated)
   Active: active (running) since Sun 2019-11-24 20:19:29 CET; 11h ago
     Docs: man:systemd-sysv-generator(8)
  Process: 2377 ExecStart=/etc/init.d/socat start (code=exited, status=0/SUCCESS
    Tasks: 1 (limit: 4915)
   Memory: 804.0K
   CGroup: /system.slice/socat.service
           └─2383 /usr/bin/socat -d -d -d -lf /var/log/socat.log pty,link=/dev/t

nov. 24 20:19:29 pi4 systemd[1]: Starting LSB: Start/stop (socat a multipurpose 
nov. 24 20:19:29 pi4 socat[2377]: Starting multipurpose relay: socat.
nov. 24 20:19:29 pi4 systemd[1]: Started LSB: Start/stop (socat a multipurpose r
lines 1-13/13 (END)

tail -f /var/log/socat.log
2019/11/24 20:19:29 socat[2383] I setting option “perm” to 511
2019/11/24 20:19:29 socat[2383] I openpty({6}, {7}, {"/dev/pts/2"},) -> 0
2019/11/24 20:19:29 socat[2383] N PTY is /dev/pts/2
2019/11/24 20:19:29 socat[2383] N opening connection to AF=2 192.168.0.27:8000
2019/11/24 20:19:29 socat[2383] I starting connect loop
2019/11/24 20:19:29 socat[2383] I socket(2, 1, 6) -> 8
2019/11/24 20:19:29 socat[2383] N successfully connected from local address AF=2 192.168.0.27:49866
2019/11/24 20:19:29 socat[2383] I resolved and opened all sock addresses
2019/11/24 20:19:29 socat[2383] N starting data transfer loop with FDs [6,6] and [8,8]
2019/11/24 20:21:21 socat[2383] I transferred 3 bytes from 6 to 8

ls -lah /dev/ttyU*
lrwxrwxrwx 1 root root 10 nov. 24 20:19 /dev/ttyUSB0 -> /dev/pts/2

And so I modified the item that was related to the physical USB port (ttyAMA0) to receive socat as follows to virtual -> ttyUSB0

String RFLinkRaw	"RFLink raw data [%s]" <text> { serial="/dev/ttyUSB0@57600", autoupdate="false" }

And there I receive absolutely nothing!
I do not understand why it does not work!
Help !!

Before the blocking I had this:
At the moment everything was working I had:

2019/11/23 10:22:35 socat[1330] N opening connection to AF=2 192.168.0.27:9000
2019/11/23 10:22:35 socat[1330] N successfully connected from local address AF=2 192.168.0.27:52256

*Following my test: I had to restart the Webmos / ESP because I found in the log socat:

( This blocking appeared while I wanted to connect in parallel with my PC under TELNET)

2019/11/23 10:22:35 socat[1330] N starting data transfer loop with FDs [6,6] and [8,8]
2019/11/23 10:22:35 socat[1330] N socket 2 (fd 8) is at EOF
2019/11/23 10:22:35 socat[1330] N exiting with status 0

Then despite the disconnection of the PC and several restart of Ser2net / Socat the message

2019/11/23 10:24:25 socat[1509] N opening connection to AF=2 192.168.0.27:9000
2019/11/23 10:24:25 socat[1509] E connect(8, AF=2 192.168.0.27:9000, 16): Connection refused
2019/11/23 10:24:25 socat[1509] N exiting with status -1

The only solution for it to work is to use the built-in reboot function in ESP_Easy / Tools

2019/11/24 18:36:00 socat[30730] I setting option "symbolic-link" to "/dev/ttyJJL"
2019/11/24 18:36:00 socat[30730] I setting option "raw"
2019/11/24 18:36:00 socat[30730] I setting option "user" to 110
2019/11/24 18:36:00 socat[30730] I setting option "group" to 20
2019/11/24 18:36:00 socat[30730] I setting option "perm" to 511
2019/11/24 18:36:00 socat[30730] I openpty({6}, {7}, {"/dev/pts/3"},,) -> 0
2019/11/24 18:36:00 socat[30730] N PTY is /dev/pts/3
2019/11/24 18:36:00 socat[30730] N opening connection to AF=2 192.168.0.27:8000
2019/11/24 18:36:00 socat[30730] I starting connect loop
2019/11/24 18:36:00 socat[30730] I socket(2, 1, 6) -> 8
2019/11/24 18:36:00 socat[30730] N successfully connected from local address AF=2 192.168.0.27:49710
2019/11/24 18:36:00 socat[30730] I resolved and opened all sock addresses
2019/11/24 18:36:00 socat[30730] N starting data transfer loop with FDs [6,6] and [8,8]
2019/11/24 18:36:00 socat[30730] I transferred 74 bytes from 8 to 6
2019/11/24 18:36:00 socat[30730] I transferred 80 bytes from 6 to 8

And I see passing packets each time you press a remote control button :

2019/11/24 18:36:00 socat[30730] I transferred 74 bytes from 8 to 6
2019/11/24 18:36:00 socat[30730] I transferred 80 bytes from 6 to 8
2019/11/26 19:58:03 socat[3920] I transferred 36 bytes from 8 to 6
2019/11/26 19:58:03 socat[3920] I transferred 7 bytes from 8 to 6
2019/11/26 19:58:09 socat[3920] I transferred 2 bytes from 8 to 6
2019/11/26 19:58:09 socat[3920] I transferred 44 bytes from 8 to 6
2019/11/26 19:58:33 socat[3920] I transferred 2 bytes from 8 to 6
2019/11/26 19:58:33 socat[3920] I transferred 43 bytes from 8 to 6
2019/11/26 19:59:03 socat[3920] I transferred 2 bytes from 8 to 6
2019/11/26 19:59:03 socat[3920] I transferred 43 bytes from 8 to 6
2019/11/26 19:59:06 socat[3920] I transferred 2 bytes from 8 to 6
2019/11/26 19:59:06 socat[3920] I transferred 44 bytes from 8 to 6
2019/11/26 19:59:33 socat[3920] I transferred 3 bytes from 8 to 6

I will continue and try to trace the stream sent to the serial port

Help !!!

I finally found the solution to have a connection of RFLink in WIFI:
after many tests and many researches it turns out that for this connection it is enough of socat only.
but for this to be fully functional it takes a specific configuration that I found on [Another post]
(https://community.openhab.org/t/forwarding-of-serial-and-usb-ports-over-the- network-to-openhab / 46597)
The part that concerns me is the OPENHAB listed configuration

- Configuration of ESP_Easy:
1- Create a “Communication - Serial Server” device
2 - Give him a name (me = RFLINK)
3 - Give him a port (me = 8000)
4 - Parameters of the serial channel as used on the OPENHAB server (me = ttyAMA0 57600 Bauds 8Bite no Parity 1Stop
4 - Event Processing = RFLINK
and Submit to save and it’s over for Webmos

- OPENHAB server configuration
1- Install socat -> -> sudo apt install socat
2- Create a company service:-> -> sudo nano /etc/systemd/system/socat@service
and copy this content:

[Unit]
Description = Multipurpose relay (SOcket CAT)
After network.target =
StartLimitIntervalSec = 0
StartLimitBurst = 3000

[Service]
Restart = always
RestartSec = 3
EnvironmentFile = / etc / default / socat-% i.conf
Type = Single
PIDFile = / var / run / socat-% i.pid
ExecStart = / usr / bin / socat -L / var / run / socat-% i.pid $ SOCAT_DEFAULTS $ SOCAT_CONNECTION
ExecStop = / bin / kill -SIGKILL $ MAINPID

[Install]
WantedBy = multi-user.target

and save (CTRL + O - CTRL + X)

reload configuration -> systemctl daemon-reload
Creation and configuration of the virtual serial device (me = ttyUSB0)
-> sudo nano/etc/default/socat-ttyUSB0.conf

SOCAT_DEFAULTS = -d -d -s -lf /var/log/socat.log
SOCAT_CONNECTION = pty, link = / dev / ttyUSB0, raw, user = openhab, group = dialout, mode = 777 tcp: <ip-ESP_easy>: <ESP_easy port>

Then enable and start it after logging for system boot.

-> systemctl enable socat @ ttyUSB0
-> systemctl start company @ ttyUSB0

Adjust EXTRA_JAVA_OPTS in / etc / default / openhab2
-> sudo nano / etc / default / openhab2
EXTRA_JAVA_OPTS = "- Dgnu.io.rxtx.SerialPorts = / dev / ttyUSB0: / dev / ttyS0 / dev / ttyS2 / dev / ttyACM0 / dev / ttyAMA0 "
Then you have to connect to the Karaf console and install the serial transport.
type this -> feature: install openhab-transport-serial
-> logout
And finally, the openHAb should be restarted.
-> reboot