Home AMX User Forum AMX General Discussion

Output buffer size?

I was recently work on a module that needed to send a string to an IP device. It actually was sending out a web page and the HTML was just under 17k long.

At first I was having a problem with my variable that held the string to send being truncated at the 15999 cut off point so I used the ConcatString function that AMXJeff posted a while ago to build that string in the variable but the problem persisted although the variable was now holding the entire string the HTML was being delivered incomplete.

I can only assume that the buffer that holds the string also has a limit so I ended up having to do this:
if(LENGTH_STRING(cWebHead))
	  {
	  WHILE(LENGTH_STRING(cWebHead) > MAX_MTU)
	       {
	       SEND_STRING dvWeb, "GET_BUFFER_STRING(cWebHead,MAX_MTU)" ; 
	       }
	  if(LENGTH_STRING(cWebHead))
	       {
	       SEND_STRING dvWeb, "cWebHead" ;
	       }
	  /////////////////////////////////////////////////
	  if(LENGTH_STRING(cWebMessage))//no body w/o head
	       {
	       WHILE(LENGTH_STRING(cWebMessage) > MAX_MTU)
		    {
		    SEND_STRING dvWeb, "GET_BUFFER_STRING(cWebMessage,MAX_MTU)" ; 
		    }
	       if(LENGTH_STRING(cWebMessage))
		    {
		    SEND_STRING dvWeb, "cWebMessage" ;
		    }
	       }
	  }
Is anyone aware of a limit of what the output buffer can hold? Does anyone know how the the master sends strings to TCP IP devices? I assume it sends them in max TCP MTU chunks and doesn't try to send the entire string at once. Anybody know? I guess if I set up another master to receive the HTML I could test this but that sounds like too much work.

Comments

  • Joe HebertJoe Hebert Posts: 2,159
    vining wrote: »
    Is anyone aware of a limit of what the output buffer can hold?
    The output buffer size can be whatever it needs to be.
    The limitation is with SEND_COMMAND (approx. 200 characters) and SEND_STRING (approx 2K characters) when dealing with real devices.
    Virtual devices have the 2K limit for both COMMAND and STRING.
  • viningvining Posts: 4,368
    So the master doesn't regulate send strings to match the MTU sizes of a partucular protocol like TCP like I did in the posted code. If you do send a 2k string in TCP which has a 1500 max MTU does the receiving device have to buffer it or just choke on it?

    If send string has a limit of 2K to a real device then why did my code that sent a string which cosisted of a 16.7k variable get cut short somewhere around the 16k point? I don't know for sure since I didn't measure the the source of the incomplete HTML. It was nearly complete though so something is going on.
  • Joe HebertJoe Hebert Posts: 2,159
    vining wrote:
    So the master doesn't regulate send strings to match the MTU sizes of a partucular protocol like TCP like I did in the posted code.
    I never said that. The 2K limitation is the SEND_STRING mechanism itself. What it does after it gets the data is a different thing all together.
  • viningvining Posts: 4,368
    ok but what about the second part of that post where I was sending the the 16.7k variable in a send string and almost the entire HTML was recieved. In this case the send string was able to send almost 8 times the 2k limit.
  • Joe HebertJoe Hebert Posts: 2,159
    vining wrote: »
    ok but what about the second part of that post where I was sending the the 16.7k variable in a send string and almost the entire HTML was recieved. In this case the send string was able to send almost 8 times the 2k limit.
    You sent out 16K worth of data with one SEND_STRING command?
  • viningvining Posts: 4,368
    Joe Hebert wrote:
    You sent out 16K worth of data with one SEND_STRING command?
    Yep, that's what I've been trying to say.

    The smaller HTMLs that were around 13K could be sent out in a single send_string and worked fine but the HTML around 17K would get truncated. As I mentioned I had already fixed the variable that held the string with the ConcatString function so that was no longer the issue and in debug it could be viewed in its entirety, all 17K. So me was thinking there was a buffer limit. I never even thought of a send string limit but in this case it definitely isn't a 2K limit. Maybe it's 15999?
  • Output Buffer Size and Sockets

    There are two things at play here: SEND_STRING to sockets and max string expression size.
    1) SEND_STRING to socket D:P:S values (ex. 0:5:0) are special in that the transmission of the string ties directly from the NetLinx Interpreter to the physical IP socket. So the data is not bound by some of the more restrictive limitations of master firmware for transmission to say NetLinx Touch Panels or serial based devices.
    2) But what is a restriction is the maximum size for a single string expression. (ex. "'This is string number ',ITOA(i)") The maximum string expression allowed is 16000 8-bit CHAR.

    Have you tried simply removing the double quotes from around your array in the call to SEND_STRING? This will send the array variable directly rather than first running it through the string expression processor.
  • viningvining Posts: 4,368
    shane-a-roo wrote:
    SEND_STRING to socket D:P:S values (ex. 0:5:0) are special .............The maximum string expression allowed is 16000 8-bit CHAR.
    Ok, that's what I was thinking.
    Have you tried simply removing the double quotes from around your array in the call to SEND_STRING? This will send the array variable directly rather than first running it through the string expression processor.
    Not really but I suppose I could run the completed variable array through the ConcantString function again or just do a simpler string_to_variable - variable_to_string function since this STV function must run through the string expression processor prior to the conversion. This would essentially remove my double quotes, wouldn't it?
  • Output Buffer Size and Sockets

    Based on your code sample I assume the data to transmit is in either cWebHead or cWebMessage. So all you need to do is:

    SEND_STRING dvWeb,cWebHead

    or

    SEND_STRING dvWeb,cWebMessage
  • viningvining Posts: 4,368
    Yeah but if the contents of cWebMessage is > than 16000 it gets truncated by send_string.

    Aftere a little more thought I guess the VTS & STV function wouldn't make a difference since the string expresions have to run through the string expression processor every time you add one to the variable.

    In the code posted previously both are sent out, 1st section being the HTTP response and 2nd being the HTTP content. In the example I posted I just started sending it out in max MTU chucks since the complete content wouldn't otherwise arrive at the client.

    Basically I had what you just posted but since that didn't work I decided to send it out in 1500 byte chunks as posted.
Sign In or Register to comment.