¿ªÔÆÌåÓý

ctrl + shift + ? for shortcuts
© 2025 Groups.io

Re: Error msg. Buffer Input overflow in S+ for Panasonic PT-AE4000U


 

Regardless I'm not sure that a ClearBuffer is needed save for A) at the very beginning of the parsing operation (bootup?), or B) if there's questionable data in the buffer.



Assuming you're dealing with fixed-delimited or fixed-length incoming data, you typically don't need to bother with a programmatic semaphore. The Gather will handle that for you at the OS level.



Given the code:



Buffer_Input In[xxx];



Function Main()

{

String Frame[x];

ClearBuffer(In);//not sure it's needed, but I typically put one here

While(1)
{

Frame=Gather(delimiter,In);

//parse 'Frame' here
}
}



Or alternately:



Buffer_Input In[xxx];



Change In

{

String Frame[x];

Frame=Gather(delimiter,In);

//parse 'Frame' here
}



This will:

-Maintain the buffer (assuming it's big enough to hold 1 complete frame + whatever may arrive during the time it takes for the parse to complete and next instance of Gather to run)

-Eliminate re-entry (In example 1, more a function of the While)

-If used inside a Change, semaphore the thread automatically



Example #1 is my go to S+ parsing method and I can't remember the last time I saw a buffer overflow.



Note example #2 lacks the ability to restart if additional frame(s) arrive during the parse operation.



From: Crestron@... [mailto:Crestron@...] On Behalf Of Tray Schaeffer
Sent: Friday, August 10, 2012 5:44 PM
To: Crestron@...
Subject: Re: [Crestron] Re: Error msg. Buffer Input overflow in S+ for Panasonic PT-AE4000U





@JP:

If your data updates come in slow enough, then parsing direct from the buffer makes sense and takes less code to implement.
But if new data comes in while the parser is active, you can get erratic results. I¡¯ve learned the hard way that making copies from the Serial input (buffered or not) makes life easier.

For faster data streams, I grab a complete frame and analyze it. During that time, I ignore other incoming data until the parser is done and not busy anymore.
Then, I release the semaphore and grab/parse the next available set of data.

Just my 2 cents,

Tray

From: josephporter2020
Sent: Friday, August 10, 2012 12:43 PM
To: Crestron@... <mailto:Crestron%40yahoogroups.com>
Subject: [Crestron] Re: Error msg. Buffer Input overflow in S+ for Panasonic PT-AE4000U

Unless your parsing code has delays in it that would allow the buffer to fill up, I find that using destructive functions on the buffer does not ever require the use of a clearbuffer.
Remove() and Gather() are destructive and using them to pick off the buffer has never given me trouble to where I thought I needed to use clearbuffer. They only time I've ever used clearbuffer in the past was when I didn't get destructive functions or it was really late at night and I didn't have time to figure out where bugs were so I used it as a band aide.

JP

--- In mailto:Crestron%40yahoogroups.com, Tray Schaeffer <trayschaeffer@...> wrote:

With respect, I have to disagree.

1. Sizing the input buffer to match the expected string length is half of the solution for this problem and good coding practice. This is not just a hack or workaround, it is essential.
If the expected string is 300 bytes long, but the input buffer is only 255 wide, an error will be returned.
However, if the buffer is sized to 350 and the same 300 characters comes in, no error is returned. Both statements above assume that the Buffer_Input is empty when the data is received which brings me to #2.

2. Since a Buffer_Input constantly appends new data to any that was received before, it is easy to see how data that is already processed but not removed could cause the buffer to be full (or full enough that an incoming data frame wont fit completely in the remaining space) when new data arrives.
Wiping the slate clean after each complete frame of data is received is not merely a workaround, it is good practice that will improve reliability.
This is why I do not parse against the Buffer_Input directly. Instead, I make a copy of a complete data frame into a temp variable and immediately clear the Buffer_Input.
Again, clearing the input buffer is not just some sort of hack or work around, it?€?s the right thing to do.

3. If, for some reason, there is an aversion to clearing buffers then use a String_Input instead. Disadvantage here is that this cannot be larger than 255 chars.
Upside is that you never have to remember to clear the input as it will clear itself each time data is received.


All of that aside, you all are right that I2P modules should not suffer from these issues.


Tray


From: Stig
Sent: Friday, August 10, 2012 6:14 AM
To: mailto:Crestron%40yahoogroups.com
Subject: [Crestron] Re: Error msg. Buffer Input overflow in S+ for Panasonic PT-AE4000U


Maybe I'm overlooking something here, but I really can't see how increasing the buffer can make the overflow msg. disappear.
A Clearbuffer can accomplish it, if it is placed right, but this is suggested only as a workaround on the real issue.

If you take a look at the code in the simpl+ module, it will Remove characters from the buffer ONLY if: Lamp_Requested is 1 AND ETX("&#92;x03") is found. ie. The buffer will still be filled up with replies from other polls!
This is excactly the same issue I experienced today with the I2P "BenQ SP920 v1.0.umc with BenQ SP920 v1.0 Processor.usp"
This module will also start Removing chr's from buffer ONLY if delimter+Lampresponse is present,
otherwise buffer get filled up to maxbufsize then gulping out overflow messages...

Had to rewrite both pollroutine + simpl+, and this really annoyes me.... (especially on a Friday afternoon. Grrr)

Back to the OP's question "What should I do?" the answer is: Rewrite both the pollroutine & the lamp hours module.

IMHO We should expect I2P modules to be better written than this.

-Stig

--- In mailto:Crestron%40yahoogroups.com, Rafael Costa <rafaelg.costa@> wrote:

Hello,
I??m controlling a Panasonic projector PT-AE4000U with CresDB module
for PT-AE1000U (Panansonic Lamp Hours v1.0) and it??s working fine.
Even so, I am receiving this error message -> "Error:
splusmanagerapp.exe [App 1] # 21:01:28 8-08-2012 # Module
S-5.1.1:S-2.4 : Panansonic_Lamp_Hours_v1_1 at line 136: Buffer Input
overflow. New = 260, Max = 255"
What should I do, change the "BUFFER_INPUT From_Device$[255];"
parameter to [260], is it possible?

Here is the S+ part:
LINE 44 DIGITAL_INPUT Lamp_Requested;
LINE 47 BUFFER_INPUT From_Device$[255];

LINE 133 change From_Device$
LINE 134 {
LINE 135 // Lamp hours are of the form "&#92;x02####&#92;x03"
LINE 136 if(iBusyFlag = 0 && Lamp_Requested = 1) // if not busy
processing and it is a valid lamp request
LINE 137 {
LINE 138 iBusyFlag = 1; // set busy to avoid re-entry into parser
LINE 139 while(find("&#92;x03", From_Device$) > 0 ) // look for the
ETX during a Lamp Request
LINE 140 {
LINE 141 sTemp$ = remove("&#92;x03", From_Device$); // build the
string
LINE 142 if (find ("ER401", sTemp$) = 0 && Len(sTemp$) = 6)
// Skip errors and unwanted strings
LINE 143 {
LINE 144 Lamp_Hours = ATOI(mid(sTemp$,2,4)); // set
lamp hours
LINE 145 }
LINE 146 }
LINE 147 iBusyFlag = 0; // clear busy
LINE 148 }
LINE 149 }

PMC3+ with firmware 1.005.0008 and all programs and database up to date.

Thank??s in advance,
Rafael Costa




[Non-text portions of this message have been removed]
[Non-text portions of this message have been removed]

Join [email protected] to automatically receive all group messages.