Question on Accessing parallel port

This is a discussion on Question on Accessing parallel port within the C++ Programming forums, part of the General Programming Boards category; Hello, I am trying to access parallel port with C++ on Windows XP. I already have inpout32.dll sitting in my ...

  1. #1
    Imperator of Darkness Luciferek's Avatar
    Join Date
    Jun 2008
    Location
    Detroit, MI
    Posts
    38

    Question on Accessing parallel port

    Hello,
    I am trying to access parallel port with C++ on Windows XP. I already have inpout32.dll sitting in my Windows/system32 directory. The problem i encounter is that my complier BloodShed Dev C++ does not recognize inportb or outportb functions no matter what i include as a header.

    I need to know several things...
    1) What functions should i use to access parallel port? and what header file to include? I do not want to use VC++ or Borland, most of the internet websites give examples on those compilers. I like using free compilers

    2) How do i use inpout32.dll? Do i have to link to it in my code? if I do, how do I do it? or is it just fine sitiing where it is?

    3) Can someone point me to a good resource that describes step by step how to
    access parrallel port in free compiler?

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,848
    http://www.lvr.com/parport.htm

    > I do not want to use VC++ or Borland
    But that doesn't stop you using the win32 API, which DevC++ is perfectly capable of using.
    The link has examples of how to use the win32 API.

    > How do i use inpout32.dll?
    Since it seems to be a hack to get old inport() (aka DOS) programs to work, I would suggest you forget about it if you're just starting to learn this stuff.
    It's a quick fix now, but will cause serious problems later.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  3. #3
    Imperator of Darkness Luciferek's Avatar
    Join Date
    Jun 2008
    Location
    Detroit, MI
    Posts
    38

    Angry Win32 API?

    I was trying to find any info on using win 32 API funtions to access parallel port.
    Whole buch of crap and no specifics...
    On the link you provided there is an example for visual basic, i tried it and it gives me runtime error.

    Any link that would describe the API functions to access that damn port?

  4. #4
    dra
    dra is offline
    Weak. dra's Avatar
    Join Date
    Apr 2005
    Posts
    166
    Codeplug has a class based off the win32 api that helps you access the serial port found here:

    C++ serial port programming

    BTW, just to make things clear Visual C++ Express Edition is free...

  5. #5
    Registered User Codeplug's Avatar
    Join Date
    Mar 2003
    Posts
    4,702
    >> I was trying to find any info on using win 32 API funtions to access parallel port
    Define "access". Do you want pin-level control? Or you do you want to communicate with a IEEE-1284 device?

    For pin-level access, there isn't really a Win32 API for doing that - other than the MS-CRT functions _inp() and _outp(). MinGW uses the MS-CRT so these functions are available to you. The problem is that the "in" and "out" instructions are privileged under NT OS's. The inpout32 DLL provides two interfaces, Inp32() and Out32(), which somehow overcome this problem. Here's sample code that loads the library dynamically and uses those functions: http://www.hytherion.com/beattidp/comput/pport/Test1.c

    Another option (for pin-level access) is to use GiveIO or UserPort, which gives user-mode processes "permission" to use the "in" and "out" instructions - which mean you can use the MS-CRT functions: _inp() and _outp() (from conio.h).

    If you just want to communicate with a IEEE-1284 device, you can use CreateFile() on the dos-device name for the port, like "LPT1". Then use ReadFile() and WriteFile() normally. Or if you really want to keep is simple, you could try using standard stream I/O on the file "LPT1".

    >> On the link you provided there is an example for visual basic...
    There are a lot more resources than that when you use Salem's link as a starting point.

    gg

  6. #6
    Imperator of Darkness Luciferek's Avatar
    Join Date
    Jun 2008
    Location
    Detroit, MI
    Posts
    38
    All i want is to read and write to the 8 data pins on the parrallel port. However, it would be nice if i could control only one pin, instead of sending number value to drive those 8 pins. Two functions inp32() and out32() was what i needed to know in the first place.. now i'm cool
    Last edited by Luciferek; 06-16-2008 at 06:16 PM.

  7. #7
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Quote Originally Posted by Luciferek View Post
    All i want is to read and write to the 8 data pins on the parrallel port. However, it would be nice if i could control only one pin, instead of sending number value to drive those 8 pins. Two functions inp32() and out32() was what i needed to know in the first place.. now i'm cool
    As long as you keep track of "current value", you can wiggle one pin at a time - the method being that you modify you "current value", and then send the new current value to the port.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. input to parallel port prob
    By tariq7868 in forum Tech Board
    Replies: 4
    Last Post: 06-11-2009, 01:35 PM
  2. Parallel Port: Sending the signals as binary
    By h3ro in forum Tech Board
    Replies: 7
    Last Post: 08-25-2007, 01:22 PM
  3. Parallel port programming
    By h3ro in forum Windows Programming
    Replies: 6
    Last Post: 08-08-2007, 12:14 PM
  4. programming the parallel port to control device
    By griffmaster2005 in forum C Programming
    Replies: 3
    Last Post: 02-14-2005, 07:50 AM
  5. Simple Parallel Port Control
    By BigSter in forum C++ Programming
    Replies: 2
    Last Post: 11-15-2001, 10:51 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21