# Reset serial port (/dev/cuau...)



## cjm (Oct 10, 2021)

Hi all,

I've got a server console connected to my FreeBSD desktop via serial cable and run a command like


```
cu -l /dev/cuau0 -s 115200
```

to get to the console - all good. However, every few months or so, the serial port seems to get screwed up and no data is transmitted anymore. When I kill "cu" and start it again, I get a local echo, nothing else. It's a local problem, though, because it works again after rebooting the desktop.

Every time this has happened so far, I haven't had the time to debug properly because I needed the console working ASAP so I rebooted my desktop. Things I've checked so far:

There's no other process on /dev/cuau0 or /dev/ttyu0 that would lock the port.
The server doesn't use hardware flow control, only XON/XOFF, and I've had no indications that hardware flow control had been turned on somehow when this happened.
Is there a way to completely reset a serial device in FreeBSD to the settings it had right after booting?

Thanks,
--Christina


----------



## covacat (Oct 10, 2021)

other than stty no idea
but you can try looking at the cflags and then set them back


----------



## cjm (Oct 10, 2021)

Thanks for the quick reply! That's what I did (stty) but I'm not sure I understand what you mean with cflags - control mode flags for stty?


----------



## covacat (Oct 10, 2021)

yes, those for parity, flow control stop bits

```
cflags: cread cs8 -parenb -parodd hupcl -clocal -cstopb -crtscts -dsrflow
    -dtrflow -mdmbuf
```


----------



## cjm (Oct 10, 2021)

OK. I've done some cursory checks to that end last time it happened but needed the server back up ASAP; I'll try and invest some more time when it happens again.


----------



## covacat (Oct 10, 2021)

also you can use screen to connect instead of cu
for me it worked better than cu on some platforms (mac)
or if you have an usb2serial dongle just pull it out and plug back in


----------



## cjm (Oct 10, 2021)

I did try minicom, but not screen. It's a hardware serial port, though - one of the "good old" 16550-style devices. I've been wondering about using a USB/serial port, simply because I *can* unplug it and plug it back in


----------



## tingo (Oct 10, 2021)

Also look out for Ctrl-S / Ctrl-Q.


----------



## cjm (Oct 10, 2021)

Valid point, thanks, but that's the first thing I do when a terminal gets stuck. I should have mentioned this in the orignal post, of course...


----------

