Ahojte.prosim vas nevedel by mi niekto poradit ako sa mam v dev c++ dostat na paraleleny port.potreboval by som ako vystupy funkcii vysielat na urcite piny portu stav 1 alebo 0,a nemam absolutne sajnu o tom ako sa to da ak sa to vobec nejako jednoducho do zdrojaku da zapisat.dakujem a este by som poprosil ci by ste mi nemohli povedat kde by som nasiel nejake dobre priklady zdrojakov pre pracu z bitovou mapou ale aby to islo cez dev c++.este raz dik
Fórum › C / C++
Výstup na paralelený port

Mozno ti to pojde cez conio.h a funkciu _outp. Neviem vsak ci conio.h je sucastou Dev-C lebo ten je zalozeny na CygWine. Skusit vsak mozes:
#include <conio.h>
#include <stdio.h>
int _outp( unsigned short port, int databyte );
// This program accepts an input from the user
// in decimal and outputs that number as an 8-bit
// binary number to the port at 378 hex, usually
// LPT1
int main () {
int inval = 0;
while ( inval < 256) {
printf("Enter a value in decimal (256 to quit)>");
scanf("%d", &inval);
_outp(0x378, inval);
}
_outp(0x378, 0);
return 0;
}
zdroj:http://www.mattjustice.com/parport/par_vc.html
dik za odpoved.ten kod vyzeral slusne ale ked som ho dal skompilovat tak mi vypisalo chybu linkera:
[Linker error]undefined reference to _outp(unsigned short int)
ld return 1 exit status
a chcel by som poznamenat ze som zaciatocnik a ucil som sa len z tychto kurzov tak ak by sa dalo vysvetlit trosku obsirnejsie a prosim ta co znamena ze je zalozeny na CygWine?
no to je dobre a co mam teda pouzivat??co by si odporucil??
skus si precitat: http://progres.eternal.cz/article.php?nID=242 len namiesto CreteFile uvedeneho tam pouzi:
HANDLE hFile = ::CreateFile(
"LPT1", // Jméno portu
GENERIC_READ | GENERIC_WRITE, // Čtení i zápis
0, // Žádné sdílení
NULL, // Žádné bezpečnostní info
OPEN_EXISTING, // Otevíráme existující
0, // Žádné atributy souboru
NULL // Musí být NULL
);
alebo sa skus mrknut na tento projekt: http://www.codeproject.com/useritems/PaPiC.asp
dik za odkazy.pokukal som a nakkoniec som aj nasiel.tak len keby to ktosi potreboval tu je kod:
najskor ale treba vlozit kniznicu ipout32.dll do windows\system\
najdete ju na http://logix4u.net/inpout32_source_and_bins.zip
#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);getchar();
}
/***** Write the data register */
i=0x378;
x=0x77;
(oup32)(i,x);
printf("port write to 0x%X, datum=0x%2X\n" ,i ,x);getchar();
/***** And read back to verify */
x = (inp32)(i);
printf("port read (%04X)= %04X\n",i,x);getchar();
/***** One more time, different value */
i=0x378;
x=0xAA;
(oup32)(i,x);
printf("port write to 0x%X, datum=0x%2X\n" ,i ,x);getchar();
/***** And read back to verify */
x = (inp32)(i);
printf("port read (%04X)= %04X\n",i,x);getchar();
FreeLibrary(hLib);
return 0;
}
zdrojaky tej kniznice som tam bohuzial nenasiel.skoda bolo by to isto lepsie.

Přidej příspěvek
Ano, opravdu chci reagovat → zobrazí formulář pro přidání příspěvku
×Vložení zdrojáku
×Vložení obrázku
×Vložení videa
































Uživatelé prohlížející si toto vlákno
Podobná vlákna
COM port — založil Bunny
Serial port — založil omicron
Com Port v Delphi — založil beni017
BlueTooth - COM PORT — založil durmitor
Seriovy port v C — založil jatagan
Moderátoři diskuze