2 Replies - 25570 Views - Last Post: 24 August 2007 - 04:42 AM Rate Topic: -----

#1 mmk  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 13-April 07

parallel port interface

Post icon  Posted 23 April 2007 - 03:39 PM

Option Explicit On
Imports System.Data
Imports Microsoft
Imports MessengerAPI

Public Declare Function Inp Lib "inpout32.dll" Alias "Inp32" (ByVal PortAddress As Integer) As Integer
Public Declare Sub Out Lib "inpout32.dll" Alias "Out32" (ByVal PortAddress As Integer, ByVal Value As Integer)

Public Class Form1
Inherits System.Windows.Forms.Form
Dim Value As Integer
Dim PortAddress As Integer
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

'Test program for inpout32.dll
Value = 0
'Change PortAddress to match the port address to write to:
'(Usual parallel-port addresses are &h378, &h278, &h3BC)
PortAddress = &H378
End Sub


Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
'Write to a port.
Out(PortAddress, Value)
'Read back and display the result.
Text1.Text = Inp(PortAddress)
Value = Value + 1
If Value = 255 Then Value = 0
End Sub
End Class


I used this VB program as a direct input and out to my parallel port,but when I start debuggin it ,it shows to me a massage "SEHException was unhandled,so can any one tell what it meen.
I used VB.NET and used the DLL"inpout32" for direct access. I copied them from CD to Widows/system directory.
is there another way to access parallel port.

This post has been edited by mmk: 24 April 2007 - 03:20 AM


Is This A Good Question/Topic? 0
  • +

Replies To: parallel port interface

#2 data_boches  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 22-August 07

Re: parallel port interface

Posted 23 August 2007 - 01:58 AM

View Postmmk, on 23 Apr, 2007 - 03:39 PM, said:

Option Explicit On
Imports System.Data
Imports Microsoft
Imports MessengerAPI

Public Declare Function Inp Lib "inpout32.dll" Alias "Inp32" (ByVal PortAddress As Integer) As Integer
Public Declare Sub Out Lib "inpout32.dll" Alias "Out32" (ByVal PortAddress As Integer, ByVal Value As Integer)

Public Class Form1
Inherits System.Windows.Forms.Form
Dim Value As Integer
Dim PortAddress As Integer
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

'Test program for inpout32.dll
Value = 0
'Change PortAddress to match the port address to write to:
'(Usual parallel-port addresses are &h378, &h278, &h3BC)
PortAddress = &H378
End Sub


Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
'Write to a port.
Out(PortAddress, Value)
'Read back and display the result.
Text1.Text = Inp(PortAddress)
Value = Value + 1
If Value = 255 Then Value = 0
End Sub
End Class


I used this VB program as a direct input and out to my parallel port,but when I start debuggin it ,it shows to me a massage "SEHException was unhandled,so can any one tell what it meen.
I used VB.NET and used the DLL"inpout32" for direct access. I copied them from CD to Widows/system directory.
is there another way to access parallel port.


i also have same problem.but what i know, &h378, &h278, &h3BC is address for data port.actually parallel port have 4 "group". data port, control port, and status port and ground port.data port only for write,it can not read. so to read the port you can use control port or status port.address for status port is &H379 and &H37A.this address is for LPT1 only. but i still have have a a problem to read from port. i hope anybody can help me on how to control parallel port.
Was This Post Helpful? 0
  • +
  • -

#3 PsychoCoder  Icon User is offline

  • Google.Sucks.Init(true);
  • member icon

Reputation: 1638
  • View blog
  • Posts: 19,853
  • Joined: 26-July 07

Re: parallel port interface

Posted 24 August 2007 - 04:42 AM

View Postdata_boches, on 23 Aug, 2007 - 01:58 AM, said:

i also have same problem.but what i know, &h378, &h278, &h3BC is address for data port.actually parallel port have 4 "group". data port, control port, and status port and ground port.data port only for write,it can not read. so to read the port you can use control port or status port.address for status port is &H379 and &H37A.this address is for LPT1 only. but i still have have a a problem to read from port. i hope anybody can help me on how to control parallel port.


@data_boches you should have made this a separate post, its never good etiquette to ask a question in someone else's thread, plus it minimizes the chances someone is going to see it and answer your question.

@mmk, below is a link to an article on Microsoft's site that appears to have what you're looking for plus lots more. Hope it helps :)

Accessing Serial & Parallel Ports With VB.Net

Happy Coding!

This post has been edited by PsychoCoder: 24 August 2007 - 04:43 AM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1