Pitter
Posts: 8
Joined: Wed May 11, 2016 2:36 pm

Modify script to work with unstable internet connection

Tue May 24, 2016 3:25 pm

Hello again,

i want to broadcast raspivid-data using socat. As a display i use my mobile phone and an android-app, the receiving rpi is connected using USB-Tethering (more infos here http://fpv-community.de/showthread.php? ... OpenSource). Everything works at the moment, but i want to realize the following:

The script should wait the moment the usb-connection is lost, and restart the transmission if the connection is re-established.

The transmission part in the script is as follows:

$WBC_PATH/rx -p $PORT -b $BLOCK_SIZE -r $FECS -f $PACKET_LENGTH $NICS | socat -b 1024 - udp4-sendto:192.168.0.104:5000

What would be a sufficient if-else-construction (or anything similar) that doesnt add lag/delay (!)?

Thanks!

epoch1970
Posts: 5132
Joined: Thu May 05, 2016 9:33 am
Location: Paris, France

Re: Modify script to work with unstable internet connection

Mon May 30, 2016 3:59 pm

Adding the link was a nice attention, but my German is rotten...
So a general question. When you "lose the USB connection" do you receive a disconnect over the USB bus on the Pi (like when you remove a usb key)?
"udevadm monitor" (possibly with some options) would allow to answer the question.

If yes, then you can write a udev rule targeted at the usb gizmo that is used. Under the "add" event, you could run something, and under the "remove" event, do something else.
If you look for info on udev, pay attention to the age of the resources you find online. The general principles and syntax of udev have not changed since the beginning, but for example the way to call a program through systemd is something new.
"S'il n'y a pas de solution, c'est qu'il n'y a pas de problème." Les Shadoks, J. Rouxel

Return to “General discussion”