I need to send to the socket:
<STX>PIPE_DELIMITED_MESSAGE<ETX><LRC>
STX = String.fromCharCode(02) //// **Good**
ETX = String.fromCharCode(03) //// **Good**
LRC = Unable to calculate correctly
Request: LRC is the result of 8bit EXCLUSIVE OR (Binary ADD without Carry) of all bytes starting with the byte after STX and including the final ETX of the message.
I was using below, but is not correct. No much info out there for AS3.
function generate_lrc(string: String) {
var lrc = 0
var text = string.split('');
for (var i: Number = 0; i < text.length; i++) {
lrc ^= text[i].charCodeAt(0);
}
trace('lrc = ' + lrc);
return lrc;
}
Any help will be appreciated, thank you!