LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

How do i get Pci Parallel Port I/O range ?

it is waiting for the other side of the communication to acknowledge the byte sent by asserting the "ack" line on the parallel port. if you let it running, it will eventually fall in a timeout and return ERROR_DEVICE_NOT_CONNECTED (1167).
0 Kudos
Message 21 of 29
(2,709 Views)

@wally_666

 

(please note that i took great of staying polite by avoiding the RTFM words...)

 

it seems you are not used to the Windows SDK: when microsoft shows you a way of specifying a parameter, it just says "hey, try that !" regardless of what comments surrounds the example. having used a virtual COM port once (connected to a bluetooth device), i had to use the "\\.\"prefix, even though i was using COM3. i can also point you here which is meant to be the starting point for communication resources (although i concede that most functions will not work with a parallel port) and talks about parallel ports (read, LPT1 is clearly written here) as well as "\\.\".

 

regarding the DeviceIoControl codes: this is low-level stuff, intended for people writing device drivers or wrapper library. you will find much more informations about the parallel port and about how parallel devices are managed in Windows here, including more useful control codes. note that this page is part of the Windows Driver Kit (formerly known as Windows Driver Development Kit). this kit can be downloaded for free from Microsoft's website. also, if you read more about device driver development and the WIndows Hardware Abstraction Layer, you may understand why the Rube Goldberg design is finally one of the most flexible way to do it, and also why tweating the parallel chip with inp and outp may not be that great idea.

0 Kudos
Message 22 of 29
(2,706 Views)
Thanks for the info i will go through it and get back to you.
Help share your knowlegde
0 Kudos
Message 23 of 29
(2,696 Views)
How would setup to be able to send data Asynchronously ?
Help share your knowlegde
0 Kudos
Message 24 of 29
(2,694 Views)

Hi

 

For my previous question this is what i came up with.

I need to send data Async, a byte at a time.

 

char ReadBuffer,WriteBufffer;
OVERLAPPED ovRead,ovWrite;
LPOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine;

PortHandle=CreateFile("\\\\.\\LPT3", (GENERIC_READ | GENERIC_WRITE), 0, NULL, OPEN_EXISTING, (FILE_ATTRIBUTE_NORMAL | FILE_FLAG_OVERLAPPED), NULL);

WriteBufffer=(char)0x00;
WriteFileEx(PortHandle,&WriteBufffer,1,&ovWrite,lpCompletionRoutine);

ReadFileEx(PortHandle,&ReadBuffer,1,&ovRead,lpCompletionRoutine);

 The following Functions seem to work but there is still no communication with the devices.

 Am i using this fuctions correctly?

 If not how should it by done?

 

Message Edited by Shako on 07-14-2009 08:11 AM
Help share your knowlegde
0 Kudos
Message 25 of 29
(2,648 Views)
at first glance, everything seems right. can you tell me what kind of device is connected to your parallel port ?
0 Kudos
Message 26 of 29
(2,645 Views)

Its an EPROM Emulator.

 

How the program works, to load the EPROM Emulator, is that the pc sends it a Byte and then reads the data sent back and sends another byte accordinly.

Do you know if all the parallel port pins are needed for this functions ?

Because i only have the pins i need.

The parallel port connection cable is a four wire telephone cable.

 

I got the following pins:

 

Pin 3       Data1

Pin 9       Data7

Pin 10     nAck

Pin 11     Busy

Pin 12     PaperOut

Pin 21     Ground

 

These pins work with outp() and inp(),  as well has VISA functions Write and Read.

Help share your knowlegde
0 Kudos
Message 27 of 29
(2,643 Views)

I got some more questions.

Hopefully you can help.

 

Would i have to clear the OVERLAPPED structure every time there is a i call to Write or Read function ?

And for the lpCompletionRoutine would i have to create a routine or would use a point to the routine ?

 

 

Help share your knowlegde
0 Kudos
Message 28 of 29
(2,617 Views)

dummy_decoy wrote:

@wally_666

 

(please note that i took great of staying polite by avoiding the RTFM words...)

 

it seems you are not used to the Windows SDK: when microsoft shows you a way of specifying a parameter, it just says "hey, try that !" regardless of what comments surrounds the example. having used a virtual COM port once (connected to a bluetooth device), i had to use the "\\.\"prefix, even though i was using COM3. i can also point you here which is meant to be the starting point for communication resources (although i concede that most functions will not work with a parallel port) and talks about parallel ports (read, LPT1 is clearly written here) as well as "\\.\".

 

regarding the DeviceIoControl codes: this is low-level stuff, intended for people writing device drivers or wrapper library. you will find much more informations about the parallel port and about how parallel devices are managed in Windows here, including more useful control codes. note that this page is part of the Windows Driver Kit (formerly known as Windows Driver Development Kit). this kit can be downloaded for free from Microsoft's website. also, if you read more about device driver development and the WIndows Hardware Abstraction Layer, you may understand why the Rube Goldberg design is finally one of the most flexible way to do it, and also why tweating the parallel chip with inp and outp may not be that great idea.


 

I've done two projects using different bluetooth serial port hardware and neither required the \\.\ for their virtual COM ports.  Neither has several USB COM port adaptors I've used.  As I said, since my particular USB dongle does not create an LPT device in device manager, this may be the showstopper.  If the CreateFile() succeeded I could permute the parameter options to perhaps figure things out.  I'm well aware of the WIn32 SDK's errors of omission.

 

With the kind of "embedded PC" applications I'm usually involved with, all the multi-user abstractions are not particularly relavent or useful.  Writing a device driver to toggle a bit is just plain not productive.  There is a point where flexability becomes more hinderance than help.  When I actually need to write a device driver, I move to Linux where I've all the source code available to me to minimize the trial and error in the learning curve.

 

One of my most common and flexible architechures is hardware on Linux, UI on Windows communicating over ethernet.  I'd high hopes for the CVI Linux runtime for those situations where using two computers is a problem, unfortunately this has pretty much been a deadend as the Linux CVI is already three versions behind 😞

 

--wally.

 

0 Kudos
Message 29 of 29
(2,600 Views)