R
Rimmel
Guest
I wonder what the timeout is for the code to be called? e.g how long before it is decided that the usb stick is not being used.
As it is not a normal behaviour for an USB-stick to 'fall asleep', I think that that will be due to the firmware/hardware of the chipset in the pen. And hence also the duration of the period it manages to stay awake.
Good point - however that raises the question of why it never happened with ViX 2.1? As I am using exactly the same sticks (a lot of other report this as well).
I think the code was rather recently introduced in engima2 (i might be wrong).
Exactly so the firmware of the usb sticks shouldn't be of consideration.
Which code do you mean?I think the code was rather recently introduced in engima2 (i might be wrong).
Well, of course that mathers to. Otherwise all would share the same problem. For example the following usb stick
256 MB Kingston Technology DataTraveler II+ Pen Drive just ignores the command and does nothing.
My point was... why add the command in the first place?
Which code do you mean?
# the HDD idle poll daemon.
# as some harddrives have a buggy standby timer, we are doing this by hand here.
# first, we disable the hardware timer. then, we check every now and then if
# any access has been made to the disc. If there has been no access over a specifed time,
# we set the hdd into standby.
def readStats(self):
try:
l = open("/sys/block/%s/stat" % self.device).read()
except IOError:
return -1,-1
data = l.split(None,5)
return (int(data[0]), int(data[4]))
def startIdle(self):
self.last_access = time.time()
self.last_stat = 0
self.is_sleeping = False
from enigma import eTimer
# disable HDD standby timer
if self.bus() == "External":
Console().ePopen(("sdparm", "sdparm", "--set=SCT=0", self.disk_path))
else:
Console().ePopen(("hdparm", "hdparm", "-S0", self.disk_path))
self.timer = eTimer()
self.timer.callback.append(self.runIdle)
self.idle_running = True
self.setIdleTime(self.max_idle_time) # kick the idle polling loop
def runIdle(self):
if not self.max_idle_time:
return
t = time.time()
idle_time = t - self.last_access
stats = self.readStats()
l = sum(stats)
if l != self.last_stat and l >= 0: # access
self.last_stat = l
self.last_access = t
idle_time = 0
self.is_sleeping = False
if idle_time >= self.max_idle_time and not self.is_sleeping:
self.setSleep()
self.is_sleeping = True
def setSleep(self):
if self.bus() == "External":
Console().ePopen(("sdparm", "sdparm", "--flexible", "--readonly", "--command=stop", self.disk_path))
else:
Console().ePopen(("hdparm", "hdparm", "-y", self.disk_path))
def setIdleTime(self, idle):
self.max_idle_time = idle
if self.idle_running:
if not idle:
self.timer.stop()
else:
else:
self.timer.start(idle * 100, False) # poll 10 times per period.
def isSleeping(self):
return self.is_sleeping