|
2000 and XP do not allow you to write directly to memory 0x378-0x37f (parallel port). So you do need a driver to do this for you. There are free programs out there. Try UserPort. It somewhat works for me. The driver doesn't always stay installed and you have to run this small program to reinstall it sometimes.
DirectIO is another one. Costs 30$.
|
|
|
|
|
Microsoft MSDN says that there's only necessary to use CreateFile, WriteFile and ReaFile
When I use CreateFile("\\.\COMM1"... WriteFile returns immediately, so I think it works fine.
When I use CreateFile("\\.\LPT1"... WriteFile doesn't return
Why?
|
|
|
|
|
Yes, the COM port works that way. The LPT doesn't. That's why programs such as UserPort exist. I don't remember the details why.
|
|
|
|
|
WriteFile to LPT1 will not return until the bytes have gone out to the 'device', or the DeviceRetryTimeout has expired - normally about 90 seconds.
Also, if a printer device driver is attached to the LPT1, then you might see extraneous printer spooling activity when you write directly to LPT1 as a file.
Just my experience anyway.
|
|
|
|
|
I tried to change the TimeOut value of the port with SetCommTimeOut(...) to 90 ms but WriteFile doesn't return.
I also got the packet size of the driver of the port using GetCommProperties():
64 for COM1, 0 for LPT1
Does this mean that I can't send data through LPT1?
|
|
|
|
|
SetCommTimeOut(...) only seems to work with the serial ports (COM).
I was confusing the ability to controel the parallel port with soem old entries that used to be in WN.INI - TransmissionRetryTimeout and DeviceNotSelectedTimeout
When these value were reduced, the LPT1 writes would return more quickly if the printer was offline.
GetCommProperties also only works on the COM ports.
|
|
|
|
|
mario_o82 wrote:
My problem is that my WriteFile doesn't return and it waits something.
Do you have anything connected to the parallel port? The way the port works is that the data is put on the data lines, the strobe line is pulsed, and then the PC waits for a device to acknowledge by pulsing the ACK line. If it doesn't receive the acknowledge, it doesn't complete the write, and therefore WriteFile() doesn't return.
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
OK, I guess U know what I need to know!
Does this mean that it isn't necessary to use a driver to communicate through parallel port?
(because I don't want to use it...)
I just need to use WriteFile(...) and pulse the strobe line ?
How can I send control signals through parallel port?
|
|
|
|
|
mario_o82 wrote:
Does this mean that it isn't necessary to use a driver to communicate through parallel port?
That's right, you can just use WriteFile() as you were doing. Just make sure that a device is connected
mario_o82 wrote:
I just need to use WriteFile(...) and pulse the strobe line ?
WriteFile() will handle the strobe line for you
mario_o82 wrote:
How can I send control signals through parallel port?
For that you'll need to write a device driver. Usually you won't need to manipulate the control signals directly though.
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
Ryan Binns wrote:
Do you have anything connected to the parallel port?
I connected an old printer to my LPT1 and WriteFile() worked fine and the printer did something!
Now, I need to use the same progam without the printer but I don't know what to do (physically) with my port lines: WriteFile should put the data on the data lines and wait for acknowledge? Cause I can't find any data on port lines after call WriteFile. I tried to connect acknowledge line to Gnd after call WriteFile but nothing happens!
Do you know what I have to do (physically) with LPT lines?
Thank you so much.
|
|
|
|
|
|
Thank you, but I already have a DLL to access parallel port.
The problem is that some people say:
CreateFile , WriteFile... and nothing about drivers or DLLs (Like Microsoft MSDN)
and some other people say:
Use a driver, it's the only way and nothing about files!!!
So I'm realy conffused!
|
|
|
|
|
If anyone knows of a way to use the parallel port to output some signals (not to printer or some device, just set the data line high/low) then I'd really like to know because then I could get rid of the driver stuff that I'm using right now.
If you find of a way please post it.
Thanks.
|
|
|
|
|
Hi everyone,
I am searching for a Java Panel like control in MFC. Basically, I just need a drawing area with a toolbar and auto-scroll properties. I am terrible at GUI programming and designing controls scare me. Can someone point me to some control that is similar to what I need?
Cheers!
Pankaj
/**
I'm the one who's gonna have to die
When it's time for me to die
So let me live my life
The way I want to
- Jimi Hendrix
*/
|
|
|
|
|
Hy everyone.
My purpose is to download a range of bytes (i.e. from the beggining up to a certain point) from a file located by a given URL. I am trying to determine the remote file size, but so far I didn't succeded. I am using WinInet, InternetReadFile function to actually read the file. I can read it, but I would like to determine it's size prior of downloading the whole file. If anyone could show me another way tp do that, more simple than this please do so.
THANKS.
|
|
|
|
|
Try:
HttpQueryInfo(hResource, HTTP_QUERY_CONTENT_LENGTH | HTTP_QUERY_FLAG_NUMBER,
&dwContentLength, &dwSize, NULL) where hResource is the one you use when calling InternetReadFile, dwContentLength is a DWORD to return the file-size into and dwSize = sizeof (DWORD).
"though nothing
will keep us together
we can beat them
for ever and ever"
rechi
|
|
|
|
|
Thanx Rechi One extra question ? R U from Romania ?
I tried that, but unfortunately i get:
ERROR_HTTP_HEADER_NOT_FOUND ... At first i had this in mind that is to play with such functions like Internetqueryoption and stuff, but no matter how much I dig up those flags I didn't find anyone related to the whole file size, just related to sections ...
THANKZ anyway :->
|
|
|
|
|
gecool wrote:
ERROR_HTTP_HEADER_NOT_FOUND
It's about the headers, take a look at this (old) fragment:
HINTERNET hResource=::HttpOpenRequest(hConnection, _T("GET"),
szRelativeFile, NULL, NULL, NULL,
INTERNET_FLAG_KEEP_CONNECTION, 0);
if (hResource)
{
LPTSTR szHeaders=_T("Accept: audio/x-aiff, application/octet-stream, "
"application/x-msdownload, audio/basic, "
"audio/midi, audio/mpeg, audio/wav, image/jpeg, image/gif, "
"image/jpg, image/png, image/mng, image/bmp, text/plain, "
"text/html, text/htm\r\n");
CString szAgentHeader;
szAgentHeader.Format(_T("User-Agent: %s/1.0\r\n"),
(LPCTSTR)m_szAppName);
HttpAddRequestHeaders(hResource, szHeaders, _tcslen(szHeaders),
HTTP_ADDREQ_FLAG_ADD_IF_NEW);
HttpAddRequestHeaders(hResource, (LPCTSTR)szAgentHeader,
szAgentHeader.GetLength(), HTTP_ADDREQ_FLAG_ADD_IF_NEW);
if (HttpSendRequest(hResource, NULL, 0, NULL, 0))
{
DWORD dw=0, dwOut=0, i=0, n=0, dwContentLength,
dwSize=sizeof(DWORD);
CString szFileFromPath=CUpgrader::GetFileFromPath(
szRelativeFile), filepath;
if (!::HttpQueryInfo(hResource, HTTP_QUERY_CONTENT_LENGTH |
HTTP_QUERY_FLAG_NUMBER, &dwContentLength, &dwSize, NULL))
dwContentLength=-1;
and check if something is missing in your code. It's from an update system i wrote a year ago, and it works like a dream :->
gecool wrote:
R U from Romania ?
Yeah!
"though nothing
will keep us together
we can beat them
for ever and ever"
rechi
|
|
|
|
|
Mersi mult
Tocmai asta asteptam sa gasesc un piece of code ....
Geo.
|
|
|
|
|
If you think you can help me to use the code that was published by Allan Nielsen in his article "SuperGrid",
please let me know!!!
thanks in advance,
sheli
|
|
|
|
|
That's why there's a space to post questions under the article
Christian
I have several lifelong friends that are New Yorkers but I have always gravitated toward the weirdo's. - Richard Stringer
|
|
|
|
|
I have to set an icon on a toolbar button - how do I do that????
I am programming in visual 6.0.
If you realy wona help me please detail all the steps.
thank you
|
|
|
|
|
At design time or run time?
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
Please Help.
How can i use the CListView (Add new Items, Columns, Sort, etc?
Thanks
|
|
|
|
|
First call GetListCtrl() to get a reference to the "underlying" list control. Then you can use that object's InsertColumn() and InsertItem() methods.
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|