| Author |
Message |
avimit
Joined: 16 Nov 2005 Posts: 415 Helped: 68 Location: Fleet, UK
|
08 Aug 2008 12:44 Device Drivers |
|
|
|
I need a very simple device driver, which can send 0s and 1s to the parallel port of a PC running win XP? any ideas how to write it or how to get it? It will only be one way communication, i.e form the PC parallel port to the device/board, and no signal coming back from the device/board
Kr,
Avi
|
|
| Back to top |
|
 |
AdvaRes
Joined: 14 Feb 2008 Posts: 623 Helped: 33
|
08 Aug 2008 12:51 Re: Device Drivers |
|
|
|
| avimit wrote: |
I need a very simple device driver, which can send 0s and 1s to the parallel port of a PC running win XP? any ideas how to write it or how to get it? It will only be one way communication, i.e form the PC parallel port to the device/board, and no signal coming back from the device/board
Kr,
Avi |
Quite simple with Delphi.
See here:
http://www.sixca.com/eng/articles/pardel/
|
|
| Back to top |
|
 |
TekUT
Joined: 17 Jun 2008 Posts: 314 Helped: 22
|
13 Aug 2008 15:28 Re: Device Drivers |
|
|
|
If you can code in VB60 use the inpout32.dll library, this allow to set the I/O bit of the parallel port.
Declare into a .bas module:
| Code: |
Public Declare Function Inp Lib "inpout32.dll" _
Alias "Inp32" (ByVal PortAddress As Integer) As Integer
Public Declare Sub Out Lib "inpout32.dll" _
Alias "Out32" (ByVal PortAddress As Integer, ByVal Value As Integer)
|
put the dll into the program folder, to output data on the data line (D0,..., D7) use this simple code inside a form:
| Code: |
Out (888), <data_to_output_on_LPT1_data_word>
|
to read the status register (then the line BUSY, ACK, PE, SLCT, ERROR line) use this code:
| Code: |
Dim status As Integer
status = Inp(889)
|
also if (status AND 128) = 128 then the BUSY line was high otherwise is low, in a similar way you can check the other lines then:
| Code: |
' Bit 8 status register
If ((status And 128) = 128) Then
' BUSY IS HIGH
Else
' BUSY IS LOW
End If
' Bit 7 status register
If ((status And 64) = 64) Then
' ACK IS HIGH
Else
' ACK IS LOW
End If
|
and so on for the other input lines (and with 32, 16 and 8 ).
I've also attached a zip file with inside a pdf tutorial and the required dll.
Hope it help.
Bye
Pow
|
|
| Back to top |
|
 |
tomanderson
Joined: 10 Jan 2008 Posts: 34
|
17 Aug 2008 12:41 Re: Device Drivers |
|
|
|
http://www.samedisk.com/en/productinfo1051.php
Just saw something related in a Taiwan website
Looks like doing I/O without device driver
ha ha notepad controlled 8051.
|
|
| Back to top |
|
 |
mezo
Joined: 16 Jul 2007 Posts: 60 Helped: 2 Location: Egypt
|
17 Aug 2008 15:41 Re: Device Drivers |
|
|
|
This can be done very easily in Turbo C++ without any requirement of any file
just using the C function (outp) . if you have a turbo C++ or Borland C++ you will find
a total example in the help . you just know the parallel port number which is usually
0x37f or 0x378
Last edited by mezo on 18 Aug 2008 15:45; edited 1 time in total |
|
| Back to top |
|
 |
TekUT
Joined: 17 Jun 2008 Posts: 314 Helped: 22
|
18 Aug 2008 9:19 Re: Device Drivers |
|
|
|
| mezo wrote: |
This can be done very easily in Turbo C++ without any requirement of any file
just using the C function (outp) . if you have a turbo C++ or Borland C++ you will find
a total example in the help . you just know the parallel port number which is usually
0x3f8 or 0x378
|
May be this isn't able to work with WinXP type OS, this type of OS require driver to communicate with printer port due to the kernel, but I don't know if this is also implemented into the TC++.
Bye
Pow
|
|
| Back to top |
|
 |
mezo
Joined: 16 Jul 2007 Posts: 60 Helped: 2 Location: Egypt
|
18 Aug 2008 15:51 Re: Device Drivers |
|
|
|
yes this can be done with TC++ under the Windows XP Enviroment , coz i did myself . Here is the code to do it , you will find it in the TC++ help :
sending through port :
#include<stdio.h>
#include<conio.h>
int main(void)
{
unsigned port = 0x378 // first pin in parallel port 0x378-0x37f
int value ;
value = outp(port,'c') // c is the number you'll send to LPT
printf("value %c sent to port %d\n", value, port);
return 0
}
receiving through port :
#include <stdio.h>
#include <dos.h>
int main(void)
{
int result;
int port = 0x378;
result = inoprt(port);
printf("Word read from port %d = 0x%X\n", port, result);
}
Try it & tell me.
|
|
| Back to top |
|
 |
avimit
Joined: 16 Nov 2005 Posts: 415 Helped: 68 Location: Fleet, UK
|
18 Aug 2008 17:07 Re: Device Drivers |
|
|
|
Dear mezo,
I seriously doubt that what you have written is going to work. But you say you have checked it? Please let me know how did you check it.
A very simple way to check it, is to connect a LED board at the o/p parallel port. Did you use something like that?
If what you say will work, and it is as simple as you have written, then why so much 'fuss' about device driver?
|
|
| Back to top |
|
 |
mezo
Joined: 16 Jul 2007 Posts: 60 Helped: 2 Location: Egypt
|
20 Aug 2008 22:30 Re: Device Drivers |
|
|
|
Dear , My friend
i checked it using µc AT89c52 interfacing with a seven segment register and my PC's serial port .
i typed the number on the output program that i typed before using the serial port number and when i compiled the program the number i typed to be transmitted was written on the seven segment .
that's how i checked it . hope you check it
|
|
| Back to top |
|
 |