Broadcasting the output of the firmware in the network

Hi there,
I configured my RPi2 as an Access Point.
Instead to connect to the GroundStation via a certain IP,
I want to broadcast the output via UDP to all connected devices.
Is it possible to send the output of the firmware to localhost via the -C argument.
Then I easily could setup a python script.

Best, Daniel

Hi Daniel,

-C udp: should work.

Some additional info may be found in the following discussion:

My intention was that I just capture what ArduCopter-quad is sending with a udp socket
and send it via wifi to the GCS. The IP adress of the groundstation is unfortunately unknown
and it would be easier to connect to the known IP address of my copter.
Initially, I thought it would be done with such a script.

udp_port = 14550
udp_server  = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
udp_server.bind(('', udp_port))

def echo_thr():                                                         # trnm_thr() sends commands to Arduino
  udp_msg    = None
  if_name = "wlan0"
  # get local interface address
  apif_wlan0 = get_if_address(if_name)
  apif_wlan0 = get_ip4_adr(apif_wlan0)
  while True:
    # receive a message running on local host
    udp_msg, udp_client = udp_server.recvfrom(512)                    # Wait for UDP packet from ground station

    # forward the msg and broadcast it in the complete network :D
    for ofs in xrange(1, 254):
      adr = apif_wlan0 + str(ofs)
      print(adr, ": ", udp_msg)
      udp_server.sendto(udp_msg, (adr, udp_port) )


I am able to get a heartbeat and the vehicle state on the GCS software (APMPlanner).
Unfortunately all the parameters seem to require a request from the GCS
and I don’t get any data through the same socket from the GCS on the RPi end.
I don’t understand were the problem is. Is the GCS maybe sending on another port?

Your suggestion to use MAVProxy seems to allow forwarding on a device or on another udp-socket.
However, Mavproxy just seems to bind a udp socket on, but the APMPlanner listens for sendto()
That means, I still cannot get a link or I simply didn’t understood MAVProxy.
Or is there a possibility on APMPlanner or any other GCS that it acts as a client instead as a server?

I found a working solution.
Socat can be used for broadcasting to all connected computers.
So everyone who will connect to my copter will get a link :smiley:

socat UDP4-RECVFROM:14550,fork UDP4-DATAGRAM:,broadcast,range=
1 Like

With SOCAT I just get one message repeated forever “PreArm: RC not calibrated” (okay because I have no RC connected at the moment) but it never gets past that message to the point of loading the parameter list, which it does when I add a specific communication target.

APM start command in “/etc/rc.local”:

sudo ArduCopter-quad -A udp: > /home/pi/APM\ Start.log &

SOCAT command (entered directly on command line to test):

socat UDP4-RECVFROM:14550,fork UDP4-DATAGRAM:,broadcast,range=

I’m running APM Planner v2.0.17 and the UDP link settings are default. I guess two things are happening:

  1. ArduCopter is re-transmitting the last message endlessly so any new devices can detect it.
  2. APM Planner 2 should send some kind of message (acknowledgement?) to start a normal communication protocol, i.e. continue to request the parameter list and maybe ArduCopter stops repeating the last message then.

Any ideas?

Thanks @dgrat from your post here I was able to work out that the fix to the problem is to change the SOCAT parameter RECVFROM to LISTEN, i.e. that fixed the problem I described directly:

socat UDP4-LISTEN:14550,fork UDP4-DATAGRAM:,broadcast,range=

Working great now, this is a significant configuration people should seriously consider as standard. Anyone reading this should go read that post to install it properly, as a Linux service.

Yep, I also changed it yesterday to LISTEN. RECV is not working well together with broadcasting, but okay for a single IP.
Changes regarding my init scripts are welcome. I also prepared some monit scripts. If something fails monit will try to solve it :smiley: However they are very simple.

I also configured the RPi2 as an Access Point and the above definitely does not work. Is socat the only solution for a point-to-point telemetry communication between the RPi2 and Mission Planner running in a laptop?

Just use -A udp:GCSIP:14550

You can’t hardcode the GCS IP if you want peer or multiple access, have a floating IP (e.g. long range GSM) or just want flexibility (mesh network).

Although technically correct for point to point configurations, some people had to resort to broadcast to get around issues there too.

I’d hope the point to point bugs are solved already, but still prefer to configure my systems this way for ease of use.

Maybe one could try to use samplicator.
So far I had no time to test, but maybe someone in the forum.
I guess, it may work …
Here is the link:

Hey I have a question!
Are you running this script through a command window or typing all these commands on Mavproxy window?

I’m in desperate need of help. My whole team is failing and I really need a solution.
We don’t know how to detect a WiFi network through mavproxy.
We want this WiFi network set up so our quadrotor can hover stably.