initailize parallel port
-
i'm using visual c++6.0 to initialize the parallel port i try to use the command of _outp and _inp so as to write and read the signal but i can't success then i use inline aassembler to do it but it has errors again. i have tried for many times but i still can't success. i think the main problem are in the lines below, _asm out dx,al _asm in al,dx would anyone can help me? the programme is as follows, #include #include #include #define PortAddress 0x378 short PortOut(unsigned int portadr,unsigned char data) { _asm mov edx, portadr _asm mov al, data _asm out dx,al //Loaded 'C:\WINNT\system32\ntdll.dll', no matching symbolic information found. return(portadr,data); } unsigned char PortIn(unsigned int portadr) { unsigned char data; _asm mov edx,portadr _asm in al,dx _asm mov data,al return data; } int main(void) { short Dummy; short PortData=0; int pd=0; cout<<"Input portdata\n"; cin>>pd; Dummy=PortOut(PortAddress,pd); PortData=PortIn(PortAddress); cout<<"data at"<
-
i'm using visual c++6.0 to initialize the parallel port i try to use the command of _outp and _inp so as to write and read the signal but i can't success then i use inline aassembler to do it but it has errors again. i have tried for many times but i still can't success. i think the main problem are in the lines below, _asm out dx,al _asm in al,dx would anyone can help me? the programme is as follows, #include #include #include #define PortAddress 0x378 short PortOut(unsigned int portadr,unsigned char data) { _asm mov edx, portadr _asm mov al, data _asm out dx,al //Loaded 'C:\WINNT\system32\ntdll.dll', no matching symbolic information found. return(portadr,data); } unsigned char PortIn(unsigned int portadr) { unsigned char data; _asm mov edx,portadr _asm in al,dx _asm mov data,al return data; } int main(void) { short Dummy; short PortData=0; int pd=0; cout<<"Input portdata\n"; cin>>pd; Dummy=PortOut(PortAddress,pd); PortData=PortIn(PortAddress); cout<<"data at"<
You're on the right lines with _inp() and _outp() but if you are using an "NT-based" OS (Win NT, 2000 or XP) you have to use a special driver to bypass the port security - by default you cannot directly access I/O ports. There are a number of drivers available that do the same thing. UserPort is as good as any: http://www.embeddedtronics.com/public/Electronics/minidaq/userport/UserPort.zip Hope that helps
-
i'm using visual c++6.0 to initialize the parallel port i try to use the command of _outp and _inp so as to write and read the signal but i can't success then i use inline aassembler to do it but it has errors again. i have tried for many times but i still can't success. i think the main problem are in the lines below, _asm out dx,al _asm in al,dx would anyone can help me? the programme is as follows, #include #include #include #define PortAddress 0x378 short PortOut(unsigned int portadr,unsigned char data) { _asm mov edx, portadr _asm mov al, data _asm out dx,al //Loaded 'C:\WINNT\system32\ntdll.dll', no matching symbolic information found. return(portadr,data); } unsigned char PortIn(unsigned int portadr) { unsigned char data; _asm mov edx,portadr _asm in al,dx _asm mov data,al return data; } int main(void) { short Dummy; short PortData=0; int pd=0; cout<<"Input portdata\n"; cin>>pd; Dummy=PortOut(PortAddress,pd); PortData=PortIn(PortAddress); cout<<"data at"<
You can't do it using
_inp
and_outp
, or even in assembler. Windows won't let you. You'll have to use the Windows functions for accessing parallel ports - look atCreateFile()
.Ryan
"Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"