// Parameter:
var system_id = '\x43'; // the system ID
var heartbeat_time_s = 5.0; // heartbeat timer in sec [0-50] (0 is disabled)
var append_crlf = true; // wether to
function CommHandler()
{
function getChecksum(data)
{
var sum = 0;
for(var i = 0; i < data.length; i++)
sum += data.charCodeAt(i);
return 0x7F - (sum % 0x7f);
}
var TelegramState = {
WAIT4CONTENT: {value: 0, name: "Wait For Content"},
CHECKSUM: {value: 1, name: "Header Received"}
};
var errorCodes = {
undef_index: 0x31,
multi_index: 0x32,
index_in_use: 0x33,
telegram_error: 0x34,
trigger_overrun: 0x40,
buffer_overflow: 0x41,
};
var filler = '#';
var separator = ',';
var telegram_types = {
heartbeat: {type: 'F', content: sy'\xf7'},
init_resp: {type: 'J', content: system_id},
};
// initialization: J
// index: S
var telegram;
var status;
var index;
var all_index = new Array();
return {
sendResultTelegram: function (decodeResults)
{
var data = system_id;
var length = 0;
70
DataMan Application Development