Android calls the printer

        In fact, printer and Android no big relationship and association linux kernel is relatively strong.

       The end result is to be achieved printer driver in Android, but generally commissioning a new driver process is as follows: 1. First tested on linux PC. 2. debugging on standard embedded linux. 3. retrofitted to go Android.

       Why do you arrange? Because resources are diminishing, the device can determine whether the problem, and workflow linux device in the first phase; because the standard embedded linux or the GNU specified in the second phase, including most at this stage to verify that the device can be successfully compiled on the ARM architecture through; the third stage is the stage of practical, because in the end this is not how you want to run on the Android system to comply with the provisions of the GNU.

 

The first stage

       I tested three printers: 1.Canon iP2780 2.Canon MX428 3.HP Deskjet 1000. Because of my operating system is Linux, then one by one to get quickly on a Linux PC. The first stage is driven here by (deb package including source code and partially open) plus the "iP2700 series IJ Printer Driver Ver 3.30 for Linux (instructions).", The machine can be properly used; and the second stage a drive mode are the same except that here; the third stage is a choice with a download file is finally here: hplip-3.14.1.run, will direct the implementation of all the things missing from the installation, It can be used successfully.

       If I'm just a user, it can now ended. But I'm a developer, my ultimate goal is ported to Android, so my destination is not here, I want to continue to dig deep. To dig a lot of points here that one of the most pressing is how to print a file with the command? The problem seems very strange, but I do not know how to do. But eventually he found that: lp or lpr plus the file name, you can print out a file of. E.g:

lp ~/hello.pdf

 

       I find such a command would spend a few hours, here I have a strong hunch that road ahead is a long way off. (Step finishing order of articles and experiments will be slightly different, in fact, the command "iP2700 series IJ Printer Driver Ver. 3.30 for Linux (Operating Instructions)" is there, but the "Operating Instructions" is later seen ).

       Now it seems I should not be rushed to carry out the second stage, should take a good look at the Linux printing system. Come on in accordance with the summary article on the best procedure. Let me talk about how I learned about the linux printing system.

       Surprised to discover that this book "Linux System Administration Technical Manual", I know Linux is really to help the printing system is the largest, covering knowledge is the most complete and used in later phases since that is something new, In fact, this book are explained in detail. Print explain not explain how to print just fine, but a detailed explanation of the principle of the printer, what steps to go through the printer language, etc., if it is a book written by the people in general would say within the scope of "This content is not discussed in this book "a summary. I repeatedly read the chapter a week considered some prospect of a solution.

       Everything, after all, a picture:

       In fact, so far I should take a look at what I plan to design, implement in my quick success, and do not plan to complete for the second phase.

Small planning:

       Select the printer: HP's recommended choice, the laser can be inkjet, HP is the full support of Linux.

       Printing system options:

              Grand architecture is CUPS, the main modules are:

                     Backstage:

                     filter:

                     PPD:

       In fact, even just one line from top to bottom, can be combined into a printing system in FIG. Here we enter the second stage. 

       During the test CUPS also surprised to discover that a bug, or that I have not already have the solution I have not found it. CUPS that is missing error handling, a printer, if the cartridge runs out, the cartridge and so effective when problems arise, CUPS is without informing the user. For example, my HP Deskjet 1000, appear in the CUPS print this situation: The printer is not responding, -t with a view to lpstat state is "Rendering completed". This problem can not be found, but under the same circumstances to find the answer under Windows:

 

second stage

       Debugging Canon printer when I chose this architecture: CUPS + cnijfilter-source-3.30-1.tar.gz.

1. Configure Linux kernel (action: generating a device node)

make menuconfig chosen USB printer options:
       Device the Drivers --->
                      [*] USB Support ---> 
                                   <*> USB Printer Support     
(After the configuration, inserted into the printer device node appears at / dev / usb / directory General name "lp0")  

 2. cross compiler CUPS 1.3.9

! # / bin / SH 

# 1 . Download Source 
wget HTTP: // www.cups.org/software/1.3.9/cups-1.3.9-source.tar.gz && 

# 2 . unzip and open the 
tar xvzf the CUPS - CD-called source.tar.gz CUPS && 1.3.9 1.3.9-&& 

# . 3 . configuration 
. / configure --host = ARM-ARM-Linux Linux --build --target = = = i686 the CC-ARM-Linux Linux -gcc CXX = arm-linux-g ++ LD = arm-linux-ld rANLIB = arm-linux-ranlib AR = arm-linux-ar --disable-gnutls --disable-gssapi --disable-dbus --prefix = / && 

# 4 . it does not modify the Makefile compiler man 
Sed -i '22S / Monitor the locale man / Monitor the locale /' ./Makefile && 

# . 5 . compiled and installed 
make&& make install DSTROOT=/work/rootfs/rootfs_qtopia_qt4 &&

echo "cups build install ok!"

 

3. Cross-compiling ghostscript 8.15

! # / bin / SH 

DESTDIR = / Work / rootfs / rootfs_qtopia_qt4 

# 1 Download Source. 
wget HTTP: // iweb.dl.sourceforge.net/project/ghostscript/GPL%20Ghostscript/8.15/ghostscript-8.15.tar.gz && 

# 2 . extract the source 
the tar xvzf Ghostscript -8.15.tar.gz && 

# . 3 . respectively copied as the ARM and the PC version version 
CP Ghostscript -8.15 8.15 Ghostscript-ARM--R & lt && Music Videos Ghostscript 8.15 Ghostscript-8.15-PC-&& 

# . 4 compile the PC version 
# -DHAVE_SYS_TIME_H solve warning: the Implicit declaration of function 'gettimeofday' 
cd Ghostscript -8.15 PC-&& ./configure &&make XCFLAGS=-DHAVE_SYS_TIME_H=1 && cd ../ &&

# 5 . Configuration arm version 
CD Ghostscript -8.15 && ./configure --host = arm-arm-Linux && 

# 6. The modifications to the Makefile STDLIBS = -lm STDLIBS = -lm - static 
Sed -i '257S / stdlibs = - LM / -lm -static stdlibs = / './Makefile && 

# . 7 . PC copy version of the tool 
mkdir obj && CP ../ghostscript-8.15-pc/obj/genarch ../ghostscript-8.15-pc/obj/genconf. ./obj/ && ./ghostscript-8.15-pc/obj/echogs 

# 8 . compile 
the make XCFLAGS = -DHAVE_SYS_TIME_H = 1 && 

# 9 . installation (this version does not support DESTDIR make install root directory of the specified manually copy it to the future to adjust the directory) 
mkdir -p $ {DESTDIR} /usr/local/share/ghostscript/8.15/ && 
CP-r lib ${DESTDIR}/usr/local/share/ghostscript/8.15/ &&
cp -r Resource ${DESTDIR}/usr/local/share/ghostscript/8.15/ &&
cp bin/gs ${DESTDIR}/bin/

 

4. The cross compiler gutenprint 5.2.9

! # / bin / SH 

# 1. Download Source Project Address: HTTP: // sourceforge.net/projects/gimp-print/files/gutenprint-5.2/5.2.9/ 
wget HTTP: // SoftLayer-ams.dl.sourceforge .NET / Project / GIMP-Print / the gutenprint-5.2 / 5.2.9 / 5.2.9.tar.bz2 the gutenprint-&& 

# 2 . extracting 
the tar xvjf the gutenprint -5.2.9.tar.bz2 && 

# . 3 . PC are copied as ARM version and version 
cp -r gutenprint-5.2.9 gutenprint-5.2.9-ARM-5.2.9 && mv gutenprint gutenprint-5.2.9-PC && 

# 4 . compile the PC version 
cd gutenprint -5.2.9-PC &&. / the make the configure && && && cd ../ 

# 5 . configuration arm version 
cd gutenprint-5.2.9-arm && ./configure --host=arm-linux --target=arm-linux --build=i686-linux CC=arm-linux-gcc CXX=arm-linux-g++ LD=arm-linux-ld RANLIB=arm-linux-ranlib AR=arm-linux-ar --with-gimp2=no --without-gimp2 --enable-cups-ppds --enable-cups-level3-ppds --without-ghostscript --without-foomatic --disable-libgutenprintui2 &&

# 6.拷贝PC版本工具 
make || cp ../gutenprint-5.2.9-pc/src/xml/.libs/extract-strings ./src/xml/.libs/ &&

# 7.编译并安装
make && make install DSTROOT=/work/rootfs/rootfs_qtopia_qt4 &&

echo "gutenprint build install ok!"

 

The cross compiler hpijs-2.1.4

 

! # / bin / SH 

# 1. Download Source Project Address: HTTP: // sourceforge.net/projects/hpinkjet/files/ 
wget HTTP: // superb-dca2.dl.sourceforge.net/project/hpinkjet/hpijs/2.1 .4 / hpijs-2.1.4.tar.gz 

# 2 . extract the source 
the tar xvzf hpijs -2.1.4.tar.gz && 2.1.4 CD-hpijs 

# . 3 . configuration 
. / configure-ARM Linux --host = - = ARM-Linux --build -target = i686 the CC = Linux-ARM-GCC CXX = Linux-ARM-Linux-ARM-G ++ = the LD LD rANLIB = Linux-ARM-Linux-ARM-Linux- ranlib the AR = Ar 

# . 4 . char correcting grammatical errors dj3320.cpp beginning of line 403 and 249 registry.cpp change the line to const char 
sed -i '249s / \ TCHAR \ t / \ TCONST char \ t /' registry.cpp 
sed-i '403s/ char/ const char/' dj3320.cpp

# 5.编译并安装
make && make install DESTDIR=/work/rootfs/rootfs_qtopia_qt4

 

6. Start each module

       These are my source code to compile all the records, each of which can all be run separately verified.

Start cups: $ /etc/init.d/cups start

CUPS can /etc/cups/cupsd.conf log level LogLevel to debug, so if you start failure reasons will print to / var / log / cups / error_log in. I have not encountered any major bug, a problem encountered is the lack of a directory.

 

7. The most simple printing system ghostscript + hpijs

       This program is mainly made reference to "embedded Linux-based print control system design," this is more suitable for embedded printer, is not accounted for resources without some of the more tasteless compared to function. Save a resource to download (Note: It is best to compile the source code yourself, does not guarantee available to all cpu, must be the ARM architecture and the ARMv7 above) can be used directly. Android can be installed directly into the primary or general embedded Linux.

 

8. The printer system implemented without

       This is more simple, is not an operating system controller to operate the printer, this is my debugging HP Deskjet 1000 accidentally discovered a cow achieve "USB HOST + HP DeskJet 1000 printer." Of course I'm real experiment BIN file his offer, he is TQ2440, I tested directly on MINI2440 is no problem, print out the contents of "HP802 black ink cartridge ink method" Both boards are S3C2440 uses the ARM's CPU. Although the source code is not provided, but can be considered to provide a possible, if in the future there is a demand in this area we can continue along this road study.

 

The third stage reserved ported to Android

1. The most simple print ported to Android in

       First a horse in the past, libraries do not worry, static links are only used to compile the. The key is "file system hierarchy standard" Android does not comply, through the establishment of a mandatory test two directories, you can use the normal / usr and / tmp directory.
       Some need to be optimized: 1 adjustment on the / tmp directory is dynamically created about 2 / 3. The adjustment of the device node usr directory. . . .
               1. a solution on the adjustment of the / tmp directory in the discussion on stackoverflow is / data / local / tmp instead;
               2. Adjust on the / usr directory recompiled ghostscript adjustment / system / usr / .. directory;
               3 The device node has not yet debugging;

    4. Print font problems in English;

Fix / tmp directory problem:

       In order to distinguish the function in accordance with, the final selection / data / misc / printer / tmp / directory as the / tmp directory. The gs in the code gp_unifs.c tmp /, replace.

       $ sed -i '74s/"\/tmp\/"/"\/data\/misc\/printer\/tmp\/"/' ./src/gp_unifs.c

Fix / usr directory problem:

  Usr is usually in the root directory, Android is in / system / on, ghostscript to be adjusted at compile time, the result of the adjustment is to add when configuring: - prefix = / system / ghostscript will then put the resource file adjustments to / system / usr / share under / .... directories, so just to solve the problem.

Fix device node problem:

  Stars based on "Android contrast with the standard Linux" experience and experiment: Android with ueventd + VOLD to complete the work udev Linux in general, the former is responsible for creating the device node, which is used for processing. Inserted into the printer automatically creates device nodes / dev / usb / lp0. ,
Ueventd created by default out of the privileges that only the root user can access and change the permissions in the Android approach is uevent $ {BOARD} .rc add the following:

#For USB printer
/dev/usb/lp0 0666 system system

View device node permissions again, normal.


Fix font problem:

  I have been testing all pictures to print, in English when will complain, hit the solutions according to the specific cause of the error.

! # / bin / SH 
# Note: This script and download the required font packages GS 
# version: 2013-01-17 
# character will be packaged into the 
# Android: /system/usr/share/ghostscript/8.15/Resource/ the decompression 
# Linux: /usr/local/share/ghostscript/8.15/Resource/ in extracting 
# * solve common English font required to print 

DESTDIR = $ {PWD} / System 

# 1. Download gs-fonts-source project address : HTTP: // sourceforge.net/projects/gs-fonts/ 
wget HTTP: // superb-dca2.dl.sourceforge.net/project/gs-fonts/gs-fonts/8.11%20%28base%2035%2C% 29% 20GPL / Ghostscript-Fonts-STD-8.11.tar.gz && 

# 2. extracting GS- Fonts source 
tar xvzf ghostscript&&-std-8.11.tar.gz -fonts 

# 3. Download gs-9.04, which acquired the character Project Address: HTTP: // sourceforge.net/projects/ghostscript/files/GPL%20Ghostscript/9.04/ 
wget HTTP: / / softlayer-ams.dl.sourceforge.net/project/ghostscript/GPL%20Ghostscript/9.04/ghostscript-9.04.tar.bz2 && 

# 4. decompression. 9-GS .04 source 
the tar xvjf Ghostscript -9.04.tar.bz2 && 

# 5 . establishment fonts directory Font 
Test -d ./Font && RM -rf ./Font; mkdir ./Font && 

# . 6 copied font in the Font directory. 
# copy GS - Fonts 
CP -rf Fonts / * ./Font &&  
# copy font gs-9.04
CP -rf ghostscript-9.04 / Resource / Font / * ./Font &&

# 7 font package 
tar cvzf Font.tar.gz the Font && 

echo "Fonts the ok!"

 

  Font issue is resolved, Android also has its own font located in / system / fonts, where the majority ttf format, and here with mostly pfb format.


---------------------
Author: kangear
Source: CSDN
Original: https: //blog.csdn.net/kangear/article/details/18141741 

Guess you like

Origin www.cnblogs.com/DreamRecorder/p/11224070.html