<?xml version="1.0" encoding="utf-8"?>
<feed version="0.3" xmlns="http://purl.org/atom/ns#">
<link rel="alternate" type="text/html" href="https://gamma.unpythonic.net/"/>

<title>Jeff Epler's blog</title>
<modified>2024-10-06T14:15:01Z</modified>
<tagline>Photos, electronics, cnc, and more</tagline>
<author><name>Jeff Epler</name><email>jepler@unpythonic.net</email></author>
<entry>
<title>Talking directly to in-process tcl/tk</title>
<issued>2024-10-06T14:15:01Z</issued>
<modified>2024-10-06T14:15:01Z</modified>
<id>https://gamma.unpythonic.net/01728224101</id>
<link rel="alternate" type="text/html" href="https://gamma.unpythonic.net/01728224101"/>
<content type="text/html" mode="escaped">

I recently saw &lt;a href=&quot;https://beauty-of-imagination.blogspot.com/2024/10/simpler-than-pysimplegui-and-python.html&quot;&gt;a post on a blog&lt;/a&gt; about using wish as a subprocess of Python, as a way to access tk without the complexity of tkinter.

&lt;p&gt;To be clear the original post also calls out the situation where the tkinter part of python is not installed by default, and my technique would not be applicable there.

&lt;p&gt;So what do you do if you like Tk but don't care for the high level abstraction provided by Tkinter? Well, you can &lt;tt&gt;import _tkinter&lt;/tt&gt; and create a tkapp object with &lt;tt&gt;_tkinter.create()&lt;/tt&gt;.

&lt;p&gt;The _tkinter module and the tkapp object is largely undocumented, but in Python
3.11 here are some useful methods:
&lt;ul&gt;
&lt;li&gt; tkapp.createcommand: Create a callback into Python code. Takes a string and a callable. Creates a Tcl command with that name, that calls back into Python code: &lt;tt&gt;app.createcomand(&quot;cb&quot;, lambda *args: print(&quot;cb&quot;, args))&lt;/tt&gt;
&lt;li&gt; tkapp.eval: Takes a command and evaluates it. Call it with a single string: &lt;tt&gt;app.eval(&quot;button .b -text HI -command {cb arg1 arg2}&quot;)&lt;/tt&gt;
&lt;li&gt; tkapp.call: Takes a series of arguments, does proper Tcl quoting, and evaluates it: &lt;tt&gt;app.call(&quot;pack&quot;, &quot;.b&quot;)&lt;/tt&gt;
&lt;/ul&gt;
Now, go forth and program your graphical app without all that Python object
nonsense!

&lt;p&gt;&lt;pre&gt;
Python 3.11.2 (main, Aug 26 2024, 07:20:54) [GCC 12.2.0] on linux
Type &quot;help&quot;, &quot;copyright&quot;, &quot;credits&quot; or &quot;license&quot; for more information.
&gt;&gt;&gt; import _tkinter
&gt;&gt;&gt; app = _tkinter.create()
&gt;&gt;&gt; app.createcommand(&quot;cb&quot;, lambda *args: print(&quot;cb&quot;, args))
&gt;&gt;&gt; app.eval(&quot;button .b -text HI -command {cb arg1 arg2}&quot;)
'.b'
&gt;&gt;&gt; app.call(&quot;pack&quot;, &quot;.b&quot;)
''
&gt;&gt;&gt; # Now I click the button several times ...
&gt;&gt;&gt; cb ('arg1', 'arg2')
cb ('arg1', 'arg2')
cb ('arg1', 'arg2')
&lt;/pre&gt;
</content>
</entry>
<entry>
<title>DragonBoard™ 410c with rt-preempt failure</title>
<issued>2015-09-01T14:39:18Z</issued>
<modified>2015-09-01T14:39:18Z</modified>
<id>https://gamma.unpythonic.net/01441118358</id>
<link rel="alternate" type="text/html" href="https://gamma.unpythonic.net/01441118358"/>
<content type="text/html" mode="escaped">

&lt;div style=&quot;float:right;clear:right&quot;&gt;&lt;!-- linaro-01Sep2015-49.png--&gt;&lt;div class=albumouter style=width:306px id=&gt;&lt;div class=albumimage style=&quot;width:292px;margin-left:7.0px;&quot;&gt;&lt;a href=&quot;https://media.unpythonic.net/emergent-files/01441118358/linaro-01Sep2015-49.png&quot; class=&quot;thickbox&quot; rel=&quot;album&quot; title=&quot;LinuxCNC latency test results on
DragonBoard&quot;&gt;&lt;img src=&quot;https://media.unpythonic.net/emergent-files/01441118358/linaro-01Sep2015-49-small.jpg&quot; width=286 height=300&gt;&lt;/a&gt;&lt;div &gt;&lt;div style=&quot;float: right&quot; &gt;&lt;a href=&quot;https://media.unpythonic.net/emergent-files/01441118358/linaro-01Sep2015-49.png&quot;&gt;&lt;img class=zoom src=&quot;https://media.unpythonic.net/emergent-files/default/zoom.png&quot;&gt;&lt;/a&gt;&lt;/div&gt;&lt;a href=&quot;https://media.unpythonic.net/emergent-files/01441118358/linaro-01Sep2015-49.png&quot;&gt;LinuxCNC latency test results on
DragonBoard&lt;/a&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;
&lt;/div&gt;
I was excited to obtain a &lt;a href=&quot;https://www.96boards.org/products/ce/dragonboard410c/&quot;&gt;DragonBoard&lt;/a&gt;, an
affordable 64-bit ARM single-board computer, but unfortunately it hasn't lived
up to my hopes.

&lt;p&gt;First of all, it shipped with one terrible problem, making it useless for
headless development: &lt;a href=&quot;https://bugs.96boards.org/show_bug.cgi?id=66&quot;&gt;The onboard wireless doesn't receive multicast traffic, including ARP
requests&lt;/a&gt;!  And their kernel doesn't provide many modular drivers, so adding
any old USB wireless dongle doesn't work until you rebuild the kernel.  As
of this writing, there is no useful workaround.

&lt;p&gt;And that's when I hit the second show-stopper problem.  I planned to build
kernels for this thing anyway, because the goal is to run LinuxCNC on it
with rt-preempt realtime.  So I stuck in a large capacity micro-sd card,
obtained the kernel source, built it, and rebooted with my new kernel.

&lt;p&gt;(incidentally, testing kernels is a PITA.  You have two choices: one,
flash the one and only boot area with your new and untested kernel and
hope for the best; two, tether to a PC (losing USB keyboard and mouse on the
dragonboard!) and use fastboot every time you boot.  ugh)

&lt;p&gt;.. but the new kernel just didn't work.  It scrolled kernel messages,
but got stuck partway through booting.  dmesg implicated the wireless card.
This one at least has a workaround: &lt;a href=&quot;https://bugs.96boards.org/show_bug.cgi?id=80&quot;&gt;cherry-pick a certain commit from
their kernel git&lt;/a&gt;.  As I understand it, this bug is triggered by using the
compiler on the dragonboard, and not encountered with the linaro cross-compiler
running on a traditional x86 desktop.

&lt;p&gt;Anyway, having found out about this I was briefly celebratory.  I booted with
my own kernel and had a working USB dongle.  Unfortunately, that celebration
was short-lived.  The USB dongle hasn't been terribly reliable either,
particularly under high CPU load.

&lt;p&gt;I soldiered on and patched the linaro 4.0 kernel with the 4.0-rt5 patchset.
There were a few minor conflicts which I believe I resolved correctly.
Unfortunately, the LinuxCNC latency-test readily encounters latencies above
15ms (15000us).  LinuxCNC really would like sub-100us max latencies.

&lt;p&gt;I briefly enabled tracers, and have traces that seem to implicate a variety
of subsystems: networking, usb, and video *all* figure.  More experienced
developers than I will have to be the ones to sort out RT on 64-bit ARM.

&lt;p&gt;</content>
</entry>
<entry>
<title>Proven Delights (and what are proofs anyway)</title>
<issued>2015-08-05T13:13:49Z</issued>
<modified>2015-08-05T13:13:49Z</modified>
<id>https://gamma.unpythonic.net/01438780429</id>
<link rel="alternate" type="text/html" href="https://gamma.unpythonic.net/01438780429"/>
<content type="text/html" mode="escaped">
I won a copy of the book &lt;a href=&quot;http://hackersdelight.org/&quot;&gt;Hacker's
Delight&lt;/a&gt; from &lt;a href=&quot;http://blog.regehr.org/&quot;&gt;John Regehr&lt;/a&gt; for my entry in
his &lt;a href=&quot;http://blog.regehr.org/archives/1213&quot;&gt;nibble sort contest&lt;/a&gt;
earlier this year.

&lt;p&gt;In that thread I had heard about the &lt;a href=&quot;http://www.cprover.org/cbmc/&quot;&gt;CBMC Bounded Model Checking software&lt;/a&gt;, and it gave me the idea to combine
the two: a project to take implementations of the algorithms from Hacker's
Delight and prove the algorithms' properties with CBMC.

&lt;p&gt;I have a modest start on github, which I am calling &amp;quot;Proven Delights&amp;quot;:</content>
</entry>
<entry>
<title>Better pasting for irssi in X</title>
<issued>2014-06-24T12:35:40Z</issued>
<modified>2014-06-24T12:35:40Z</modified>
<id>https://gamma.unpythonic.net/01403613340</id>
<link rel="alternate" type="text/html" href="https://gamma.unpythonic.net/01403613340"/>
<content type="text/html" mode="escaped">
While it's otherwise an excellent irc client, I've been frustrated by pasting
in &lt;a href=&quot;http://www.irssi.org&quot;&gt;irssi&lt;/a&gt;.  There are two main problems:</content>
</entry>
<entry>
<title>mailpie moves to github</title>
<issued>2013-12-02T19:30:20Z</issued>
<modified>2013-12-02T19:30:20Z</modified>
<id>https://gamma.unpythonic.net/01386012620</id>
<link rel="alternate" type="text/html" href="https://gamma.unpythonic.net/01386012620"/>
<content type="text/html" mode="escaped">

My e-mail full text search software &lt;a href=&quot;https://gamma.unpythonic.net/software/mailpie&quot;&gt;mailpie&lt;/a&gt; is
now hosted at github: &lt;a href=&quot;https://github.com/jepler/mailpie&quot;&gt;https://github.com/jepler/mailpie&lt;/a&gt;

&lt;p&gt;</content>
</entry>
<entry>
<title>SNTP from Python: getting server's esimate of time quality</title>
<issued>2013-11-23T18:19:15Z</issued>
<modified>2013-11-23T18:19:15Z</modified>
<id>https://gamma.unpythonic.net/01385230755</id>
<link rel="alternate" type="text/html" href="https://gamma.unpythonic.net/01385230755"/>
<content type="text/html" mode="escaped">


&lt;p&gt;Anders Wallin &lt;a href=&quot;http://www.anderswallin.net/2013/11/ntp-failure-detection/&quot;&gt;recently discussed&lt;/a&gt;
generating graphs of server time error using a timestamp from the Date:
header of an http request.

&lt;p&gt;NTP servers themselves have estimates of time error, and it's possible to
get the local server's idea of the error by sending SNTP packets to the
local machine.  You can also see the last time this NTP server successfully
communicated with a peer or upstream, and see whether the server considers
itself desynchronized by checking the stratum and leap second fields.

&lt;p&gt;Based on my tinkering, the root_dispersion field or the derived LAMBDA value is
the easiest to look at for estimating how bad the NTP time is.  Between
communications with a peer, root_dispersion and LAMBA increase at a rate of
15µs/s, ntp's arbitrary estimate of the accuracy of the local undisciplined
clock.  (YMMV and you can appaerntly tweak CLOCK_PHI in your NTP configuration
file)

&lt;p&gt;The attached program is a basic Python SNTP client which by default polls the local server every 5 seconds and prints some information.  License: GPLv2+

&lt;p&gt;Typical output:
&lt;pre &gt;
12:25:58  0.06233  228.95875 ST-SYNCH LI-SYNCH
12:26:03  0.06241  233.96404 ST-SYNCH LI-SYNCH
12:26:08  0.06247  238.96745 ST-SYNCH LI-SYNCH
12:26:13  0.06255  243.97141 ST-SYNCH LI-SYNCH
12:26:18  0.06262  248.97673 ST-SYNCH LI-SYNCH
12:26:23  0.06270  253.98213 ST-SYNCH LI-SYNCH
12:26:28  0.06277  258.98746 ST-SYNCH LI-SYNCH
&lt;/pre&gt;
&lt;p&gt;&lt;b&gt;Files currently attached to this page:&lt;/b&gt;
&lt;table cellpadding=5 style=&quot;width:auto!important; clear:none!important&quot;&gt;&lt;col&gt;&lt;col style=&quot;text-align: right&quot;&gt;&lt;tr bgcolor=#eeeeee&gt;&lt;td&gt;&lt;a href=&quot;https://media.unpythonic.net/emergent-files/01385230755/ntpsynch.py&quot;&gt;ntpsynch.py&lt;/a&gt;&lt;/td&gt;&lt;td&gt;4.9kB&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;p&gt;
</content>
</entry>
<entry>
<title>GNU 30th—Celebrating 30 years</title>
<issued>2013-09-30T14:19:03Z</issued>
<modified>2013-09-30T14:19:03Z</modified>
<id>https://gamma.unpythonic.net/01380550743</id>
<link rel="alternate" type="text/html" href="https://gamma.unpythonic.net/01380550743"/>
<content type="text/html" mode="escaped">

&lt;a href=&quot;https://gnu.org/gnu30/&quot;&gt;The GNU project&lt;/a&gt; and the Free
Software movement are two of the most important computer-related
things in my life.  At $DAY_JOB we depend critically on many pieces
of GNU software (such as gcc).  This blog is hosted on a system with
a GPL kernel and a GNU userspace, and the blog software itself is
covered by the GPL license.  My everyday computer is a GNU/Linux
system, and my cellphone and tablet have GPL-licensed major
components, such as the operating system kernel.

&lt;p&gt;I personally have contributed thousands of unpaid hours developing
GPL-licensed software, which is my way of repaying everyone else who
has developed Free software.

&lt;p&gt;On the other hand, we haven't come as far as one might wish.  My
everyday computer doesn't function as well without proprietary
drivers, and many devices that should be general purpose computers
don't ship in a mode that allows their owners to install the
software of their choice.  Careful choices are still necessary when
buying hardware, particularly if you insist on an operating system
that consists only of Free software.

&lt;p&gt;Here's hoping that the next 30 years bring more gains for Free
software and the GNU system.  Either way, we'll still be here.
</content>
</entry>
<entry>
<title>Debugging realtime components in UBC3</title>
<issued>2013-09-19T01:34:41Z</issued>
<modified>2013-09-19T01:34:41Z</modified>
<id>https://gamma.unpythonic.net/01379554481</id>
<link rel="alternate" type="text/html" href="https://gamma.unpythonic.net/01379554481"/>
<content type="text/html" mode="escaped">Here's how to run the debugger on realtime code in the &amp;quot;unified-build-candidate3&amp;quot; branch from linuxcnc.org.  This assumes you are using a run-in-place tree with a userspace realtime model, and that you understand the basics of gdb.</content>
</entry>
</feed>
