楼主最近还看过
我看GALIL 关于VB的例子中是这么用的
RC = DMCArrayDownload(hDmc, "AA", 0, 99, Data, Len(Data), BytesWritten)
于是我类比了一下,我指的G()就是这里的Data,也就是数组的内容,不过他这里是字符串
下传数组的时候 需要以字符串的类型发送吗?
抱歉,,昨天没有上网。
既然您已经看到了VB的例子,您自然就可以看到,Data是个字符串。字符串的内容就是数组内各元素的值
Private Sub Command5_Click()
Dim Data As String
Dim BytesWritten As Long
Response = Space(256)
ResponseLength = 256
RC = DMCCommand(hDmc, "DA AA【】;DM AA【100】", Response, ResponseLength)
Data = "0" + Chr$(13) + "1" + Chr$(13) + "2" + Chr$(13) + "3" + Chr$(13) + "4" + Chr$(13) + "5" + Chr$(13) + "6" + Chr$(13) + "7" + Chr$(13) + "8" + Chr$(13) + "9" + Chr$(13)
Data = Data & "0" + Chr$(13) + "1" + Chr$(13) + "2" + Chr$(13) + "3" + Chr$(13) + "4" + Chr$(13) + "5" + Chr$(13) + "6" + Chr$(13) + "7" + Chr$(13) + "8" + Chr$(13) + "9" + Chr$(13)
Data = Data & "0" + Chr$(13) + "1" + Chr$(13) + "2" + Chr$(13) + "3" + Chr$(13) + "4" + Chr$(13) + "5" + Chr$(13) + "6" + Chr$(13) + "7" + Chr$(13) + "8" + Chr$(13) + "9" + Chr$(13)
Data = Data & "0" + Chr$(13) + "1" + Chr$(13) + "2" + Chr$(13) + "3" + Chr$(13) + "4" + Chr$(13) + "5" + Chr$(13) + "6" + Chr$(13) + "7" + Chr$(13) + "8" + Chr$(13) + "9" + Chr$(13)
Data = Data & "0" + Chr$(13) + "1" + Chr$(13) + "2" + Chr$(13) + "3" + Chr$(13) + "4" + Chr$(13) + "5" + Chr$(13) + "6" + Chr$(13) + "7" + Chr$(13) + "8" + Chr$(13) + "9" + Chr$(13)
Data = Data & "0" + Chr$(13) + "1" + Chr$(13) + "2" + Chr$(13) + "3" + Chr$(13) + "4" + Chr$(13) + "5" + Chr$(13) + "6" + Chr$(13) + "7" + Chr$(13) + "8" + Chr$(13) + "9" + Chr$(13)
Data = Data & "0" + Chr$(13) + "1" + Chr$(13) + "2" + Chr$(13) + "3" + Chr$(13) + "4" + Chr$(13) + "5" + Chr$(13) + "6" + Chr$(13) + "7" + Chr$(13) + "8" + Chr$(13) + "9" + Chr$(13)
Data = Data & "0" + Chr$(13) + "1" + Chr$(13) + "2" + Chr$(13) + "3" + Chr$(13) + "4" + Chr$(13) + "5" + Chr$(13) + "6" + Chr$(13) + "7" + Chr$(13) + "8" + Chr$(13) + "9" + Chr$(13)
Data = Data & "0" + Chr$(13) + "1" + Chr$(13) + "2" + Chr$(13) + "3" + Chr$(13) + "4" + Chr$(13) + "5" + Chr$(13) + "6" + Chr$(13) + "7" + Chr$(13) + "8" + Chr$(13) + "9" + Chr$(13)
Data = Data & "0" + Chr$(13) + "1" + Chr$(13) + "2" + Chr$(13) + "3" + Chr$(13) + "4" + Chr$(13) + "5" + Chr$(13) + "6" + Chr$(13) + "7" + Chr$(13) + "8" + Chr$(13) + "9"
RC = DMCArrayDownload(hDmc, "AA", 0, 99, Data, Len(Data), BytesWritten)
If RC = 0 Then
MsgBox "Array downloaded successfully"
End If
End Sub
另外,VB中声明这个函数的时候,也有变量说明的,您仔细看一下。而且前面还有个说明“Array data can be delimited by a comma or CR (0x0D) or CR/LF (0x0D0A).”
也就是说,BUFFER中就是用回车分割的数值。
“Buffer to write the array data from. Data does not need to be NULL terminated.”
PublicdeclareFunction DMCArrayDownload Lib "dmc32.dll" (ByVal hDmc As Long, ByVal ArrayName As String, ByVal FirstElement As Integer, ByVal LastElement As Integer, ByVal Data As String, ByVal DataLength As Long, BytesWritten As Long) As Long
‘ Download an array to the Galil controller. The array must exist. Array data can be
‘ delimited by a comma or CR (0x0D) or CR/LF (0x0D0A).
‘ NOTE: The firmware on the controller must be recent enough to support the QD command.
‘ hDmc Handle to the Galil controller.
‘ ArrayName Array name to download to the Galil controller.
‘ FirstElement First array element.
‘ LastElement Last array element.
‘ Data Buffer to write the array data from. Data does not need to be
‘ NULL terminated.
‘ DataLength Length of the array data in the buffer.
‘ BytesWritten Number of bytes written.
谢谢刘工,这个问题解决了。不过我又有新的问题,不好意思,麻烦您了
我现在数组太大了,所以需要分行发送到卡中,所以等第一行数据运动完成后,再发送下一行数据到卡中
这里我没找到如何让上位机知道下位机运动完了?有没有这样一个函数,让卡发送信息到上位机的呢
试过上位机查询的方式,不太行