carsten_h wrote: 
> 
> I also don't know python, but I would make it the following way:
> > 
Code:
--------------------
  >   >         while True:
  >             temp = os.popen("vcgencmd measure_temp").readline()
  >             temp = temp.replace("temp=","")
  >             val = float(temp.replace("'C",""))
  >             fanconfig = load_config("/home/tc/argononed.conf")
  >             block = get_fanspeed(val, fanconfig)
  >             if block < prevblock:
  >                     time.sleep(30)
  >             prevblock = block
  >             try:
  >                     bus.write_byte(address,block)
  >             except IOError:
  >                     temp=""
  >             time.sleep(30)
  > 
--------------------
> > 
> 
> But I don't know what happens to the performance then, because every
> 30 seconds the file has to be opened, read and closed.
> You can try it. :-)

This works perfectly.  The argononed.conf file can now be edited while
the script is running, and the changes are applied on the fly.  In fact
I moved the whole fanconfig block inside the loop, so that the script
will continue to operate with the defaults even if the conf file is
deleted.


Code:
--------------------
    def temp_check():
  #     fanconfig = ["65=100", "60=55", "57=30", "55=10", "30=0"]
  #     tmpconfig = load_config("etc/argononed.conf")
  #     tmpconfig = load_config("/home/tc/argononed.conf")
  #     if len(tmpconfig) > 0:
  #             fanconfig = tmpconfig
        address=0x1a
        prevblock=0
        while True:
                fanconfig = ["65=100", "60=55", "57=30", "55=10", "30=0"]
                tmpconfig = load_config("/home/tc/argononed.conf")
                if len(tmpconfig) > 0:
                        fanconfig = tmpconfig
                temp = os.popen("vcgencmd measure_temp").readline()
                temp = temp.replace("temp=","")
                val = float(temp.replace("'C",""))
                block = get_fanspeed(val, fanconfig)
                if block < prevblock:
                        time.sleep(30)
                prevblock = block
                try:
                        bus.write_byte(address,block)
                except IOError:
                        temp=""
                time.sleep(30)
--------------------


This is useful for testing purposes - I changed the conf file to contain
a single entry, '35=100', and within 30 seconds the fan came on at 100%.
I renamed the conf file, and within 30 seconds the fan turned off again
in accordance with the defaults in the python script.


------------------------------------------------------------------------
chill's Profile: http://forums.slimdevices.com/member.php?userid=10839
View this thread: http://forums.slimdevices.com/showthread.php?t=113575

_______________________________________________
unix mailing list
[email protected]
http://lists.slimdevices.com/mailman/listinfo/unix

Reply via email to