如题
工具截图请看
发送 是以 HEX 格式 发送 16进制
此主题相关图片如下:捕获.png
以下是我写的代码
不知道哪里错了 以前能用 ,现在写不进数据
内部函数 comwrite 如下
Dim stra As String = Args(0)
If stra.Length > 18 Then
stra =stra.SubString(0,18)
ElseIf stra.length < 18 Then
stra = stra.PadRight(18)
End If
Dim strms As String
Dim v() As String
For i As Integer = 0 To stra.Length - 1
strms = strms & DecToHex(Asc(stra.SubString(i,1))) & " "
Next
strms = "02 01 12 A1 " & strms & "03"
Dim Val() As String = strms.Split(" ")
Dim Valb(val.Length - 1) As Byte
For vb As Integer = 0 To Val.Length - 1
valb(vb) = HexToDec(Val(vb))
Output.Show( valb(vb))
Next '在把 这段字符串转为10进制 然后 写入机械
Ports("com1").Write(Valb, 0, Valb.Length)
调用 Functions.Execute("comwrite","1234")
烦请版主指点下