# Difficulty connecting screen to a socat generated serial console via tcp.



## poetaster (Sep 9, 2019)

I have a Moxa 5450 with 4 FreeBSD servers (11) connected. Each Port on the Moxa ist set to use Reverse Telent.  Each serial port is then available at IP of console server 400x. The Null-modem cables have all been tested with a server in the office that is Identical to those in the Rack.

The following config in `/boot/loader.conf` works on test machines.

```
boot_multicons="YES"
boot_serial="YES"
console="comconsole,vidconsole"
```
.

In my test setup, using a machine identical to the 4 machines in the rack, I simply did the following:
`socat -d -d -d PTY,link=/dev/moxa,wait-slave tcp:10.0.0.253:4004`
and then connect
`screen /dev/moxa`.

This worked with a clone machine on a private network when the client (socat and screen) where running on a linux box. But I only get junk with the same approach on FreeBSD.

����������

Is an example of ouptut I get.

Socat seems to be running correctly:


```
2019/09/09 14:51:10 socat[24468] I setting option "symbolic-link" to "/dev/moxa"
2019/09/09 14:51:10 socat[24468] I setting option "pty-wait-slave" to 1
2019/09/09 14:51:10 socat[24468] I setting option "crnl"
2019/09/09 14:51:10 socat[24468] I openpty({5}, {6}, {"/dev/pts/1"},,) -> 0
2019/09/09 14:51:10 socat[24468] N PTY is /dev/pts/1
2019/09/09 14:51:10 socat[24468] I close(6)
2019/09/09 14:51:16 socat[24468] N opening connection to LEN=16 AF=2 10.0.0.253:4004
2019/09/09 14:51:16 socat[24468] I starting connect loop
2019/09/09 14:51:16 socat[24468] I socket(2, 1, 6) -> 6
2019/09/09 14:51:16 socat[24468] N successfully connected from local address LEN=16 AF=2 10.0.0.7:64061
2019/09/09 14:51:16 socat[24468] I resolved and opened all sock addresses
2019/09/09 14:51:16 socat[24468] N starting data transfer loop with FDs [5,5] and [6,6]
2019/09/09 14:51:16 socat[24468] I transferred 15 bytes from 6 to 5
```

I'm a bit stumped since the reverse telnet setup worked so well with a linux client talking to freebsd boxes. I even tested a FreeNAS (FreeBSD 9?) in parallel.

I even went so far as to take my 'primitive' screen rc from the linux box and dump it over the much nicer settings on the FreeBSD box. But that was of no use.


----------



## roper (Sep 9, 2019)

Have you confirmed that the serial ports are using the same settings?


----------



## t4z3v4r3d (Sep 9, 2019)

I need help to solve same issue .
I'm trying to access my device on raspberry-pi with ser2net -as server - and socat - as client -. 
Its OK in a Linux machine, but with FreeBSD the command:
`socat -d -d -d PTY,link=/dev/cuaU0,wait-slave,raw tcp:192.168.X.Y:2003`
Will not make /dev/cuaU0.init and lock.
Whats wrong here ?
Thanks.


----------



## roper (Sep 10, 2019)

I don't have a raspberry-pi but I do have an older Moxa Nport device which worked fine with FreeBSD. The garbage output is what you'd expect if the serial connection parameters aren't in sync. Maybe with the raspberry-pi you need to link /dev/ttyu0 instead of /dev/cuau0. If you're not seeing the cuauN.init and cuauN.lock devices the hardware may not be detected.


----------



## Phishfry (Sep 10, 2019)

poetaster said:


> ����������
> 
> Is an example of ouptut I get.


What about baud. This is the typical output you might see with the wrong speed.
Have you tried different speeds. You might need to reduce FreeBSD default speed of 115200 down to 9600 or 38400.
Settings can be added to /boot/loader.conf

```
comconsole_speed="9600"
```


----------



## Phishfry (Sep 10, 2019)

It appears t4z3v4r3d  is calling up a USB port with cuaU1
For serial ports FreeBSD uses cuau1
Little u=Serial, Big U=USB


----------



## t4z3v4r3d (Sep 10, 2019)

Other side On rpi, A hardware like a modem is installed and working with /dev/ttyACM0. The baud rate is 115200.
The port is /dev/cuaUx and i did it about 2 years ago, And now ? I can't remember how .


----------



## t4z3v4r3d (Sep 10, 2019)

Found it ! Share Z-wave dongle over IP

`pty,link=/dev/cuaU0,raw,user=user,group=dialout,mode=777 192.168.X.Y:2003`
Thanks for helps


----------



## poetaster (Sep 10, 2019)

Ok, Although I didn't set this up on the cloned box, adding baudrate to the boot config did the trick.

To recap, on all FreeBSD servers with null-modem cables on com0/1:

```
boot_multicons="YES"
boot_serial="YES"
console="comconsole,vidconsole"
comconsole_speed="115200"
```

Connecting from a client works fine with:
`socat -d -d -d PTY,link=$HOME/dev/ttyV0,wait-slave tcp:10.0.0.253:4003`

and simply connecting with:
`screen /$HOME/dev/ttyV0`



It was a bit odd but the ouput from dmesg showing uart0 at 9600 baud clarified.

```
# grep uart /var/run/dmesg.boot
uart0: <16550 or compatible> port 0x3f8-0x3ff irq 4 flags 0x10 on acpi0
uart0: console (9600,n,8,1)
uart0: <16550 or compatible> port 0x3f8-0x3ff irq 4 flags 0x10 on acpi0
uart0: console (9600,n,8,1)
uart0: <16550 or compatible> port 0x3f8-0x3ff irq 4 flags 0x10 on acpi0
uart0: console (115200,n,8,1)
```
This output with the last line coming after I added the setting to /boot/loader.conf

The commands that helped clarify:
`grep uart /var/run/dmesg.boot`
and
`stty -a -f /dev/xxx`[/B][/B]

For reference, the Moxa ist configured N,8,1 (parity,data,stop) and that seems to the FreeBSD default.

Thanks everyone


----------

