07-13-2009 05:38 AM
07-13-2009 06:01 AM
@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.
07-13-2009 06:54 AM
07-13-2009 07:21 AM
07-14-2009 01:08 AM - edited 07-14-2009 01:11 AM
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?
07-14-2009 01:21 AM
07-14-2009 01:44 AM
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.
07-14-2009 06:41 AM
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 ?
07-14-2009 04:14 PM
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.