"Out of stack space" with MScomm
"Out of stack space" with MScomm
"Out of stack space" with MScomm
"Out of stack space" with MScomm
"Out of stack space" with MScomm
"Out of stack space" with MScomm "Out of stack space" with MScomm "Out of stack space" with MScomm "Out of stack space" with MScomm "Out of stack space" with MScomm "Out of stack space" with MScomm "Out of stack space" with MScomm "Out of stack space" with MScomm
"Out of stack space" with MScomm "Out of stack space" with MScomm
"Out of stack space" with MScomm
Go Back  Xtreme Visual Basic Talk > > > "Out of stack space" with MScomm


Reply
 
Thread Tools Display Modes
  #1  
Old 08-20-2003, 08:30 AM
Bieli Bieli is offline
Newcomer
 
Join Date: Aug 2003
Posts: 3
Default "Out of stack space" with MScomm


I get data over RS232 it take date every 60 sec. (about 500 bytes).
After getting data over Com I call showdata function which controll incoming string remove <32 chars and some letters (control strings).
After 14h it give "Out of stack space". How can I free stack?
Thanks for advice

Last edited by Bieli; 08-20-2003 at 08:46 AM.
Reply With Quote
  #2  
Old 08-20-2003, 05:13 PM
samr samr is offline
Senior Contributor
 
Join Date: Jul 2003
Location: London, England
Posts: 993
Default

This error is caused by subs running and not ending. After a number of subs (I don't know the number) are running you will get this error. You will have to look at the structure of your program and try to let some of the subs exit.

When you get the error look at the stack and see if any of the subs that are running should not be, or that they are running many times (more likely) and try to see if you can get round this.
Reply With Quote
  #3  
Old 08-27-2003, 02:13 AM
Bieli Bieli is offline
Newcomer
 
Join Date: Aug 2003
Posts: 3
Default

Where can I chack how my stack look like?
The main part of program look like this. It seams form me that it should end every time it is called and close file after each Z letter - after every data packed (1/minute).
I would be great full for any suggestions.
Code:
Private Static Sub MSComm1_OnComm() Select Case MSComm1.CommEvent Case comEvReceive Dim Buffer As Variant Buffer = MSComm1.Input Debug.Print "Receive - " & StrConv(Buffer, vbUnicode) ShowData txtTerm, (StrConv(Buffer, vbUnicode)) End Select End Sub Private Static Sub ShowData(Term As Control, Data As String) Dim OpenFlag As Integer Dim TermSize As Long, i Dim koniec As Byte Dim Data2 As String Dim a As Integer Const MAXTERMSIZE = 10000 On Error GoTo Handler TermSize = Len(Term.Text) If TermSize > MAXTERMSIZE Then Term.Text = Mid$(Term.Text, 4097) TermSize = Len(Term.Text) End If Term.SelStart = TermSize ' delete chars 0-12 For a = 0 To 12 Do i = InStr(Data, Chr$(a)) If i Then Data = Left$(Data, i - 1) & Mid$(Data, i + 1) End If Loop While i Next a For a = 14 To 31 ' delete chars 14-31 Do i = InStr(Data, Chr$(a)) If i Then Data = Left$(Data, i - 1) & Mid$(Data, i + 1) End If Loop While i Next a ' make new line i = 1 Do i = InStr(i, Data, Chr$(13)) If i Then Data = Left$(Data, i) & Chr$(10) & Mid$(Data, i + 1) i = i + 1 End If Loop While i ' Finding supervisoring chars i = 1 Do i = InStr(i, Data, Chr$(75)) ' Letter K If i Then Data2 = Left$(Data, i - 1) ' Term.SelText = Data2 ' Remove this char Term.SelStart = Len(Term.Text) ' pole = 1 ' data will be show in txt_kontrolne Data = Mid$(Data, i + 1) i = i + 1 End If Loop While i i = 1 Do i = InStr(i, Data, Chr$(79)) ' Letter O If i Then MSComm1.Output = Chr$(79) ' response this same letter Data = Left$(Data, i - 1) & Mid$(Data, i + 1) ' remove this char i = i + 1 End If Loop While i i = 1 Do i = InStr(i, Data, Chr$(80)) ' letter P If i Then Data2 = Left$(Data, i - 1) ' Term.SelText = Data2 ' remove this char Term.SelStart = Len(Term.Text) ' pole = 0 ' data will be show in txtterm Data = Mid$(Data, i + 1) i = i + 1 End If Loop While i i = 1 Do i = InStr(i, Data, Chr$(90)) ' Letter Z If i Then 'koniec = 1 Data = Mid$(Data, i + 1) i = i + 1 NazwaPliku = "c:\rejestracja\" & Year(Now) & Data NazwaPliku = Left$(NazwaPliku, 26) 'make file name NazwaPliku = NazwaPliku & "_1.rej" lbl_NazwaPliku.Caption = NazwaPliku FileNum = FreeFile Open NazwaPliku For Append As FileNum Print #FileNum, Trim$(txtTerm.Text) Close FileNum Term.Text = "" Data = "" End If Loop While i ' put received data to specified txtterm If pole = 0 Then txtTerm.SelText = Data txtTerm.SelStart = Len(txtTerm.Text) Else ' or txt_kontrolne txt_kontrolne.SelText = Data txt_kontrolne.SelStart = Len(txt_kontrolne.Text) End If Exit Sub Handler: MsgBox Error$ Resume Next End Sub

[/edit] Added the VB tags...[/edit]

Last edited by BillSoo; 08-28-2003 at 05:03 AM.
Reply With Quote
  #4  
Old 08-28-2003, 05:43 AM
BillSoo's Avatar
BillSoo&quot;Out of stack space&quot; with MScomm BillSoo is offline
Code Meister

Retired Moderator
* Guru *
 
Join Date: Aug 2000
Location: Vancouver, BC, Canada
Posts: 10,441
Default

I would suggest simplifying your code. If the function ran faster, it might avoid the problem. For instance:

Code:
Private Static Sub ShowData(Term As Control, Data As String) Dim i as Long Dim Data2 as String Dim c as string Dim pole as Boolean Dim TermSize as Long Dim NazwaPliku as String Dim FileNum as Long TermSize = Len(Term.Text) If TermSize > 10000 Then Term.Text = Mid$(Term.Text, 4097) TermSize = Len(Term.Text) End If Term.SelStart = TermSize For i = 1 to Len(Data) c = mid$(Data,i,1) Select Case asc(c) Case 0 to 12,14 to 31 Case 13: Data2 = Data2 & vbCRLF Case 75, 80 'K,P term.SelText = Data2 term.SelStart = len(term) Data2 = "" Pole = (c = "K") 'will return true if c is K, false otherwise Case 79 'O MsComm1.Output = "O" 'maybe this might case a problem? Case 90 'Z NazwaPliku = Left$("c:\rejestracja\" & Year(Now) & Mid$(Data, i + 1),26) & "_1.rej" lbl_NazwaPliku.Caption = NazwaPliku FileNum = FreeFile Open NazwaPliku For Append As FileNum Print #FileNum, Trim$(txtTerm.Text) Close FileNum Term.Text = "" Term.SelStart = 0 'I wonder if this is required.....? Data2 = "" Exit For case else: Data2 = Data2 & c End Select Next i If Pole Then 'K was found last txt_kontrolne.SelText = Data2 txt_kontrolne.SelStart = len(txt_kontrolne.Text) Else 'P was found last, or neither was found... txtTerm.SelText = Data2 txtTerm.SelStart = len(txtTerm.Text) End If End Sub

The logic is slightly different in my version....
In your version, if you have KPKPK, pole will be 0 since you check for P after you check for K. In my version, pole will be 1 since a K is last found in the string. I don't know if that makes a difference to you or not...
__________________
"I have a plan so cunning you could put a tail on it and call it a weasel!" - Edmund Blackadder

Last edited by BillSoo; 08-28-2003 at 05:53 AM.
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
PCI and MSCOMM awefullyfungi Communications 1 08-05-2003 06:18 PM
MSComm and a CallerID Box Question DTFan Communications 6 07-08-2003 01:08 PM
Possible Use of MsComm pinster Communications 9 06-13-2003 10:47 AM
Serious Mscomm Problem a_deepblue Communications 0 04-21-2003 03:17 AM
MSComm dwfvb Communications 7 08-11-2002 12:52 PM

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
&quot;Out of stack space&quot; with MScomm
&quot;Out of stack space&quot; with MScomm
&quot;Out of stack space&quot; with MScomm &quot;Out of stack space&quot; with MScomm
&quot;Out of stack space&quot; with MScomm
&quot;Out of stack space&quot; with MScomm
&quot;Out of stack space&quot; with MScomm &quot;Out of stack space&quot; with MScomm &quot;Out of stack space&quot; with MScomm &quot;Out of stack space&quot; with MScomm &quot;Out of stack space&quot; with MScomm &quot;Out of stack space&quot; with MScomm &quot;Out of stack space&quot; with MScomm
&quot;Out of stack space&quot; with MScomm
&quot;Out of stack space&quot; with MScomm
 
&quot;Out of stack space&quot; with MScomm
&quot;Out of stack space&quot; with MScomm
 
-->