• Not sure I really understand this... so you have:

    //Handle +IPD input data from ESP8266
    function ipdHandler(line) {
      var colon = line.indexOf(":");
      if (colon<0) return line; // not enough data here at the moment
      var parms = line.substring(5,colon).split(",");
      parms[1] = 0|parms[1];
      var len = line.length-(colon+1);
      if (len>=parms[1]) {
       // we have everything
       sockData[parms[0]] += line.substr(colon+1,parms[1]);
       /** INSTRUMENTED =>**/ console.debug('ipdHandler (empty): ', line.length, ' bytes in packet, ', sockData[parms[0]].length, ' bytes in total');
       return line.substr(colon+parms[1]+1); // return anything else
      } else { 
       // still some to get
       sockData[parms[0]] += line.substr(colon+1,len);
       ///** INSTRUMENTED =>**/ console.debug('ipdHandler (more) : ', line.length, ' bytes in packet, ', sockData[parms[0]].length, ' bytes in total');
       return "+IPD,"+parms[0]+","+(parms[1]-len)+":";­ // return IPD so we get called next time
      }
    }
    

    So it should be reporting back every single time it gets more data in?

    But it actually reports:

    ipdHandler (empty):  61  bytes in packet,  591  bytes in total
    ipdHandler (empty):  63  bytes in packet,  2051  bytes in total
    ipdHandler (empty):  64  bytes in packet,  3511  bytes in total
    ipdHandler (empty):  65  bytes in packet,  4971  bytes in total
    ipdHandler (empty):  67  bytes in packet,  6431  bytes in total
    recv [sckt:0] (deltaTime:  949377358.046 ) :  64  bytes of  7063  sent to socketServer
    ipdHandler (empty):  67  bytes in packet,  7827  bytes in total
    ipdHandler (empty):  69  bytes in packet,  9287  bytes in total
    ipdHandler (empty):  70  bytes in packet,  10747  bytes in total
    ipdHandler (empty):  72  bytes in packet,  12207  bytes in total
    ipdHandler (empty):  72  bytes in packet,  13667  bytes in total
    ipdHandler (empty):  73  bytes in packet,  14632  bytes in total
    

    I'd have expected bytes in total to increment by a bit less than 'bytes in packet' each time, but it's going up by about 1500 bytes!

    I think one solution would be to change the netRecv function such that it used JsVars rather than a fixed size buffer. That way it'd read as much data as the network connection was willing to give it.

About

Avatar for Gordon @Gordon started