Dumping printer command and data to a printer port

Reply

Join Date: Oct 2006
Posts: 216
Reputation: jamello is an unknown quantity at this point 
Solved Threads: 6
jamello's Avatar
jamello jamello is offline Offline
Posting Whiz in Training

Dumping printer command and data to a printer port

 
0
  #1
Feb 27th, 2007
please, how do you dump pirnter commands Like
 LF, CF, CR
with font commands etc to a printer port for the pirnter to obey? I had thought that when these commands are mixed with data in a text format and copied to a port eg.
 "copy prncmd lpt1"
on the command prompt the printer would be able to strip out the commands from plain printable text (I hope I am not sounding naive!).
What I am getting is the whole commands being printed with the data part. Pleaase help!
Reply With Quote Quick reply to this message  
Join Date: Jan 2007
Posts: 3,210
Reputation: MidiMagic has a spectacular aura about MidiMagic has a spectacular aura about 
Solved Threads: 165
MidiMagic's Avatar
MidiMagic MidiMagic is offline Offline
Nearly a Senior Poster

Re: Dumping printer command and data to a printer port

 
0
  #2
Mar 3rd, 2007
For a plain textfile, the commands used to be unprintable control characters (the original use of the CTRL key). Those instructions were for a line printer or a teletype - single-font impact printers and some dot-matrix printers.

But now that Wordstar, Windows, and laser printers ruined everything (from this point of view), you have to insert formatting codes with a text editor. Each printer has its own set of instructions (many do not understand the concept of a line of type - they think in pixels). The print driver puts the correct adjustments to the text in when the text editor prints the page.

This is why old computers can't use new printers. The new printers can't understand the stream of text and control characters the old computers generate.

What's CF? Never heard of it.

If you are using an old inpact printer, the ASCII codes are:

letter A = hex 41 (for reference)
Carriage Return = hex 0D (old ctrl M)
Linefeed = Hex 0A (old ctrl J)
Backspace = Hex 08 (old ctrl H)
Formfeed (top of page) = Hex 0C (old ctrl L)

But on the IBM PC screen, these characters were used for special symbols.
Daylight-saving time uses more gasoline
Reply With Quote Quick reply to this message  
Join Date: Oct 2006
Posts: 216
Reputation: jamello is an unknown quantity at this point 
Solved Threads: 6
jamello's Avatar
jamello jamello is offline Offline
Posting Whiz in Training

Re: Dumping printer command and data to a printer port

 
0
  #3
Mar 7th, 2007
Thanks alot for your response, midiMagic.
I am trying to program a particular brand of ticket printer. The documentation is sparse. They have a template manager where tickets are designed and then outputed to the port.
Unfortunately this template manager is not available. but a similar documentatiion is. Here special commands like LF, CR etc are said to be dumped with the data onto the printer ports. My understanding is that the printer is able to stripout the data from the commands.

Since the printer is not behaving as expected, My question now is -does "copy prncmd lpt1" rightly constitute dumping data to a port? This is because from the documentation is shows that when these commands are dumped to the port it is supposed to work!
What I am having now is the printing of both command and text.

I would be glad for any other insight(s)
CF is a typho! sorry about that!!
Reply With Quote Quick reply to this message  
Join Date: Jan 2007
Posts: 3,210
Reputation: MidiMagic has a spectacular aura about MidiMagic has a spectacular aura about 
Solved Threads: 165
MidiMagic's Avatar
MidiMagic MidiMagic is offline Offline
Nearly a Senior Poster

Re: Dumping printer command and data to a printer port

 
0
  #4
Mar 8th, 2007
This printer might be a line printer. If so the character codes I mentioned above are valid.

The hard part is getting the codes into the printer with a program. Usually this is done through a printer driver. Do you have a driver for this printer?

There used to be a DOS Text Printer driver, but Microsoft, in it's infinite stupidity, seems to have removed it. For some reason, Microsoft doesn't seem to want people to use old equipment. But maybe you can find such a driver.

The alternative is using a program to write directly to the port. This requires the codes the printer actually uses, plus the character codes for the characters themselves. Often these are the ASCII or ISO chracter sets. This page has the character codes for ASCII:

http://www.asciitable.com/
Last edited by MidiMagic; Mar 8th, 2007 at 2:56 pm.
Daylight-saving time uses more gasoline
Reply With Quote Quick reply to this message  
Join Date: Oct 2006
Posts: 216
Reputation: jamello is an unknown quantity at this point 
Solved Threads: 6
jamello's Avatar
jamello jamello is offline Offline
Posting Whiz in Training

Re: Dumping printer command and data to a printer port

 
0
  #5
Mar 9th, 2007
Thanks once again midiMagic!
Yes indeed the printer is a line printer. Yes the printer was properly installed on the system with its driver and all. Like I pointed out, the documentation is sparse and some what grey in some aspects.

Below is an example of what is required to be done for me to print a line(s) of data.


1. Send an ESC @ command to initialize the printer.
2. Select the font.
3. Set any supporting features for the font.
4. Send the print data for one line.
5. End the line of data with a CR LF (carriage return, line feed).
6. Repeat steps 2 through 5 for each line on the page.
7. End the printing with an FF command (form feed).

For item 2 and 3, the document provides for what codes to send for choosing the fonts.
All the commands mentioned above have their hexadecimal equivalents.

So I hope my challenge is seen in a better light. When these commands are "sent" to the port, the printer does not respond as desired. Or is my "sending" mechanism/understanding not correct?

Thanks once again for your concern!
Hope to hear from you soon.
Last edited by jamello; Mar 9th, 2007 at 12:03 pm.
Reply With Quote Quick reply to this message  
Join Date: Jan 2007
Posts: 3,210
Reputation: MidiMagic has a spectacular aura about MidiMagic has a spectacular aura about 
Solved Threads: 165
MidiMagic's Avatar
MidiMagic MidiMagic is offline Offline
Nearly a Senior Poster

Re: Dumping printer command and data to a printer port

 
0
  #6
Mar 15th, 2007
Those instructions may be for assembly language programming or older compilers or BASIC interpreters.

The driver may automatically do the setup and font selection for you when you start Windows.

Your programming language should automatically send the carriage return and line feed for you when you print successive lines using the language. The driver makes sure the codes are the right ones.

The formfeed is the command your language uses to send the printer to a new page.

The rest will depend on what language you are writing the program in. What language are you using? The commands are different in each programming language.
Last edited by MidiMagic; Mar 15th, 2007 at 5:45 am.
Daylight-saving time uses more gasoline
Reply With Quote Quick reply to this message  
Join Date: Oct 2006
Posts: 216
Reputation: jamello is an unknown quantity at this point 
Solved Threads: 6
jamello's Avatar
jamello jamello is offline Offline
Posting Whiz in Training

Re: Dumping printer command and data to a printer port

 
0
  #7
Mar 19th, 2007
Thanks once again Midimagic for your response!
I use vb.net/asp.net. I will keep troubleshooting until I get it!



Originally Posted by MidiMagic View Post
Those instructions may be for assembly language programming or older compilers or BASIC interpreters.

The driver may automatically do the setup and font selection for you when you start Windows.

Your programming language should automatically send the carriage return and line feed for you when you print successive lines using the language. The driver makes sure the codes are the right ones.

The formfeed is the command your language uses to send the printer to a new page.

The rest will depend on what language you are writing the program in. What language are you using? The commands are different in each programming language.
Last edited by jamello; Mar 19th, 2007 at 12:51 pm.
Reply With Quote Quick reply to this message  
Join Date: Jan 2007
Posts: 3,210
Reputation: MidiMagic has a spectacular aura about MidiMagic has a spectacular aura about 
Solved Threads: 165
MidiMagic's Avatar
MidiMagic MidiMagic is offline Offline
Nearly a Senior Poster

Re: Dumping printer command and data to a printer port

 
0
  #8
Mar 20th, 2007
In vb, the char$ function lets you put in codes.

LPRINT automatically puts in the CR LF, unless you put a semicolon at the end of the statement.

char$(13) is carriage return
char$(10) is line feed
char$(12) is form feed
char$(27) is escape
Daylight-saving time uses more gasoline
Reply With Quote Quick reply to this message  
Join Date: Oct 2006
Posts: 216
Reputation: jamello is an unknown quantity at this point 
Solved Threads: 6
jamello's Avatar
jamello jamello is offline Offline
Posting Whiz in Training

Re: Dumping printer command and data to a printer port

 
0
  #9
Apr 3rd, 2007
I am pretty thankful for your insights
I am still trying to get it right. You have been most helpful. I will definitely get back to you. thanks
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the Windows NT / 2000 / XP Forum


Views: 3692 | Replies: 8
Thread Tools Search this Thread



Tag cloud for Windows NT / 2000 / XP
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC