if (!index)
{
this.sendErrorTelegram(errorCodes.undef_index);
index = '9999';
}
data += index;
for (var i = 0; i < decodeResults.length; i++) {
length = decodeResults[i].content.length;
data += String.fromCharCode(length / 256, length % 256);
}
data += sep filler;
length = 0;
for (var i = 0; i < decodeResults.length; i++) {
= decodeResults[i].content.length;
data += decodeResults[i].content;
}
if (length & 0x1)
data += filler;
data += String.fromCharCode(getChecksum(data));
this.sendTelegram({type: system_id, content: data});
index = null; // invalidate the used index
},
sendErrorTelegram: function (errcode)
{
var errtel = {type: 'F', content: syString.fromCharCode
(errcode)}
this.sendTelegram(errtel);
},
sendTelegram: function (telegram)
{
var data = telegram.type + telegram.content;
data = '\x02'+data+String.fromCharCode(getChecksum(data))+'\03';
this.send(data);
if (append_crlf)
this.send('\r\n');
},
checkTelegram: function(data, checksum)
{
var exp_checksum = getChecksum(data);
if (checksum != exp_checksum) {
this.sendErrorTelegram(errorCodes.telegram_error);
} else {
switch (data[0])
{
case 'I':
71
DataMan Application Development