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

Huge delay on CLI #48

Closed
Zach443 opened this issue Aug 25, 2018 · 17 comments
Closed

Huge delay on CLI #48

Zach443 opened this issue Aug 25, 2018 · 17 comments
Labels
awaiting feedback When issue is blocked because feedback from submitter is requested

Comments

@Zach443
Copy link

Zach443 commented Aug 25, 2018

I have a Pi 1, so I'm not sure if this is the cause, but when using the CLI there is a 10-20 second delay on every command. Is this normal? The command output is normal, but the delay seems insane.

@timofurrer
Copy link
Owner

but when using the CLI there is a 10-20 second delay

Are you experiencing this delay when using the Python API, too? Or is it really just the CLI?

Are you using sudo when running the CLI tool? If so, can you do a sudo su and verify that it's not sudo which causes that delay.

If that's not the case, please set W1THERMSENSOR_NO_KERNEL_MODULE=1. Without this setting it'll always load the w1-gpio and w1-therm kernel modules when running the CLI.

@bsimmo
Copy link

bsimmo commented Aug 26, 2018 via email

@timofurrer
Copy link
Owner

hmmm, that's strange 🤔
Can you verify if the delay is coming from the modprobe?

Could you also do something like this:

from time import time
from w1thermsensor import W1ThermSensor

sensor = W1ThermSensor()
print(time())
sensor.raw_sensor_value
print(time())

If you are seeing the delay with this, too the problem might be when open / reading the file.

@Zach443
Copy link
Author

Zach443 commented Aug 26, 2018

For me, the delay is strictly with the CLI. Printing the reading to the console every second programmatically works just fine. The huge delay is only when using any operation with the CLI, whether that be a temp reading, listing available sensors, or anything else. I'm not totally sure by what you meant in your first response to do.

@timofurrer
Copy link
Owner

timofurrer commented Aug 27, 2018

Alright, please try:

W1THERMSENSOR_NO_KERNEL_MODULE=1 w1thermsensor get 1

do you see the delay here, too?

@bsimmo
Copy link

bsimmo commented Aug 27, 2018 via email

@Zach443
Copy link
Author

Zach443 commented Aug 31, 2018

@timofurrer Same delay with that command.

@timofurrer
Copy link
Owner

Could you please do:

sudo time ls -l /sys/bus/w1/devices

You'll see a directory for each sensor connected to your Pi. Once you spotted the right (maybe even the only) one, can you run the following: (whereas <THE_SENSOR_DIRECTORY> is the directory of your sensor)

sudo time cat /sys/bus/w1/devices/<THE_SENSOR_DIRECTORY>/w1_slave

Please post the output here, including the time infos.

@timofurrer
Copy link
Owner

@Zach443 could you give it a try already?

@bsimmo
Copy link

bsimmo commented Nov 1, 2018

sudo: time: command not found
For me

So no sudo as not needed.

Reading is fine, its the program it seems


pi@AIYTankPi:~ $ time w1thermsensor all
Got temperatures of 2 sensors:
Sensor 1 (031561e6d7ff) measured temperature: 21.0 celsius
Sensor 2 (031561dd98ff) measured temperature: 25.0 celsius

real 0m18.656s
user 0m12.725s
sys 0m0.271s


pi@AIYTankPi:~ $ time ls -l /sys/bus/w1/devices
total 0
lrwxrwxrwx 1 root root 0 Oct 24 12:18 28-031561dd98ff -> ../../../devices/w1_bus_master1/28-031561dd98ff
lrwxrwxrwx 1 root root 0 Oct 24 12:18 28-031561e6d7ff -> ../../../devices/w1_bus_master1/28-031561e6d7ff
lrwxrwxrwx 1 root root 0 Oct 24 12:17 w1_bus_master1 -> ../../../devices/w1_bus_master1

real 0m0.052s
user 0m0.012s
sys 0m0.019s


pi@AIYTankPi:~ $ time cat /sys/bus/w1/devices/28-031561dd98ff
cat: /sys/bus/w1/devices/28-031561dd98ff: Is a directory

real 0m0.022s
user 0m0.002s
sys 0m0.013s


pi@AIYTankPi:~ $ time cat /sys/bus/w1/devices/28-031561e6d7ff
cat: /sys/bus/w1/devices/28-031561e6d7ff: Is a directory

real 0m0.039s
user 0m0.012s
sys 0m0.000s
pi@AIYTankPi:~ $


@bsimmo
Copy link

bsimmo commented Nov 1, 2018

Just noticed I'm using 1.0.3 it seems
( python3-w1thermsensor/stable,now 1.0.3 all [installed] )
which is the one in apt , so cannot use anything newer as that the default installed version.

Could you update apt so we can use 1.0.5 and see if that fixes it?

@timofurrer
Copy link
Owner

Can you cat the file in the directory you've used?
In /sys/bus/w1/devices/28-031561e6d7ff there should be a sensor file.

@bsimmo
Copy link

bsimmo commented Nov 1, 2018

Do you mean

pi@AIYTankPi:~ $ cat /sys/bus/w1/devices/28-031561e6d7ff
cat: /sys/bus/w1/devices/28-031561e6d7ff: Is a directory

pi@AIYTankPi:~ $ cd /sys/bus/w1/devices/28-031561e6d7ff
pi@AIYTankPi:/sys/bus/w1/devices/28-031561e6d7ff $ ls
driver  hwmon  id  name  power  subsystem  uevent  w1_slave

pi@AIYTankPi:/sys/bus/w1/devices/28-031561e6d7ff $ cat w1_slave
68 01 01 01 1f ff 0c 10 ac : crc=ac YES
68 01 01 01 1f ff 0c 10 ac t=22500

pi@AIYTankPi:/sys/bus/w1/devices/28-031561e6d7ff $ time cat w1_slave
68 01 01 01 1f ff 0c 10 ac : crc=ac YES
68 01 01 01 1f ff 0c 10 ac t=22500

real    0m0.908s
user    0m0.002s
sys     0m0.038s

Time of <1s seems normal to me. As it should be .75s plus a bit

@timofurrer
Copy link
Owner

Could you update apt so we can use 1.0.5 and see if that fixes it?

Unfortunately, I don't do this apt syncing. I'll ask for the update though!

@timofurrer
Copy link
Owner

Seems pretty good. Can you try do the same from source, so you don't have to wait for apt to be updated with the newest release.

@bsimmo
Copy link

bsimmo commented Dec 14, 2018

Bump to remind me to check this (or the other chap @Zach443

@timofurrer timofurrer added the awaiting feedback When issue is blocked because feedback from submitter is requested label Feb 22, 2019
@timofurrer
Copy link
Owner

I'm going to close this, due to inactivity.
@Zach443 when you are ready with the feedback - I can re-open. 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting feedback When issue is blocked because feedback from submitter is requested
Projects
None yet
Development

No branches or pull requests

3 participants