Break through the MSCOMM control Rthreshold limit, all data is all!

xiaoxiao2021-03-06  14

Global Parameters: Private RV_Data () AS BYTE 'Store Received Data Private TMPRV () AS Byte' Stained Data Private Declare Sub Sleep LIB "Kernel32" (Byval dwmilliseconds as ring)

--------------------------------------------

Form_Load () First initialization control parameter with mscomm1.settings = "9600, n, 8, 1" .InputMode = 1 'Settings the type of acceptance data is binary type data .Inputlen = 8' One-time from the receiving buffer All data (8 bytes are set) .INBuffercount = 0 'Clear Receive buffer .outbuffercount = 0' Empty send buffer .Sthreshold = 0 'Trigger an oncomm () event once to detect whether to return data .rtroshold = 1 'Receive 1 byte data, trigger the oncomm () event. Commport = 1' uses the first serial port .portopen = true 'Open the serial port end with

---------------------------------------------- thinking is this : Press 8 to take out the group and then take it out until the buffer data is all taken out of the private sub mscomm1_oncomm () DIM Ub1%, UB2%, TM AS Integer, I as Integerseect Case Mscomm1.com (") Cases Mscomm1.com () COSEPEP ( 20) 'Separate 20ms, you can correctly receive 24 bytes of data do while mscomm1.inbuffercount> 0TM = Tm 1 if Tm = 1 THEN RV_DATA = MSCOMMM1.INPUT ELSETMPRV = MSCOMM1.INPUT UB1 = Ubound (RV_DATA) UB2 = Ubound (TMPRV) 1 'Element is more subscript of 1 redim preserve rv_data (UB1 UB2) for i = UB1 1 To UB1 UB2 RV_DATA (i) = TMPRV (I - Ub1 - 1) Next I endiff LOOPIF Check_rvdata Then Call response_ok () 'This is used to perform the correct handle, Else Call response_bad ()' is used here to handle end ifrage tmprverase RV_DATAEND SELECTEND SUB

----------------------------------------------

转载请注明原文地址:https://www.9cbs.com/read-48055.html

New Post(0)