0

I have a question linked to Linux and serial port.

I want to be able to receive and send messages to a dedicated serial port and to redirect it to another port (/dev/tty).

For the first part, I’m able to dialog with my hardware equipment without any problem, but I’m just wondering if it’s possible to intercept and redirect message coming from a serial port #1 to another port #2.

To give more context, I had used a GPS Antenna and NTP open source software for years.

Since 2018, the new GPS antenna protocol has modified the order of bytes in the message used by NTP to steer and now it’s not working anymore.

So my idea is to put a simple C program (middleware) which fixes this byte ordering; but I’m wondering if I have to build a kernel-specific module or if it can be done in another way. The NTP software uses the symbolic link to dialog.

Thanks for your help.

1
  • IMO there may not be a "simple C program which fixes this byte ordering". How are you going to (robustly) identify which is the high-order byte versus the low-order byte? "I’m wondering if I have to build a kernel-specific module" -- Typically in Linux, you do not want to access the actual "serial port" or UART, but rather a serial terminal device node, e.g. /dev/ttyS0 with its termios interface. See stackoverflow.com/questions/5379720/… Commented Jan 23, 2020 at 7:54

1 Answer 1

0

You can probably use a simple redirect, look here: Pipe One Serial Port to Another in Linux

If the ports are in different rates you can use stty or perhaps screen to adjust: https://unix.stackexchange.com/a/117064

If you need it to be in c program to manipulate it you can use the following: https://stackoverflow.com/a/6947758/8901188

Using c it will need to run in an infinite loop so it can constantly read, manipulate and write the data.

Sign up to request clarification or add additional context in comments.

1 Comment

"If you need it to be in c program to manipulate it you can use the following:..." -- You provided a link to the "inferior" answer (that has more complaints of problems).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.