Friday, July 21, 2006

Some Info regarding PS, PCL etc.

PostScript is a programming language optimized for printing graphics and text.

Here is some links about printing, especially in Linux:

http://www.linuxprinting.org/kpfeifle/LinuxKongress2002/Tutorial/III.PostScript-and-PPDs/III.PostScript-and-PPDs.html

http://www.cs.indiana.edu/docproject/programming/postscript/postscript.html

Host-based Printer

I had just got my new printer, HP LJ1020, 2 days ago and tested from my PC. My old printer (HP color DeskJet 930c had been dead for about 2 months now and I desperately needed to get a printer). My 5-year old 930c printer was actually good for casual uses, eventhough the printouts were not good enough against water (caused smearing). The reason I bought the new one was, after my wife's friend brought her two toddlers came over our house and messing around (nobody noticed that they also played around my printer, turned it on/off several times and only-God-knows-what-they-did stuff)

The only major con of this printer is that it uses PC (with Windows only) to render printing, and sends the raw data to the printer using HP proprietary protocol via USB cable.

After installing the driver, I noticed there were 2 virtual USB ports created. These two ports were proprietary ports and unconfigurable. Print server could not use the port. That's the reason why this printer is not for people who want to network their printer thru print server. Anyway, the print quality of this LP 1020 is really good and comparable to higher-end and more expensive ones.

I think the only way to make it networkable is making the USB-connected PC to share its port. But then, this PC has to be up and running Windows all the time to make the printer available.

For the same reason, printing process is very fast, because half part of the printing process is done on the PC (which in general nowadays is much faster than even RISC processors usually deployed on various laser printers). From a few tests, I could see the printer started to print a second after I press print.

This printer is in the family of "host-based printer". I found a definition of "Host-based printer" on the net: "A printer that relies on the computer's CPU to do the rasterization of the pages. Non-host-based printers accept a command language from the computer, such as PostScript and PCL, and perform the rasterization internally. GDI printers are an example of host-based printers, which rely on the CPU's processing power to do the work." I believe this printer uses Windows' GDI (Graphical Device Interface) commands to rasterize printing. Does anybody have come up with a brilliant idea on how to hack it and make it work on Linux machines? And, here is more definitive information about it: http://www.laserquipt.com/support/idx/26/083/article/Host-Based-Drivers.html

Host-based printing is a cost-efficient printing technology that enables printers to utilize the processing power and memory resources of the PC (or the Host). In comparison, PDL-based (printer description language) printers use the processor and memory resources of the printer. Host-based printing allows HP to minimize the cost of the printer by significantly reducing the capabilities of the formatter of the printer and relying on the customer's computer processing power.
Host-based printing works by converting Windows GDI commands (graphics commands) generated by the application to the dot pattern to be created on the page. This dot pattern is then compressed and sent from the host PC to the printer, which stores the image of the page before printing. The data MUST be rasterized (converted into dots) when sent to the printer. This function is usually performed by the application itself. There are, however, some high-end graphics applications such as Quark™, Adobe PageMaker™, Adobe Indesign™, or Macromedia Freehand™ that do NOT rasterize data before sending to the printer.

Output from these applications to a host-based printer is typically very poor. When you print to a PS printer, PS commands are sent from your computer in the form of text commands. This text contains exact information about what is on the page. The text is received, understood and translated by a PS interpreter in your printer. Because of the simplicity of text commands and the consistency of PS interpreters, any PS printer will print the text information in the same way. Sending the same PS information to 560 different printers would yield the same results. PS is an invaluable graphics language because of its consistency and portability. Workarounds such as saving EPS files to different file formats such as JPEG’s or TIFF’s aren’t acceptable to users of high-end graphics applications who rely on PostScript specifically for the reasons above. In comparison, PDL-based printers require a more extensive formatter with higher RAM and ROM requirements, as well as a more powerful processor on board the printer.

Benefits of Host-Based Printing: A host-based printer utilizes the host computer’s processing power to convert the software application’s page information into a raster format to be printed by the printer. Since newer computers process at much faster speeds than most printer processors, complex jobs can often print faster when utilizing a host-based printer driver. Most host-based printers utilize USB ports which typically print much faster than parallel ports. Host-based printing requires a software print engine in the host operating system, and unlike a PDL (Printer Description Language) printer, cannot accept ASCII text direct from a computer. This means that the Host based printer will only work in the Windows and Macintosh environments that are specifically supported with the print engine written for that environment. Users of unsupported Windows and Macintosh environments, as well as users of Linux, Unix, OS/2 should consider a PDL printer like the HP Color LaserJet 2550 or CLJ3700.

Limitations of Host-Based Printing: Host-based printers are excellent small workgroup printers suitable for Windows and limited Mac printing to include internet and typical office printing but NOT EPS file printing. The drawback is that it is not possible to network such printers. A printer needs a steady flow of data, which is easily accomplished when it is connected directly to a PC, but cannot be guaranteed when the printer is connected via a LAN. Also, these technologies require intensive handshaking between the driver and the printer. However, the communication will time-out often enough over the LAN to make the solution impractical.

No wonder if you have a very fast PC (mine is not considered very fast anymore, eventhough it uses AMD 64-bit 2.4 GHz Athlon w/ 1 GB RAM and USB v2.0), it prints very fast. I haven't tried with USB1.0, but by just looking at the ratio of the rate between USB1.0 and USB2.0, we can tell roughly how it will behave. Sad to know there is no practical way to network the printer, except maybe by spending a couple of hundred $$ to buy a dedicated PC (with Windows) to be its "print server" (well, it is not going to be a real print server, it may only be "a shared port" PC.

Wednesday, June 7, 2006

Keeping your files secret

There are many ways to store our files safely and securely. One way is to just encrypt each file with a strong encryption method (e.g 256-bit AES). Another way is to create a virtual drive that encrypt the whole files in it. There are some softwares for the second method. One of them is PGP Desktop (non-free), and another one is TrueCrypt (GPL, downloadable from http://www.truecrypt.org/)

Sunday, May 14, 2006

Some Superfast Inline functions

The following functions are snippets to calculate trigonometry functions Sine and Cosine using GCC 3.1 or newer. fSinCos calculates sine and cosine simultaneously using FP assembly fsincos.


double fSin(double angle)
{
double _res;
asm ("fld %[angle]\nfsin"
: [output] "=&t" (_res)
: [angle] "0" (angle));
return _res;
}

void fSinCos(double angle, double *rsin, double *rcos)
{
double _arg = angle;
double _rsin, _rcos;
/*
asm ("fsinx %[angle],%[output]"
: [output] "=&t" (result)
: [angle] "f" (angle));
*/
// asm volatile("fld %[angle]" : "=t" (_rsin): [angle] "0" (angle));
asm volatile ("fsincos" : "=%&t" (_rcos), "=%&u" (_rsin) : "0" (angle));
*rsin = _rsin;
*rcos = _rcos;
}

But somehow, the fSinCos function stalls for some numbers. Dunno what it happened. Will post it later once I find the solution.

Friday, May 12, 2006

Heaven for hobbiest

Recently, my order of some chips had arrived. One package was from Analog-Device Ltd., another one was from Maxim Electronics Ltd. These microchips (various chips, but majority are ADC/DAC) were sent by them for free (yes, it is totally free, including the shipping and handling) as samples.

I was so delighted and cannot wait more to try some projects using these chips. Oh, by the way, I also ordered some components from Digikey.com (this one is not free, of course, but yet they sell components with affordable prices). My first project is to build a parallel-port Oscilloscope.