1 <?xml version=
"1.0" encoding=
"utf-8"?>
2 <rss version='
2.0' xmlns:lj='http://www.livejournal.org/rss/lj/
1.0/' xmlns:
atom=
"http://www.w3.org/2005/Atom">
4 <title>Petter Reinholdtsen
</title>
5 <description></description>
6 <link>https://people.skolelinux.org/pere/blog/
</link>
7 <atom:link href=
"https://people.skolelinux.org/pere/blog/index.rss" rel=
"self" type=
"application/rss+xml" />
10 <title>Speech to text, she APTly whispered, how hard can it be?
</title>
11 <link>https://people.skolelinux.org/pere/blog/Speech_to_text__she_APTly_whispered__how_hard_can_it_be_.html
</link>
12 <guid isPermaLink=
"true">https://people.skolelinux.org/pere/blog/Speech_to_text__she_APTly_whispered__how_hard_can_it_be_.html
</guid>
13 <pubDate>Sun,
23 Apr
2023 09:
40:
00 +
0200</pubDate>
14 <description><p
>While visiting a convention during Eastern, it occurred to me that
15 it would be great if I could have a digital Dictaphone with
16 transcribing capabilities, providing me with texts to cut-n-paste into
17 stuff I need to write. The background is that long drives often bring
18 up the urge to write on texts I am working on, which of course is out
19 of the question while driving. With the release of
20 <a href=
"https://github.com/openai/whisper/
">OpenAI Whisper
</a
>, this
21 seem to be within reach with Free Software, so I decided to give it a
22 go. OpenAI Whisper is a Linux based neural network system to read in
23 audio files and provide text representation of the speech in that
24 audio recording. It handle multiple languages and according to its
25 creators even can translate into a different language than the spoken
26 one. I have not tested the latter feature. It can either use the CPU
27 or a GPU with CODA support. As far as I can tell, CODA in practice
28 limit that feature to NVidia graphics cards. I have few of those, as
29 they do not work great with free software drivers, and have not tested
30 the GPU option. While looking into the matter, I did discover some
31 work to provide CODA support on non-NVidia GPUs, and some work with
32 the library used by Whisper to port it to other GPUs, but have not
33 spent much time looking into GPU support yet. I
've so far used an old
34 X220 laptop as my test machine, and only transcribed using its
37 <p
>As it from a privacy standpoint is unthinkable to use computers
38 under control of someone else (aka a
"cloud
" service) to transcribe
39 ones thoughts and personal notes, I want to run the transcribing
40 system locally on my own computers. The only sensible approach to me
41 is to make the effort I put into this available for any Linux user and
42 to upload the needed packages into Debian. Looking at Debian Bookworm, I
43 discovered that only three packages were missing,
44 <a href=
"https://bugs.debian.org/
1034307">tiktoken
</a
>,
45 <a href=
"https://bugs.debian.org/
1034144">triton
</a
>, and
46 <a href=
"https://bugs.debian.org/
1034091">openai-whisper
</a
>. For a while
48 <a href=
"https://bugs.debian.org/
1034286">ffmpeg-python
</a
> was
50 <a href=
"https://github.com/kkroening/ffmpeg-python/issues/
760">upstream
51 seem to have vanished
</a
> I found it safer
52 <a href=
"https://github.com/openai/whisper/pull/
1242">to rewrite
53 whisper
</a
> to stop depending on in than to introduce ffmpeg-python
54 into Debian. I decided to place these packages under the umbrella of
55 <a href=
"https://salsa.debian.org/deeplearning-team
">the Debian Deep
56 Learning Team
</a
>, which seem like the best team to look after such
57 packages. Discussing the topic within the group also made me aware
58 that the triton package was already a future dependency of newer
59 versions of the torch package being planned, and would be needed after
60 Bookworm is released.
</p
>
62 <p
>All required code packages have been now waiting in
63 <a href=
"https://ftp-master.debian.org/new.html
">the Debian NEW
64 queue
</a
> since Wednesday, heading for Debian Experimental until
65 Bookworm is released. An unsolved issue is how to handle the neural
66 network models used by Whisper. The default behaviour of Whisper is
67 to require Internet connectivity and download the model requested to
68 <tt
>~/.cache/whisper/
</tt
> on first invocation. This obviously would
69 fail
<a href=
"https://people.debian.org/~bap/dfsg-faq.html
">the
70 deserted island test of free software
</a
> as the Debian packages would
71 be unusable for someone stranded with only the Debian archive and solar
72 powered computer on a deserted island.
</p
>
74 <p
>Because of this, I would love to include the models in the Debian
75 mirror system. This is problematic, as the models are very large
76 files, which would put a heavy strain on the Debian mirror
77 infrastructure around the globe. The strain would be even higher if
78 the models change often, which luckily as far as I can tell they do
79 not. The small model, which according to its creator is most useful
80 for English and in my experience is not doing a great job there
81 either, is
462 MiB (deb is
414 MiB). The medium model, which to me
82 seem to handle English speech fairly well is
1.5 GiB (deb is
1.3 GiB)
83 and the large model is
2.9 GiB (deb is
2.6 GiB). I would assume
84 everyone with enough resources would prefer to use the large model for
85 highest quality. I believe the models themselves would have to go
86 into the non-free part of the Debian archive, as they are not really
87 including any useful source code for updating the models. The
88 "source
", aka the model training set, according to the creators
89 consist of
"680,
000 hours of multilingual and multitask supervised
90 data collected from the web
", which to me reads material with both
91 unknown copyright terms, unavailable to the general public. In other
92 words, the source is not available according to the Debian Free
93 Software Guidelines and the model should be considered non-free.
</p
>
95 <p
>I asked the Debian FTP masters for advice regarding uploading a
96 model package on their IRC channel, and based on the feedback there it
97 is still unclear to me if such package would be accepted into the
98 archive. In any case I wrote build rules for a
99 <a href=
"https://salsa.debian.org/deeplearning-team/openai-whisper-model
">OpenAI
100 Whisper model package
</a
> and
101 <a href=
"https://github.com/openai/whisper/pull/
1257">modified the
102 Whisper code base
</a
> to prefer shared files under
<tt
>/usr/
</tt
> and
103 <tt
>/var/
</tt
> over user specific files in
<tt
>~/.cache/whisper/
</tt
>
104 to be able to use these model packages, to prepare for such
105 possibility. One solution might be to include only one of the models
106 (small or medium, I guess) in the Debian archive, and ask people to
107 download the others from the Internet. Not quite sure what to do
108 here, and advice is most welcome (use the debian-ai mailing list).
</p
>
110 <p
>To make it easier to test the new packages while I wait for them to
111 clear the NEW queue, I created an APT source targeting bookworm. I
112 selected Bookworm instead of Bullseye, even though I know the latter
113 would reach more users, is that some of the required dependencies are
114 missing from Bullseye and I during this phase of testing did not want
115 to backport a lot of packages just to get up and running.
</p
>
117 <p
>Here is a recipe to run as user root if you want to test OpenAI
118 Whisper using Debian packages on your Debian Bookworm installation,
119 first adding the APT repository GPG key to the list of trusted keys,
120 then setting up the APT repository and finally installing the packages
121 and one of the models:
</p
>
124 curl https://geekbay.nuug.no/~pere/openai-whisper/D78F5C4796F353D211B119E28200D9B589641240.asc \
125 -o /etc/apt/trusted.gpg.d/pere-whisper.asc
126 mkdir -p /etc/apt/sources.list.d
127 cat
> /etc/apt/sources.list.d/pere-whisper.list
&lt;
&lt;EOF
128 deb https://geekbay.nuug.no/~pere/openai-whisper/ bookworm main
129 deb-src https://geekbay.nuug.no/~pere/openai-whisper/ bookworm main
132 apt install openai-whisper
133 </pre
></p
>
135 <p
>The package work for me, but have not yet been tested on any other
136 computer than my own. With it, I have been able to (badly) transcribe
137 a
2 minute
40 second Norwegian audio clip to test using the small
138 model. This took
11 minutes and around
2.2 GiB of RAM. Transcribing
139 the same file with the medium model gave a accurate text in
77 minutes
140 using around
5.2 GiB of RAM. My test machine had too little memory to
141 test the large model, which I believe require
11 GiB of RAM. In
142 short, this now work for me using Debian packages, and I hope it will
143 for you and everyone else once the packages enter Debian.
</p
>
145 <p
>Now I can start on the audio recording part of this project.
</p
>
147 <p
>As usual, if you use Bitcoin and want to show your support of my
148 activities, please send Bitcoin donations to my address
149 <b
><a href=
"bitcoin:
15oWEoG9dUPovwmUL9KWAnYRtNJEkP1u1b
">15oWEoG9dUPovwmUL9KWAnYRtNJEkP1u1b
</a
></b
>.
</p
>
154 <title>rtlsdr-scanner, software defined radio frequency scanner for Linux - nice free software
</title>
155 <link>https://people.skolelinux.org/pere/blog/rtlsdr_scanner__software_defined_radio_frequency_scanner_for_Linux____nice_free_software.html
</link>
156 <guid isPermaLink=
"true">https://people.skolelinux.org/pere/blog/rtlsdr_scanner__software_defined_radio_frequency_scanner_for_Linux____nice_free_software.html
</guid>
157 <pubDate>Fri,
7 Apr
2023 23:
10:
00 +
0200</pubDate>
158 <description><p
>Today I finally found time to track down a useful radio frequency
159 scanner for my software defined radio. Just for fun I tried to locate
160 the radios used in the areas, and a good start would be to scan all
161 the frequencies to see what is in use. I
've tried to find a useful
162 program earlier, but ran out of time before I managed to find a useful
163 tool. This time I was more successful, and after a few false leads I
164 found a description of
165 <a href=
"https://www.kali.org/tools/rtlsdr-scanner/
">rtlsdr-scanner
166 over at the Kali site
</a
>, and was able to track down
167 <a href=
"https://gitlab.com/kalilinux/packages/rtlsdr-scanner.git
">the
168 Kali package git repository
</a
> to build a deb package for the
169 scanner. Sadly the package is missing from the Debian project itself,
170 at least in Debian Bullseye. Two runtime dependencies,
171 <a href=
"https://gitlab.com/kalilinux/packages/python-visvis.git
">python-visvis
</a
>
173 <a href=
"https://gitlab.com/kalilinux/packages/python-rtlsdr.git
">python-rtlsdr
</a
>
174 had to be built and installed separately. Luckily
'<tt
>gbp
175 buildpackage
</tt
>' handled them just fine and no further packages had
176 to be manually built. The end result worked out of the box after
177 installation.
</p
>
179 <p
>My initial scans for FM channels worked just fine, so I knew the
180 scanner was functioning. But when I tried to scan every frequency
181 from
100 to
1000 MHz, the program stopped unexpectedly near the
182 completion. After some debugging I discovered USB software radio I
183 used rejected frequencies above
948 MHz, triggering a unreported
184 exception breaking the scan. Changing the scan to end at
957 worked
185 better. I similarly found the lower limit to be around
15, and ended
186 up with the following full scan:
</p
>
188 <p
><a href=
"https://people.skolelinux.org/pere/blog/images/
2023-
04-
07-radio-freq-scanning.png
"><img src=
"https://people.skolelinux.org/pere/blog/images/
2023-
04-
07-radio-freq-scanning.png
" width=
"100%
"></a
></p
>
190 <p
>Saving the scan did not work, but exporting it as a CSV file worked
191 just fine. I ended up with around
477k CVS lines with dB level for
192 the given frequency.
</p
>
194 <p
>The save failure seem to be a missing UTF-
8 encoding issue in the
195 python code. Will see if I can find time to send a patch
196 <a href=
"https://github.com/CdeMills/RTLSDR-Scanner/
">upstream
</a
>
197 later to fix this exception:
</p
>
200 Traceback (most recent call last):
201 File
"/usr/lib/python3/dist-packages/rtlsdr_scanner/main_window.py
", line
485, in __on_save
202 save_plot(fullName, self.scanInfo, self.spectrum, self.locations)
203 File
"/usr/lib/python3/dist-packages/rtlsdr_scanner/file.py
", line
408, in save_plot
204 handle.write(json.dumps(data, indent=
4))
205 TypeError: a bytes-like object is required, not
'str
'
206 Traceback (most recent call last):
207 File
"/usr/lib/python3/dist-packages/rtlsdr_scanner/main_window.py
", line
485, in __on_save
208 save_plot(fullName, self.scanInfo, self.spectrum, self.locations)
209 File
"/usr/lib/python3/dist-packages/rtlsdr_scanner/file.py
", line
408, in save_plot
210 handle.write(json.dumps(data, indent=
4))
211 TypeError: a bytes-like object is required, not
'str
'
214 <p
>As usual, if you use Bitcoin and want to show your support of my
215 activities, please send Bitcoin donations to my address
216 <b
><a href=
"bitcoin:
15oWEoG9dUPovwmUL9KWAnYRtNJEkP1u1b
">15oWEoG9dUPovwmUL9KWAnYRtNJEkP1u1b
</a
></b
>.
</p
>
221 <title>OpenSnitch available in Debian Sid and Bookworm
</title>
222 <link>https://people.skolelinux.org/pere/blog/OpenSnitch_available_in_Debian_Sid_and_Bookworm.html
</link>
223 <guid isPermaLink=
"true">https://people.skolelinux.org/pere/blog/OpenSnitch_available_in_Debian_Sid_and_Bookworm.html
</guid>
224 <pubDate>Sat,
25 Feb
2023 20:
30:
00 +
0100</pubDate>
225 <description><p
>Thanks to the efforts of the OpenSnitch lead developer Gustavo
226 Iñiguez Goya allowing me to sponsor the upload,
227 <a href=
"https://tracker.debian.org/pkg/opensnitch
">the interactive
228 application firewall OpenSnitch
</a
> is now available in Debian
229 Testing, soon to become the next stable release of Debian.
</p
>
231 <p
>This is a package which set up a network firewall on one or more
232 machines, which is controlled by a graphical user interface that will
233 ask the user if a program should be allowed to connect to the local
234 network or the Internet. If some background daemon is trying to dial
235 home, it can be blocked from doing so with a simple mouse click, or by
236 default simply by not doing anything when the GUI question dialog pop
237 up. A list of all programs discovered using the network is provided
238 in the GUI, giving the user an overview of how the machine(s) programs
239 use the network.
</p
>
241 <p
>OpenSnitch was uploaded for NEW processing about a month ago, and I
242 had little hope of it getting accepted and shaping up in time for the
243 package freeze, but the Debian ftpmasters proved to be amazingly quick
244 at checking out the package and it was accepted into the archive about
245 week after the first upload. It is now team maintained under the Go
246 language team umbrella. A few fixes to the default setup is only in
247 Sid, and should migrate to Testing/Bookworm in a week.
</p
>
249 <p
>During testing I ran into an
250 <a href=
"https://github.com/evilsocket/opensnitch/issues/
813">issue
251 with Minecraft server broadcasts disappearing
</a
>, which was quickly
252 resolved by the developer with a patch and a proposed configuration
253 change. I
've been told this was caused by the Debian packages default
254 use if /proc/ information to track down kernel status, instead of the
255 newer eBPF module that can be used. The reason is simply that
256 upstream and I have failed to find a way to build the eBPF modules for
257 OpenSnitch without a complete configured Linux kernel source tree,
258 which as far as we can tell is unavailable as a build dependency in
259 Debian. We tried unsuccessfully so far to use the kernel-headers
260 package. It would be great if someone could provide some clues how to
261 build eBPF modules on build daemons in Debian, possibly without the full
262 kernel source.
</p
>
264 <p
>As usual, if you use Bitcoin and want to show your support of my
265 activities, please send Bitcoin donations to my address
266 <b
><a href=
"bitcoin:
15oWEoG9dUPovwmUL9KWAnYRtNJEkP1u1b
">15oWEoG9dUPovwmUL9KWAnYRtNJEkP1u1b
</a
></b
>.
</p
>
271 <title>Is the desktop recommending your program for opening its files?
</title>
272 <link>https://people.skolelinux.org/pere/blog/Is_the_desktop_recommending_your_program_for_opening_its_files_.html
</link>
273 <guid isPermaLink=
"true">https://people.skolelinux.org/pere/blog/Is_the_desktop_recommending_your_program_for_opening_its_files_.html
</guid>
274 <pubDate>Sun,
29 Jan
2023 11:
00:
00 +
0100</pubDate>
275 <description><p
>Linux desktop systems
276 <a href=
"https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html
">have
277 standardized
</a
> how programs present themselves to the desktop
278 system. If a package include a .desktop file in
279 /usr/share/applications/, Gnome, KDE, LXDE, Xfce and the other desktop
280 environments will pick up the file and use its content to generate the
281 menu of available programs in the system. A lesser known fact is that
282 a package can also explain to the desktop system how to recognize the
283 files created by the program in question, and use it to open these
284 files on request, for example via a GUI file browser.
</p
>
286 <p
>A while back I ran into a package that did not tell the desktop
287 system how to recognize its files and was not used to open its files
288 in the file browser and fixed it. In the process I wrote a simple
289 debian/tests/ script to ensure the setup keep working. It might be
290 useful for other packages too, to ensure any future version of the
291 package keep handling its own files.
</p
>
293 <p
>For this to work the file format need a useful MIME type that can
294 be used to identify the format. If the file format do not yet have a
295 MIME type, it should define one and preferably also
296 <a href=
"https://www.iana.org/assignments/media-types/media-types.xhtml
">register
297 it with IANA
</a
> to ensure the MIME type string is reserved.
</p
>
299 <p
>The script uses the
<tt
>xdg-mime
</tt
> program from xdg-utils to
300 query the database of standardized package information and ensure it
301 return sensible values. It also need the location of an example file
302 for xdg-mime to guess the format of.
</p
>
307 # Author: Petter Reinholdtsen
308 # License: GPL v2 or later at your choice.
310 # Validate the MIME setup, making sure motor types have
311 # application/vnd.openmotor+yaml associated with them and is connected
312 # to the openmotor desktop file.
316 mimetype=
"application/vnd.openmotor+yaml
"
317 testfile=
"test/data/real/o3100/motor.ric
"
318 mydesktopfile=
"openmotor.desktop
"
320 filemime=
"$(xdg-mime query filetype
"$testfile
")
"
322 if [
"$mimetype
" !=
"$filemime
" ] ; then
324 echo
"error: xdg-mime claim motor file MIME type is $filemine, not $mimetype
"
326 echo
"success: xdg-mime report correct mime type $mimetype for motor file
"
329 desktop=$(xdg-mime query default
"$mimetype
")
331 if [
"$mydesktopfile
" !=
"$desktop
" ]; then
333 echo
"error: xdg-mime claim motor file should be handled by $desktop, not $mydesktopfile
"
335 echo
"success: xdg-mime agree motor file should be handled by $mydesktopfile
"
341 <p
>It is a simple way to ensure your users are not very surprised when
342 they try to open one of your file formats in their file browser.
</p
>
344 <p
>As usual, if you use Bitcoin and want to show your support of my
345 activities, please send Bitcoin donations to my address
346 <b
><a href=
"bitcoin:
15oWEoG9dUPovwmUL9KWAnYRtNJEkP1u1b
">15oWEoG9dUPovwmUL9KWAnYRtNJEkP1u1b
</a
></b
>.
</p
>
351 <title>Opensnitch, the application level interactive firewall, heading into the Debian archive
</title>
352 <link>https://people.skolelinux.org/pere/blog/Opensnitch__the_application_level_interactive_firewall__heading_into_the_Debian_archive.html
</link>
353 <guid isPermaLink=
"true">https://people.skolelinux.org/pere/blog/Opensnitch__the_application_level_interactive_firewall__heading_into_the_Debian_archive.html
</guid>
354 <pubDate>Sun,
22 Jan
2023 23:
55:
00 +
0100</pubDate>
355 <description><p
>While reading a
356 <a href=
"https://sneak.berlin/
20230115/macos-scans-your-local-files-now/
">blog
357 post claiming MacOS X recently started scanning local files and
358 reporting information about them to Apple
</a
>, even on a machine where
359 all such callback features had been disabled, I came across a
360 description of the Little Snitch application for MacOS X. It seemed
361 like a very nice tool to have in the tool box, and I decided to see if
362 something similar was available for Linux.
</p
>
364 <p
>It did not take long to find
365 <a href=
"https://github.com/evilsocket/opensnitch
">the OpenSnitch
366 package
</a
>, which has been in development since
2017, and now is in
367 version
1.5.0. It has had a
368 <a href=
"https://bugs.debian.org/
909567">request for Debian
369 packaging
</a
> since
2018, but no-one completed the job so far. Just
370 for fun, I decided to see if I could help, and I was very happy to
372 <a href=
"https://github.com/evilsocket/opensnitch/issues/
304">upstream
373 want a Debian package too
</a
>.
</p
>
375 <p
>After struggling a bit with getting the program to run, figuring
376 out building Go programs (and a little failed detour to look at eBPF
377 builds too - help needed), I am very happy to report that I am
378 sponsoring upstream to maintain the package in Debian, and it has
379 since this morning been waiting in NEW for the ftpmasters to have a
380 look. Perhaps it can get into the archive in time for the Bookworm
383 <p
>As usual, if you use Bitcoin and want to show your support of my
384 activities, please send Bitcoin donations to my address
385 <b
><a href=
"bitcoin:
15oWEoG9dUPovwmUL9KWAnYRtNJEkP1u1b
">15oWEoG9dUPovwmUL9KWAnYRtNJEkP1u1b
</a
></b
>.
</p
>
390 <title>LinuxCNC MQTT publisher component
</title>
391 <link>https://people.skolelinux.org/pere/blog/LinuxCNC_MQTT_publisher_component.html
</link>
392 <guid isPermaLink=
"true">https://people.skolelinux.org/pere/blog/LinuxCNC_MQTT_publisher_component.html
</guid>
393 <pubDate>Sun,
8 Jan
2023 19:
30:
00 +
0100</pubDate>
394 <description><p
>I watched
<a href=
"https://yewtu.be/watch?v=jmKUV3aNLjk
">a
2015
395 video from Andreas Schiffler
</a
> the other day, where he set up
396 <a href=
"https://linuxcnc.org/
">LinuxCNC
</a
> to send status
397 information to the MQTT broker IBM Bluemix. As I also use MQTT for
398 graphing, it occured to me that a generic MQTT LinuxCNC component
399 would be useful and I set out to implement it. Today I got the first
400 draft limping along and submitted as
401 <a href=
"https://github.com/LinuxCNC/linuxcnc/pull/
2253">a patch to the
402 LinuxCNC project
</a
>.
</p
>
404 <p
>The simple part was setting up the MQTT publishing code in Python.
405 I already have set up other parts submitting data to my Mosquito MQTT
406 broker, so I could reuse that code. Writing a LinuxCNC component in
407 Python as new to me, but using existing examples in the code
408 repository and the extensive documentation, this was fairly straight
409 forward. The hardest part was creating a automated test for the
410 component to ensure it was working. Testing it in a simulated
411 LinuxCNC machine proved very useful, as I discovered features I needed
412 that I had not thought of yet, and adjusted the code quite a bit to
413 make it easier to test without a operational MQTT broker
416 <p
>The draft is ready and working, but I am unsure which LinuxCNC HAL
417 pins I should collect and publish by default (in other words, the
418 default set of information pieces published), and how to get the
419 machine name from the LinuxCNC INI file. The latter is a minor
420 detail, but I expect it would be useful in a setup with several
421 machines available. I am hoping for feedback from the experienced
422 LinuxCNC developers and users, to make the component even better
423 before it can go into the mainland LinuxCNC code base.
</p
>
425 <p
>Since I started on the MQTT component, I came across
426 <a href=
"https://yewtu.be/watch?v=Bqa2grG0XtA
">another video from Kent
427 VanderVelden
</a
> where he combine LinuxCNC with a set of screen glasses
428 controlled by a Raspberry Pi, and it occured to me that it would
429 be useful for such use cases if LinuxCNC also provided a REST API for
430 querying its status. I hope to start on such component once the MQTT
431 component is working well.
</p
>
433 <p
>As usual, if you use Bitcoin and want to show your support of my
434 activities, please send Bitcoin donations to my address
435 <b
><a href=
"bitcoin:
15oWEoG9dUPovwmUL9KWAnYRtNJEkP1u1b
">15oWEoG9dUPovwmUL9KWAnYRtNJEkP1u1b
</a
></b
>.
</p
>
440 <title>ONVIF IP camera management tool finally in Debian
</title>
441 <link>https://people.skolelinux.org/pere/blog/ONVIF_IP_camera_management_tool_finally_in_Debian.html
</link>
442 <guid isPermaLink=
"true">https://people.skolelinux.org/pere/blog/ONVIF_IP_camera_management_tool_finally_in_Debian.html
</guid>
443 <pubDate>Sat,
24 Dec
2022 08:
00:
00 +
0100</pubDate>
444 <description><p
>Merry Christmas to you all. Here is a small gift to all those with
445 IP cameras following the
<a href=
"https://www.onvif.org/
">ONVIF
446 specification
</a
>. There is finally a nice command line and GUI tool
447 in Debian to manage ONVIF IP cameras. After working with upstream for
448 a few months and sponsoring the upload, I am very happy to report that
449 the
<a href=
"https://tracker.debian.org/libonvif
">libonvif package
</a
>
450 entered Debian Sid last night.
</p
>
452 <p
>The package provide a C library to communicate with such cameras, a
453 command line tool to locate and update settings of (like password) the
454 cameras and a GUI tool to configure and control the units as well as
455 preview the video from the camera. Libonvif is available on Both
456 Linux and Windows and the GUI tool uses the Qt library. The main
457 competitors are non-free software, while libonvif is GNU GPL licensed.
458 I am very glad Debian users in the future can control their cameras
459 using a free software system provided by Debian. But the ONVIF world
460 is full of slightly broken firmware, where the cameras pretend to
461 follow the ONVIF specification but fail to set some configuration
462 values or refuse to provide video to more than one recipient at the
463 time, and the onvif project is quite young and might take a while
464 before it completely work with your camera. Upstream seem eager to
465 improve the library, so handling any broken camera might be just
<a
466 href=
"https://github.com/sr99622/libonvif/
">a bug report away
</a
>.
</p
>
468 <p
>The package just cleared NEW, and need a new source only upload
469 before it can enter testing. This will happen in the next few
472 <p
>As usual, if you use Bitcoin and want to show your support of my
473 activities, please send Bitcoin donations to my address
474 <b
><a href=
"bitcoin:
15oWEoG9dUPovwmUL9KWAnYRtNJEkP1u1b
">15oWEoG9dUPovwmUL9KWAnYRtNJEkP1u1b
</a
></b
>.
</p
>
479 <title>Managing and using ONVIF IP cameras with Linux
</title>
480 <link>https://people.skolelinux.org/pere/blog/Managing_and_using_ONVIF_IP_cameras_with_Linux.html
</link>
481 <guid isPermaLink=
"true">https://people.skolelinux.org/pere/blog/Managing_and_using_ONVIF_IP_cameras_with_Linux.html
</guid>
482 <pubDate>Wed,
19 Oct
2022 12:
30:
00 +
0200</pubDate>
483 <description><p
>Recently I have been looking at how to control and collect data
484 from a handful IP cameras using Linux. I both wanted to change their
485 settings and to make their imagery available via a free software
486 service under my control. Here is a summary of the tools I found.
</p
>
488 <p
>First I had to identify the cameras and their protocols. As far as
489 I could tell, they were using some SOAP looking protocol and their
490 internal web server seem to only work with Microsoft Internet Explorer
491 with some proprietary binary plugin, which in these days of course is
492 a security disaster and also made it impossible for me to use the
493 camera web interface. Luckily I discovered that the SOAP looking
494 protocol is actually following
<a href=
"https://www.onvif.org/
">the
495 ONVIF specification
</a
>, which seem to be supported by a lot of IP
496 cameras these days.
</p
>
498 <p
>Once the protocol was identified, I was able to find what appear to
499 be the most popular way to configure ONVIF cameras, the free software
501 <a href=
"https://sourceforge.net/projects/onvifdm/
">ONVIF Device
502 Manager
</a
>. Lacking any other options at the time, I tried
503 unsuccessfully to get it running using Wine, but was missing a dotnet
504 40 library and I found no way around it to run it on Linux.
</p
>
506 <p
>The next tool I found to configure the cameras were a non-free Linux Qt
507 client
<a href=
"https://www.lingodigit.com/onvif_nvcdemo.html
">ONVIF
508 Device Tool
</a
>. I did not like its terms of use, so did not spend
509 much time on it.
</p
>
511 <p
>To collect the video and make it available in a web interface, I
512 found the Zoneminder tool in Debian. A recent version was able to
513 automatically detect and configure ONVIF devices, so I could use it to
514 set up motion detection in and collection of the camera output. I had
515 initial problems getting the ONVIF autodetection to work, as both
516 Firefox and Chromium
<a href=
"https://bugs.debian.org/
1001188">refused
517 the inter-tab communication
</a
> being used by the Zoneminder web
518 pages, but managed to get konqueror to work. Apparently the
"Enhanced
519 Tracking Protection
" in Firefox cause the problem. I ended up
520 upgrading to the Bookworm edition of Zoneminder in the process to try
521 to fix the issue, and believe the problem might be solved now.
</p
>
523 <p
>In the process I came across the nice Linux GUI tool
524 <a href=
"https://gitlab.com/caspermeijn/onvifviewer/
">ONVIF Viewer
</a
>
525 allowing me to preview the camera output and validate the login
526 passwords required. Sadly its author has grown tired of maintaining
527 the software, so it might not see any future updates. Which is sad,
528 as the viewer is sightly unstable and the picture tend to lock up.
529 Note, this lockup might be due to limitations in the cameras and not
530 the viewer implementation. I suspect the camera is only able to
531 provide pictures to one client at the time, and the Zoneminder feed
532 might interfere with the GUI viewer. I have
533 <a href=
"https://bugs.debian.org/
1000820">asked for the tool to be
534 included in Debian
</a
>.
</p
>
536 <p
>Finally, I found what appear to be very nice Linux free software
537 replacement for the Windows tool, named
538 <a href=
"https://github.com/sr99622/libonvif/
">libonvif
</a
>. It
539 provide a C library to talk to ONVIF devices as well as a command line
540 and GUI tool using the library. Using the GUI tool I was able to change
541 the admin passwords and update other settings of the cameras. I have
542 <a href=
"https://bugs.debian.org/
1021980">asked for the package to be
543 included in Debian
</a
>.
</p
>
545 <p
>As usual, if you use Bitcoin and want to show your support of my
546 activities, please send Bitcoin donations to my address
547 <b
><a href=
"bitcoin:
15oWEoG9dUPovwmUL9KWAnYRtNJEkP1u1b
">15oWEoG9dUPovwmUL9KWAnYRtNJEkP1u1b
</a
></b
>.
</p
>
549 <p
><strong
>Update
2022-
10-
20</strong
>: Since my initial publication of
550 this text, I got several suggestions for more free software Linux
551 tools. There is
<a href=
"https://github.com/quatanium/python-onvif
">a
552 ONVIF python library
</a
> (already
553 <a href=
"https://bugs.debian.org/
824240">requested into Debian
</a
>) and
554 <a href=
"https://github.com/FalkTannhaeuser/python-onvif-zeep
">a python
3
555 fork
</a
> using a different SOAP dependency. There is also
556 <a href=
"https://www.home-assistant.io/integrations/onvif/
">support for
557 ONVIF in Home Assistant
</a
>, and there is an alternative to Zoneminder
558 called
<a href=
"https://www.shinobi.video/
">Shinobi
</a
>. The latter
559 two are not included in Debian either. I have not tested any of these
565 <title>Time to translate the Bullseye edition of the Debian Administrator
's Handbook
</title>
566 <link>https://people.skolelinux.org/pere/blog/Time_to_translate_the_Bullseye_edition_of_the_Debian_Administrator_s_Handbook.html
</link>
567 <guid isPermaLink=
"true">https://people.skolelinux.org/pere/blog/Time_to_translate_the_Bullseye_edition_of_the_Debian_Administrator_s_Handbook.html
</guid>
568 <pubDate>Mon,
12 Sep
2022 15:
45:
00 +
0200</pubDate>
569 <description><p align=
"center
"><img align=
"center
" src=
"http://people.skolelinux.org/pere/blog/images/
2020-
10-
20-debian-handbook-nb-testprint.jpeg
" width=
"60%
"/
></p
>
571 <p
>(The picture is of the previous edition.)
</p
>
573 <p
>Almost two years after the previous Norwegian Bokmål translation of
574 the
"<a href=
"https://debian-handbook.info/
">The Debian Administrator
's
575 Handbook
</a
>" was published, a new edition is finally being prepared. The
576 english text is updated, and it is time to start working on the
577 translations. Around
37 percent of the strings have been updated, one
578 way or another, and the translations starting from a complete Debian Buster
579 edition now need to bring their translation up from
63% to
100%. The
580 complete book is licensed using a Creative Commons license, and has
581 been published in several languages over the years. The translations
582 are done by volunteers to bring Linux in their native tongue. The
583 last time I checked, it complete text was available in English,
584 Norwegian Bokmål, German, Indonesian, Brazil Portuguese and Spanish.
585 In addition, work has been started for Arabic (Morocco), Catalan,
586 Chinese (Simplified), Chinese (Traditional), Croatian, Czech, Danish,
587 Dutch, French, Greek, Italian, Japanese, Korean, Persian, Polish,
588 Romanian, Russian, Swedish, Turkish and Vietnamese.
</p
>
590 <p
>The translation is conducted on
591 <a href=
"https://hosted.weblate.org/projects/debian-handbook/
">the
592 hosted weblate project page
</a
>. Prospective translators are
593 recommeded to subscribe to
594 <a href=
"http://lists.alioth.debian.org/mailman/listinfo/debian-handbook-translators
">the
595 translators mailing list
</a
> and should also check out
596 <a href=
"https://debian-handbook.info/contribute/
">the instructions for
597 contributors
</a
>.
</p
>
599 <p
>I am one of the Norwegian Bokmål translators of this book, and we
600 have just started. Your contribution is most welcome.
</p
>
602 <p
>As usual, if you use Bitcoin and want to show your support of my
603 activities, please send Bitcoin donations to my address
604 <b
><a href=
"bitcoin:
15oWEoG9dUPovwmUL9KWAnYRtNJEkP1u1b
">15oWEoG9dUPovwmUL9KWAnYRtNJEkP1u1b
</a
></b
>.
</p
>
609 <title>Automatic LinuxCNC servo PID tuning?
</title>
610 <link>https://people.skolelinux.org/pere/blog/Automatic_LinuxCNC_servo_PID_tuning_.html
</link>
611 <guid isPermaLink=
"true">https://people.skolelinux.org/pere/blog/Automatic_LinuxCNC_servo_PID_tuning_.html
</guid>
612 <pubDate>Sat,
16 Jul
2022 22:
30:
00 +
0200</pubDate>
613 <description><p
>While working on a CNC with servo motors controlled by the
614 <a href=
"https://en.wikipedia.org/wiki/LinuxCNC
">LinuxCNC
</a
>
615 <a href=
"https://en.wikipedia.org/wiki/PID_controller
">PID
616 controller
</a
>, I recently had to learn how to tune the collection of values
617 that control such mathematical machinery that a PID controller is. It
618 proved to be a lot harder than I hoped, and I still have not succeeded
619 in getting the Z PID controller to successfully defy gravity, nor X
620 and Y to move accurately and reliably. But while climbing up this
621 rather steep learning curve, I discovered that some motor control
622 systems are able to tune their PID controllers. I got the impression
623 from the documentation that LinuxCNC were not. This proved to be not
626 <p
>The LinuxCNC
627 <a href=
"http://linuxcnc.org/docs/html/man/man9/pid
.9.html
">pid
628 component
</a
> is the recommended PID controller to use. It uses eight
629 constants
<tt
>Pgain
</tt
>,
<tt
>Igain
</tt
>,
<tt
>Dgain
</tt
>,
630 <tt
>bias
</tt
>,
<tt
>FF0
</tt
>,
<tt
>FF1
</tt
>,
<tt
>FF2
</tt
> and
631 <tt
>FF3
</tt
> to calculate the output value based on current and wanted
632 state, and all of these need to have a sensible value for the
633 controller to behave properly. Note, there are even more values
634 involved, theser are just the most important ones. In my case I need
635 the X, Y and Z axes to follow the requested path with little error.
636 This has proved quite a challenge for someone who have never tuned a
637 PID controller before, but there is at least some help to be found.
639 <p
>I discovered that included in LinuxCNC was this old PID component
640 at_pid claiming to have auto tuning capabilities. Sadly it had been
641 neglected since
2011, and could not be used as a plug in replacement
642 for the default pid component. One would have to rewriting the
643 LinuxCNC HAL setup to test at_pid. This was rather sad, when I wanted
644 to quickly test auto tuning to see if it did a better job than me at
645 figuring out good P, I and D values to use.
</p
>
647 <p
>I decided to have a look if the situation could be improved. This
648 involved trying to understand the code and history of the pid and
649 at_pid components. Apparently they had a common ancestor, as code
650 structure, comments and variable names were quite close to each other.
651 Sadly this was not reflected in the git history, making it hard to
652 figure out what really happened. My guess is that the author of
653 <a href=
"https://github.com/LinuxCNC/linuxcnc/blob/master/src/hal/components/at_pid.c
">at_pid.c
</a
>
655 <a href=
"https://github.com/LinuxCNC/linuxcnc/blob/master/src/hal/components/pid.c
">pid.c
</a
>,
656 rewrote it to follow the structure he wished pid.c to have, then added
657 support for auto tuning and finally got it included into the LinuxCNC
658 repository. The restructuring and lack of early history made it
659 harder to figure out which part of the code were relevant to the auto
660 tuning, and which part of the code needed to be updated to work the
661 same way as the current pid.c implementation. I started by trying to
662 isolate relevant changes in pid.c, and applying them to at_pid.c. My
663 aim was to make sure the at_pid component could replace the pid
664 component with a simple change in the HAL setup loadrt line, without
665 having to
"rewire
" the rest of the HAL configuration. After a few
666 hours following this approach, I had learned quite a lot about the
667 code structure of both components, while concluding I was heading down
668 the wrong rabbit hole, and should get back to the surface and find a
669 different path.
</p
>
671 <p
>For the second attempt, I decided to throw away all the PID control
672 related part of the original at_pid.c, and instead isolate and lift
673 the auto tuning part of the code and inject it into a copy of pid.c.
674 This ensured compatibility with the current pid component, while
675 adding auto tuning as a run time option. To make it easier to identify
676 the relevant parts in the future, I wrapped all the auto tuning code
677 with
'#ifdef AUTO_TUNER
'. The end result behave just like the current
678 pid component by default, as that part of the code is identical. The
679 <a href=
"https://github.com/LinuxCNC/linuxcnc/pull/
1820">end result
680 entered the LinuxCNC master branch
</a
> a few days ago.
</p
>
682 <p
>To enable auto tuning, one need to set a few HAL pins in the PID
683 component. The most important ones are
<tt
>tune-effort
</tt
>,
684 <tt
>tune-mode
</tt
> and
<tt
>tune-start
</tt
>. But lets take a step
685 back, and see what the auto tuning code will do. I do not know the
686 mathematical foundation of the at_pid algorithm, but from observation
687 I can tell that the algorithm will, when enabled, produce a square
688 wave pattern centered around the
<tt
>bias
</tt
> value on the output pin
689 of the PID controller. This can be seen using the HAL Scope provided
690 by LinuxCNC. In my case, this is translated into voltage (+-
10V) sent
691 to the motor controller, which in turn is translated into motor speed.
692 So at_pid will ask the motor to move the axis back and forth. The
693 number of cycles in the pattern is controlled by the
694 <tt
>tune-cycles
</tt
> pin, and the extremes of the wave pattern is
695 controlled by the
<tt
>tune-effort
</tt
> pin. Of course, trying to
696 change the direction of a physical object instantly (as in going
697 directly from a positive voltage to the equivalent negative voltage)
698 do not change velocity instantly, and it take some time for the object
699 to slow down and move in the opposite direction. This result in a
700 more smooth movement wave form, as the axis in question were vibrating
701 back and forth. When the axis reached the target speed in the
702 opposing direction, the auto tuner change direction again. After
703 several of these changes, the average time delay between the
'peaks
'
704 and
'valleys
' of this movement graph is then used to calculate
705 proposed values for Pgain, Igain and Dgain, and insert them into the
706 HAL model to use by the pid controller. The auto tuned settings are
707 not great, but htye work a lot better than the values I had been able
708 to cook up on my own, at least for the horizontal X and Y axis. But I
709 had to use very small
<tt
>tune-effort
<tt
> values, as my motor
710 controllers error out if the voltage change too quickly. I
've been
711 less lucky with the Z axis, which is moving a heavy object up and
712 down, and seem to confuse the algorithm. The Z axis movement became a
713 lot better when I introduced a
<tt
>bias
</tt
> value to counter the
714 gravitational drag, but I will have to work a lot more on the Z axis
715 PID values.
</p
>
717 <p
>Armed with this knowledge, it is time to look at how to do the
718 tuning. Lets say the HAL configuration in question load the PID
719 component for X, Y and Z like this:
</p
>
721 <blockquote
><pre
>
722 loadrt pid names=pid.x,pid.y,pid.z
723 </pre
></blockquote
>
725 <p
>Armed with the new and improved at_pid component, the new line will
726 look like this:
</p
>
728 <blockquote
><pre
>
729 loadrt at_pid names=pid.x,pid.y,pid.z
730 </pre
></blockquote
>
732 <p
>The rest of the HAL setup can stay the same. This work because the
733 components are referenced by name. If the component had used count=
3
734 instead, all use of pid.# had to be changed to at_pid.#.
</p
>
736 <p
>To start tuning the X axis, move the axis to the middle of its
737 range, to make sure it do not hit anything when it start moving back
738 and forth. Next, set the
<tt
>tune-effort
</tt
> to a low number in the
739 output range. I used
0.1 as my initial value. Next, assign
1 to the
740 <tt
>tune-mode
</tt
> value. Note, this will disable the pid controlling
741 part and feed
0 to the output pin, which in my case initially caused a
742 lot of drift. In my case it proved to be a good idea with X and Y to
743 tune the motor driver to make sure
0 voltage stopped the motor
744 rotation. On the other hand, for the Z axis this proved to be a bad
745 idea, so it will depend on your setup. It might help to set the
746 <tt
>bias
</tt
> value to a output value that reduce or eliminate the
747 axis drift. Finally, after setting
<tt
>tune-mode
</tt
>, set
748 <tt
>tune-start
</tt
> to
1 to activate the auto tuning. If all go well,
749 your axis will vibrate for a few seconds and when it is done, new
750 values for Pgain, Igain and Dgain will be active. To test them,
751 change
<tt
>tune-mode
</tt
> back to
0. Note that this might cause the
752 machine to suddenly jerk as it bring the axis back to its commanded
753 position, which it might have drifted away from during tuning. To
754 summarize with some halcmd lines:
</p
>
756 <blockquote
><pre
>
757 setp pid.x.tune-effort
0.1
758 setp pid.x.tune-mode
1
759 setp pid.x.tune-start
1
760 # wait for the tuning to complete
761 setp pid.x.tune-mode
0
762 </pre
></blockquote
>
764 <p
>After doing this task quite a few times while trying to figure out
765 how to properly tune the PID controllers on the machine in, I decided
766 to figure out if this process could be automated, and wrote a script
767 to do the entire tuning process from power on. The end result will
768 ensure the machine is powered on and ready to run, home all axis if it
769 is not already done, check that the extra tuning pins are available,
770 move the axis to its mid point, run the auto tuning and re-enable the
771 pid controller when it is done. It can be run several times. Check
773 <a href=
"https://github.com/SebKuzminsky/MazakVQC1540/blob/bon-dev/scripts/run-auto-pid-tuner
">run-auto-pid-tuner
</a
>
774 script on github if you want to learn how it is done.
</p
>
776 <p
>My hope is that this little adventure can inspire someone who know
777 more about motor PID controller tuning can implement even better
778 algorithms for automatic PID tuning in LinuxCNC, making life easier
779 for both me and all the others that want to use LinuxCNC but lack the
780 in depth knowledge needed to tune PID controllers well.
</p
>
782 <p
>As usual, if you use Bitcoin and want to show your support of my
783 activities, please send Bitcoin donations to my address
784 <b
><a href=
"bitcoin:
15oWEoG9dUPovwmUL9KWAnYRtNJEkP1u1b
">15oWEoG9dUPovwmUL9KWAnYRtNJEkP1u1b
</a
></b
>.
</p
>