Home > Software engineering >  Used in Winsock1_DataArrival doevents appeared Out of the stack space error
Used in Winsock1_DataArrival doevents appeared Out of the stack space error

Time:09-17

Have all make uncertain Winsock problem for a long time, a great god, please help: using Winsock control receive credit card data, records per second in about five to eight, and then deposit to SQL SERVER data table, in order to prevent the interface card dead, intermediate use doevents, but after a period of time running in the doevents appear "error number: 28 error description: Out of stack space error source: Rfid error line number: 2061" error, really don't understand doevents also noticed the error? Part of the code:

Private Sub Winsock1_DataArrival (ByVal bytesTotal As Long)
On Error GoTo lblErr:

.

2060 Me. Text5. Text card number=strCardNo '

2061 DoEvents

2062 Me. TxtAll. Text=STRLS

.

LblExit:
The Exit Sub
LblErr:


If Err. Number=28 Then 'Out of stack space may be caused by process cycle call stack overflow
905 Open App. Path & amp; "\ log. TXT" For Append As FreeNum
Error 906 Print # FreeNum, "time:" & amp; Now () & amp; "Wrong number" & amp; Err. Number & amp; Error description: "" & amp; Err, Description & amp; "Error source:" & amp; Err. Source & amp; "Wrong line number:" & amp; Erl
907 the Close FreeNum
910 If cn. State=1 Then cn. Close
911 cn. Open strconn
The Exit Sub
End If

CodePudding user response:

DataArrival is "data to" when triggered,
This time should be take the data in the buffer, and do the related processing,

In the process of this event, don't need DoEvents!!!!

CodePudding user response:

Don't DoEvents, this interface to run for half an hour is no response, I this year is to require in addition to the Spring Festival holiday those days, other time is 24 hours of restless

CodePudding user response:

Use a FIFO buffer...

CodePudding user response:

With the line number of the code, this code is a bit old, or to write the code a bit first

CodePudding user response:

Winsock1_DataArrival before and after the complete code or the doevents 20 lines of code to see,
Estimation is here there is a cycle, basically it is to die, you guess you're after dataarrival cycle for subsequent data, do not add doevents is inside silly, etc., added doevents data would form a nested call stack two will burst in the second half

CodePudding user response:

Fyi:
 Private Sub tcpRTB_DataArrival (ByVal bytesTotal As Long) 
Dim As Long I
Dim p As Long
Dim qn As Long
Dim As Long s
Dim e As Long
Dim Total_Length As Long
Dim iBuf () As Byte
Dim LNX As String
Const STX=2
Const ETX=3
Dim As Long L
Dim XORSUM As Long
Dim BYTESUM As Long
Dim strMsgToProcess As String
Dim bt As Long
On the Error Resume Next
If INtcpRTB_DataArrival Then
INtcpRTB_DataArrival_TotalBytes=bytesTotal
If bytesTotalLogDebug "ReEnter tcpRTB_DataArrival bytesTotal=" + CStr (bytesTotal)
The Exit Sub
The Else
LogErrMsg "ReEnter tcpRTB_DataArrival bytesTotal=" + CStr (bytesTotal) + "& gt;
=128"End the If
End the If
Bt=bytesTotal
INtcpRTB_DataArrival=True
REDATA:
'charge current flow
ReDim iBuf (bt - 1)
TcpRTB. GetData iBuf
'the log every byte received
I=0
LNX="RTB - & gt; BYTE: "+ Right (" 0000000" + Hex (I), 8) + "-"
For I=0 To bt - 1
LNX=LNX + "" + Right (" 0" + Hex (iBuf (I)), 2)
If I Mod 16=15 Then
LogRX LNX
LNX="RTB - & gt; BYTE: "+ Right (" 0000000" + Hex (I + 1), 8) + "-"
End the If
Next
I=bt - 1
If I Mod 16 & lt;> 15 Then
LogRX LNX
End the If

'will be at the end of the received bytes in the receive buffer
For I=0 To bt - 1
IRTB iRTBn + (I)=iBuf (I)
Next
IRTBn=iRTBn + bt
'one by one from the receive buffer solution package
Qn to unpack the remaining bytes=iRTBn '
P=0 'the unpacking of the first byte
Do
'0 1 2 3 4 5 6 7 |...
'STX - DATA - ETX - XORSUM - BYTESUM | STX - DATA - ETX - XORSUM - BYTESUM |...
If qn & gt; 7 Then=
For I=0 To qn - 1
If STX=iRTB (p + I) Then the Exit For
Next
If I & gt;=qn Then
For I=0 To qn - 1
IRTB (I)=iRTB (p + I)
Next
IRTBn=qn
Exit the Do 'can't find the STX
End the If
S=I
For I=s To qn - 1
If ETX=iRTB (p + I) Then the Exit For
Next
If I & gt;=qn Then
For I=0 To qn - 1
IRTB (I)=iRTB (p + I)
Next
IRTBn=qn
Exit the Do 'can't find the ETX
End the If
E=I
If e - p + 4 & gt;=qn Then
For I=0 To qn - 1
IRTB (I)=iRTB (p + I)
Next
IRTBn=qn
To Exit the Do 'ETX after less than 4 bytes
Endif
Total_Length + 5=e - s
L=e - s - 1
XORSUM=STX
BYTESUM=STX
StrMsgToProcess=""
For I=1 To L
XORSUM=XORSUM Xor iRTB (p + s + I)
BYTESUM=BYTESUM + iRTB (p + s + I)
StrMsgToProcess=strMsgToProcess + ChrW (iRTB (p + s + I))
Next
XORSUM=XORSUM Xor ETX
BYTESUM=BYTESUM + ETX
If iRTB (p + e + 1)=Asc (Hex (16) (256) XORSUM Mod \) And iRTB (p + e + 2)=Asc (Hex (XORSUM Mod (16)) And iRTB (p + e + 3)=Asc (Hex (16) (256) BYTESUM Mod \) And iRTB (p + e + 4)=Asc (Hex (BYTESUM Mod 16)) Then
LogRX RTB - & gt; "" + strMsgToProcess
RTBput strMsgToProcess
TimerRTB. Enabled=True
The Else
LogRX RTB - & gt;" CKSUM error!"
End the If
NEXTMSG:
P=p + Total_Length
Qn=qn - Total_Length
If qn & lt;=0 Then
IRTBn=0
The Exit Do
End the If
The Else
If p & gt; 0 Then
If qn & gt; 0 Then
For I=0 To qn - 1
IRTB (I)=iRTB (p + I)
Next
End the If
IRTBn=qn
End the If
The Exit Do
End the If
Loop
If INtcpRTB_DataArrival_TotalBytes & gt; 0 Then
nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull
  • Related