各位高手,本人是菜鸟,求助: CH365如果不采用本地硬件定址功能,则原ISA板卡的应用程序应该作少量修改,包括: 1。获取计算机自动分配给CH365的I/O端口基址; 在VB中该使用Declare Function CH365GetIoBaseAddr Lib "CH365DLL.DLL" (ByRef oIoBaseAddr As mCH365_IO_REG) As Boolean ' CH365GetIoBaseAddr 获取I/O端口的基址 ' oIoBaseAddr 保存I/O端口基址的单元地址 吗,如何使用啊, 帮帮忙阿,不胜感激!
把声明加在你的VB中,然后在程序中调用CH365GetIoBaseAddr函数,它的返回值表示是否成功获取基地址,而oIoBaseAddr就是返回的基地址啊. 具体的调用可以是这样.你先定义一个变量比如"BaseAddr",然后,if CH365GetIoBaseAddr(BaseAddr)=true then: BaseAddr就是你取得的基地址啦.
可以将下面的两个函数对基址的声明 Declare Function CH365GetIoBaseAddr Lib "CH365DLL.DLL" (ByRef oIoBaseAddr As mCH365_IO_REG) As Boolean ' CH365GetIoBaseAddr 获取I/O端口的基址 ' oIoBaseAddr 保存I/O端口基址的单元地址 Declare Function CH365SetIoBaseAddr Lib "CH365DLL.DLL" (ByVal iIoBaseAddr As mCH365_IO_REG) As Boolean ' CH365SetIoBaseAddr 设定I/O端口的基址 ' iIoBaseAddr 指定I/O端口基址 改为 Declare Function CH365SetIoBaseAddr Lib "CH365DLL.DLL" (ByVal iIoBaseAddr As Any) As Boolean ' CH365SetIoBaseAddr 设定I/O端口的基址 ' iIoBaseAddr 指定I/O端口基址
这样地址值就保存至iIoBaseAddr 变量内了.你可以这样试试
谢谢,好人那........
楼上的大哥,弱弱的问问 我申明 Declare Function CH365SetIoBaseAddr Lib "CH365DLL.DLL" (ByVal iIoBaseAddr As Any) As Boolean 然后定义 DIM IOBASEADDR AS LONG 读出的地址是 C800,那么我对其偏移地址7写55H操作时,是不是可以用 CH365SetIoBaseAddr IOBASEADDR CH365ReadIoByte(IOBASEADDR+7, &H55) 或者CH365ReadIoByte(&HC807, &H55)
严重感谢啊!
错了是 CH365WriteIoByte(IOBASEADDR+7, &H55) 或者CH365WriteIoByte(&HC807, &H55)
CH365WriteIoByte ( // 向I/O端口写入一个字节 PVOID iAddr, // 指定I/O端口的地址 UCHAR iByte ) // 待写入的字节数据
是用 CH365WriteIoByte(0xC807, 0x55) ;
谢谢AERY,再问问 我原来的ISA卡是用74688,用定址的方式操作硬件和软件都没问题 ,我现在把它改为自动分配地址,接法是A9-A3悬空了(原来接74688上,就是把74688取下不用),把74688的输出端接地,用A0-A2 ,IOW译码,在DEBUG365中读出的地址是 C800, 为什么我对IO其偏移地址7写55H操作时,读出的值也是55H,但是我的硬件没有动作, 请问在VB中该用什么函数操作啊,是用CH365WriteIoByte 和 CH365ReadIoByte吗?如果不是 该用什么函数呢? 在VB中使用的函数如下: Declare Function CH365GetIoBaseAddr Lib "CH365DLL.DLL" (ByRef oIoBaseAddr As ANY) As Boolean '申明函数 Dim Ioadd As ANY LoadLibrary "CH365DLL.DLL" ' 加载动态库 mOpen = CH365mOpenDevice(0, True, True) '打开CH365 CH365GetIoBaseAddr Ioadd '取IO基址 CH365WriteIoByte Ioadd+7,&h55 'IO偏移地址7写55 If (CH365ReadIoByte(Ioadd+7, ChByte)) Then '读取IO偏移地址7的数据 txtByte.Text = Hex(ChByte) '显示 Else MsgBox "Read failed£¡" End If
解决了,谢谢!