Solved

lpt pins access

Posted on 1997-04-16
4
769 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

IntroductionThis article is the second in a three part article series on the Visual Studio 2008 Debugger.  It provides tips in setting and using breakpoints. If not familiar with this debugger, you can find a basic introduction in the EE article loc…
Many modern programming languages support the concept of a property -- a class member that combines characteristics of both a data member and a method.  These are sometimes called "smart fields" because you can add logic that is applied automaticall…
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.

752 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