Solved

lpt pins access

Posted on 1997-04-16
4
767 Views
Last Modified: 2008-03-03
Is there a way in vc++ 5.0 to send signals to any of the individual pins in lpt1 and what would be the voltage emited.
0
Comment
Question by:d.wilmer
  • 2
  • 2
4 Comments
 
LVL 3

Accepted Solution

by:
LucHoltkamp earned 50 total points
ID: 1162751
Yes, you can send a byte directly to the printerport, every bit in the byte corresponds to one pin of the printerport. The outputlevel is 0 or 5 Volt.
The simplest way is to use the BIOS interrupt17 (DOS only) to send the databyte. Borland C++ has a function 'biosprint' that does the trick. I'm sure VC++ has a simular function. Look in your DOS-helpfiles for BIOS.
The BIOS interrupt checks the inputline's to see if the printer is busy, out of paper etc. You could use the lines as inputlines for data. (The actual datalines are output only).
If you want to do this you have to write your own assembly interface. Look at the bios routine (follow the call with your debugger) to see how it is done.
0
 

Author Comment

by:d.wilmer
ID: 1162752
I do not own Borland C++ and cannot locate an example in VC++. Would you E-mail this example that you are using, The biosprint function.

Thanks for the help!!!
0
 
LVL 3

Expert Comment

by:LucHoltkamp
ID: 1162753
Are you sure VC++ doesn't have something like a 'biosprint'? Did you check the online-help (search for BIOS)

I implemented a biosprint as a simple call  to bios interrupt-17. You can use it if you can't find anything in VC++:

int biosprint(unsigned port, unsigned char abyte, unsigned char cmd)
{
  // some inline assembly does the trick
  asm
  {
    mov al, abyte
    mov ah, cmd
    mov dx, port
    int 17
    mov al, ah     // bios returns results in ah!
    mov ah, 00
  }
}

***EXTRACTION FROM BORLAND HELP:
Description

biosprint performs various printer functions on the printer identified by the parameter port using BIOS interrupt 0x17.
A port value of 0 corresponds to LPT1; a port value of 1 corresponds to LPT2; and so on.
The value of cmd can be one of the following:

0      Prints the character in abyte.
1      Initializes the printer port.
2      Reads the printer status.

The value of abyte can be 0 to 255.

Return Value

The value returned from any of these operations is the current printer status, which is obtained by ORing these bit values together:

Bit 0      0x01      Device time out
Bit 3      0x08       I/O error
Bit 4      0x10       Selected
Bit 5      0x20       Out of paper
Bit 6      0x40       Acknowledge
Bit 7      0x80       Not busy
0
 

Author Comment

by:d.wilmer
ID: 1162754
Thanks,
i found something that may work, your information was very helpfull.

David Wilmer
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Errors will happen. It is a fact of life for the programmer. How and when errors are detected have a great impact on quality and cost of a product. It is better to detect errors at compile time, when possible and practical. Errors that make their wa…
Container Orchestration platforms empower organizations to scale their apps at an exceptional rate. This is the reason numerous innovation-driven companies are moving apps to an appropriated datacenter wide platform that empowers them to scale at a …
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

860 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question