Swarts

I am wondering if anyone has a class already made for parallel port programs. I found several different examples but they were all for Unix and would not compile for me. I don't want to start from complete scratch because my tech lead told me to not "reinvent the wheel" because there is so much information already out there. The program I need to write must be compatible with Windows XP and must be written in Visual C++. The person previously working on this got the send program to work, I just need to write the part that will receive information from another computer.

Forums I've searched already have told me to use CreateFile() and ReadFile() and I'm not having much success understanding how to use these. Also, I've been told to use inpout32.dll, but after downloading it, reading all about it, and asking how to use it, I still don't know how to include that in my project.

If anyone has done this sort of project before, could you please post some sample code or give me information on how to do this


Re: Visual C++ General Parallel Port

_johnr_

Hi Swarts,

If you want to use the inpout32 library then take the following steps:

First, copy the inpout32.dll and inpout.lib files into your project directory. inpout.lib can be found in the VC_test_app directory. Now go to the project properties page, click through Configuration Properties->Linker->Input. Where it says Additional Dependencies add "inpout32.lib" to the list.

Next you need to include the function declarations somewhere in your project:

Code Snippet
short _stdcall Inp32(short PortAddress);
void _stdcall Out32(short PortAddress, short data);

Now you can just call either of those functions to send or receive data on the parallel port. Normally, the port address is 0x378 but you shouldn't rely on that.

John.





Re: Visual C++ General Parallel Port

Swarts



Thanks so much! It's working a lot better than it used to.

Now my new problem is with testing it out. I borrowed my friends' computers and connected them with a bidirectional cable. The program ran just fine on one computer, but when I tried to run the program on the other, it gave me errors about msvcp71.dll and and mfc71.dll. I just copied those into the system32 folder and it works fine, but I was just wondering what those libraries are for and why they are only on some computers

Unfortunately, solving the problem with the .dll files took too long and I didn't get to see if any data would transfer. And can I only use a short data type What would I need to modify if I wanted to send text or files




Re: Visual C++ General Parallel Port

Swarts

I tested out the programs. It sort of works. I can't test it again (on better computers) until later today, so I want to ask a few more questions. Hopefully someone will be able to answer. Please be aware that I have only had one year of C++ and my questions will probably not make much sense, so feel free to dumb things down for me.

Pretending that I have two computers attached with a parallel port cable, and I can send one byte of data with no trouble, how would I need to modify the programs to work with each other to send more than one byte The way I have it, the executable needs to be run each time I want to send/receive something. This seems like it's definitely not the best way. Is there some way to pause the send program until the receive program receives the byte, and then pause the receive program until the send program sends another byte Would I need to toggle the Ack pin somehow for this to work




Re: Visual C++ General Parallel Port

Swarts

So I tested it out on other computers, and it didn't work the same way it did during my first testing attempt. I didn't think it would because when I said "it sort of works", there was probably just a fluke from all of my trial and error attempts that made it seem like it was working. So now, I've been set up with a machine that sends data through the parallel port, and my current task is to just see if I can receive any of the information being sent. Using Inp32 from inpout32.dll, I still wasn't receiving anything.

Does inpout32.dll actually work the way I'm hoping it does Should Inp32 return data from the machine I'm only trying to read one byte, but I'm not receiving anything.

Please help!!




Re: Visual C++ General Parallel Port

Swarts

When I run it with the transport machine (which is sending the data), I get a value of 223 for the status port. Does this value actually mean anything