PDA

Archiv verlassen und diese Seite im Standarddesign anzeigen : lpt1 unter windows



Thomas$
08.05.2011, 14:43
Hallo
folgendes Problem ich will die Druckerschnitstelle ansteuern. und das mit relativ hohergeschwindigkeit >40kHz

hab verschiedenes gefunden
z.b. http://www.administrator.de/LPT_mit_C_Programm_ansteuern.html
unter qbasic ging es einfach da konnte man dierekt auf die geräte adresse schreiben
unter windows brauch man die inpout32.dll hab das auch unter visualbasic mal zum laufen bekommen

nur hätte ich das ganze gern unter c++ zum laufen bekommen
als ide nutze ich Dev-c++ 4.9.9.2
wäre für jede Hilfe dankbar

bei bedarf häng ich zu jedem programm was ich getestet hab die ganzen fheler meldungen an

mfg thomas

TobiKa
08.05.2011, 15:26
Erstmal, Windows ist nicht gleich Windows, also etwas genauer bitte.

Und dann ja häng doch einfach mal an was du schon hast, aber bitte in nem Code-Tag!

Thomas$
08.05.2011, 15:39
stimmt vergessen zu sagen winxp wobei die Windowsversion nicht ganz so wichtig ist in diesem falle
die inpout32.dll liegt im sytem32 ordner


/**************************************************/
/*** ***/
/*** TEST.c -- test interface to inpout32.dll ***/
/*** ( http://www.logix4u.net/inpout32.htm ) ***/
/*** ***/
/*** Copyright (C) 2003, Douglas Beattie Jr. ***/
/*** ***/
/*** <beattidp@ieee.org> ***/
/*** http://www.hytherion.com/beattidp/ ***/
/*** ***/
/**************************************************/


/************************************************** *****/
/* */
/* Builds with Borland's Command-line C Compiler */
/* (free for public download from Borland.com, at */
/* http://www.borland.com/bcppbuilder/freecompiler ) */
/* */
/* Compile with: */
/* */
/* BCC32 -IC:\BORLAND\BCC55\INCLUDE TEST.C */
/* */
/* */
/* Be sure to change the Port addresses */
/* accordingly if your LPT port is addressed */
/* elsewhere. */
/* */
/************************************************** *****/




#include <stdio.h>
#include <conio.h>
#include <windows.h>


/* Definitions in the build of inpout32.dll are: */
/* short _stdcall Inp32(short PortAddress); */
/* void _stdcall Out32(short PortAddress, short data); */


/* prototype (function typedef) for DLL function Inp32: */

typedef short _stdcall (*inpfuncPtr)(short portaddr);
typedef void _stdcall (*oupfuncPtr)(short portaddr, short datum);

int main(void)
{
HINSTANCE hLib;
inpfuncPtr inp32;
oupfuncPtr oup32;

short x;
int i;

/* Load the library */
hLib = LoadLibrary("inpout32.dll");

if (hLib == NULL) {
printf("LoadLibrary Failed.\n");
return -1;
}

/* get the address of the function */

inp32 = (inpfuncPtr) GetProcAddress(hLib, "Inp32");

if (inp32 == NULL) {
printf("GetProcAddress for Inp32 Failed.\n");
return -1;
}


oup32 = (oupfuncPtr) GetProcAddress(hLib, "Out32");

if (oup32 == NULL) {
printf("GetProcAddress for Oup32 Failed.\n");
return -1;
}


/************************************************** *************/
/* now test the functions */

/* Try to read 0x378..0x37F, LPT1: */

for (i=0x378; (i<0x380); i++) {

x = (inp32)(i);

printf("port read (%04X)= %04X\n",i,x);
}



/***** Write the data register */

i=0x378;
x=0x77;

(oup32)(i,x);

printf("port write to 0x%X, datum=0x%2X\n" ,i ,x);

/***** And read back to verify */
x = (inp32)(i);
printf("port read (%04X)= %04X\n",i,x);



/***** One more time, different value */

i=0x378;
x=0xAA;

(oup32)(i,x);

printf("port write to 0x%X, datum=0x%2X\n" ,i ,x);

/***** And read back to verify */
x = (inp32)(i);
printf("port read (%04X)= %04X\n",i,x);




FreeLibrary(hLib);
return 0;
}
von http://logix4u.net/Legacy_Ports/Parallel_Port/Inpout32.dll_for_Windows_98/2000/NT/XP.html

das Programm lässt sich ohne Fehler kompilieren startet rauscht vorbei fenster blitz kurz auf dann ist alles vorbei

TobiKa
08.05.2011, 15:43
stimmt vergessen zu sagen winxp wobei die Windowsversion nicht ganz so wichtig ist in diesem falle
Oh doch!


as Programm lässt sich ohne Fehler kompilieren startet rauscht vorbei fenster blitz kurz auf dann ist alles vorbei
Ja, was sollte es sonst auch tun?! Steht dort irgendwo "warte bis ich ne Taste drück"?

Ich würde dir empfehlen erstmal programmieren zu lernen.

Thomas$
10.05.2011, 21:00
war sehr hilfreich danke ...

nagut mittlerweile hat er es gefressen und wenn es dich jetzt doch wundert es erscheinen erstmal paar zeilen und die Ausgabe lässt sich anhalten. vorher hat er wahrscheinlich die dll nicht richtig geladen