Hello!

This is a new thread for the question how to use the fan and the
powerbutton of the Argon One case together with piCorePlayer.
Let's start at the beginning.

I want to use a Raspberry Pi 4 as a LMS server with the piCorePlayer
installation. This will be no problem.
I want to place this into this case:
https://www.argon40.com/catalog/product/view/id/52/s/argon-one-raspberry-pi-4-case/
This case has a software for using the Power-Button together with eg.
Raspbian.

Does anyone know if this software button will also work somehow together
with piCorePlayer? So is it possible to switch it off gracefully with
the button?
This case has also been available for older Raspberry Pi.

The script for the button and the fan can be found here (for Raspbian):
https://download.argon40.com/argon1.sh

FIRST PART: \"THE FAN\"

The installation of the script consists of a few different parts.
First it installs the following packages: "raspi-gpio python-rpi.gpio
python3-rpi.gpio python-smbus python3-smbus i2c-tools"
Then it creates a few files:
- daemonconfigfile (there are only temperatures and fan speeds in a
"table"
- shutdownscript (this will be called later from the daemon when the
button is pressed.
- powerbuttonscript (this is the script that will later run as a
daemon)
- daemonfanservice (this is the configfile for the service, it is placed
at: /lib/systemd/system/$daemonname.service)
- removescript (to remove the installation)
- configscript (to configure the reactions to different temperatures,
later it will write the daemonconfigfile)
At the end it starts the service via:

Code:
--------------------
    sudo systemctl daemon-reload
  sudo systemctl enable $daemonname.service
  sudo systemctl start $daemonname.service
--------------------


This is the part of the daemon for temperature checking and switching
the fan to the different speeds:

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


They are reading the temperature with "vcgencmd measure_temp" and if it
reaches the next step from the config they call this:

Code:
--------------------
    bus.write_byte(address,block)
--------------------


where address is 0x1a and block is the fanspeed from config.

I don't know what this bus.write_byte is doing. Maybe it is enough to
write this a single time to have the fan running always at the same
speed?

The fan is controlled via I2c as paul has written and bus.write... is
for writing to I2c.

Is it possible to write to I2c with piCorePlayer? So I can write one
byte at start to let the fan work in one defined speed.

paul- wrote: 
> Yes you can, we can probably run the scripts(Daemon) that they use.  You
> just can use the installation script.

SECOND PART: \"THE POWERBUTTON\"

Aldoszx wrote: 
> I also have this RPi4 case.
> From the script itself, i saw that: 'shutdown_pin=4'.
> I suppose that is the pin used for shutdown command.
> And, it must be pulled down: 'pull_up_down=GPIO.PUD_DOWN'

So I used this configuration in piCorePlayer:
29143
I pressed the button to create the script and it can be found in the
filesystem.

But what happens is that I get the following messages at startup:

Code:
--------------------
    Mounting USB Drives...
  Mounting USB Drive: 5D0B-9332...
  FUSE exfat 1.2.7
  WARN: volume was not unmounted cleanly.
  Disk Mounted at /mnt/LMS.
  Mounting USB Drive: 5E28-AD65...
  FUSE exfat 1.2.7
  WARN: volume was not unmounted cleanly.
  Disk Mounted at /mnt/Musikbox.
  Done.
--------------------


So the Pi was not correctly shutdown, as the filesystems are not clean.

Is there any possibility to see if the shutdown script is called when
switching off without an attached monitor? E.g. via looking at the
logfile via ssh or something like that?


+-------------------------------------------------------------------+
|Filename: Bildschirmfoto 2020-01-24 um 21.05.05.png                |
|Download: http://forums.slimdevices.com/attachment.php?attachmentid=29143|
+-------------------------------------------------------------------+

------------------------------------------------------------------------
carsten_h's Profile: http://forums.slimdevices.com/member.php?userid=69113
View this thread: http://forums.slimdevices.com/showthread.php?t=111546

_______________________________________________
unix mailing list
unix@lists.slimdevices.com
http://lists.slimdevices.com/mailman/listinfo/unix

Reply via email to