Friday, April 25, 2014

Distant Print at Democamp Hamilton

I presented the working model of Distant-Print on April 2 at Democamp Hamilton.

Check out the featured article:
http://www.techtalkx.com/reed-zhao-demonstrates-his-remote-printer-for-e-commerce-at-democamphamilton16/

Here is the youtube video.

Tuesday, April 8, 2014

Review: SPRT SP-POS58IV thermal receipt printer

I promised to post some thermal printer reviews earler in Jan; however my other tasks had sucked away all my time.  So, better late than never, here is the first piece of 5 printer reviews.

This SPRT printer is one of the "good" printers I have been able to source from China.  And this particular model is been used to build my remote-printer prototypes, therefore I have enough experiences to backup the claim.

1.Appearance

I have to say that this one differs from most other China made 58mm thermal printers.  The printer prints fast and quiet; the plastic case feels better; and the paper chamber cover is even spring loaded.  When I press on the release button, it will pop up to full open.  Unfortunately I don't have a youtube video to share, but you can see the springs below.



It has (1) usb port and (1) RJ11 for connecting the cash drawer.


2.Internals

As usual, I disassembled the printer and took photos of everything.

1) Main controller: STM32F103
This is an ARM Cortex-M3 controller.  Compare to a M0 solution found in generic 5890 printers, it just has more processing power.

So the claim of faster printer speed seems reasonable.

2) The components and soldering job are okay.  No scrapped parts but no fancy stuff too.

One thing I have noticed is that they don't cut corner on wires.  Some other printers has very short internal wire length, making it difficult for me to disassemble.


3) Paper feeding gear.
It uses a rather large plastic gear for paper feeding mechanism.(approx over 1.2cm in diameter)  This is a good sign, because small gears wear out faster. Some other Chinese manufacturers just don't spend the extra 0.02 on gears.

4) Motor
Can't see the actual model number, but it is larger than 5890s too.



3.Software-windows (tested on win7 64bit)

This one comes with 32/64 bit drivers for windows.  The whole installation process is quite easy.  Windows issued a warning because the driver was not signed, but we don't worry about that, just continue.


After the installation process is done, SPRT printer appeared in my device list.

Test print

First try to print something from notepad; just pure text. The result is okay.


Then I used photoshop to print out a grey-scale image.  To my surprise, it actually printed out instantly, and the result is satisfactory.  (I was expecting some problems since this is not a laser jet.)

4.Software-linux

For the linux test, it is as good as it could be.  That is from my experiences using this model with Raspberry Pi for remote printer project. Everything has been tested and working.

This is the test print out:


  • ESC !  -  fully supported.   
  • Every other ESC POS command I have tested are also supported.


Here is a simplified list of supported ECS/POS command.

5. ESC/POS Barcode 

Barcode printing is easy. Test code in python:
import shutil
import sys

printer = open('/dev/usb/lp0','w')

string = "--test EAN-13 barcode wide--\n"
string += "\x1d\x77\x04"   # GS w 4
string += "\x1d\x6b\x02"   # GS k 2 
string += "5901234123457\x00"  # [data] 00
string += "-end-\n"

printer.write(string)
printer.close()



6. ESC/POS Graphics

SP-POS58IV supports two ways of bitmap printing.  The main difference is how you define the bitmap data.   The actual printing code is too long to list here. You will have to consult with the user manual for instructions on how to format the command.
  • Method 1:
  • ESC * m n1 n2 [d]k   ---- Print bitmap in one big command (8 or 24 bit column)
  • Method 2:
  • GS /    ---- print bitmap data
  • GS *   ---- define bitmap data   (n x 8 bit column)

Overall

I am quite happy with this unit so far.  It has several advantages over many cheap 58mm thermal printers:

  • Prints faster.
  • Better build quality
  • Windows 32/64 compatible.
  • Better ESC/POS command support
  • Barcode support

However, the benefits come at a price.  This SPRT POS58IV costs 2x as much as the cheapest 5890 I can find.  But it is still significantly cheaper than EPSON or Zebra.




Thursday, February 6, 2014

A Better Cloud Printer III - The Hardware

This post continues from my earlier post:

The Hardware

The prototype has been finished for two weeks, but I have not had time to update this blog.  Now I proudly present the 1st unit, hand crafted by Reed:

  • A: 12v~5v voltage converter module. 
  • B: Raspberry Pi running modified Raspbian.
  • C: the original printer board.
The printer looks industrial solid and cost me just about $100.


What next?

- Make a youtube demo video.
- Setup a webstore to take pre-order.
- Complete the public API.
- Attract buyers/investors.

Update 2014-04-08:

1) The printer project name is officially "Distant Print".  http://distantprint.com/
2) I am finishing up the client program, hopefully will release a RPi SD image soon.


For anyone who is reading this:

If you feel that you are good at any tasks above, I am looking for a co-founder.  Feel free to send me a message.  (6-Feb-2014)







Friday, January 3, 2014

Review: 5 thermal receipt printers line-up

Part-one: Thermal printers line-up.

Finally, I put together 5 thermal printers for a side-by-side comparison.

As far as I know, this is the only review for thermal printers beyond the manufacturer's brochures.  I hope it can help you in your POS project.

Because I don't have enough time to finish the review in one go, will post the rest in multiple parts during the next few weeks.

Printer/Models covered in this review:
  • POS58 - 58mm, USB
  • POS80 - 80mm, auto-cutter, USB+RS232+LAN
  • SP-POS58IV - 58mm, USB
  • SP-POS88V - 80mm, auto-cutter, USB
  • HDD-80260 - 80mm, auto-cutter, USB+RS232+LAN




Read the reviews:

http://reed-printer.blogspot.ca/2014/04/review-sprt-sp-pos58iv-thermal-receipt.html



POS58 - 58mm, USB




POS80 - 80mm, auto-cutter, USB+RS232+LAN




SP-POS58IV - 58mm, USB




SP-POS88V - 80mm, auto-cutter, USB




HDD-80260 - 80mm, auto-cutter, USB+RS232+LAN







Thursday, December 19, 2013

A Better Cloud Printer II - API interface

This post continues from my earlier post:

The API definition

So I have got my software stack on a drawing board, next is to make it happen with actual code. RestFul API requests are defined in JSON format:

// this is the very 1st API definition, print out something to a remote printer
{
  "sid"         :"asdfasdf",
  "secret"      :"13wd23d2323r",
  "apiversion"  :"2014-01-01",
  "service"     :"submit",
  "parameter"   :{
      "printerid"   :"asdf2323wd2e",
      "title"       :"xxxxxxx",
      "content"     :"xxxxxxx",
      "contentType" :"PLAINTEXT"
  }
}

  // Response
  {
    "jobid" :"xxxx",
    "status":"ok",  // in progress, fail, ...
    "printerid" :"xxxx"
  }
  


Will update the progress soon....

*Edit 2013-12-27

I have been working on this thing during the holiday season. The rough framework code for public API has been setup as follows:

Public facing software stack: Centos + Nginx + PHP + mySQL + GearMan
PHP libraries are:
  • Luracast Restler - the framework handles RESTful requests
  • Idiorm - ActiveRecord library. (When I am too lazy to write real SQL queries)
  • Whole bunch of PHP utility functions I wrote in the past.
Although the rage is all about Redis and Node.js, I don't see a compelling reason to use the newer software stack. Call me old school:
  • Print API data is strictly structured, saved to database as json encoded string.
  • RESTful, no state between requests.
  • The API will return right after been fired.  (before the actual printer output is finished)
  • Client Callback url for job status update.
Why not Redis/Node/Mongo/Riak/Erlang/whatever?  With Nginx + PHP-fpm, this setup should easily handle 100+ requests/sec on a very cheap VPS(by cheap,  I mean $5 per month).  And I don't see it reaching that limit with a deployment of less than 2000 printers.  If I ever run out of server capacity, the fortune is on my side.  I should already be making enough money to upgrade the servers.

For the actual worker process that handles individual request processing, I might consider something runs on top of libev as daemon.  Could be Node.js or Python Twisted, will leave that for later decision.

*Side note: I am thinking about opensource the entire thing on Github, anyone interested?
If someone can help manage the repo, I'll make it happen.


A Better Cloud Printer I

Continue from my last post: Looking for a better cloud receipt printer.

A Better Cloud Printer I

So this is my ideal cloud thermal printer:
  • Small form factor. (takes little desktop space)
  • Connects on Lan/Wifi/3G
  • Easy to use API to print things.
  • Provide server infrastructure at very low recurring charge. (Just like Twilio)
  • And the printer sells for under $100

Cost

My initial thought was to attach a Raspberry Pi to a regular thermal printer.  The total cost would be roughly $100.
  • $50 Thermal printer
  • $40 Raspberry Pi
  • $10 SD card
  • Adding 3G connectivity would require $50 extra 3G dongle
Sounds simple enough, and I got my Raspberry Pi right away from a local electronics store.

However, the search for a $50 thermal printer took me to an unexpected journey. You can read the experiences on my other blog posts. (Post 1),(Post 2).  Long story short, now I have a working Thermal Printer attached to the Raspberry Pi, the rest is software.

Software

Then the problem becomes how to implement a software stack to control printer from remote server.
  • Communication between printer and server
    • All China-made GPRS printers uses some custom TCP Socks protocol.  This requires me to implement all server structure and error checking mechanism.  (Not great)
    • TCP Socks will have problem behind firewall/proxy.(Not great)
    • I favor XMPP protocol for its ability to fallback to HTTP if Socks fail.
    • XMPP servers already implemented off-line message and presence etc.
    • Downside is: XMPP uses more bandwidth than custom TCP Socks.
  • The actual print out
    • This is simple, just issue ESC/POS command to serial port.
  • API interface for issuing printing command, managing printer.
    • The server must have a XMPP master node to oversee all printers.
    • Upon every API request, the master node talks to printer and returns result to caller.
    • API return data in JSON form.
  • Server Software
    • RPi runs archlinux because I wish to use the latest software.
      • Final product should run a more stable distro.
    • Prosody as XMPP server.  Fast, small memory footprint.
    • Nginx/PHP-fpm as web server.
  • Programming landuage
    • It appears that Python has better resources to work on Raspberry Pi as XMPP client.
    • PHP for API, easy to use.  Small resource foot print.

Software II

Upon some initial discovery, the solution lead to even more problems:
  • Gracious shutdown (fixed, Jan 2014)
    • File System corruption. The printer is turned off arbitrarily. However, default Linux filesystems are not designed to handle that. 
    • Need to fit Archlinux onto live-CD or something similar.
    • Also need the client to be able to update itself.  Therefore it takes a little more than live-CD.
  •  XMPP master node (fixed, Jan 2014)
    • At every API request, I need to initialize the master node in PHP.  Is there a way to have a long-running master-node?
    • What if the long-running master-node fails? How do I fail-over to a second node?
    • It is possible for printer to initial the communication when coming online; how do I feedback to the server?
  • Remote Configuration
    • Since the printer is suppose to "just work" for end user, I need something to config the printer's wifi/network remotely.
      • what if I need to config WIFI when the printer is not connected?
These problems are important for a production-ready product, however they do not get in the way of building my very first demo unit.  I will come back and fix them soon.

Next post: A Better Cloud Printer II - API definition





Tuesday, December 17, 2013

Looking for a better cloud receipt printer.

The problem of remote printing

I have been looking for a solution to print out receipt-like stuff remotely, be it online food order or e-commerce shipping request.  As a geek person, I also wish it to be cheap enough to use.  So far I have not had great success in finding such a product/service.

A few promising candidates are:

Little Printer from BERG
Problem:
  • Expensive. I mean, very expensive. 
  • Not durable.  The construction fits for a hobby project, but not shop floor.
This little printer fits the bill except for its price tag.  I don't know about you guys; a little printer retails for $219 plus $40 shipping is insane to me.


     
    SMS/GPRS Printer
    Problem:
    • Need to roll(develop) my own server infrastructure.
    • Requires mobile data plan. (Expensive in Canada)
    This $99 device is almost right for my purpose.  Only it is offered by some Chinese suppliers that I do not have a lot of faith in their software quality.



    E-print, Cloud Print, Epson, HP, Canon
    Problem:
    • Large size. (Don't like a full size laser-jet on the desk.)
    • Printing delivery by email, no API/Service for delivery status.
    • Maintenance issue. (ink, toner, paper jam)




    Google Clould Print
    Problem:
    • Can only use under someone's gmail account.  Not ideal for large number of deployment.
    • Requires computer(or Raspberry Pi).



    Seriously, how difficult it is to make a receipt printer that fits my use case without breaking the bank?
    • Connects on Lan/Wifi (Free if I already have internet)
    • Easy to use API to print things.
    • Provide server infrastructure at very low recurring charge. (Just like Twilio)
    • And the printer sells for under $100


    Please read on...

    A Better Cloud Printer I

    A Better Cloud Printer II - API interface 


    (I will post updates on my own version of cloud receipt printer as it is being developed)