G
goujie
Unregistered / Unconfirmed
GUEST, unregistred user!
vb程序如下:(这是一段使用pci卡的接口程序声明,
我把结构类型声明成记录类型[Record]但总是不成功,请高手指点)谢谢
Public Declare Function CAN_Open Lib "Pcicandrv" () As Integer
Public Declare Function CAN_Init Lib "Pcicandrv" (prtStruct As PORT_STRUCT, prtConfig As PORT_CONFIG) As Integer
Public Declare Function CAN_Detect_Baudrate Lib "Pcicandrv" (prtStruct As PORT_STRUCT) As Integer
Public Declare Function CAN_Inquiry_Trans Lib "Pcicandrv" (prtStruct As PORT_STRUCT) As Integer
Public Declare Function CAN_Trans Lib "Pcicandrv" (prtStruct As PORT_STRUCT, prtPacket As CAN_PACKET) As Integer
Public Declare Function CAN_Clear_TxBuffer Lib "Pcicandrv" (prtStruct As PORT_STRUCT, prtPacket As CAN_PACKET) As Integer
Public Declare Function CAN_Inquiry_Rece Lib "Pcicandrv" (prtStruct As PORT_STRUCT) As Integer
Public Declare Function CAN_Rece Lib "Pcicandrv" (prtStruct As PORT_STRUCT, prtPacket As CAN_PACKET) As Integer
Public Declare Function CAN_Clear_RxBuffer Lib "Pcicandrv" (ptrStruct As PORT_STRUCT) As Integer
Public Declare Function CAN_Get_RxBufferCount Lib "Pcicandrv" (ptrStruct As PORT_STRUCT) As Integer
Public Declare Function CAN_Read_RxBuffer Lib "Pcicandrv" (ptrStruct As PORT_STRUCT, ptrPacket1000 As CAN_PACKET1000) As Integer
Public Declare Function CAN_Enable_Receive Lib "Pcicandrv" (prtStruct As PORT_STRUCT) As Integer
Public Declare Function CAN_Disable_Receive Lib "Pcicandrv" (prtStruct As PORT_STRUCT) As Integer
Public Declare Function CAN_Inquiry_Status Lib "Pcicandrv" (prtStruct As PORT_STRUCT) As Integer
Public Declare Function CAN_Get_ErrorWarningLimit Lib "Pcicandrv" (prtStruct As PORT_STRUCT) As Integer
Public Declare Function CAN_Get_RxErrorCount Lib "Pcicandrv" (prtStruct As PORT_STRUCT) As Integer
Public Declare Function CAN_Get_TxErrorCount Lib "Pcicandrv" (prtStruct As PORT_STRUCT) As Integer
Public Declare Function CAN_Read_Register Lib "Pcicandrv" (ptrPortReg As PORT_REG) As Integer
Public Declare Function CAN_Write_Register Lib "Pcicandrv" (ptrPortReg As PORT_REG) As Integer
Public Declare Function CAN_Reset Lib "Pcicandrv" (prtStruct As PORT_STRUCT) As Integer
Public Declare Function CAN_Hardware_Reset Lib "Pcicandrv" (prtStruct As PORT_STRUCT) As Integer
Public Declare Function CAN_Hard_Reset Lib "Pcicandrv" (prtStruct As PORT_STRUCT) As Integer
Public Declare Sub CAN_Close Lib "Pcicandrv" ()
Type PORT_CONFIG
workMode As Integer '0 for 11-bit(CAN2.0A)
' 1 for 29-bit(CAN2.0B)
filterMode As Integer ' 0 for single filter mode,
' 1 for dual filter mode;
accCode As Long ' accept code
accMask As Long ' accept mask
timer0 As Byte ' timer0 register (set baudrate)
timer1 As Byte 'timer1 register
control As Byte ' enable interrupt
End Type
Type PORT_STRUCT
card As Byte ' index of card(start from 0)
value As Byte ' reserved
End Type
Type PORT_REG
card As Byte ' index of card(start from 0)
reg As Byte ' one of register in SJA1000
value As Byte
End Type
Type CAN_PACKET
CAN_ID As Long ' CAN ID field (32-bit unsigned integer)
rtr As Byte ' CAN RTR bit.
length As Byte
data(8) As Byte ' Data (8 bytes maximum)
time As Long ' Reserved for future use
reserved As Byte ' Reserved byte
End Type
Type CAN_PACKET1000
num As Integer
packet(1000) As CAN_PACKET
End Type
我把结构类型声明成记录类型[Record]但总是不成功,请高手指点)谢谢
Public Declare Function CAN_Open Lib "Pcicandrv" () As Integer
Public Declare Function CAN_Init Lib "Pcicandrv" (prtStruct As PORT_STRUCT, prtConfig As PORT_CONFIG) As Integer
Public Declare Function CAN_Detect_Baudrate Lib "Pcicandrv" (prtStruct As PORT_STRUCT) As Integer
Public Declare Function CAN_Inquiry_Trans Lib "Pcicandrv" (prtStruct As PORT_STRUCT) As Integer
Public Declare Function CAN_Trans Lib "Pcicandrv" (prtStruct As PORT_STRUCT, prtPacket As CAN_PACKET) As Integer
Public Declare Function CAN_Clear_TxBuffer Lib "Pcicandrv" (prtStruct As PORT_STRUCT, prtPacket As CAN_PACKET) As Integer
Public Declare Function CAN_Inquiry_Rece Lib "Pcicandrv" (prtStruct As PORT_STRUCT) As Integer
Public Declare Function CAN_Rece Lib "Pcicandrv" (prtStruct As PORT_STRUCT, prtPacket As CAN_PACKET) As Integer
Public Declare Function CAN_Clear_RxBuffer Lib "Pcicandrv" (ptrStruct As PORT_STRUCT) As Integer
Public Declare Function CAN_Get_RxBufferCount Lib "Pcicandrv" (ptrStruct As PORT_STRUCT) As Integer
Public Declare Function CAN_Read_RxBuffer Lib "Pcicandrv" (ptrStruct As PORT_STRUCT, ptrPacket1000 As CAN_PACKET1000) As Integer
Public Declare Function CAN_Enable_Receive Lib "Pcicandrv" (prtStruct As PORT_STRUCT) As Integer
Public Declare Function CAN_Disable_Receive Lib "Pcicandrv" (prtStruct As PORT_STRUCT) As Integer
Public Declare Function CAN_Inquiry_Status Lib "Pcicandrv" (prtStruct As PORT_STRUCT) As Integer
Public Declare Function CAN_Get_ErrorWarningLimit Lib "Pcicandrv" (prtStruct As PORT_STRUCT) As Integer
Public Declare Function CAN_Get_RxErrorCount Lib "Pcicandrv" (prtStruct As PORT_STRUCT) As Integer
Public Declare Function CAN_Get_TxErrorCount Lib "Pcicandrv" (prtStruct As PORT_STRUCT) As Integer
Public Declare Function CAN_Read_Register Lib "Pcicandrv" (ptrPortReg As PORT_REG) As Integer
Public Declare Function CAN_Write_Register Lib "Pcicandrv" (ptrPortReg As PORT_REG) As Integer
Public Declare Function CAN_Reset Lib "Pcicandrv" (prtStruct As PORT_STRUCT) As Integer
Public Declare Function CAN_Hardware_Reset Lib "Pcicandrv" (prtStruct As PORT_STRUCT) As Integer
Public Declare Function CAN_Hard_Reset Lib "Pcicandrv" (prtStruct As PORT_STRUCT) As Integer
Public Declare Sub CAN_Close Lib "Pcicandrv" ()
Type PORT_CONFIG
workMode As Integer '0 for 11-bit(CAN2.0A)
' 1 for 29-bit(CAN2.0B)
filterMode As Integer ' 0 for single filter mode,
' 1 for dual filter mode;
accCode As Long ' accept code
accMask As Long ' accept mask
timer0 As Byte ' timer0 register (set baudrate)
timer1 As Byte 'timer1 register
control As Byte ' enable interrupt
End Type
Type PORT_STRUCT
card As Byte ' index of card(start from 0)
value As Byte ' reserved
End Type
Type PORT_REG
card As Byte ' index of card(start from 0)
reg As Byte ' one of register in SJA1000
value As Byte
End Type
Type CAN_PACKET
CAN_ID As Long ' CAN ID field (32-bit unsigned integer)
rtr As Byte ' CAN RTR bit.
length As Byte
data(8) As Byte ' Data (8 bytes maximum)
time As Long ' Reserved for future use
reserved As Byte ' Reserved byte
End Type
Type CAN_PACKET1000
num As Integer
packet(1000) As CAN_PACKET
End Type