lynsayshepherd.com
October 18th 2015

Wireless Printing/AirPrint Server via the Raspberry Pi [updated guide]

NOTICE: This blog post is based on my original post from 2012 which you can find here- https://www.lynsayshepherd.com/blog/2013/01/14/wireless-printingairprint-server-via-the-raspberry-pi/.

Before going any further, update your Pi:

sudo apt-get update
sudo apt-get update

Next, install the following packages required for printing. I think the avahi-discover package is still required (I installed it anyway)

sudo apt-get install avahi-discover cups cups-pdf python-cups

Grab a cup of tea whilst the packages install. You’ll need to add your username to the CUPS server so you’re able to add printers, view print queues, etc.

sudo usermod -aG lpadmin pi

Check that CUPS has installed correctly and that the service works.

sudo /etc/init.d/cups start

You’ll need to check the Avahi service works too (it finds various devices on the network which are discoverable). Again, I’m not 100% sure this is required with the more up-to-date versions of CUPS. You can try omitting it if you wish.

sudo /etc/init.d/avahi-daemon start

Next, you’ll need to edit the CUPS config file:

sudo nano /etc/cups/cupsd.conf

You’ll need to set-up the port we’re going to be listening on. Comment out the line that reads “Listen localhost:631”. Add in “Port 631”. It should look something like this:

#Listen localhost:631
Port 631

The config file will also need to be edited to control access to the server by adding “Allow @Local” in several places e.g.:

# Restrict access to the server...
Order allow,deny
Allow @Local

You need to include it in these areas of the config file:

# Restrict access to the server...
# Restrict access to the admin pages...
# Restrict access to configuration files...

Save the config file and restart the CUPS service:

sudo /etc/init.d/cups restart

Now, find the IP address of your Pi. It’ll be something like 192.168.1.x

ifconfig

Navigate to the CUPS configuration page by typing the IP address you just retrieved and the port number CUPS uses (so it’ll be an address like 192.168.1.x:631). A security exception message may pop up but that’s ok.

Click on the Admin tab and view the server settings which are towards the right-hand side of the screen. Tick the box that says “share printers connected to this system”.   You’ll be asked for the username and password of the Raspberry Pi.

Plug your printer into one of the USB ports on the Pi. Click “add printer” in the CUPS web interface and it should appear under local printers. You’ll have to fill in details for the printer, such as name and location. You can enter whatever you want in here but the important part is ensuring you tick the “share this printer” box.

Following this, you’ll have to select the appropriate printer driver from a (large) list that appears. Enter print and paper settings too. You’re now ready to click on maintenance > print test page. If everything has gone to plan, the test page will print successfully.

Wireless printing should now work!

In the past, I have included a section regarding AirPrint, with details on how to set that up. AirPrint is now supported by CUPS and it should (and I emphasise “should”) work. Personally, I have tested it on both i0S 9.0.2 and iOS 6.1.6 and had no problems printing.

The section on printing with Windows has been omitted this time around too- I use OS X, iOS or, Raspbian 99% of the time. Sorry.

May 20th 2015

Using multiple Firefox profiles on OS X

If you’re developing Firefox extensions, it may be useful to have multiple profiles: one for every day use containing the extensions/setting you use regularly, and another as a development environment. Separate profiles ensure that if you accidentally break something during development, your usual browser environment will remain the same. I’ve found this to be particularly useful so thought I’d write a post about it. Before I get started, I should point out this post is geared towards OS X users.

First of all, you will need to access Firefox’s profile manager tool. To do this, type the following into the Terminal-

/Applications/Firefox.app/Contents/MacOS/firefox-bin --profilemanager

This will cause the Profile Manager window to appear. If you’re already a Firefox user, your default profile should appear. Click on the Create Profile button to make a new profile. Give it a name (remember this name) and choose the folder in which you wish to store your profile information. For the purpose of this post we’ll call our profile “devProfile”. That’s all there is to creating a new profile however, if you wish to use it as a development environment, you must launch it with Firefox. The next part of this tutorial will show you how to create a second instance of Firefox for your development profile.

Open the Script Editor app. On Yosemite, this can be found in Applications > Utilities > Script Editor. Type in the following-

do shell script "/Applications/Firefox.app/Contents/MacOS/firefox-bin -P devProfile"

When typing in the script, watch the quote- ensure they are regular double quotes, rather than smart quotes. Save the file as an Application. Now we need to Info.plist file. This can be found by right-clicking on the Application you just saved > Show Package Contents > Contents. Find these 2 lines-

<key>LSRequiresCarbon</key>
<true></true>

Under the true tag, add the following 2 lines-

<key>LSUIElement</key>
<string>1</string>

LSUIElement is a Launch Key in OS X. Launch keys help to launch apps and figure out which apps should open certain document types. According to Apple’s Documentation, LSUIElement Specifies whether the app is an agent app, that is, an app that should not appear in the Dock or Force Quit window.

That’s really all there is to it. You can change the icon on the new Launcher Application you have just created (or leave it as the default script icon, but that’s a bit boring). When clicked, the Application will cause another Firefox icon to appear in the Dock. This instance of Firefox will launch with the development profile you created.

Of course, an alternative way of launching a new instance of Firefox with a development profile is to use the Automator app.

February 16th 2015

Benchmarking the Raspberry Pi

raspberry pi
Since I now have various models of the Raspberry Pi sitting on my desk, I figured I’d benchmark them (to satisfy my own curiosity). Obviously, the new Raspberry Pi 2 Model B is faster, that’s a no brainer, given the improved spec of the system.

A few points before I begin. My Raspberry Pi Model B is the version with 512MB RAM. As for cases, my Model B is in an original Pibow case, the other 2 devices are encased within Pibow Coupes. All have 16GB class 10 SD Cards in them. No overclocking, no overvolting. I’m not going to list the full spec of each of the devices; this page contains information for each revision.

The benchmarking tools came from Roy Longbottom. Longbottom’s site provides a comprehensive library of benchmarking tools, along with an explanation of what each of the tests actually do.

Here’s a summary of the tests I ran.

Whetstone Benchmark
Raspberry Pi Model B Raspberry Pi Model B+ Raspberry Pi 2 Model B
MWIPS (million whetstones instructions per second) 270.808 272.801 530.060
secs 10.044 9.934 9.980
Dhrystone Benchmark
Raspberry Pi Model B Raspberry Pi Model B+ Raspberry Pi 2 Model B
Nanoseconds one Dhrystone run 671.88 668.75 370.00
Dhrystones per Second 1488372 1495327 2702703
VAX MIPS rating 847.11 851.07 1538.25
Linpack Double Precision Unrolled Benchmark
Raspberry Pi Model B Raspberry Pi Model B+ Raspberry Pi 2 Model B
MFLOPS (mega floating-point operations per second) 41.76 44.02 119.79
Livermore Loops Benchmark (overall ratings)
Raspberry Pi Model B Raspberry Pi Model B+ Raspberry Pi 2 Model B
Maximum 146.7 148.6 250.1
Average 64.4 64.7 126.6
Geomean 54.8 55.0 115.4
Harmean 46.7 46.7 104.3
Minimum 21.3 17.6 41.8

I also ran a few temperature tests though I’m not convinced the results I got were accurate. The tests showed that the Model B produced temperature readings which were 7-8 degrees celcius higher than the other 2 Pis. It had been sitting running constantly for a few days prior to testing so I’d expect it to be warmer in this case. The other 2 Pis had only just been switched on.

So there you have it. The Raspberry Pi 2 Model B is definitely faster (duh). Still, I think the figures presented in each of the tables make for an interesting comparison.

February 14th 2015

Raspberry Pi 2 Model B and a camera flash

You may have heard about an issue with the new Raspberry Pi 2 Model B computers which were released recently. If you haven’t, the story is that the Pi will unexpectedly reboot if a camera flash is triggered too close to the computer. Apparently it’s caused by the photoelectric effect, which is very interesting. The camera has to be relatively close for it to work though and I don’t think it’s a huge issue. Cool though!

My conclusion: the Pi is shy, and there’s nothing wrong with being shy.

I managed to replicate the issue, and I have posted a video of it on YouTube.

February 14th 2015

Raspberry Pi 2 Model B- an overview

Last Monday, the Raspberry Pi foundation announced the launch of the Raspberry Pi 2 Model B. Being a massive geek, I had to purchase one, and on Tuesday evening, one landed on my doorstep.

The Raspberry Pi 2 Model B is a huge improvement compared to both the first and second revisions of the original Raspberry Pi Model B. The original Model B had a 700 MHz single-core ARM1176JZF-S processor and 256MB RAM. The newly released Raspberry Pi 2 Model B features a 900MHz quad-core ARM Cortex-A7 CPU and 1GB RAM. Saying that it’s much faster is an understatement!

The Raspberry Pi 2 Model B also features 4 USB ports, 40 GPIO pins, HDMI port, Ethernet port, 3.5mm audio jack/composite video port, camera interface, display interface, micro SD card slot and a VideoCore IV 3D graphics core. All for just under £30 which is an absolute bargain!

The new Raspberry Pi will also be capable of running Windows 10. Microsoft announced the version of Windows 10 for the Pi will be free and will run natively. Currently, the Maker community is being encouraged to register as a Windows Internet of Things Developer. The link is- https://dev.windows.com/en-us/featured/raspberrypi2support.

Though I haven’t yet had much time to play with the new Raspberry Pi, I’m really excited about the development. I think the foundation are making computing education more accessible and affordable. Purchasing my first Pi inadvertently taught me about electronics, and it even got me soldering again (something I hadn’t done since my first year of High School). If a Pi has had that effect on me, a seasoned nerd, it must be fantastic for those just starting to learn about computers.

Anyway, I’m off to think up some new projects for my new Pi!