In function is transmited double.
function writebyte(id, data)
{
data = Math.floor(data);
buf[id] = String.fromCharCode(data & (255));
}
It works ok for 0-127 values. But with negative or > 127 works wrong.
128 = 0xC2 0x80 (should be 0x80 1 byte)
-1 = 0xC3 0xBF (should be 0xFF 1 byte)
So I think problem is function String.fromCharCode with parameter 128++ or negative.
Is there any way writing bytes to array directly without String.fromCharCode?