2018-09-10

Current podcasts



Here is my current list of podcasts. It is shorter than the previous, mostly due to a move to a new computer.


The links are RSS URLs.




2018-04-07

Using ChatZilla in the age of Firefox Quantum

ChatZilla is a very good IRC application that both allows logging an IRC channel and automatically reconnect if some network error happens (both in contrast to using a web-based approach, e.g. http://webchat.freenode.net/?channels=sigrok). Disconnections happen a lot, especially with 3G connections that are far from stable.

But Firefox Quantum (Firefox from v. 56 and later, end of 2017) has introduced a lot of confusion as it breaks a lot of extensions, including ChatZilla, so it appears it can not be used any more. But it can!

Note that SeaMonkey promises to have ChatZilla built in (and presumably working), but that is because their documentation has not been updated. It is actually not included in the later versions. It suffers from the same problem as Firefox as it based on the Firefox code base. You have to get some year-old version to get it working.

Instead it is much easier to install ChatZilla as an independent application (that doesn't share any setting with Firefox or SeaMonkey) - ChatZilla can also run as a normal application under XULrunner. Even though XULrunner has been deprecated for a long time there is a version of ChatZilla available for it (there are of course security implications, but as long as it used in the limited fashion here it should not be a problem).

HowTo


  1. Download the XULrunner version of ChatZilla
    From http://chatzilla.rdmsoft.com/xulrunner/, e.g. http://chatzilla.rdmsoft.com/xulrunner/download/chatzilla-0.9.92.en-US.win32.installer.msi
    It is about 36 MB.
  2. Install ChatZilla by opening the downloaded MSI file
  3. Add the "sigrok" IRC channel:
    Menu "ChatZilla" → "Preferences" → Global settings:
        Nick name: <Your preferred IRC nickname - one word, no spaces>
    Menu "IRC" → "Join channel"
        Network: freenode
        Channel: sigrok
  4. Set up logging
    In this example, for base folder "C:\UserProf\IRC logs". The actual log files are burried two levels deeper, in this example in folder "C:\UserProf\IRC logs\freenode\channels", with file names like "#sigrok.2018-04-07.log".
    Menu "ChatZilla" → "Preferences" → "Global Settings" → "Logging":
        "Log folder": file:///C:/UserProf/IRC%20logs/

    Note: It is NOT necessary check "Log this view" (for this global setting) - this is done for the specific channel, in this case "sigrok".
    Menu "ChatZilla" → "Preferences" → "freenode/#sigrok" → "Logging": Check the checkbox.
  5. Show timestamps:
    Menu "View" → "Show Timestamps"
  6. Rejoin the channels when the program is restarted or the computer is restarted:
    Right click "#sigrok" at the lower left and check "Open This Channel at Startup".
  7. Put a shortcut of ChatZilla in the startup folder
    • <Windows key> + R, "shell:startup" (this will open a window with the startup folder)
    • <Windows key> + "chat" → right click on "ChatZilla" → "Open file position" → right drag "ChatZilla" to the startup folder (the window that was opened with "shell:startup"), and select "Create shortcut here".





2018-03-31

Level shifter, 18 V to 5 V

As part of the baud rate converter (see later), it was required to interface CMOS at 18 V (CD4046 PLL) to a 5 V part (TTL, 7493).

The requirement was that it should work up to 3 MHz.


1. BJT inverter

This is a simple way, 2 resistors and a transistor (BC547B), but it is also shockingly slow. Both in simulation in LTSpice and in a realised circuit it could not even handle a 50% dutycycle 1 MHz squareware.

2. Resistive divider

This will not work due to the relative low input impedance of the TTL. The output swing is reduced to 1.3 V (1.1 V to 2.4 V).


3. Diode

Here we use let the internal pull-up in the TTL part for the high signal and place a diode in reverse so the output stage of the CMOS get a low-impedance path to pull the signal low. The input voltage will be close to the limit, about 0.7 V due to the diode voltage drop.




2017-06-14

Getting started with 1Bitsy and Black Magic Probe

The Kickstarter project was great, but how do you actually get started using the two things, 1Bitsy and Black Magic Probe, once they are in your possession???

There is information about the devices, but not actually how to get started - like a step-by-step introduction with the blinking LED (single stepping over the code lines for ON and OFF would actually turn the built-in LED on and off). Or at least it is difficult to find - why isn't it featured very prominently? Where is the blog post that gets you started?

So far the best I have found is the YouTube video 1Bitsy & Black Magic Probe Linux Quickstart Tutorial  (and now with a transcript for the many required command-line commands - by yours truly).

I am also posting the transcript here due to the ephemeral nature of YouTube comments:


Transcript for commands and links

Note: Unlike the video, the three hardware connect events (indicated in the below) should be separate to get the same output on the command line as in the video. I have also inserted the missing 'cd' to the 'fancy blink' directory (with the .elf file). For a live USB Ubuntu 17.10 installation it was also necessary to install 'make' (added to the transcript), and for another install variation of Ubuntu 17.10 (regular install on an external USB SSD drive), also 'python-minimal' (for Python 2 - Python 3 was already installed).

01 min 10 secs sudo add-apt-repository ppa:team-gcc-arm-embedded/ppa

01 min 30 secs sudo apt-get update

01 min 38 secs sudo apt-get install gcc-arm-embedded

01 min 51 secs sudo apt-get install git

XX min XX secs sudo apt-get install make

XX min XX secs sudo apt-get install python-minimal

02 min 02 secs git clone https://github.com/1bitsy/1bitsy-examples.git

02 min 07 secs cd 1bitsy-examples

02 min 12 secs git submodule init

02 min 15 secs git submodule update

02 min 21 secs make

02 min 28 secs id

02 min 32 secs sudo adduser $USER dialout

02 min 41 secs id

02 min 48 secs <The output should include "(dialout)" in the "groups=" part. In that case, log out. If it is not in the output, a restart of the computer is required (if a restart is not done the result is "Permission denied" in the "target extended-remote /dev/ttyACM0" line below).>

04 min 54 secs <Plug in Black Magic Probe to microUSB>

05 min 32 secs dmesg | tail

05 min 34 secs <Output includes: "ttyACM0" and "ttyACM1". "ttyACM0" is the COM port that GDB uses to communicate with the Black Magic Probe and "ttyACM1" is the auxiliary COM port that can be used to connect to the target board's serial port (so it is not necessary to use a separate USB-to-serial adapter).>

05 min 42 secs <Plug in 1bitsy to microUSB>

05 min 43 secs dmesg | tail

05 min 44 secs <Output includes: "ttyACM2" - but ONLY if there is already firmware on it that makes it appear as a serial device. This is NOT the case for the Kickstarter one...>

05 min 45 secs <Connect 1bitsy and Black Magic Probe using the JTAG cable. Note: the ribbon cable is to come from the SAME DIRECTION as the USB cable. That is, the ribbon cable does NOT cover the main chip/IC.>

05 min 48 secs cd ~/1bitsy-examples/examples/1bitsy/fancyblink

05 min 49 secs arm-none-eabi-gdb fancyblink.elf

05 min 54 secs target extended-remote /dev/ttyACM0

06 min 04 secs monitor version

06 min 11 secs monitor help

06 min 17 secs monitor jtag_scan

06 min 23 secs attach 1

06 min 27 secs load

06 min 30 secs run

06 min 32 secs y

06 min 37 secs <Ctrl + C>

06 min 38 secs list

06 min 43 secs tui enable

06 min 47 secs cont

06 min 51 secs <Ctrl + C>

06 min 52 secs step

06 min 53 secs start

06 min 56 secs y

07 min 00 secs next

07 min 04 secs step

07 min 07 secs next

07 min 07 secs next

07 min 17 secs next

07 min 22 secs cont

07 min 22 secs cont

07 min 25 secs quit

07 min 26 secs y

07 min 26 secs y

DFU part:

07 min 44 secs <Press the user button and insert microUSB cable>

07 min 47 secs dmesg | tail

07 min 50 secs lsusb

07 min 54 secs <Output includes: "STMicroelectronics STM Device in DFU Mode">

07 min 57 secs sudo apt-get install dfu-util

08 min 13 secs make fancyblink.bin

08 min 18 secs ls

08 min 23 secs sudo dfu-util -d 0483:df11 -c 1 -a 0 -s 0x08000000:leave -D fancyblink.bin

09 min 07 secs <1bitsy is now programmed!>

09 min 10 secs <Links: <http://1bitsquared.com> (1BitSquared USA), <http://1bitsquared.de> (1BitSquared Germany), <http://1bitsy.org> (1Bitsy), and <http://github.com/blacksphere/blackmagic> (Black Magic Probe) >




Perhaps this blog post will do (covers Linux, Mac OS X, and Windows):

1Bitsy Quickstart Guide, Quickstart on the command line


A partial one (but with more in-depth explanations) is:

Getting Started (on GitHub, blacksphere/blackmagic)


Some GBD commands

  next (n)    Step over
  step (s)     Step into
  ????          Step out

  break 37  Set breakpoint at line 37
   ????        Set up watch for variable X



<To be expanded...>



Other resources:

Blackmagic probe Windows driver install tutorial  (YouTube video. It only contains instructions for installing the three different USB drivers, one for DFU (for Black Magic Probe itself) and the two that makes for the two virtual COM ports. And only for Black Magic Probe, not 1Bitsy.)


2017-04-16

Emacs basics

If you seldom use Emacs it is easy to forget the arcane operation of Emacs...



Exit Emacs

Ctrl + X Ctrl + C.



M-x notation

"M" is effectively "Alt" (on most systems).

Thus M-x means Alt + X.



C-x notation

"C" is effectively "Ctrl" (on most systems).

Thus C-x means Ctrl + X.



Creating/locating the settings file



Alt + X customize. Press "Apply and Save" (Emacs 24 for Windows). This will create the file ".emacs" in C:\Documents and Settings\username\Application Data or C:\Users\username\AppData\Roaming depending on the Windows version.

Locate it by: Ctrl + X D ~/ Return


Add modes/Elisp code

<This section is under construction...>

Example: Add the Intel-hex-mode Elisp code

Download it and copy file intel-hex-mode.el to the same folder as file .emacs.

Add this to .emacs:

    (require 'intel-hex-mode)




Files

To open a file: Ctrl + X Ctrl + F Enter <Select file> Enter

To save: Ctrl + X Ctrl + W Enter y 

Ctrl + X O to switch in split windows (e.g. after Ctrl + X B).


Ctrl + X Ctrl + B to get a list of windows (buffers).

Ctrl + X B to switch between windows.




To be continued...




2016-12-31

Installing a Subversion server on a (new) Raspberry Pi, Apache 2.4


Installing a Subversion (SVN) server on a Raspberry Pi used to be (relatively) straightforward (see Appendix A).


This worked without problems on an older Raspberry Pi earlier this year when I had the need to set up a test server for some heavy SVN operations (before unleashing them on the real SVN server at work).

However, repeating the same installation steps on a newer Raspberry Pi (model 3, with Wi-Fi) failed to get a working SVN server. Installing an SVN server in another place was a reasonable way to reset the server state such that adding of new files could be tested more than once (and not erasing the rich history on the old server) and also a way of testing the installation procedures should they be needed again in some other place and time.

Having the older server still working I had the luxury of being able to compare configuration files for Apache and SVN. However, nothing appeared to be incorrect.

One difference was that, by the same installation procedure, eight months apart, Apache 2.2 had been installed on the old server and Apache 2.4 on the new server. It later became clear that the way of configuration has changed significantly between Apache 2.2 and Apache 2.4.

Long story short, a symbolic link for enabling the SVN thing in Apache was not created (perhaps a bug in the installation scripts or change to defaults) in the new installation. Detection became:

        ls -ls /etc/apache2/mods-enabled | grep svn

This was empty (symbolic link not present) on the new server, but on the old working server the output was:

        dav_svn.conf -> ../mods-available/dav_svn.conf
        dav_svn.load -> ../mods-available/dav_svn.load
 
There is (apparently) a standard mechanism for making these symbolic links by use of the script a2enmod and the fix/solution was:

        sudo a2enmod dav_svn
        sudo service apache2 restart


Retrospectively, I found a Stack Overflow post, Configuring SVN server on Apache on Ubuntu 12.04,  that had the exact solution. I had failed to locate it (one of the first steps was of course to search on Stack Exchange sites, primarily Stack Overflow, but also Super User and Server Fault).





Appendix A Installing an SVN server on a Raspberry Pi from scratch (with Apache for HTTP access)

These are command lines, done remotely over SSH using PuTTY on Windows.

           sudo apt-get update
           sudo apt-get install subversion
           sudo apt-get install libapache2-svn
           sudo apt-get install apache2

           sudo service apache2 restart

Creating two repositories, "RCL" and "CGW"

           sudo mkdir /var/svn-repos/
           sudo svnadmin create --fs-type fsfs /var/svn-repos/RCL
           sudo svnadmin create --fs-type fsfs /var/svn-repos/CGW

Set permissions

            sudo groupadd subversion
            sudo addgroup pmn subversion
            sudo addgroup pi subversion
            sudo addgroup someOtherSVNuser subversion

            sudo chown -R www-data:subversion /var/svn-repos/*
            sudo chmod -R 770 /var/svn-repos/*

Add to /etc/apache2/mods-available/dav_svn.conf (so HTTP can be used, through Apache (and also enabling browsing from a web browser)):

          sudo vi /etc/apache2/mods-available/dav_svn.conf

            
     <Location /svn>
               DAV svn
               SVNParentPath /var/svn-repos
               AuthType Basic
               AuthName "Subversion Repo"
               AuthUserFile /etc/apache2/dav_svn.passwd
               <LimitExcept GET PROPFIND OPTIONS REPORT>
                   Require valid-user
              
               </LimitExcept>
           </Location>

    

Add an SVN user

           sudo htpasswd -c /etc/apache2/dav_svn.passwd jeremy

             somePassword

Add some content to a repository (locally on the server)

           mkdir /home/pi/projects
           mkdir /home/pi/projects/helloworld
           cd /home/pi/projects/helloworld
           sudo nano main.cpp

           sudo svn import -m 'Some first checked in file' /home/pi/projects/helloworld/ file://localhost/var/svn-repos/CGW


Test in browser (Raspberry Pi server at IP address 192.168.0.120):

   http://192.168.0.120/svn/CGW/

2015-12-01

Drawing a line in Inkscape

In Inkscape, it is not at all intuitive to do the simplest task: drawing a straight line.

The key is double clicking when at the second point of the line (otherwise, nothing will be drawn).


Do:

  1. Select the Bezier drawing tool. In later versions of Inkscape there is also a help text for this tool that indicates that it can be used to draw straight lines.
  2. Left click for the first point of the line.
  3. Drag to the position of the second point of the line.
  4. Double click.

 


2015-01-02

Installing VLC media player and MPlayer on Raspberry Pi and Ubuntu

To install VLC media player and MPlayer on Raspberry Pi and Ubuntu, issue these at the command line:

    sudo apt-get install software-properties-common
    sudo apt-get install python-software-properties
    sudo add-apt-repository ppa:videolan/stable-daily
    sudo apt-get update
    sudo apt-get install mplayer vlc

The first two lines are for installing add-apt-repository. It may not be strictly necessary to install both (add-apt-repository is only in one of them, depending on particular versions of the operating system), but in this way it is guaranteed to work.

2014-12-05

Breaking into PowerShell

DRAFT

 
Notes for climbing the steep PowerShell learning curve...


Commonly used cmdlets:
  • Get-ChildItem. Aliases: ls, dir, and gci
  • Get-Content. Aliases: cat, gc, and type
  • Get-Help. Using the option -full will output examples of use for the cmdlet in question.
  • Get-WmiObject. Alias: gwmi. In PowerShell 1.0 it was largely the only way to access remote computers.
  • Format-List. Effectively reverse rows and columns (in output).
  • Get-Location. Aliases: pwd and gl
  • Get-Member. Alias: gm
  • Get-Process. Aliases: gps and ps
  • Group-Object. Alias: group
  • Measure-Command. For timing.
  • Measure-Object. Alias: measure
  • New-Item. Alias: ni (and mkdir with parameter -ItemType "Directory"). For instance, create a new file, new folder or registry entry.
  • New-Object.
  • Out-GridView. Open GUI window with the fields as columns and objects as rows. The columns can be interactively sorted and the clipboard works with the usual shortcut Ctrl + C, including disjoint selected rows!. Alias: ogv 
  • Select-Object. Effectively choose another subset of fields from an object than the default (e.g. for the ultimate goal of an output). Alias: select
  • Set-Location. Sets the current working location. Aliases cd, chdir, and sl
  • Sort-Object. Alias: sort
  • Test-Path. Test if the syntax for a path is correct. Useful when dealing with user input.
  • Where-Object. Used to filter (get a subset of piped objects). A common idiom is Where-Object {$_ -match '\d{3}[-|\s]\d{3}[-|\s]\d{3}$'}, where what is between the two single quotes is a regular expression. Aliases: where and ?
  • Write-Output. If the command is the last command in the pipeline, the objects are displayed in the console. Aliases: echo and write

wc

Equivalent to Linux' wc (used on a directory listing in this example):


  Get-ChildItem | Measure-Object | Select-Object -ExpandProperty Count

Using aliases:

  dir | measure | select -ExpandProperty Count


Example: get desired information from the running processes on the computer

Get-Process returns a (very long) list of running processes on the computer. Assume we are interested in the processes that take up a lot of memory and that are potentially leaking (Private Bytes is the proper quantity for this). First explore the different kind of values with Get-Member:

  Get-Process | Get-Member

The field "PrivateMemorySize" seems to be what is called "Private Bytes".

Use Where-Object to only get the subset of processes that take up more than about 1 MB:

  Get-Process | Where-Object {$_.PrivateMemorySize -gt 1000000}

This returns some processes with eight different kinds of fields (or at least that is how it appears in the output on the screen), but not private bytes. Say we still want the process ID and process name, but also private bytes and the full path to the executable. Use Select-Object to get those four fields instead of the eight defaults (the four names are from the output of Get-Member, above):

  Get-Process | Where-Object {$_.PrivateMemorySize -gt 1000000} | Select-Object Id, PrivateMemorySize, Name, Path

We can sort by any of the four fields:

  Get-Process | Where-Object {$_.PrivateMemorySize -gt 1000000} | Select-Object Id, PrivateMemorySize, Name, Path | Sort-Object -Property PrivateMemorySize

When this is output to the screen, it is way too wide. To get more readable output we can effectively reverse rows and columns with Format-List:

  Get-Process | Where-Object {$_.PrivateMemorySize -gt 1000000} | Select-Object Id, PrivateMemorySize, Name, Path | Sort-Object -Property PrivateMemorySize | Format-List

Alternatively, we can get the output into a GUI window using cmdlet Out-GridView:

  Get-Process | Where-Object {$_.PrivateMemorySize -gt 1000000} | Select-Object Id, PrivateMemorySize, Name, Path | Sort-Object -Property PrivateMemorySize | Out-GridView

The GUI window is quite sophisticated. For instance, using Add criteria, all instances of svchost can be excluded from the displayed processes.


Using aliases and the fact that the parameter to Sort-Object is positional, it can be shortened to:

  ps | where {$_.PrivateMemorySize -gt 1000000} | select Id, PrivateMemorySize, Name, Path | sort PrivateMemorySize | Format-List

and

  ps | where {$_.PrivateMemorySize -gt 1000000} | select Id, PrivateMemorySize, Name, Path | sort PrivateMemorySize | ogv

, respectively.
 
On my system the last items in the output was:

Id                : 448
PrivateMemorySize : 56143872
Name              : powershell
Path              : C:\WINDOWS\system32\WindowsPowerShell\v1.0\powershell.exe

Id                : 3636
PrivateMemorySize : 90882048
Name              : CCC
Path              : C:\Program Files (x86)\ATI Technologies\ATI.ACE\Core-Static\ccc.exe

Id                : 4952
PrivateMemorySize : 349118464
Name              : opera
Path              : D:\Program Files (x86)\Opera1051\opera.exe

Id                : 2648
PrivateMemorySize : 630624256
Name              : firefox
Path              : D:\Program Files (x86)\Mozilla Firefox27\firefox.exe

Firefox took up 601 MB, the Opera web browser 332 MB, some videodisplay thingy 87 MB and PowerShell itself 54 MB. 


2013-02-26

M95C512 is a 64 kilobyte EEPROM

M95C512 is not googable (or bingable for that matter) - although M95512 is.

M95C512 is a standard serial EEPROM in STMicroelectronics's (ST) M95 series and is a 512 kbit (64 kilobyte) serial SPI bus EEPROM.

The datasheet (PDF) is at http://www.st.com/web/en/resource/technical/document/datasheet/CD00048102.pdf. Here it is listed as M95512-W, M95512-R, M95512-DR, and M95512-DF (the difference is in the lowest supply voltage they accept; they have 5.5 V as their upper limit).

So why did I post this information? Because I am working every day with a device that employs a M95C512!

2012-04-15

The scripting story for .NET

Update 2014-08-16:

Promising references:

  1. Make your .NET application support scripting - a practical approach
  2. Scripting for .NET
  3. Script Happens .NET  "Writing applications that host a script engine to enable people to write scripts to customize and extend applications has proven to be very successful" 
  4. Using .NET to make your Application Scriptable  "The Object Model, Host Application & Script Editor"




Finding the scripting story of .NET (and what to actually do in order to implement scripting in a .NET application) turns out to be very hard. Part of the reason may be that scripting is not in vogue anymore, even though it is (still) important for any successful desktop or server application - sooner or later there will be a need to automate things, instead of tediously doing things only through the user interface.
An indication of the sad state of affairs is that Stack Overflowers will completely misunderstand a question of this kind and think it is about choosing a particular scripting language (PowerShell, Iron Python, etc.) when the question is about how to make an application scriptable and define/implement an object model. They will completely fail to understand what an object model is, even if it is explained in the question (often they will not read such an explanation, but immediately associate "scripting" or "scriptable" with "scripting language").
In the 1990s both Apple and Microsoft had focus on scripting. Apple with the Open Scripting Architecture (OSA) and Microsoft with COM. Both had "object models", a term that is often misunderstood by the ignorant or those that think in terms of a programming language for implementing an application. An object model is how an external application or script (internal or external) sees and interact with the application. A class in the object model represent something in the application and roughly represent the same thing as from the user interface.
For instance, in many cases there is a document class that represent a document in the application. The document class will often have a property named "title" (property is also an object model term and is not to be confused with, say, properties in binary components in COM or .NET). Changing the "title" property of a document in an external script will have the side effect of changing the title in the running instance of the application, corresponding to (in this case) of the user doing a Save As operation to save the document in a new file and as a result changing the title of the document.
Microsoft has implemented object models in their Office Suite of applications.
With the advent of .NET there was not much fanfare regarding scripting, but the scripting story for .NET may actually have been summarised by the MSDN Magazine article "Scripting and .NET: Visual Studio for Applications Provides Customized Scripting Facilities for Your .NET Project" (2002-08):
In the past, the Microsoft Active Scripting architecture has allowed you to make your applications extensible. But it came with some drawbacks. You couldn't call into DLLs; you had to use COM interfaces. The scripts were not compiled, so they ran more slowly than they otherwise might, and a number of objects had to ride along with the script. To solve these problems and make extensibility easier to attain, Visual Studio for Applications (VSA) was introduced.
The Microsoft® Active Scripting architecture was a COM-based solution that met many of these criteria, but it wasn't perfect."
The Microsoft .NET platform has a set of classes that offers the benefits of Active Scripting without the drawbacks. This set of classes, named Visual Studio® for Applications (VSA), provides a pluggable IDE and debugger for Visual Basic® .NET."
But that is 10 years ago, so where are we now?
VSA, though, is not even contained in Wikipedia.
Further reading:


To Be Continued...

2011-12-29

Firefox version history

Ever wondered when a particular feature was introduced in Firefox and not being able to navigate the maze that is mozilla.org?

There is a Wikipedia page with Firefox's version history!

The table in section Release history has information for each minor version, for example, "3.6.21 - Off-cycle security update. Blacklisted a compromised HTTPS certificate.".