0

We routinely use netcat (nc) to read data from UDP ports. For example:

user@host ~$ nc -luv 57303
Listening on [0.0.0.0] (family 0, port 57303)
NAV 2024/12/05 12:09:56.326365 DPS112 $GPZDA,121003.35,05,12,2024,,*63NAV 2024/12/05 12:09:56.422294 DPS112 $GPGGA,121003.00,3251.764736,N,07957.683827,W,2,12,0.8,21.38,M,-32.34,M,11.0,1007*72NAV 2024/12/05 12:09:56.470322 DPS112 $GPGLL,3251.764736,N,07957.683827,W,121003.00,A,D*71NAV 2024/12/05 12:09:56.518252 DPS112 $GPVTG,292.37,T,,M,0.0,N,0.0,K,A*30NAV 2024/12/05 12:09:57.302279 DPS112 $GPZDA,121004.33,05,12,2024,,*62NAV 2024/12/05 12:09:57.398194 DPS112 $GPGGA,121004.00,3251.764735,N,07957.683825,W,2,12,0.8,21.38,M,-32.34,M,12.0,1007*77NAV 2024/12/05 12:09:57.446220 DPS112 $GPGLL,3251.764735,N,07957.683825,W,121004.00,A,D*77NAV 2024/12/05 12:09:57.478284 DPS112 $GPVTG,63.00,T,,M,0.0,N,0.0,K,A*08NAV 2024/12/05 12:09:58.310157 DPS112 $GPZDA,121005.33,05,12,2024,,*63NAV 2024/12/05 12:09:58.390253 DPS112 $GPGGA,121005.00,3251.764738,N,07957.683824,W,2,12,0.8,21.37,M,-32.34,M,13.0,1007*74^C

Is it possible to do the same with a serial port, e.g. /dev/ttyUSB0? So far I haven't seen the appropriate options to do this, ending up with errors like this one:

user@host:~/tmp$ nc -lv 127.0.0.1:/dev/ttyUSB0
nc: getaddrinfo: Servname not supported for ai_socktype
user@host:~/tmp$ nc -lv 127.0.0.1:ttyUSB0
nc: getaddrinfo: Servname not supported for ai_socktype

This is on an Ubuntu installation.

1 Answer 1

2

Serial ports are not network ports, despite the similarity in name.

To read from a local device such as /dev/ttyUSB0, use regular cat.

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.