Blobs causing problems

My read serial function is having problems reading and writing to blobs, first time i have used them so could well be me.
`
data <- blob(256); // this is more efficent than local data superblob(256) for a free variable, i.e. not tied to a scope;
bytesRead <- 0;

//---------------------------------------------------------
function readUntilEOS( EOS )
//---------------------------------------------------------
// return 1 success
// -1 for all else
//---------------------------------------------------------
{
bytesRead = 1;
local byte = hardware.uart57.read();

while ( byte != -1 ) {
    //
    data.writen( byte, 'b' );
    bytesRead += 1;

    byte = hardware.uart57.read();

    if ( byte == EOS ) {

        local out = "";
        for ( local n=0; n<bytesRead; n++ ) {
            if ( data.eos()) break;
            local c = data.readn('b');
            out += c.tochar();
        }
        server.log("bytes = " + out);
    
        return 1;
    }
}

return -1;

}
`

perhaps i should have tried to data.seek(0) before posting!

:slight_smile: