Serial to UDP or TCP

I have written two tutorials how to get Pixhawk's serial connected to UDP or TCP on my blog: http://matilai.net/blog/pixhawks-serial-to-tcp/ and http://matilai.net/blog/pixhawks-serial-to-udp/.

I hope those guides will help someone in this group.

Note that those commands are executed on a linux single board computer connected to a Pixhawk and not directly on a Pixhawk.

The program called socat is a common tool on linux and it's written in C. For these reasons I prefer it over any Python or similar creation.

You need to be a member of diydrones to add comments!

Join diydrones

Email me when people reply –

Replies

  • @Wilhelm - this is great.  This could be really useful for connecting offboard control to a sim.  Any chance you can re-post the contents of your blog here?  or did all it have were the commands? An explanation of what the above commands do would be awesome! (to avoid trying to parse it from the link you gave above).

  • Here are the commands for serial to tcp/udp
    socat /dev/pixhawk,lockfile=pixhawk.lock tcp-listen:5760,fork
    socat /dev/pixhawk,lockfile=pixhawk.lock,b115200 udp-recvfrom:14555,fork,sourceport=14550
  • Wilhelm your work looks very interesting, but both links to your blog seem to timeout, do you have another way for me to access the serial to UDP connection guide?

  • Good information.  I've been using a program called ser2net for things like this.  The main trunk of the project doesn't do UDP and the one patch to do UDP is unreliable.  Can you elaborate on the UDP parameters you're using?  You've got two ports going there.  Why is that?

  • This reply was deleted.
    • Please clarify when this technique "Pixhawk's serial device named automatically"... is necessary?

      If one of the PixHawk telemetry ports is connected to the companion computer with a USB to serial adapter (e.g. FTDI)?

      If the USB micro usb interface of the PixHawk is directly connected to the USB Host of the companion computer?

      If one of the PixHawk telemetry ports is connected to the UART interface of the companion computer? Should always be /dev/ttyAMA0 ?

      What do you mean with "if the pixhawk crashes"? This should never happen? Otherwise drone will crash also without any control?

    • If usb is used on a host computer, then the serial is renamed each time it is plugged. If you're using direct uart connections, then this is not needed.

      For example, if you plug a pixhawk to your pc it's always at /dev/pixhawk.
    • Developer

      I assume you are using an on board computer. I'd recommend not using USB connection, but connecting using a real serial port.

      For a USB connection it doesn't matter what you set baud or flow control to, it's ignored as it's a CDC virtual com port, not a real serial port.

    • Yes, exactly.

  • Moderator

    Thanks - this is a great guide.  I've been experimenting with Odroid C1 and Pixhawk. 

This reply was deleted.