vb.neti2c通信 vb tcp通信
I2C通信一
一、什么是I2C通信
专注于为中小企业提供网站设计、成都网站设计服务,电脑端+手机端+微信端的三站合一,更高效的管理,为中小企业岱山免费做网站提供优质的服务。我们立足成都,凝聚了一批互联网行业人才,有力地推动了近1000家企业的稳健成长,帮助中小企业通过网站建设实现规模扩充和转变。
二、I2C通信特征:串行、同步、非差分、低速率
注: 串口通信和I2C通信属于低速通信, 用电平信号即可. 网线和USB线属于高速通信, 所以用差分信号.
三、I2C通信的突出特征
注: 主设备会以 广播 的形式发送8位的从设备地址(其实8位中只有7位是从设备地址, 还有一位bit0是读写位)到总线, 总线上的所有从设备都能收到这个地址, 并且收到地址后和自己的地址比较. 如果相等, 则发送ACK应答. 否则不应答.
四、I2C通信的主要用途
Acknowledge: 以上部分资料文字来自@朱有鹏
I2C burst mode
是I2C连续写的mode和速率没有关系,使用该功能可以写寄存器节约时间。
I2C transmission speed
standard mode: 100kbps
fast mode: 400kbps
high-speed mode: 3.4Mbps (但是有些外设不支持这么高的速率,所以不能跑到这么高的速率。具体能支持到多大需要查看具体外设的spec)
VB如何直接与IIC器件通讯
没办法,VB做不了底层。其一VB不支持驱动开发。其二PC不能直接控制硬件IO。只能通过PC跟单片机的通信,告诉单片机控制IIC器件。
用vb.net实现网络通信
用 vb.net socket通信
Dim th As Threading.Thread
2 Dim tcpl As System.Net.Sockets.TcpListener
3
4 Private Sub Form1_Load()Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
5 th = New System.Threading.Thread(New System.Threading.ThreadStart(AddressOf MyListen))
6 th.Start()
7 End Sub
8
9 Public Sub SendMessage()Sub SendMessage(ByVal IP As String, ByVal SendMsg As String)
10 Try
11 If IP "" Then
12 Dim tcpc As New System.Net.Sockets.TcpClient(IP, 5656)
13 Dim tcpStream As Net.Sockets.NetworkStream = tcpc.GetStream
14 Dim reqStream As New IO.StreamWriter(tcpStream)
15 reqStream.Write(SendMsg)
16 reqStream.Flush()
17 tcpStream.Close()
18 tcpc.Close()
19 End If
20 Catch ex As Exception
21 MsgBox(ex.Message.ToString)
22 End Try
23 End Sub
24 Private Sub MyListen()Sub MyListen()
25 Try
26 Dim ipAddress As System.Net.IPAddress = System.Net.Dns.Resolve(System.Net.Dns.GetHostName).AddressList(0)
27 tcpl = New System.Net.Sockets.TcpListener(ipAddress, 5656)
28 tcpl.Start()
29 While True
30 Dim s As System.Net.Sockets.Socket = tcpl.AcceptSocket()
31 Dim MyBuffer(1024) As Byte
32 Dim i As Integer
33 i = s.Receive(MyBuffer)
34 If i 0 Then
35 Dim lstrRec As String
36 Dim j As Integer
37 For j = 0 To i - 1
38 TextBox1.Text += Chr(MyBuffer(j)) ","
39 Next
40 End If
41 End While
42 Catch ex As Exception
43 MsgBox(ex.Message.ToString)
44 End Try
45 End Sub
46
47 Private Sub Button1_Click()Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
48 SendMessage("192.168.0.61", TextBox2.Text)
49 End Sub
当前题目:vb.neti2c通信 vb tcp通信
路径分享:http://ybzwz.com/article/dogdige.html