我有塊i/o的卡,說明上寫可以讀取280h的內容.(100分)

  • 主题发起人 主题发起人 hlyu
  • 开始时间 开始时间
H

hlyu

Unregistered / Unconfirmed
GUEST, unregistred user!
我有塊i/o的卡,說明上寫可以讀取280h的內容.並且原卡中的提供的dll文件和相關的function 和procedure
參數是16位的i/o address,我該如何操作,因我在參數中改為$280時,程序就報錯.
 
>>因我在參數中改為$280時,程序就報錯.
正常是與你bios中設置中有衝突吧, 在bios中看看, 特別是看com1, com2設置對應的地址, 不能衝突!!!
 
我的是ISA卡,在vb下編程是可以實現的,我不知在Delphi下如何操作?
 
你用Tvichw32试一试吧,因为你要操作实际端口地址,而操作系统提供的是虚拟的
 
你在vb下是怎么实现的?
 
Dim Auto9201Data As Byte
Dim status As Long
Public cardaddr As Integer
Dim output_data As Long

Private Sub Auto_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
chk_card
If (Chk_run.Value = 1) Then
Timer2.Enabled = Auto.Value
Else
Auto.Value = False
End If
End Sub

Private Sub Chk_run_Click()
Timer1.Enabled = Chk_run.Value

If (Chk_run.Value = True) Then
Chk_run.ToolTipText = "start"

Else
Chk_run.ToolTipText = "stop"
Timer2.Enabled = False
Auto.Value = False
End If

End Sub

Private Sub exit_Click()
Quit_Click
End Sub

Private Sub Form_Load()
JSDIOInit &&初使化
cardaddr = &H280 &&此處在delphi中如何實現?
Lab_addr.Caption = Hex(cardaddr)

End Sub




Private Sub mnu_address_Click()
frmSetAddr.Show 1
Lab_addr = Hex(cardaddr)
End Sub



Private Sub OutP_MouseUp(Index As Integer, Button As Integer, Shift As Integer, X As Single, Y As Single)
chk_card
If (Chk_run.Value = 1) Then
write_output

Else
OutP(Index).Value = False
End If

End Sub

Private Sub Quit_Click()
JSDIOClose
End
End Sub
Private Sub Timer1_Timer()

ReadIN
UpdateColor
End Sub

Private Sub Timer2_Timer() '執行 OUT 00~ 自動位移一次輸出
Dim i As Integer
If Auto9201Data > 15 Then
Auto9201Data = 0
End If

For i = 0 To 15
OutP(i).Value = 0
write_output
Next i

OutP(Auto9201Data).Value = 1
write_output

Auto9201Data = Auto9201Data + 1
End Sub
Private Sub ReadIN()

Dim bytedataL, bytedataH As Long
Dim worddata As Long
Dim i As Integer
bytedataL = JSReadChar(cardaddr) &&讀此地址的值
bytedataH = JSReadChar(cardaddr + 1)
worddata = (bytedataH * 256) + bytedataL
For i = 0 To 15
InP(i) = worddata Mod 2
worddata = worddata / 2
Next i
worddata = 0
End Sub

Private Sub UpdateColor()
For i = 0 To 15
If InP(i) = 0 Then
If (i Mod 8) = 0 Then
InP(i).ForeColor = &H8000&
Else
InP(i).ForeColor = &H80&
End If
Else
If (i Mod 8) = 0 Then
InP(i).ForeColor = &HFF00&
Else
InP(i).ForeColor = &HFF&
End If
End If
Next i
For i = 0 To 15
If OutP(i) = 0 Then
If (i Mod 8) = 0 Then
OutP(i).ForeColor = &H8000&
Else
OutP(i).ForeColor = &H800000
End If
Else
If (i Mod 8) = 0 Then
OutP(i).ForeColor = &HFF00&
Else
OutP(i).ForeColor = &HFF0000
End If
End If
Next i
End Sub


Public Sub cali_output_data()
output_data = 0
For i = 0 To 15
output_data = output_data + OutP(i) * (2 ^ i)
Next i


End Sub

Public Sub chk_card()
If (Chk_run.Value = 0) Then

MsgBox "Please click RUN botton", 48, "ERROR"

End If

End Sub

Private Sub Timer3_Timer()
timeLabel = Time '顯示時間
End Sub

Public Sub write_output()
cali_output_data
JSWriteWord cardaddr, output_data &&寫此地址的值
End Sub
 
那个地址用$280应该没错
JSReadChar和JSWriteWord的声明在哪?
 
JSReadChar和JSWriteWord,原卡中的提供的dll文件.
那我在delphi中就如何寫?
 
vb中的声明在哪?
你没贴出来叫我怎么看啊?
最好把你改写的DELPHI声明也一并贴出来
 
Attribute VB_Name = "DLPortIO"

Public Declare Function JSDIOInit Lib "jsioport.dll" () As Byte
Public Declare Sub JSDIOClose Lib "jsioport.dll" ()

Public Declare Function JSReadChar Lib "jsioport.dll" (ByVal Port As Integer) As Byte
Public Declare Function JSReadWord Lib "jsioport.dll" (ByVal Port As Integer) As Integer
Public Declare Function JSReadLong Lib "jsioport.dll" (ByVal Port As Integer) As Long
Public Declare Function JSReadIntelligentWord Lib "jsioport.dll" (ByVal Port As Integer, ByVal Index As Integer) As Integer
Public Declare Function JSReadIntelligentLong Lib "jsioport.dll" (ByVal Port As Integer, ByVal Index As Integer) As Long

Public Declare Sub JSWriteChar Lib "jsioport.dll" (ByVal Port As Integer, ByVal Data As Byte)
Public Declare Sub JSWriteWord Lib "jsioport.dll" (ByVal Port As Integer, ByVal Data As Long)
Public Declare Sub JSWriteLong Lib "jsioport.dll" (ByVal Port As Integer, ByVal Data As Long)
Public Declare Sub JSWriteIntelligentWord Lib "jsioport.dll" (ByVal Port As Integer, ByVal Index As Integer, ByVal Data As Integer)
Public Declare Sub JSWriteIntelligentLong Lib "jsioport.dll" (ByVal Port As Integer, ByVal Index As Integer, ByVal Data As Long)

Public Declare Function GetBitFrByte Lib "jsioport.dll" (ByVal Data As Byte, ByVal Bit As Byte) As Byte
Public Declare Function GetBitFrWord Lib "jsioport.dll" (ByVal Data As Integer, ByVal Bit As Byte) As Byte
Public Declare Function SetBitToByte Lib "jsioport.dll" (ByVal Data As Byte, ByVal Bit As Byte, ByVal OnOff As Byte) As Byte
Public Declare Function SetBitToWord Lib "jsioport.dll" (ByVal Data As Integer, ByVal Bit As Byte, ByVal OnOff As Byte) As Integer
 
function JSReadChar(Port: Integer): Byte; stdcall; external 'jsioport.dll';
procedure JSWriteWord(Port: Integer; Data: Longint); stdcall; external 'jsioport.dll';
 
To:weiwei81123
我是這樣寫的,只是沒有port沒有辦法給值,vb中的&h280相當於delphi中的多少呢?
 
不介意的话你可以按Ascii码保存起来,或显示出来
然后在DELPHI中用
chr(Ascii)
 
To:xebaobei
不懂為什麼要用Ascii碼.
 
&h280
十六進制的 0x280
 
To:Aiirii
十六進制的 0x280,定義成什麼類型的變量
 
在delphi是 &280;
你定義成一個整型就可
var I: integer;
begin
i := &280;
 
To:Aiirii
在delphi是 &280;
你定義成一個整型就可
var I: integer;
begin
i := &280;
**********
這樣做是不行的,程式都無法編譯.
其實我只想把那段VB代碼改在delphi中實現而矣.現在的問題是:
1.如何讀取&280的值.
2.如何定議變量
我用的是一塊I/O卡
1.初始化
2.寫一個開關控制位------參數一地址280,參數二是一整數(就是無法表達地址位)
3.讀一個開關控制位-----參數是一地址280,返回值是一byte(也是無法表達地址位)
4.關閉

 
i:=JSReadChar($280);
JSWriteWord($280, i);
 
To:weiwei81123
i:=JSReadChar($280);此處一執行,就報錯誤.
 
后退
顶部