Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 775
  • Last Modified:

lpt pins access

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
d.wilmer
Asked:
d.wilmer
  • 2
  • 2
1 Solution
 
LucHoltkampCommented:
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
 
d.wilmerAuthor Commented:
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
 
LucHoltkampCommented:
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
 
d.wilmerAuthor Commented:
Thanks,
i found something that may work, your information was very helpfull.

David Wilmer
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now