Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Seems like a memory leak or long run time crash? #19

Open
alanmimms opened this issue Dec 10, 2018 · 10 comments
Open

Seems like a memory leak or long run time crash? #19

alanmimms opened this issue Dec 10, 2018 · 10 comments

Comments

@alanmimms
Copy link

This is a cool add-on. I use it for remote controls and for monitoring temperature sensors.

After a week or two of uptime, I find the add-on stops working. All I have to do to fix it is to hit restart in the add-on details page, but it's slightly annoying. Do others see this behavior?

The length of time it works with no issue makes me think it's a very infrequent driver hang or maybe a memory leak. I have not yet looked into the memory leak theory by paying attention to size of the process, etc., but that's the next step to debugging this I suppose. What exactly does the restart button do? Does it completely rmmod the driver? Or does it simply restart the userland process(es)?

@seayworld
Copy link

I am having the same issue. Sometimes is runs for days, sometimes just hours. Each time I can clear with a restart. Tried looking for logs, but nothing is there.

@messismore
Copy link
Contributor

See here
Does that fix the issue for you?

@alanmimms
Copy link
Author

That seems like a crude work around. I want a real fix. When I get some time I'll try debugging it.

@messismore
Copy link
Contributor

I was experiencing the issue described here. There's references to other issues that might also help to debug it.

@alanmimms
Copy link
Author

I ordered a heatsinked R820T USB dongle to replace the one I have now in hopes that overheating is the source of the problem. For anyone interested:

​NooElec NESDR Nano 3 - Premium Tiny RTL-SDR w/Aluminum Enclosure, 0.5PPM TCXO, SMA & MCX Input & Custom Heatsink. RTL2832U & R820T2-Based Software Defined Radio
by Nooelec
Learn more: https://smile.amazon.com/dp/B073JZ8CC2/ref=cm_sw_em_r_mt_dp_U_t2P6CbW2JDS3G

@messismore
Copy link
Contributor

Have you had better luck with the Nano? Would you recommend it?

@alanmimms
Copy link
Author

So far no time to implement it. I'm buried at work.

@robertopiumatti
Copy link

robertopiumatti commented Oct 29, 2019

i'm solved!
In sh:

MQTT_PATH=$MQTT_TOPIC
/usr/local/bin/rtl_433 -F json -R $PROTOCOL -f $FREQUENCY -g $GAIN -p $OFFSET | /usr/bin/mosquitto_pub -h $MQTT_HOST -u $MQTT_USER -P $MQTT_PASS -i RTL_433 -l -t $MQTT_PATH

instead:

/usr/local/bin/rtl_433 -F json -R $PROTOCOL -f $FREQUENCY -g $GAIN -p $OFFSET | while read line
do
  DEVICE="$(echo $line | jq --raw-output '.model' | tr -s ' ' '_')" # replace ' ' with '_'
  DEVICEID="$(echo $line | jq --raw-output '.id' | tr -s ' ' '_')"

  MQTT_PATH=$MQTT_TOPIC

  if [ ${#DEVICE} > 0 ]; then
    MQTT_PATH=$MQTT_PATH/"$DEVICE"
  fi
  if [ ${#DEVICEID} > 0 ]; then
    MQTT_PATH=$MQTT_PATH/"$DEVICEID"
  fi

  # Create file with touch /tmp/rtl_433.log if logging is needed
  [ -w /tmp/rtl_433.log ] && echo $line >> rtl_433.log
  echo $line | /usr/bin/mosquitto_pub -h $MQTT_HOST -u $MQTT_USER -P $MQTT_PASS -i RTL_433 -r -l -t $MQTT_PATH
done

As repository https://github.com/merbanan/rtl_433 I used its mqtt function directly.
Now it has been running for a month, now without interruption

@alanmimms
Copy link
Author

In case anyone is interested, my usage pattern is a little different, but I have about the same functionality as @robertopiumatti's solution. Yet I still have the hang after a period of time, requiring reboot of the Raspberry Pi3 to resolve.

This script isn't all that clean and I admit it. But there are some good ideas in it as well.

# Remove hash on next line for debugging                    
#set -x                                                    
                                                           
export LANG=C                                              
export PATH="/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/bin:/sbin"
LOG=/tmp/rtl_433.log                                                      
                                                                          
touch $LOG                                                                
                                                                          
#                                                                         
# Start the listener and enter an endless loop
#                                             
rtl_433 -F json |  while read json            
do                                            
# Log to file if file exists.                 
  [ -w $LOG ] && echo $json >> $LOG           
                                   
  T=$( echo $json | \              
        jq -r '.model + "-" + (.id // 0 | tostring) + "-" + (.channel // 0 | tostring) | gsub("[^a-zA-Z0-9_-]"; "_")' )
                                                                                                                       
  # Raw message to MQTT                                                                                                
  echo $json | /usr/bin/mosquitto_pub -h 192.168.0.109 -u x -P yyy -i RTL_433 -l -t "homeassistant/rtl433/raw"       
                                                                                                                       
  echo $json | \                                                                                                       
    case $T in                                                                                                  
      Acurite*Sensor* | Nexus_Temperature*)                                                                     
        jq -c '{temperature: (.temperature_C * 9/5 + 32), battery: .battery, time: .time, model: .model}' | \   
          /usr/bin/mosquitto_pub -h 192.168.0.109 -u xx -P yyy -i RTL_433 -l -t "homeassistant/sensor/"$T   
        ;;                                                                                                   
                                                                                                             
      Generic_Remote*)                                                                                       
        echo $json | \                                                                                       
         jq -r '.cmd' | \                                                                                 
         /usr/bin/mosquitto_pub -h 192.168.0.109 -u xx -P yyy -i RTL_433 -l -t "homeassistant/remote/"$T
        ;;                                                                                               
                                                                                                         
      *)                                                                                                 
        ;;                                                                                               
    esac                                                                                                 
done

@yvesle
Copy link

yvesle commented Dec 27, 2019

@alanmimms you may want to check out my solution. It turns out rtl_433 can send its output to a mqtt broker natively !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants