Skip to content

autogain1090 not cleanly handling commented lines in config #48

@f3sty

Description

@f3sty

I ran into an issue with a commented-out RECEIVER_OPTIONS line in /etc/default/readsb from an SDR swap, e.g.

 # RECEIVER_OPTIONS="--device 0 --device-type rtlsdr --gain 48.0 --ppm 50"  
RECEIVER_OPTIONS="--device 0 --device-type rtlsdr --gain 44.5 --ppm 25"

autogain1090 was throwing awk errors, not selecting an appropriate new gain value, and writing the new (incorrect) value to both config lines, not just the uncommented line.

Below is an excerpt from a autogain1090 run - oldgain is being set to 48.0\n44.5 which is breaking all the math:

+ '[' -f /boot/adsb-config.txt ']'
++ grep -P -e 'gain \K[0-9-.]*' -o /etc/default/readsb
+ oldgain='48.0
44.5'
+ [[ 48.0
44.5 == '' ]]
+ gain_index=28
+ for i in "${!ga[@]}"
+ awk 'BEGIN{ exit  (48.0
44.5 <= 0.0) }'
awk: line 1: missing ) near end of line
awk: line 2: extra ')'
+ gain_index=0
+ break
+ awk 'BEGIN{ exit  (48.0
44.5 > 49.6) }'
awk: line 1: missing ) near end of line
awk: line 2: extra ')'
+ gain_index=28
+ [[ 48.0
44.5 == \-\1\0 ]]
+ awk 'BEGIN{ exit (0.000 > 0.5) }'
+ awk 'BEGIN{ exit (0.000 < 0.5) }'
+ [[ 28 == 29 ]]
+ awk 'BEGIN{ exit (0.000 < 0.5) }'
+ gain_index=29
+ action=Increasing
+ awk 'BEGIN{ exit (0.000 > 7.0) }'
+ awk 'BEGIN{ exit (0.000 > 7.0) }'
+ gain=-10
+ [[ -10 == '' ]]
+ '[' -f /boot/piaware-config.txt ']'
+ '[' -f /boot/adsb-config.txt ']'
+ grep gain /etc/default/readsb
+ sed --follow-symlinks -i -E -e 's/--gain -?[0-9]*\.?[0-9]*/--gain -10/' /etc/default/readsb
+ systemctl restart readsb
+ echo 0
+ echo 0
+ echo 'Increasing gain to -10 (0.000% messages >-3dB)'
Increasing gain to -10 (0.000% messages >-3dB)

Resulting /etc/default/readsb with both lines modified and incorrect gain step:

# RECEIVER_OPTIONS="--device 0 --device-type rtlsdr --gain -10 --ppm 50"
RECEIVER_OPTIONS="--device 0 --device-type rtlsdr --gain -10 --ppm 25"

I'll submit a PR for this shortly.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions