prallel port programming

This is a discussion on prallel port programming within the Windows Programming forums, part of the Platform Specific Boards category; Originally Posted by grumpy Assuming your circuit is wired correctly, there are various modes of the parallel port that disable ...

  1. #16
    Infant of C
    Join Date
    May 2010
    Location
    Karachi, Pakistan
    Posts
    118
    Quote Originally Posted by grumpy View Post
    Assuming your circuit is wired correctly, there are various modes of the parallel port that disable outputs. For example, if the port supports PS/2 mode and bit 5 of the control port is set, all output to the data port is disabled.
    I think my parallel port is enabled and is working correctly. I tired writing the data with this small utility and found that data is received and sent correctly.

  2. #17
    Registered User
    Join Date
    Jun 2005
    Posts
    6,658
    Given the way the parallel port works I really doubt your testing is sufficient. There is much more to interacting with a parallel port than just writing data to its output register (which is all your code does) or reading from the input register. Are you aware, for example, that there are at least five distinct operating modes for parallel ports, and that older ports do not support all modes?

    Because of that, just throwing data at the output register of the parallel port (as you are doing) will not reliably work. There is also interaction with the operating system and other installed drivers to consider.

    I'm not familiar with the utility you are using, but would bet that (on commencement) it places the port into some known state. If it is a good windows citizen, it would clean up after itself (i.e. remember the initial settings it detected, and restore them as it exits). That would explain why you can do what you want with the utility, but not with your code. It is, more than likely, your code (and assumptions it makes) that is the problem.

    As I said before, you need to read up on the parallel port itself. All your code is doing is throwing data to the output register of the port. Depending on the type of parallel port, and the state it is in, your data may simply be ignored by the port. That means, it will not be passed onto your device or circuit.
    Right 98% of the time, and don't care about the other 3%.

    If I seem grumpy or unhelpful in reply to you, or tell you you need to demonstrate more effort before you can expect help, it is likely you deserve it. Suck it up, Sunshine, and read this, this, and this before posting again.

  3. #18
    Infant of C
    Join Date
    May 2010
    Location
    Karachi, Pakistan
    Posts
    118
    Well I need to work in Byte mode. I have not yet connected my actual device to the port but I have used a test circuit consist of LEDs to check whether the port is working or not. And by "data is not written on the port" I mean to say that circuit is not detecting the change in signals.
    Come back to the working mode. I need to work in Byte mode. I have searched on internet "how to set parallel port mode in C/C++" but found no use full result regarding my problem. Secondly, this is previously discussed that the program is working properly on win Xp with out setting or changing the operation mode. But (if this is really the reason) why win & is waiting for me to change the operation mode before running my program?

  4. #19
    Registered User
    Join Date
    Jun 2005
    Posts
    6,658
    You're asking the wrong question.

    The windows NT family of operating systems (NT/2000/XP/win 7) specifically prevent direct access to the parallel port, by design. You are using a third-party DLL, which installs a kernel-mode driver, in order to explicitly bypass design features of the operating system, and access the parallel port in a manner that the operating system cannot control. The folks who designed your operating system had no knowledge of the particular needs of your program.

    Why, given that you are going out of your way to bypass the operating system, would you expect that the operating system would ensure that the parallel port is kept in some state or mode that ensures your program would work?

    I gave links in previous posts to information on programming the parallel port. Granted, those links do not provide cookbook recipes of "do this to place the port in byte mode", but the information is there if you take the trouble to seek it. I'm not aware of any guides to programming the parallel port that provide simple cookbook recipes. Which is usually a hint that experts do not consider parallel port programming to be difficult enough to warrant writing "parallel ports for dummies" guides.
    Right 98% of the time, and don't care about the other 3%.

    If I seem grumpy or unhelpful in reply to you, or tell you you need to demonstrate more effort before you can expect help, it is likely you deserve it. Suck it up, Sunshine, and read this, this, and this before posting again.

  5. #20
    Infant of C
    Join Date
    May 2010
    Location
    Karachi, Pakistan
    Posts
    118
    This sounds to me that I should skip chasing parallel port and should look for a third party ware that enables me to communicate with my device since I do not have this much which allows me to first study a whole book on parallel port programming then writing a simple code that would send a single byte of data to my device.

  6. #21
    Registered User
    Join Date
    Jun 2005
    Posts
    6,658
    That's a matter of perspective, I guess. It strikes me that you want canned solutions without effort.

    To find a "third party ware" to do what you want, you'll need to go through a process of testing any you find. But, yeah, I suppose you might consider that less complicated than reading documentation, and implementing your own solution.
    Right 98% of the time, and don't care about the other 3%.

    If I seem grumpy or unhelpful in reply to you, or tell you you need to demonstrate more effort before you can expect help, it is likely you deserve it. Suck it up, Sunshine, and read this, this, and this before posting again.

  7. #22
    Infant of C
    Join Date
    May 2010
    Location
    Karachi, Pakistan
    Posts
    118
    Yes. You are right. Even if I dont want a canned solution then again I do not want to waste time reading documentations and learning something which one would rarely need in life. Most of the guys at my academy also have "advised" me not to go behind something which do not exist in the modern world any more (almost all the mother board's manufacturer's are not providing parallel port any more), therefore I should achieve my target by using some "USB to parallel port converter" or some sort of USB supported Micro Controllers.

Page 2 of 2 FirstFirst 12
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. port programming
    By Anuradh_a in forum C Programming
    Replies: 3
    Last Post: 03-19-2008, 03:23 PM
  2. port programming
    By geek@02 in forum Windows Programming
    Replies: 1
    Last Post: 11-20-2005, 06:53 AM
  3. I/O port programming in C???
    By shraddha in forum C Programming
    Replies: 1
    Last Post: 09-12-2005, 11:59 AM
  4. C++ I/O port programming????
    By shraddha in forum C++ Programming
    Replies: 2
    Last Post: 09-12-2005, 11:58 AM

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