?
Solved

dll to read from lpt or serial

Posted on 2005-05-12
12
Medium Priority
?
295 Views
Last Modified: 2008-01-09
we have a device with a switch, this device will be connected to a PC from lpt or Com port. when the switch on it sends an electrical signal indicating that, and when it is off it will send a signals indecating that too,
i need to read these signals in vb.net programe,do i need special dll files, and if so where can find them,and how can i use them in vb.net .
any help please
0
Comment
Question by:jamal99
  • 5
  • 4
9 Comments
 
LVL 13

Expert Comment

by:softplus
ID: 13984787
If you're using the serial port (COM), you can just use the vb6 MsComm32.ocx.
Otherwise, take a look at the following links:
Serial: http://www.codeworks.it/net/VBNetRs232.htm
Parallel: http://www.experts-exchange.com/Programming/Programming_Languages/Q_20818873.html
0
 
LVL 1

Author Comment

by:jamal99
ID: 14008472
thanx softplus , but i dint know how  to do it yet,
i did download the inpout32.dll.i dont know if it is useful.

but i need hel on how to include it in my application and how to let it read bytes from the port(com or lpt).


in fact i am a web developer, i dont know much about windows applications and api.
0
 
LVL 13

Expert Comment

by:softplus
ID: 14009511
How far have you gotten? Which port are you trying to use first? What kind of data are you expecting from the port? :)
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 1

Author Comment

by:jamal99
ID: 14013087
not so far
i still cant include the dll in the project
please give me simple steps
just to include it and read when i want
0
 
LVL 13

Accepted Solution

by:
softplus earned 1000 total points
ID: 14013222
OK, I assume you want to use the parallel port  first (from the inpout32.dll)? If so, I would throw the inpout32.dll away and use the io.dll from here: http://www.geekhideout.com/iodll.shtml
Then in your vb.net you will want to define your dll as follows in a seperate module file:
    Public Declare Sub PortOut Lib "IO.DLL" (ByVal Port As Short, ByVal Data As Byte)
    Public Declare Sub PortWordOut Lib "IO.DLL" (ByVal Port As Short, ByVal Data As Short)
    Public Declare Sub PortDWordOut Lib "IO.DLL" (ByVal Port As Short, ByVal Data As Integer)
    Public Declare Function PortIn Lib "IO.DLL" (ByVal Port As Short) As Byte
    Public Declare Function PortWordIn Lib "IO.DLL" (ByVal Port As Short) As Short
    Public Declare Function PortDWordIn Lib "IO.DLL" (ByVal Port As Short) As Integer
    Public Declare Sub SetPortBit Lib "IO.DLL" (ByVal Port As Short, ByVal Bit As Byte)
    Public Declare Sub ClrPortBit Lib "IO.DLL" (ByVal Port As Short, ByVal Bit As Byte)
    Public Declare Sub NotPortBit Lib "IO.DLL" (ByVal Port As Short, ByVal Bit As Byte)
    Public Declare Function GetPortBit Lib "IO.DLL" (ByVal Port As Short, ByVal Bit As Byte) As Boolean
    Public Declare Function RightPortShift Lib "IO.DLL" (ByVal Port As Short, ByVal Value As Boolean) As Boolean
    Public Declare Function LeftPortShift Lib "IO.DLL" (ByVal Port As Short, ByVal Value As Boolean) As Boolean
    Public Declare Function IsDriverInstalled Lib "IO.DLL" () As Boolean

Now you can access these functions directly, i.e. to get a byte of data from the port:
bytData = PortIn( (intPortNo) ) ' where intPortNo = the parallel port number

Note, I can't test this as I don't have anything that will send me data on LPT-Ports :)
0
 
LVL 1

Author Comment

by:jamal99
ID: 14021371
i will try ,and thanx alot but do i need to add a reference to the dll file?
0
 
LVL 13

Expert Comment

by:softplus
ID: 14021486
no, you don't need to add a reference, as the functions are specifically declared for the DLL. The DLL needs to be in the path, possibly in the same directory as the exe-file. :)
0
 
LVL 1

Author Comment

by:jamal99
ID: 14024717
hello softplus , just on e more question.
how could i know the lpt port number, i maybe put a lpt switch so i can use the printer. so i dont know if this will causes a problem.???
0
 
LVL 1

Author Comment

by:jamal99
ID: 14543668
dear softplus ,
at last, the application works fine after doing some electical circuits , but the problem is that it works fine on some computers and only the (PortOut) on other computers,
do i need to do some configurations on the LPT port, or do i need to change som BIOS configurations, please advice so i let it work on these compters
0

Featured Post

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
With just a little bit of  SQL and VBA, many doors open to cool things like synchronize a list box to display data relevant to other information on a form.  If you have never written code or looked at an SQL statement before, no problem! ...  give i…

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question