18 px] [size=turn with a USB serial port line test no problem, but received up to collect a few sensor data is not received, the sensor for marposs will always hair G25 measured data, then jumped into the following two events comEvDSR 4 data - set ready line change,
ComEvCD 5 carrier detect linear change, explain
Option Explicit
Private Sub Command1_Click ()
'... To send data
MSComm1. OutBufferCount=0 '... Empty the output register
MSComm1. The Output=Text1. Text '... To send data
'MSComm1. The Output="H"
End Sub
Private Sub Command2_Click ()
'... Out
With MSComm1
If the PortOpen=True Then
. PortOpen=False
End the If
End With
Unload Me
End Sub
Private Sub Form_Load ()
'... Initialize the
MSComm1.Com mPort=2 '... Use Com1 port
MSComm1. Settings="9600, n, 8, 1" '... Set the communication parameters
'MSComm1. An InputMode=comInputModeText text retrieve data
MSComm1. InputLen=0 'sets or returns a read number of bytes, from the receive buffer 0 indicates a read all data
'MSComm1. InBufferCount=0
'MSComm1. OutBufferCount=0'... Empty the output register
MSComm1. OutBufferSize=512
MSComm1. InBufferSize=5120
MSComm1. RThreshold=1
MSComm1. SThreshold=1
MSComm1. PortOpen=True '... Open the serial port
End Sub
Private Sub Mscomm1_Oncomm ()
'... Communication event
'Dim s As String
Select Case mEvent MSComm1.Com
'the EVENT CASES in
Case comEvReceive
'Case s=MSComm1. Input
Text2. Text=Text2. Text + MSComm1. Input + "" '... Accept display data
'MSComm1. InBufferCount=0'... Empty the input register
'Case Else
Case comEvCD
MsgBox "5 carrier detect linear change," vbCritical, "communication events:
"Case comEvCTS
MsgBox "3 clear - to - change the send line", vbCritical, "communication events:
"Case comEvDSR
MsgBox "4 data - set ready line change," vbCritical, "communication events:
"Case comEvRing
MsgBox "6 ringing detection," vbCritical, "communication events:
"Case comEvSend
MSComm1. OutBufferCount=0
'MsgBox "1 send events", vbCritical, "communication events:
"Case comEvEOF
MsgBox "7 end of file", vbCritical, "communication events,"
'the Error cases in
Case comEventBreak
MsgBox "1001 receives the interrupt signal," vbCritical, "communication error:
"Case comEventCTSTO
MsgBox "1002 Clear - to - send timeout", vbCritical, "communication error:
"Case comEventDSRTO
MsgBox "1003 Data - set ready" overtime, vbCritical, "communication error:
"Case comEventFrame
VbCritical MsgBox "1004 frame error", "communication error:
"Case comEventOverrun
MsgBox "port 1006 speeding," vbCritical, "communication error:
"Case comEventCDTO
MsgBox "1007 Carrier detect timeout," vbCritical, "communication error:
"Case comEventRxOver
MsgBox "1008 receive buffer overflow" vbCritical, "communication error:
"Case comEventRxParity
VbCritical MsgBox "1009 Parity error", "communication error:
"Case comEventTxFull
MsgBox "1010 transmission buffer is full," vbCritical, "communication error:
"Case comEventDCB
MsgBox "1011 retrieval port equipment control block (DCB) when accidental error", vbCritical, "communication error:
"End the Select
End Sub
CodePudding user response:
CodePudding user response:
Just learning VB to write a serial port good sad, thank you for your guidanceCodePudding user response:
Is this sensor communication requirements, saying how close the flow control?
CodePudding user response:
Come and learn, LZ refuelingCodePudding user response:
Don't pop-up dialog debugging,CodePudding user response:
Don't pop up, although program can run, but only receive a few data behind, there is no responseCodePudding user response:
Don't pop up, although program can run, but only receive a few data behind, there is no responseCodePudding user response:
In exchange for better U turn seton try, based on the FT232 chips, for example,Or in a machine with a serial port debug through, with a U turn string test,
CodePudding user response:
As no clear input buffer, know not have any effectAccording to my experience
Receive events in general form is
Dim sdata As String
MSComm1. InputLen=0
If MSComm1.Com mEvent=comEvReceive Then
MSComm1. InputLen=0
Sdata=https://bbs.csdn.net/topics/MSComm1.Input
MSComm1. InBufferCount=0
End the If
You can set the trigger MSComm1_OnComm conditions -- -- -- -- -- - mscomm1. RThreshold=do you want the length of the
CodePudding user response:
Both the cache is set to the same, why don't you seeMSComm1. OutBufferSize=512
MSComm1 InBufferSize=5120
CodePudding user response:
In VB serial control is not good with no tone down the value of multiple serial port debugging before a few not receive data, to give up in the earlierGo to the next pcommlite_1. 6 very reliable to use
CodePudding user response:
The so-called bad, is often not used, wrong,CodePudding user response: