Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. initailize parallel port

initailize parallel port

Scheduled Pinned Locked Moved C / C++ / MFC
c++helpquestion
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • U Offline
    U Offline
    User 1218055
    wrote on last edited by
    #1

    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"<

    R R 2 Replies Last reply
    0
    • U User 1218055

      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"<

      R Offline
      R Offline
      Rory Solley
      wrote on last edited by
      #2

      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

      1 Reply Last reply
      0
      • U User 1218055

        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"<

        R Offline
        R Offline
        Ryan Binns
        wrote on last edited by
        #3

        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 at CreateFile().

        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"

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups