刚接触wincc通过vbs进行串口通讯,目前一直未成功一下是我编写的程序,请各位帮看下错在哪里
1.mscomm控件中oncomm vbs编程
Sub OnComm(ByVal Item)
Dim MScomm
Set MSComm=ScreenItems("COM1_IN")
Set MScomm=HMIRuntime.Tags("COM1_IN")
MScomm.read
Internal tag("COM1_IN")=Input
Internal tag("COM2_IN") = MSComm.Input
ScreenItems("COM1_IN") = MSComm.Input
bufflen = Len(buff)
End If
End Sub
通讯按键中vbs程序
Sub OnKeyDown(Byval Item, Byval nChar, Byval nRepCnt, Byval nFlags)
Dim mscomm
Set mscomm=ScreenItems("mscomm")
mscomm.CommPort =8
mscomm.Settings="38400,N,8,1"
mscomm.InputMode=1
mscomm.portopen=True
End Sub