毕业论文开发语言企业开发JAVA技术.NET技术WEB开发Linux/Unix数据库技术Windows平台移动平台嵌入式论文范文英语论文
您现在的位置: 毕业论文 >> 开发语言 >> 正文

VB动态链接库EasyUSB23xx.dll调用问题

更新时间:2013-5-21:  来源:毕业论文

VB动态链接库EasyUSB23xx.dll调用问题

EasyUSB23xx.dll文件中的两个函数定义如下:
int __stdcall ReadData23xx(int pipenum,unsigned char *recbuffer,int len,int waittime=-1);
int __stdcall WriteData23xx(int pipenum,unsigned char *sendbuffer,int len,int waittime=-1);


我用VB6.0时调用函数发出的数据不对,
申明:
Public Declare Function ReadData23xx Lib "EasyUSB23xx.dll" (ByVal pipenum As Long, ByRef bytRecvBuf() As Byte, _
                                                            ByVal len1 As Long, ByVal waittime As Long) As Long
                                                           
Public Declare Function WriteData23xx Lib "EasyUSB23xx.dll" (ByVal pipenum As Long, ByRef bytSendBuf() As Byte, _
                                                            ByVal len1 As Long, ByVal waittime As Long) As Long

使用:
    Dim intRet  As Integer
    Dim i       As Long
    Dim intLen  As Integer
    Dim bytSendBuf(1 To 200)  As Byte
    Dim bytRecvBuf(1 To 200)  As Byte
    Dim intSendNum As Integer
    Dim strDis  As String
   
    intSendNum = 10
    For i = 1 To intSendNum Step 1
        bytSendBuf(i) = ((i - 1) Mod 100)
    Next i
   
    intRet = WriteData23xx(1, bytSendBuf, intSendNum, 1000)
    If intRet <> intSendNum Then
        MsgBox "发送错误!", vbExclamation
        Exit Sub
    End If

发现发出的数据乱七八糟的不对,我怀疑是申明的问题,大侠帮我看看怎么修改啊?

参考下VC下的使用
unsigned char sendbuf[3072]; /* send buffer      */
unsigned char recbuf[3072]; /* receive buffer   */
int i;

srand((unsigned)time(NULL)); /* use the current time as the random bytes */;
for (i = 0; i < sizeof(sendbuf); i++)
{
sendbuf[i] = (rand() & 0xFF);
recbuf[i] = 0; /* clear the receiving buffer */
}

m_DispSend = "";
for (i = 0; i < sizeof(sendbuf); i++)
m_DispSend += IntToASCII(sendbuf[i]) + " ";

UpdateData(FALSE);

/* send 3072 random bytes to LPC23xx */
int ret = WriteData23xx(3,sendbuf,sizeof(sendbuf),1000);
if (ret != sizeof(sendbuf))
{
MessageBox("send data error!");
return;
}

' 试下这样的声明:
'Public Declare Function ReadData23xx Lib "EasyUSB23xx.dll" ( _
'                                 ByVal pipenum As Long, ByRef bytRecvBuf As Any, _
'                                 ByVal len1 As Long, ByVal waittime As Long) As Long
'
'Public Declare Function WriteData23xx Lib "EasyUSB23xx.dll" ( _
'                                 ByVal pipenum As Long, ByRef bytSendBuf As Any, _
'                                 ByVal len1 As Long, ByVal waittime As Long) As Long
 
' 使用:
'Dim bytSendBuf(1 To 200)  As Byte
'Dim bytRecvBuf(1 To 200)  As Byte
intRet = WriteData23xx(1, bytSendBuf(1), intSendNum, 1000)
 
intRet = ReadData23xx(1, bytRecvBuf(1), intSendNum, 1000)

设为首页 | 联系站长 | 友情链接 | 网站地图 |

copyright©youerw.com 优尔论文网 严禁转载
如果本毕业论文网损害了您的利益或者侵犯了您的权利,请及时联系,我们一定会及时改正。