help with parallel port

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

hi all i have this probem, question:

i have an x86 industrial device with windows CE and NETcf2.0. this device
has a parallel port and three serial port.

using the serialports.getPortsName() method i can see the 3 serials but not
the parallel port..but here the strange things if i call :
serialPort.PortName="LPT1"
serialPort.Open();
no problem i can comunicate with a printer linked with the parallel port.

But here the problem if the printer is off, so i can send string to it, the
writeTimeout exception never fires, even if i set it at 5000 milliseconds.

So my question is..how can i recognize if the priter is linked and on ? i
have also tried the cdHolding propriety but no scuccess..
 
Hi,
But here the problem if the printer is off, so i can send string to it, the
writeTimeout exception never fires, even if i set it at 5000 milliseconds.

So my question is..how can i recognize if the priter is linked and on ? i
have also tried the cdHolding propriety but no scuccess..
<<

You cannot, Sytem.IO.Ports is designed for serial ports, not parallel. The
reason that it "works" with the parallel port is because both serial and
parallel ports are opened using the CreateFile API (which is called when you
call the Open method). However, the remainder of the code in the IO.Ports
class uses serial-specific APIs (except writing and reading) for accessing
the hardware itself.

You really need to inquire of the board vendor if they supply a dll for the
printer port.

Dick

--
Richard Grier, MVP
Hard & Software
Author of Visual Basic Programmer's Guide to Serial Communications, Fourth
Edition,
ISBN 1-890422-28-2 (391 pages, includes CD-ROM). July 2004, Revised March
2006.
See www.hardandsoftware.net for details and contact information.
 
Hi bule,

We have experiences in manipulating LPT port under WinCE, such as use
them as GPIOs, getting the interrupts.......
Here I suggest you trying the following approaches....

1. Set the parallel port address in BIOS as 0x378
And the mode you use with your printer
2. There are register detail description in the website
http://www.beyondlogic.org/epp/epp.htm
make a reference to it....
Since now the base address is 0x378
so that
Data Port - 0x378 (Base + 0)
Status Port - 0x379 (Base + 1)
Control Port - 0x37A (Base + 2)
.......
Trying to use these register to get your printer status or
communicate with it...Though I have never tried detecting a printer
existence, I suggest you frist try to read the status from the status port
....to see if any bit of it is different between power on / off.....

using the APIs WRITE_PORT_UCHAR and READ_PORT_UCHAR to write and
read from the registers...............
If you're in WinCE42/50, you may use them directly in your AP....
However in CE60, there is kernel and user mode distinction, you have to do
it in a driver......

Any problem, feel free to discuss....

Best Regards,
 
thanks all for your attention:
very intersting the Josh chang's post but i have found out a simpler way to
detected the printer:

the write timeout exception seems to raise, probably i have made some error
yesterday in code, so before writting the right text to the printer i do the
following steps:
--set a short write timeout (5 ms)
--open the parallel port
--write a blank charachter
--intercept the timeout exception
--close the port

if i don't have the timeout exception i start the printer operation ..
 
You're aware this is a CF group, right? The OP likely has no idea how to
access registers from code (and probably shouldn't even try before asking
the OEM if there's a driver available).


--

Chris Tacke, Embedded MVP
OpenNETCF Consulting
Managed Code in an Embedded World
www.OpenNETCF.com
 
Hi ~
What I told is the real possible solution..The true is people come here
to find solutions, isnt it?
Since there is no such things in CF......It is originally meant to deal with
high level stuff..right? And essentially, LPT is all about hardware low-level
things....

Besides that...WRITE_PORT_UCHAR and READ_PORT_UC are available on all
CEPCs...you could just use PINVOKE to call them in any .NET CF based
languages...
 
Back
Top