以文本方式查看主题

-  Foxtable(狐表)  (http://www.foxtable.com/bbs/index.asp)
--  专家坐堂  (http://www.foxtable.com/bbs/list.asp?boardid=2)
----  已知串口指令为a01d102 要怎么发送a01d102这个内容给串口呢?  (http://www.foxtable.com/bbs/dispbbs.asp?boardid=2&id=178319)

--  作者:cnsjroom
--  发布时间:2022/6/29 16:42:00
--  已知串口指令为a01d102 要怎么发送a01d102这个内容给串口呢?
已知串口指令为a01d102 要怎么发送a01d102这个内容给串口呢?
--  作者:有点蓝
--  发布时间:2022/6/29 16:43:00
--  
http://www.foxtable.com/webhelp/topics/1978.htm
--  作者:cnsjroom
--  发布时间:2022/6/29 17:05:00
--  回复:(有点蓝)http://www.foxtable.com/webhelp/to...

怎么获取当前所有的端口  然后赋值给选择框呢?

Dim c1 As WinForm.ComboBox = e.Form.Controls("ComboBox1")
Dim s As String
For Each sp As String In Ports.PortNames
    s = sp
    s = s & "|"
    Output.Show(s)
Next
c1.ComboList = s

当前代码得到的数据输出为空?


--  作者:有点蓝
--  发布时间:2022/6/29 17:08:00
--  
For Each sp As String In Ports.PortNames
    s = s & "|" & sp
Next
    Output.Show(s)
c1.ComboList = s

--  作者:cnsjroom
--  发布时间:2022/6/29 17:22:00
--  回复:(有点蓝)For Each sp As String In Ports.Por...

zhDim s As String
For Each sp As String In Ports.PortNames
    If sp.Contains("COM") = False Then
        s = "空"
    Else
        s = s & "|" & sp
    End If
   
Next
Output.Show(s)

 

怎么判断当前是否存在com系列的串口号呢?不存在就提示未空  上述运行直接是空白

 

发送字节  按钮代码如下:

红色部分要怎么表示呢?

 

Dim t1 As WinForm.TextBox = e.Form.Controls("TextBox1")

Dim c1 As WinForm.ComboBox = e.Form.Controls("ComboBox1")

Dim Val()As Byte = New Byte() {t1.Text}

Ports(c1.Text).Write(Val, 0, Val.Length)

 

帮助中的{49,50,51,52}这个代表什么意思呢?


--  作者:有点蓝
--  发布时间:2022/6/29 17:40:00
--  
Dim Val(t1.Text.length - 1) As Byte 

for i as integer = 0 to t1.Text.length - 1
val(i) = Asc(t1.Text(i))
next

--  作者:qqzwc
--  发布时间:2022/10/13 11:11:00
--  
Dim str As String = "ABCDEFG"
Dim buf() As Byte = Encoding.ASCII.GetBytes(str)
Ports("COM1").Write(buf, 0, buf.Length)