TIMING
From
c186282@c186282@nnada.net to
comp.os.linux.misc on Mon Dec 22 02:38:20 2025
From Newsgroup: comp.os.linux.misc
Had been working on a little Py pgm to augment
my security cams ... some of which are USB
attached to mini-boxes/PIs.
Nice new app, uses Navy sunrise/sunset table (which
can be downloaded AS a super-nice/regular table !).
The idea is to have a 'day mode' and 'night mode'
with different brightness/contrast/etc settings.
The app runs a Day script or a Night script using
plain-Jane os.system()
BUT, there was a problem. The damned thing would not
set the cameras with v4l2 on unit reboot ... had to
wait at least 15 minutes.
Spent hours looking for a code fault, re-did
a few bits over and over.
Finally discovered it .... the app is started by
root crontab at reboot ... and it'd run BEFORE 'motion'
got up and running on the units. My app would set things,
and then 'motion' would start and set everything back
to defaults. By design, I'd have to wait 15 minutes
for my desired settings to kick in.
Solution ... put "time.sleep(30)" at the top of
the pgm. That gave 'motion' time to init and
THEN would fix the settings I wanted :-)
Irritating pgm alas ... need to check the Navy chart
every minute, but don't wanna reset v4L very often
unless there's been a big change. DST also gets
involved. Yea yea there are ways to deal by converting
everything to system time, but that winds up being a
lot more code. Ultimately it's (hour*60)+minute with
a DST fix and minimal day-rollover logic. A lot less
code. Not EVERYTHING needs to be millisecond perfect ...
And yes, I commented the hell out of it :-)
--- Synchronet 3.21a-Linux NewsLink 1.2