Solved

lpt pins access

Posted on 1997-04-16
4
763 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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Unlike C#, C++ doesn't have native support for sealing classes (so they cannot be sub-classed). At the cost of a virtual base class pointer it is possible to implement a pseudo sealing mechanism The trick is to virtually inherit from a base class…
Templates For Beginners Or How To Encourage The Compiler To Work For You Introduction This tutorial is targeted at the reader who is, perhaps, familiar with the basics of C++ but would prefer a little slower introduction to the more ad…
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

744 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now