Home AMX User Forum AMX General Discussion

Max length of DATA.TEXT ?

Hi

I'm writing a new program and I need to parse some datas incoming through IP connection. As I heard that DEFINE_PROGRAM is no more usable in new NX processors, I'm stuck with DATA.TEXT but limit is around 2K characters :( Is there a way to upper this limit ? so I can get my full IP strings without losing characters !!

Thanks for advices,

Vincèn

Comments

  • rfletcherrfletcher Posts: 217
    vincen wrote: »
    Hi

    I'm writing a new program and I need to parse some datas incoming through IP connection. As I heard that DEFINE_PROGRAM is no more usable in new NX processors, I'm stuck with DATA.TEXT but limit is around 2K characters :( Is there a way to upper this limit ? so I can get my full IP strings without losing characters !!

    Thanks for advices,

    Vincèn

    You should still be able to create a buffer, and just do your processing in the data_event instead of define_program. (I'm assuming you were creating a buffer and parsing it's contents in define_program before).
  • vincenvincen Posts: 526
    rfletcher wrote: »
    You should still be able to create a buffer, and just do your processing in the data_event instead of define_program. (I'm assuming you were creating a buffer and parsing it's contents in define_program before).
    Hum very confused here :s if you do it old way with Create_Buffer in Define Start you can only handle it in Define program not in Data_Event or I missed something ?
    Right now I do it in Netlnx way with a DATA_Event and I parse the data.text but I lose 3/4 of incoming datas due to very lenghty strings received :(
  • a_riot42a_riot42 Posts: 1,624
    vincen wrote: »
    Hum very confused here :s if you do it old way with Create_Buffer in Define Start you can only handle it in Define program not in Data_Event or I missed something ?
    Right now I do it in Netlnx way with a DATA_Event and I parse the data.text but I lose 3/4 of incoming datas due to very lenghty strings received :(

    You aren't forced to deal with the buffer in define_program, but many people use it to constantly check for content in the buffer and then do something with it. That might not work with the new controllers and isn't the best way to do it imho. I only use data.text and have parsed XML documents that are 1 MB in size so you can too. The fact that data.text has a size limit shouldn't be a problem, and if you are losing incoming data then there is a problem with your code. Post it and then maybe someone can help you with it.
    Paul
  • GregGGregG Posts: 251
    Quick example

    This example assumes messages from the IP device have CR,LF termination, adapt as needed...
    DEFINE_DEVICE
    dvSomeIPThingy = 0:4:0
    
    DEFINE_VARIABLE
    Volatile Char cBuffer[16000]
    
    Define_Function ParseThingyBuffer()
    {
    Stack_Var Char cMessage[16000]
      While(Find_String(cBuffer,"13,10",1))
      {
        cMessage=Remove_String(cBuffer,"13,10",1)
        // Your code to process a single line of incoming
        // data from cMessage goes here
      }
    }
    
    DEFINE_START
    Create_Buffer dvSomeIPThingy,cBuffer
    
    DEFINE_EVENT
    Data_Event[dvSomeIPThingy]
    {
      String: { ParseThingyBuffer() }
    }
    
  • rfletcherrfletcher Posts: 217
    vincen wrote: »
    Hum very confused here :s if you do it old way with Create_Buffer in Define Start you can only handle it in Define program not in Data_Event or I missed something ?
    Right now I do it in Netlnx way with a DATA_Event and I parse the data.text but I lose 3/4 of incoming datas due to very lenghty strings received :(

    You can use create_buffer and still do the processing in the data_event. if you have a defined message termination character you can do something like this to make sure you process all the messages in the buffer:
    data_event
    {
    	string:
    	{
    		while(find_string(buffer,<your terminator here>,1))
    		{
    			//buffer processing
    		}
    	}
    }
    
  • viningvining Posts: 4,368
    Typicalyl the max transmission unit (mtu) 1500 bytes unless you're using jumbo frame so the most you'll ever get in a single IP data event is 1524 or something allowing a little more for header crap so the 2048 length of data.text is more than adequate. You can also just use a local var and concatenate it with data.text which is how I usually do it. If your expected returns are real long you can use the local var to concatenate the incoming data but use find string on data .text so it never has to search through more than 1500 byte on each data event until the delimiter is found and when it is parse the local var.
  • vincenvincen Posts: 526
    Thanks for all advises, I stayed with Data_Event to be sure to use at maximum Netlinx power and did concatenation till I receive the end of string to start string processing, and it works like a charm ;)
Sign In or Register to comment.