Fairly Positive

Success in Scanning a University Barcode

Yay! I’ve managed to successfully scan some telepen barcodes (including one in a University library book) with the iPhone.

Successfully scanned barcode

I created a telepen decoder to work with the ZBar barcode reader library and related iPhone SDK. The code needs more testing and improving, but I’m happy with the result.

How the Barcodes Numbers Are Encoded and Decoded

In a previous post I noted that Telepen is the proprietary barcode format used in the Library at the University of Bristol. The Telepen symbology is publicly available and this post documents my understanding of the symbology.

The symbology has a number of key characteristics:

  • It represents the full ASCII character set
  • Characters take up the same amount of space
  • Wide to narrow bar ratio is 3:1
  • Four possible combinations of wide and narrow bars and spaces
  • Can be read as a binary sequence; uses 8-bit even-parity characters
  • Has a start character(_), stop character (z) and a check character

Telepen barcodes can represent numeric data (like the numbers used by the University) in a double-density mode. This means an ASCII character is used to represent a pair of numeric characters.


For each pair of numbers (15 11 07 59 64), we add 27 to get their ASCII representation (17-26 are reserved for the character series 0X to 9X), which leaves us with:

42 38 34 86 91

These should be prefixed by the start character ‘_’ (ascii value of 95) and postfixed by the check digit (90 in this case) and the stop character ‘z’ (ascii value 122), giving us:

95 42 38 34 86 91 90 122

The values can then be looked up in the symbology character set to create the barcode. Alternatively, for creating barcodes for testing, I used a barcode generator with the unencoded values:

telepen barcode for 1511075964

To decode the barcode you could analyse the image against the symbology character set. However, more interestingly, the barcode can be read as a bit stream. There are four possible patterns:

  • narrow bar + narrow space (1)
  • wide bar + narrow space (00)
  • wide bar + wide space (010)
  • narrow bar + wide space (01 or 10 - alternates within a byte)

We are dealing with 8-bit even-parity characters which are encoded with least significant bit first.

Looking at the barcode above, the first pattern is a narrow bar and a narrow space (1) giving us the pattern:


There are then four more narrow bar and narrow space patterns (1), giving us the following pattern:


The next pattern is then a wide bar + wide space (010), so we now have the following 8 bit pattern:


The decimal value for this pattern is 95, which represents ‘_’ in ascii which, in turn, is the start character for the barcode.

If we continued to look at the next set of bar and space patterns, we would get the following 8 bit pattern:


So, the decimal value for this pattern is 170. However, the most significant bit is set to 1 and this can be discounted to obtain the correct ascii value. The decoded bytes are even parity, so if the first 7 bits in the byte have an uneven number of 1s then the most significant bit will be set to 1 - this provides some simple error detection when decoding the barcodes.

We can use a bitwise operation to mask the most significant bit to obtain the ascii value:

int ascii_value = decoded_byte & 0x7F

In the case of 170 that would leave us with 42. If we deduct 27, that will leave 15, which are the first two digits if the barcode number 1511075964.

If we decoded all of the patterns we would have the following numeric values:

95 170 166 34 86 219 90 250

After we mask the most significant bit we are left with:

95 42 38 34 86 91 90 122

We can remove the start character ‘_’ (95) and the stop character ‘z’ (122) and that leaves us with the decoded numbers and the check digit:

42 38 34 86 91 90

To validate against the check digit obtain the sum of the numbers (excluding the check digit):

42 + 38 + 34 + 86 + 91 = 291

We then use modulus 127 to find the remainder:

291 % 127 = 37

Deduct the remainder from 127 to get the check digit:

127 - 37 = 90

So, the check digit matches! If we then subtracted 27 from each of the decoded numbers:

42 - 27 = 15, 38 - 27 = 11, 34 - 27 = 07, 86 - 27 = 59, 91 - 27 = 64

Thus, giving us 15 11 07 59 64. :-)

There are some exceptions to be noted.

  • The barcode numbers can end in X, and so the pair sequence 0X to 9x are represented by values to 17 to 26.
  • When working out the check digit, if the calculated value is 127 then the check digit is actually 0
  • There are other conditions when representing ascii values and not the double-density numeric mode - I won’t worry about those for the moment since I’m interested in only numeric values for this project.

In future posts, I’ll document how I’m attempting to write a decoder for the ZBar bar code reader so I can decode the telepen barcodes without using pencil and paper. :)

University of Bristol Barcode Numbers

The Telepen barcode used by the Library at the University of Bristol encodes a 10 digit number that uniquely identifies an item of stock such as a book or journal. The barcode number has a number of characteristics:

  • The first digit is the prefix and is always the number 1
  • The second through to the 9th digit will be from the range 0 to 9.
  • The tenth digit is the check digit and can range from 0 to 9 or be the character X

The check digit allows us to test whether or not the barcode number is a valid number used by the University, since we use a specific weighting algorithm. This is independent of the check digit used by the Telepen barcode symbology.

In testing the check digit we ignore the prefix which is the first digit. Each remaining number is multiplied against a relevant weighting in the following list: {7, 8, 4, 6, 3, 5, 2, 1}. Modulus 11 is then used on the sum of the weighted values to get a remainder. The remainder is then subtracted against 11 to get the check digit value. If the value is 10 or 11, then that is represented by the characters X or 0 respectively.

Example 1


We ignore the prefix and multiply the next 8 digits against the appropriate number in the weightings list:

(5 x 7) + (1 x 8) + (1 x 4) + (0 x 6) + (7 x 3) + (5 x 5) + (9 x 2) + (6 x 1) = 117

Find the remainder:

117 % 11 = 7

Subtract from 11 to find the check digit:

11 - 7 = 4

Therefore, 1511075964 is a valid University barcode because the last number matches the check digit created by the algorithm.

Example 2


Ignore the prefix and multiply the next 8 digits against the appropriate number in the weightings list:

(4 x 7) + (2 x 8) + (8 x 4) + (3 x 6) + (7 x 3) + (0 x 5) + (7 x 2) + (4 x 1)

Find the remainder:

133 % 11 = 1

Subtract from 11 to find the check digit:

11 - 1 = 10

10 is represented by X and this matches the last digit of 142837074X

Reading Telepen Barcodes

The Library at the University of Bristol uses Telepen barcodes for stock management. In the m-biblio project I’d like to be able to read the barcodes within the smartphone application we are creating. I’m looking at using the ZBar bar code reader, which also includes an iPhone SDK. ZBar supports a number of barcodes implementations, including EAN-13/UPC-A, UPC-E, EAN-8, Code 128 and QR Codes. However, it doesn’t support the Telepen barcode symbology. I’ve spent far more time that I’d like to admit into looking at how easy it would be to add a new decoder to the ZBar SDK to decode the Telepen symbology. It probably would have been a lot easier if I’d written a reasonable amount of C in the last eight years.

I’ve had some success implementing a new decoder that can successfully decode a number of Telepen barcodes of various sizes. For example, the following barcode was decoded by using the command line zbarimg utility:


Alt text

I’m planning to document what I’ve learnt and implemented over a series of blog posts.

Currently Working on … M-biblio

At work I’m currently working on the JISC funded m-biblio project. The project started in November and runs until the end of July. The aims of the project are fairly ambitious considering the time and effort available:

“We propose to enhance the learning and research activities of the University of Bristol’s academic community by developing a mobile application that can record and organise references to books, journals and other resources. These references can be added actively by scanning barcodes and QR codes, or passively by automatically recording RFID tags in items being used for study and research. With permission of the user, the application will submit anonymous usage data to their library. This innovation will provide library staff with a valuable set of user-derived usage statistics. It will be able to track which resources were used, and where. The library will therefore be given a rich seam of usage patterns, including data about library items that are often confined to branches such as periodicals, journals and reference books. The application will be made available to the wider FE/HE community for use in other institutions.”

We were hoping to be able to read the library’s RFID tags with NFC capable phones, but this isn’t possible due to the way the tags are encoded. I’m currently focussing on adding telepen decoder support to the ZBar bar code reader, so we can scan library barcodes via the phone’s camera. Telepen is the barcode format used by the library. My C is very rusty but I’m plodding along … who new bit twiddling could be so much fun? :)

Negative Reviews

I’ve got a pretty simple iPhone application on the App Store called Sensory Play. It recently got a negative 1 star review:

This is a total con, just a bunch of suggestions any parent with a special needs child would already do, it’s disgusting when people rip off others who are desperate for special needs apps. Want my money back!

Negative reviews are part and parcel of the App store but this one did annoy me a little. I’m not sure they are ideas that every parent will do, especially if you are just starting down the road of living with a young special needs child. Also, at 69p it is hardly expensive. It certainly pails in comparison to some of the kit we’ve had to purchase in the last few years that has the label ‘special needs’.

A little history of Sensory Play and why it was developed … Our son Thomas was born extremely premature and is severely disabled with numerous physical and learning disabilities. My partner, Alison, developed a number of ideas to engage with Thomas and placed them on laminated cards. One of Thomas’ sensory support professionals liked the cards and thought that other parents would find them useful and suggested that we printed more of the cards and sell them for a nominal amount. As an alternative, I wanted a project to start learning the iOS SDK and this seemed like a good opportunity. I worked on the app in 2009 and placed it on the App store.

I could have been altruistic and given the application away for free. However, setting the app at the lowest tariff (was 59p and now 69p) seemed a reasonable way of recouping some of the £59 a year I pay for the iOS developer programme. In 2011 we earned a very modest £108 for the application.

I think the product description needs updating to make it very clear what the application is about and maybe give more information on why the app was developed. More screen shots might help. That said, I’m not convinced that everyone reads descriptions and screenshots before downloading.

The app is well overdue an overhaul … the UI needs updating since doesn’t take into consideration retina displays and the extra screen retail estate provided by the iPad. Hopefully Alison has some additional ideas we can incorporate into the app. It would be good to allow parents to add their own ideas and maybe update the existing ideas to make them suitable for their own personal situations.

With regard to another 1 star review:

All the 6 reviews must of been written by authors of this “app” as it’s just a hand full of ideas nothing else , it’s just text for 59p absolute rubbish

I can confirm that neither Alison or I wrote any of the other reviews, although one does look like it was written by a well meaning relative.

Changing Blog Software

I’ve decided to change the blogging software I use from Wordpress to Octopress. I’ve migrated the old posts but they have different URLs - I’ll try and be a good ‘net citizen and add some redirects. The blog only had a dozen comments and I didn’t have the energy to migrate them. Since Octopress provides a way of creating a blog with static web pages I’m going to try the Disqus for comments in the future.

University of Bristol Walking Tour

I recently wrote an iPhone application that provides a guided tour of the University of Bristol’s precinct. You can get the application from the iTunes Store. The Undergraduate Recruitment team had already created the concept of a walking tour with a paper printed map and some mp3 files when I became aware of the idea in one of the MyMobileBristol project meetings. Delivering the content in an app seemed like the logical next step. The content was further developed by the Public Relations Office and Ben Hayes provided help with the design. I worked on bringing it all together with the iPhone SDK.

main screen of the app

The core of the application provides a map (that shows your location if you are near the campus) with a number of points of interest:

points of interest

Selecting a point will give you an audio narration and some photos:

audio and photos

The app also provides access to videos that should be of interest to prospective students:

list of videos available in the app

Version 1.0 of the application was around 22MB in size which was an issue because the phone won’t let you download anything that large over 3G. I compressed the audio files for version 1.0.1 and we are down to a slimmer 12MB.

Update 2011

On the 5th September I was lucky enough to attend Update 2011 (@updateconf) at the Brighton Dome. The event was part of Brighton Digital Festival and had a mix of sessions including presentations, panel discussions interspersed by music. I only went to the conference on the Monday but there were also a number of workshops on design and development on the following days.

The event had a generous education discount … nice :). Anyway, here are my rambling notes on some of the sessions …

The event kicked off with the event organiser, Aral Balkan, singing ‘The Flesh Failures/Let the Sunshine In’ with a live band - it certainly woke up the delegates.

Matt Gemmell (@mattgemmell) gave a talk on usability under an ‘evil’ persona (@evilmattgemmell), looking at how best we can create applications that annoy people, let them know that we have them and, if possible, cause physical injury :). The reverse psychology approach was refreshing and there were some key themes: do less, be useful, support orientaton, localise and be accessible. There were plenty of points to think about and I’ve already started to think about improvements to the Walking Tour iPhone app that I did for the University of Bristol.

Jeremy Keith (@adactio) provided a robust argument that we should be concentrating on using the Web rather than native applications and walled gardens - the Web is great because you don’t need permission to use it and it has a universality because it can be used by any device that has a Web browser. The whole Web versus the native app panel discussion aka Geek Ninja Battle. On the whole, I agree with the sentiment but clearly if you want to use certain hardware features like the camera, you currently have to use native APIs. For the Mobile Campus Assistant and MyMobileBristol projects at the University we opted to focus on the Web but, for some reason, App stores have captured a significant mindshare since people, on the whole, liked what we were doing but wanted to know when they could download it as an app.

Seb Lee-Delisle (@seb_ly) gave a live coding presentation on creating an Angry Birds clone (The Irritable Exorcists) in thirty minutes using the Corono SDK using Lua based code. It was certainly a fun session and Seb is a very engaging presenter. Seb also co-presents The Creative Coding Podcast which is on my list of things to listen too on the bus.

Sara Parmenter (@sazzy), a designer with plenty of experience of working with developers of iOS apps, gave a presentation on designing beyond the HIG and tips for working with developers. You should be thinking about designing with real content and avoiding Lorem ipsum and understanding how developers will use your designs.

Relly Annett-Baker (@rellyab) gave a presentation entitles ‘Arse Over Tit’ whose thesis focussed on the fact that developers decide they are going to make an app, but don’t think about the user and what problem they are going to solve.

Joachim Bondo (@osteslag), the creator of Deep Green Chess, presentation was called “Beyond Delicious” - from the title I thought it was going to be about improved social bookmarking but was actually about creating “delicious” applications that focussed on the user experience. Quality is more that the user interface and the user experience, it also extends to the code. Above all, quality takes time.

Cennydd Bowles (@cennydd) provided the closing keynote that talked about how current economic activity isn’t sustainable, with its planned obsolesce and artificial inflation of demand. However, society is changing and people want to be more than just consumers. Products need to be more human … well, humanise the projects we undertake. We also need to trust the intangibles - great UX creates trust and loyalty. This can’t be quantified. Profit will come. Disrupt, don’t differentiate. Aim for value and significance.

Dev8D, 2011

Professional Development

Last week (16-17th February, 2011) I attended the developer conference, Dev8D. This is the third time that the event has happened and the second that I have been able to attend. The focus of the event is to provide cost effective training for developers in Higher Education. The event is free to attend, so Institutions just need to pay for travel and accommodation. Is it worth the investment? Yes!

I’ve been very lucking in my career by having managers and mentors, at both the Universities of Cardiff and Bristol, who saw the importance of training and professional development. The purchase of books and attending training courses have been viewed positively when budgets and time allow. I was disappointed to learn that this is common across the case across the sector.

The event is comprised of tutorials, workshops, lightning talks, panel sessions by experts or ‘gurus’ and challenges. These sessions are predominately delivered by my peers - developers from across the sector. It is humbling to be able to engage with such a talented, clever and friendly bunch. The programme this year was full of exciting stuff, including Arduinos, Mongo DB, Mobile Web, Linked Data, Clojure, Scala, Apache SOLR and much much more.


I gave two lightning talks at the event. The first was on MyMobileBristol, which is a project I am currently working on. The project builds upon the (Java-based) software created in Mobile Campus Assistant and powers m.bristol.ac.uk as a beta service at the University of Bristol.

I also gave an introduction to the Nature Locator project which will support researchers at the Universities of Bristol and Hull with tools for receiving and processing crowd sourced data from members of the public.

I also sat on a ‘guru session’ about the Mobile Web with Tim Fernando and Chris Northwood from Oxford’s Molly team. Molly is an excellent Python/Django based framework for creating information and service portals targeted at mobile devices. Due to a scheduling clash I arrived ten minutes late and the questions and panel discussions had moved from the ‘Mobile Web’ to Python appreciation. I had nothing to add since my current comfort zone is in the verbosity of Java (and Objective-C!). However, the discussion soon moved back to issues such as native applications vs. Mobile Web.

Bragging Rights

This year I entered one of the programming challenges. I created an iPhone application that displays some of the data in JISC’s PIMs API - a database that holds information about JISC-funded projects both past and present. I won! I was a little surprised since the other entries were very good, including Paul Walks HTML 5 application, PocketPIMs.

Here is a screen cast of my application:

I got a certificate and won a £50 Amazon voucher … now spent. :-) My colleague, Damian Steer, also won one of the challenges.