[b][red]This message was edited by the gushogh at 2002-4-8 10:4:34[/red][/b][hr]
How do I read from the LPT in windows 2000. I can white to the LTP (set the pins HIGH and LOW (I use NTPort dll file). But I cant read witch pins are HIGH and LOW on the LPT. In some way I have to set the LPT to input. But how?.
I have read something about you have to set the control port (base + 2) I can write to that address but nothing change. What Im I doing wrong ?
Hope someone can help ..
Gustav
Comments
: How do I read from the LPT in windows 2000. I can white to the LTP (set the pins HIGH and LOW (I use NTPort dll file). But I can’t read witch pins are HIGH and LOW on the LPT. In some way I have to set the LPT to input. But how?.
:
: I have read something about you have to set the ‘control port’ (base + 2) I can write to that address but nothing change. What I’m I doing wrong ?
:
: Hope someone can help ..
:
: Gustav
:
// The pinout set for the parallel port is as follows:
//
// Name Pin Function
// ---------------------------------------
// Data0 2 Data Out Active High
// Acknowledge 10 Data In Active High
// Ground 18-25 circuit common
#define CONTROL 0x37A
#define STATUS 0x379
#define OUTPUT 0x378
#define DATA_MASK 0x01 /* data out is on D0 */
#define IN_MASK 0x40 /* data in is on bit 5 (ACK) */
#define RECORD_SIZE 15000
#define DELAY_DEFAULT 3000
port.c
#include
#include
#include
#include
#include
#include "ir.h"
unsigned char button1[RECORD_SIZE]; // array to store the data
int Delay=DELAY_DEFAULT; // changes the timebase on the waveform
int offset = 3; // Grid offset from left edge
/*************************************************************************
** Function : initgraphics
** Description : set up the graphics display
** Parameters : None
** Return : None
*************************************************************************/
void initgraphics(void)
{
union REGS regs;
int graphdriver;
int graphmode;
int graph_error;
graphdriver = DETECT;
initgraph(&graphdriver,&graphmode,"");
graph_error = graphresult();
if(graph_error < 0)
{
puts(grapherrormsg(graph_error));
exit(1);
}
}
/*************************************************************************
** Function : RecordButton
** Description : records the stream from the receiver
** Parameters : None
** Return : None
*************************************************************************/
void RecordButton(void)
{
unsigned int i,j,index;
unsigned char data,status;
int x=0,y=10;
index = 0;
while(!(inportb(STATUS) & IN_MASK)); // wait for rising edge
for(i=0;i638)
{
x = 0;
y += 15;
if (y>400)
break;
}
for(j=0;j638)
{
x = 0;
y += 15;
if (y>400)
break;
}
for(j=0;j638)
{
x = 0;
y += 15;
if (y>400)
break;
}
}
}
/*************************************************************************
** Function : DrawGrid
** Description : Draws a grin on screen to compare the waveform against
** Parameters : None
** Return : None
*************************************************************************/
#define STEP 10
void DrawGrid(void)
{
int i;
cleardevice();
if (offset > STEP)
offset = STEP;
if (offset <= 0)
offset = 0;
setcolor(BLUE);
for(i=offset;i<639;i+=STEP)
line(i,0,i,359);
setcolor(CYAN);
for(i=offset;i<639;i+=STEP * 5)
line(i,0,i,359);
}
/*************************************************************************
** Function : Main program entry point
** Description : main
** Parameters : None
** Return : None
*************************************************************************/
main()
{
char ch='a';
clrscr();
printf("
");
printf("-------------------------------------------------------------------------------
");
printf(" Infrared Remote Control Recorder V1.1
");
printf(" Copyright (c) 1998 GKDesign
");
printf("-------------------------------------------------------------------------------
");
printf(" Please read the README file for instructions on how to use this program
");
printf("-------------------------------------------------------------------------------
");
printf("
Press any key to begin");
getch();
initgraphics();
DrawGrid();
while (ch != 'x') // main loop
{
gotoxy(1,25);
printf("[R] Record, [P] Play, [+/-] Move Grid, [1/2] Change Delay:%d [X] Exit ",Delay);
ch = getch();
if(ch == 'r')
{
cleardevice();
DrawGrid();
gotoxy(1,25);
printf("Point the Remote at the receiver and press a button.");
RecordButton();
}
if(ch == 'p')
{
cleardevice();
DrawGrid();
PlayButton();
}
if(ch == '+')
{
offset++;
DrawGrid();
DrawBuffer();
}
if(ch == '-')
{
offset--;
DrawGrid();
DrawBuffer();
}
if(ch == '1')
{
Delay-=100;
}
if(ch == '2')
{
Delay+=100;
}
}
closegraph();
return(0);
}
He's a very simple POLLED reader.
However some older ports will write but not read. Make sure you have one that does.
This won't compile as is. Just for info.
ET
:
: