Detecting a thermal printer on Android Tablet and printing
<p>I have an Andoid tablet which is not under Google Play Store recoginized category i.e. its model number is not the one which we can access the APK's and install them. I have to manually install the packages by downloading them from net. This device has the thermal printer attached on it. I tried to access it through Python but failed to do so as I am not able to detect the printer nor to check on which port it is so that I can give prints from it. The device is not showing any print option for files like .txt ot pdf's. Any help is appreciated.</p>

<p>Following is the code snippet of Python I tried to access the printer but did not worked...</p>

<pre><code>class ThermalPrinter(object):
    BAUDRATE = 19200
    TIMEOUT = 3
    SERIALPORT = '/dev/ttyO2'
    # pixels with more color value (average for multiple channels) are counted as white
    # tweak this if your images appear too black or too white
    black_threshold = 48
    # pixels with less alpha than this are counted as white
    alpha_threshold = 127

    printer = None

    _ESC = chr(27) 

 if __name__ == '__main__':
    import sys, os

    if len(sys.argv) == 2:
        serialport = sys.argv[1]
    else:
        serialport = ThermalPrinter.SERIALPORT


    if not os.path.exists(serialport):
        sys.exit("ERROR: Serial port not found at: %s" % serialport)

    print "Testing printer on port %s" % serialport
    p = ThermalPrinter(serialport=serialport)
    p.print_text("\nHello maailma. How's it going?\n")
    p.print_text("Part of this ")


     import Image, ImageDraw    
    i = Image.open("a.png")
    data = list(i.getdata())
    w, h = i.size
    p.print_bitmap(data, w, h, True)
    p.linefeed()
</code></pre>
