WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: VCGENCMD not getting the temperature?  (Read 2627 times)

Offline A.T.E.

  • Newbie
  • *
  • Posts: 6
VCGENCMD not getting the temperature?
« on: December 31, 2023, 02:23:46 PM »
Hello,
I am using an Android app named RasPi Check to control my Raspberry Pis. This app is basically a SSH frontend that checks the status of the device and sends commands to it: https://github.com/eidottermihi/rpicheck
On one of them, a Raspberry Pi 2 B, I have just installed piCorePlayer. RasPi Check is able to connect to it, however it does not return some information like the CORE temperature, the ARM frequency, the CORE frequency, the CORE volt and the Firmware version.
The package rpi-vc.tcz is installed (otherwise the app would not work at all). And the app fully works if it connects to other systems like Raspbian, MoodeAudio or LibreELEC.
Is there any configuration that I should make or additional package that I should install?

Offline Paul_123

  • Administrator
  • Hero Member
  • *****
  • Posts: 1264
Re: VCGENCMD not getting the temperature?
« Reply #1 on: January 01, 2024, 01:29:04 PM »
What version of piCore are you running .

Code: [Select]
tc@Pi5:~$ sudo vcgencmd measure_temp
temp=51.0'C
tc@Pi5:~$ sudo vcgencmd measure_volts
volt=0.9084V

Offline A.T.E.

  • Newbie
  • *
  • Posts: 6
Re: VCGENCMD not getting the temperature?
« Reply #2 on: January 02, 2024, 10:24:57 AM »
Hello, I am running:

piCorePlayer v8.2.0
linux 5.15.35-pcpCore-v7 (32)
piCore v13.2

Then, I can manually run the commands:

Code: [Select]
tc@pCP:~$ sudo vcgencmd measure_temp
temp=37.9'C
tc@pCP:~$ sudo vcgencmd measure_volts
volt=1.2000V

However, RasPi Check still is not getting that information, if, in the app configuration, I put the tc password as the sudo password or if I leave it blank.

Offline Paul_123

  • Administrator
  • Hero Member
  • *****
  • Posts: 1264
Re: VCGENCMD not getting the temperature?
« Reply #3 on: January 02, 2024, 11:10:42 AM »
You cannot login with root.

The device /dev/vcio, is owned by root:root and is only user readable.  You can change the permissions of this file in your boot scripts.



Offline A.T.E.

  • Newbie
  • *
  • Posts: 6
Re: VCGENCMD not getting the temperature?
« Reply #4 on: January 02, 2024, 02:48:11 PM »
Well, does the below mean that in my case it is not user readable?

Code: [Select]
tc@pCP:~$ ls -ali /dev/vcio
    975 crw-------    1 root     root       10, 126 Jan  1  1970 /dev/vcio

Should I put somewhere (I am new to TinyCore, I shall find out where and what the boot script is) "chmod a+r /dev/vcio" ?

Offline Paul_123

  • Administrator
  • Hero Member
  • *****
  • Posts: 1264
Re: VCGENCMD not getting the temperature?
« Reply #5 on: January 03, 2024, 06:46:14 AM »
Yes.

/opt/bootlocal.sh

Offline A.T.E.

  • Newbie
  • *
  • Posts: 6
Re: VCGENCMD not getting the temperature?
« Reply #6 on: January 05, 2024, 04:19:21 PM »
Hello,
I have added the line

Code: [Select]
chmod a+r /dev/vcio
to /opt/bootlocal.sh and then I have run

Code: [Select]
filetool.sh -b
Yet, after the reboot, although /opt/bootlocal.sh contains the line I added at the bottom of it, it is still:

Code: [Select]
tc@pCP:~$ ls -ali /dev/vcio
    962 crw-------    1 root     root       10, 126 Jan  1  1970 /dev/vcio

On the other hand, if I manually run

Code: [Select]
sudo chmod a+r /dev/vcio
Then the permissions change

Code: [Select]
tc@pCP:~$ ls -ali /dev/vcio
    962 crw-r--r--    1 root     root       10, 126 Jan  1  1970 /dev/vcio

But still Raspi Check cannot get the temperature

Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11694
Re: VCGENCMD not getting the temperature?
« Reply #7 on: January 06, 2024, 12:24:56 AM »
Hi A.T.E.
... Yet, after the reboot, although /opt/bootlocal.sh contains the line I added at the bottom of it, it is still: ...
Maybe the device doesn't exist yet?

Try changing bootlocal.sh to this:
Code: [Select]
if  [ -c "/dev/vcio" ]
then
    echo "vcio found" > /home/tc/vcio.status
else
    echo "vcio not found" > /home/tc/vcio.status
fi

chmod 644 /dev/vcio

Run  filetool.sh -b  and reboot. Check the contents of  vcio.status
to see if the device existed when you tried to run chmod.

Offline A.T.E.

  • Newbie
  • *
  • Posts: 6
Re: VCGENCMD not getting the temperature?
« Reply #8 on: January 07, 2024, 04:05:41 PM »
Hello,
First of all, apologies as I had not correctly added the chmod line into /opt/bootlocal.sh (I had put it at the bottom of the script instead of putting it right after the line reading "# put other system startup commands here").
I have corrected that, and the if/fi condition creates now the /home/tc/vcio.status file which contains the line "vcio found".
And:
Code: [Select]
tc@pCP:~$ ls -ali /dev/vcio
    991 crw-r--r--    1 root     root       10, 126 Jan  1  1970 /dev/vcio
Yet the app RasPi Check is still unable to retrieve the temperature.

Offline Paul_123

  • Administrator
  • Hero Member
  • *****
  • Posts: 1264
Re: VCGENCMD not getting the temperature?
« Reply #9 on: January 07, 2024, 04:51:31 PM »
What are the exact commands being executed the the remote software?

Offline A.T.E.

  • Newbie
  • *
  • Posts: 6
Re: VCGENCMD not getting the temperature?
« Reply #10 on: January 10, 2024, 02:48:10 PM »
I don't know. I have tried to search the answer, and I have found this page: https://github.com/eidottermihi/rpicheck/issues/161 that incidentally gives some indications about what the app is doing.
Also, if vcgencmd is not present, the app gives an error message reading:
"The tool 'vcgencmd' was not found on your Pi. Make sure it is located under '/usr/bin' or '/opt/vc/bin' and your SSH user is in group 'video'."
In LibreELEC, on which the app is fully working, vcgencmd is like this:
Code: [Select]
LibreELEC:~ # which vcgencmd
/usr/bin/vcgencmd
LibreELEC:~ # ls -ali /usr/bin/vcgencmd
    556 -rwxr-xr-x    1 root     root         12196 Dec 20 05:55 /usr/bin/vcgencmd
LibreELEC:~ # ls -ali /dev/vcio
     86 crw-------    1 root     root       10, 127 Feb 16  2023 /dev/vcio
In LibreELEC, it is root that connects via SSH.
« Last Edit: January 10, 2024, 02:50:16 PM by A.T.E. »

Offline Paul_123

  • Administrator
  • Hero Member
  • *****
  • Posts: 1264
Re: VCGENCMD not getting the temperature?
« Reply #11 on: January 11, 2024, 10:11:36 PM »
We package software into /usr/local/bin

So you will need to create a symlink to /usr/bin

Offline CentralWare

  • Retired Admins
  • Hero Member
  • *****
  • Posts: 776
Re: VCGENCMD not getting the temperature?
« Reply #12 on: January 12, 2024, 02:40:54 AM »
@A.T.E.: I ran into a situation similar to this quite some time ago and I found that cheating was my only "easy option" to get past SSH and non-root user access.

1. Remove your recent chmod changes
2. in /opt/bootsync.sh BEFORE the line that reads /opt/bootlocal.sh & add:
Code: [Select]
mv /usr/bin/vcgencmd /usr/bin/new_vcgencmd
cat > /tmp/vcgencmd << EOF
#!/bin/sh
sudo /usr/bin/new_vcgencmd $@
EOF
mv /tmp/vcgencmd /usr/bin/
    Repeat as necessary for any apps/scripts/etc. which require root access
    filetool.sh -b when you're done to save the changes.

What we're basically doing is swapping out the original executable (vcgencmd) with a script that runs our now "new" executable with super-user (sudo) access.
With TinyCore, even if you logged into SSH as root, you'd still be sent back to the TC account once you've finished logging in, and since the TC account has Sudoer's access without needing a password, this was the only way I could find to do something similar to what you're after.