Monday, October 24, 2016

Ubuntu 16.04 (or any other recent linux) and the Canon LBP6020B laser printer

My last post on battling with the Canon LBP6020 seems to have been quite
populer (my one and only post that regularly appears near the top of a
relevant google search), however it's getting a bit old now (Ubuntu
14.04).

I switched my daily laptop from Ubuntu to Arch Linux about a year ago,
and at the time was able to install the Canon drivers through the AUR
and everything was fine (as much as it ever is with a LBP6020).
Sometime earlier this year a regular update changed all that and it
hasn't worked since.

I finally got around to learning about docker and thought that it might
provide a solution to the LBP6020, i.e. a stable environment in which to
run the driver.

Now thanks to ticosax/cups-in-docker and Nik I've got a docker container
which appears to be reliably printing (although admittedly with only a
little testing).

If you're running Ubuntu 16.04, or any other linux capable of running
docker, this may provide a simple way to get a LBP6020 printing.

The docker image can be built from:

https://github.com/akgrant43/cups-in-docker

Instructions are in the readme.

Wednesday, December 2, 2015

hstr (hh) and fish

Thanks again to the team at the Ubuntu podcast and their listeners I'm trying out hstr, but unlike Martin, didn't want to switch from fish back to bash, so...

The proper way to do this would be to modify hstr to support the fish history file format, but I wanted to try it out a bit before putting the effort in (if I ever get around to it).

The following steps provide a poor man's port by forcing fish to maintain a bash compatible history file (in addition to fish's own history) and pointing hstr to it:

1. Modify your fish prompt to save the bash compatible history file:

~/.config/fish/functions/fish_prompt.fish:

function fish_prompt
    .
    .
    .
    echo $history[1] | grep -Ev '(^hh$|^sd|^l.$)' >> ~/.config/fish/hh.history
end


The command as written above filters out the hh command itself, my version of cd, sd, and directory list commands such as ls, ll, lh, etc.


2. Set HISTFILE in config.fish:

~/.config/fish/config.fish:

set -x HISTFILE ~/.config/fish/hh.history

If you want your existing fish history to be available immediately, use Martin's command line love from S08E32:

grep cmd ~/.config/fish/fish_history | cut -d' ' -f3- | sort -u >> ~/.bash_history

Alternatively you could just point HISTFILE to ~/.bash_history.

Saturday, April 25, 2015

Genius NetScroll 200 Laser Mouse & Linux USB3

My trusty Fujitsu mouse recently died after many years of service - 10?, I'm not sure.  I'll use a touchpad when not at a desk, but extended use drives me crazy, so it was off to the local shop and pick up something quick.

That turned out to be a Genius NetScroll 200 Laser mouse.

While it appears to have some good reviews, I assume they were on Windows or Linux machines connected to USB2 ports (eHCI).

My experience with USB3 (xHCI) has been much less positive.  The short version is that it appears that the firmware in the mouse crashes if the startup sequence strays too far from what the mouse expects, leaving it non-functional.

So...  If your PC only has USB3 ports, you run Linux, and you're looking for a new mouse, I'd suggest at least testing it before laying down your hard earned money.

If you're interested in the details, please see http://thread.gmane.org/gmane.linux.usb.general/124622/focus=124624

Wednesday, January 28, 2015

Video capture with the Hauppauge USB-Live2

I'm a bit behind the times and have only just started converting old analogue video tapes to digital format.

I chose the Hauppauge USB-Live2 to perform the analogue to digital conversion, and have been very happy with the results.

The command I used for the capture was:

mythffmpeg -y -loglevel debug -f alsa -i plughw:1,0 -f v4l2 -s pal -pix_fmt yuyv422 -i /dev/video0 -b:v 2048k myfile.nut

on a Mythbuntu 14.04 system, although it should be easily adaptable to other installations, e.g. using ffmpeg instead of mythffmpeg.

The components of the command that may need to be changed:

The Audio input device (plughw:1,0): On my system, executing:

> arecord -l
**** List of CAPTURE Hardware Devices ****
card 0: Intel [HDA Intel], device 0: AD1981 Analog [AD1981 Analog]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 1: Cx231xxAudio [Cx231xx Audio], device 0: Cx231xx Audio [Conexant cx231xx Capture]
  Subdevices: 1/1

  Subdevice #0: subdevice #0

Shows that the Live2 (which uses the Cx231xx drivers) is card 1, subdevice 0.  And:

> arecord -L
[... removed irrelevant entries ...]
default:CARD=Cx231xxAudio
    Cx231xx Audio, Conexant cx231xx Capture
    Default Audio Device
sysdefault:CARD=Cx231xxAudio
    Cx231xx Audio, Conexant cx231xx Capture
    Default Audio Device
dmix:CARD=Cx231xxAudio,DEV=0
    Cx231xx Audio, Conexant cx231xx Capture
    Direct sample mixing device
dsnoop:CARD=Cx231xxAudio,DEV=0
    Cx231xx Audio, Conexant cx231xx Capture
    Direct sample snooping device
hw:CARD=Cx231xxAudio,DEV=0
    Cx231xx Audio, Conexant cx231xx Capture
    Direct hardware device without any conversions
plughw:CARD=Cx231xxAudio,DEV=0
    Cx231xx Audio, Conexant cx231xx Capture
    Hardware device with all software conversions

shows that plughw has all the format conversions.  Putting the two together gives plughw:1,0.  I think that plughw:CARD=Cx231xxAudio,DEV=0 will also work, but haven't tested it.

The video device (/dev/video0) can usually be guessed by looking at the output of ls /dev/video*.  If there's only one video device, that's it, if there are two, the first is probably the built in webcam.  If you really want to be sure, look in /var/log/syslog at the time you plugged the Live2 in:

Jan 28 14:30:49 myth kernel: [ 5319.874560] cx231xx #0: cx231xx #0/0: registered device video0 [v4l2]
Jan 28 14:30:49 myth kernel: [ 5319.874652] cx231xx #0: cx231xx #0/0: registered device vbi0
Jan 28 14:30:49 myth kernel: [ 5319.874656] cx231xx #0: V4L2 device registered as video0 and vbi0

The PC I used for transfer doesn't have a webcam, so it is video0, as confirmed in the syslog extract above.

-b:v 2048k specifies the bitrate to record at.  2048k is probably overkill, but I figured that I won't have another chance to capture the tapes, so a little extra disk space isn't worth worrying about.

After capturing the video I trimmed the blank video at the start and end, and fixed the timestamps using:

mythffmpeg -ss -t -fflags +genpts -i myfile.nut -vcodec copy -acodec copy myfile.mkv

Where x is the start offset in seconds, and y is the length of the video in seconds.

Some articles I've read have discussed capturing video simply using:

cat /dev/video0 > file.mpg

this won't work for the Live2 as it is a simple frame-grabber, and doesn't have onboard compression.

The only hiccup in the whole process is that the Live2 more reliable if it is plugged in to a USB port that is using the ehci stack.  Newer computers that support USB3 and use the xhci stack will have problems.  If you want to check, once again looking at /var/log/syslog:

Jan 28 14:30:45 myth kernel: [ 5316.076069] usb 1-6: new high-speed USB device number 3 using ehci-pci
Jan 28 14:30:45 myth kernel: [ 5316.210847] usb 1-6: New USB device found, idVendor=2040, idProduct=c200
Jan 28 14:30:45 myth kernel: [ 5316.210856] usb 1-6: New USB device strings: Mfr=1, Product=2, SerialNumber=3
Jan 28 14:30:45 myth kernel: [ 5316.210860] usb 1-6: Product: Hauppauge Device
Jan 28 14:30:45 myth kernel: [ 5316.210863] usb 1-6: Manufacturer: Hauppauge

From the first line above we can see that in this case the Live2 is using a ehci port.

[EDIT 11 APRIL 2015] Kernel 4.0-rc7 includes patches which largely resolve the issues with USB3 / xHCI ports and Intel xHCI controllers.  More specifically, the problem was with Intel xHCI controllers and isochronous USB devices (i.e. video and audio capture devices).  It looks like there are still some issues, however the current hypothesis is that they are issues to do with the cx231xx driver that are triggered by the differences between the eHCI and xHCI drivers.  Depite these issues, if you have an Intel xHCI controller, cx231xx devices are now usable on USB3 ports, and other video / audio capture devices may well work without any problems.  If you're interested in the details, please see: http://www.gossamer-threads.com/lists/linux/kernel/2126922

Many thanks to Devin Heitmueller, Mathias Nyman and Lu Baolu for their assistance it getting the Live2 working for me.

[EDIT 25 Apr 2015] More good news: The patch has been back-ported to 3.19.5, 3.14.39 and 3.10.75.

[EDIT 20 Jun 2015] More good news: Ubuntu kernel 3.19.0-21 (and a couple of earlier version, I think) are based on mainline 3.19.8, which include a few more fixes than mentioned above.

Sunday, January 18, 2015

Guake and Fish

With many thanks to Alan Pope via the Ubuntu UK Podcast I've switched my terminal environment from the standard gnome-terminal with bash to Guake and fish.

Guake suits my workflow as I like to have applications in separate workspaces and switch between the terminal and application.  Guake, which gets its name and style of operation from early first-person-shooter games such as Quake (except it's for Gnome, get it? :-)) is easily accessible via a hotkey - F12 by default - and will always display in the current workspace.

To learn more, see:

* https://github.com/Guake/guake - the official repository
* http://dalibornasevic.com/posts/48-guake-terminal-for-super-productivity - provides some useful configuration tips

To install and automatically start at logon in Ubuntu 14.04:

sudo apt-get install guake
ln -s /usr/local/share/applications/guake.desktop ~/.config/autostart/guake.desktop


Fish - the Friendly Interactive Shell for the 1990's is a step up on bash for two simple reasons:

1. Searching and running previous commands is much more convenient than in bash.  Once can simply type in a part of the command, any part, press the up arrow and step back through commands that contained the search string.

2. While typing a command fish will offer to auto-complete it with what it thinks you want, based on command history and the current directory contents.  You can 1) ignore the offer and type your command in full, 2) press tab to auto-complete in the same manner as bash, or 3) press the right arrow to accept the suggested command, and then Enter to execute the command.

The version that is included in Ubuntu 14.10, lacks two key features that I use: vi style editing and shared history across sessions.

Fortunately, the release currently in development addresses both of these.  To install the nightly build on Ubuntu:

sudo add-apt-repository ppa:fish-shell/nightly-master
sudo apt-get update
sudo apt-get install fish


This, of course, comes with the usual disclaimer that it is still in development and you are likely to encounter bugs.  I haven't had any problems yet, and figure that if something does go drastically wrong I can boot a USB stick and set my shell back to bash until the problem resolves itself.

To learn about fish, simply type help at the prompt and a browser window will be opened.

To edit your configuration, type fish_config and once again a browser window will be opened that will allow you to set colours (as the official web page says, you'll have an astonishing 256 colors available for use), modify the prompt, view functions, variables, command history, key bindings and abbreviations.

To enable vi mode and shared history place the following in your config file (~/.config/fish/config.fish):

fish_vi_mode
function fish_prompt
    history --merge  # This enables shared command history across sessions
    fish_vi_prompt
end


Vi mode editing is still a work in progress, and is missing a few features, e.g. replace mode, however, if like me, you only use it for editing particularly long commands it will probably be more than adequate.

You can also get a poor man's replace (r) function by adding the following:

bind -m insert r delete-char force-repaint


This simply deletes the character under the cursor and puts the editor into insert mode.  Saves a keystroke sometimes.

Useful links:

* http://fishshell.com/ - the official website
* https://github.com/fish-shell/fish-shell/wiki/Nightly-builds - nightly builds

Enjoy!

Monday, August 18, 2014

BitScope DDR type field enumeration anyone?

The BitScope DSO software supports recording data to csv files for later analysis, which should be quite useful.  Unfortunately, interpreting the data is not so easy...

One of the columns is the "type" field, which the DSA Data Recorder manual describes as:
Type: the capture data type (analog, logic, decimated, filtered etc)
However if you look at a sample file, it is obviously an enumerated type.

I haven't been able to find any more details despite numerous google searches, and a request to BitScope support on 6 July hasn't been answered.

Has anyone been able to figure this out???

Saturday, June 14, 2014

Ubuntu 14.04 and the Canon LBP6020B laser printer

The Canon in general, and the LBP6020 in particular, haven't had a good reputation on Linux / Ubuntu, however the good news is that while it still doesn't work out of the box, support appears to have improved recently.

If you're running Ubuntu 16.04, or any other linux distribution that supports docker, I suggest you look at my updated post "Ubuntu 16.04 (or any other recent linux) and the Canon LBP6020B laser printer".

If you're running something between Ubuntu 14.04 and 15.10, read on...

The latest Canon Linux drivers, available from Canon Europe, with release date 28 May 2014, includes support for the LBP6020 (earlier drivers may have, this is the first that I've seen).

When trying to get the printer working, the two main articles I used were:

The first indicates that the 32 bit libraries need to be enabled on 64 bit Ubuntu.  The drivers linked above include a 64 bit version, so I'm not sure if this is necessary any more (I already had the 32 bit libraries enabled).

Other than that, the steps I followed were:

Download the drivers from Canon Europe, and install:

tar xzvf ~/Downloads/Linux_CAPT_PrinterDriver_V260_uk_EN.tar.gz 
cd Linux_CAPT_PrinterDriver_V260_uk_EN/64-bit_Driver/Debian/
sudo dpkg -i cndrvcups-common_2.60-1_amd64.deb
sudo dpkg -i cndrvcups-capt_2.60-1_amd64.deb

Check that the LBP6020 is supported directly:

grep -H ModelName /usr/share/cups/model/*.ppd | grep 6020

You should see CNCUPSLBP6020CAPTK.ppd in the output.

Assuming that you only have one USB printer plugged in, check which device it is:

ls /dev/usb/lp*

Then define the printer queue (LBP6020 in the example below) with the device found above:

sudo lpadmin -p LBP6020 -m CNCUPSLBP6020CAPTK.ppd -v ccp://localhost:59687 -E
sudo ccpdadmin -p LBP6020 -o /dev/usb/lp0
sudo service ccpd start
sudo service cups restart

Check that the ccpd service appears to have started correctly:

On Ubuntu versions prior to 15.04:

sudo service ccpd status
On Ubuntu 15.04:

sudo /etc/init.d/ccpd status

You should see two numbers at the end of the line, if not, something's not right.  You can try looking in /var/log/cups/, but the information is unfortunately sparse.

Once the printer has been installed and is working, to start the printer:

# Switch the printer on and wait for it to settle

# Confirm that the usb device exists and matches the device in /etc/ccpd.conf:

ls /dev/usb/

# Start the ccpd service:

sudo service ccpd start

# Restart CUPS

sudo service cups restart

# Check that the service appears to have started correctly

sudo /etc/init.d/ccpd status


Hope this helps.

EDIT 24 Oct 2016: Added reference to a new post for Ubuntu 16.04 and other recent linux distributions.

EDIT 30 Apr 2015: Updated the status check for Ubuntu 15.04, and included the restart instructions from 11 Dec 2014.

EDIT 28 Feb 2015: Removed the command to autostart the service.  The sequence posted in the comments on 11 Dec 2014 assumes that the service hasn't been started.