• Now what remains could be buffer overflows.

    You can check with E.getErrorFlags() - it should say if a buffer has overflowed?

    what is the reason to use the bitwise OR (|) for the length

    It's actually a performance thing. In compiled code dealing with integers is fast, but anything else falls back to Espruino's built-in maths, which must handle strings/arrays/floats/etc so is much slower.

    The compiler isn't aware that .length actually returns an integer, and so it uses built-in maths for it and anything to do with it, which makes the whole for loop slow. By forcing it to an int the compiler can then do the whole for loop using ints (which go straight into registers).

  • @Gordon Thank's, diagnostic is always the most tricky point. I think, for now, that the errors returned will be of interest to my application. More precisely those ones:

    1. 'CALLBACK': A callback (setWatch, setInterval, on('data',...)) caused an error and so was removed.
    2. 'BUFFER_FULL': A buffer for a stream filled up and characters were lost. This can happen to any stream - Serial,HTTP,etc.

    One more question: I am now moving a maximum of computations out of the Serial.on 'real time' event handler. If I understand well the .emit('someevent',function) would allow to postpone some computations and keep the order of the emits. However, what happens if I do something as setTimeot(f,0); That is a 0 timeout call. Is it queued at the end of the events waiting or inserted at the head of the events queue?

    @cwilt I 'd rather use some binary floating point format to log time stamped data streams. JSON is verbous and designed to communicate between servers through the web, not to store data on an sd-card in time / space critical situations. This was to be considerated. Right now, I am even considering using the ublox own binary protocol, non nmea protocol. It might be faster, polled, so we get data when we can want, and avoids any float -> string -> float conversions. This should save time, space thus energy.

About

Avatar for Gordon @Gordon started