Any Cognex Dataman Scripting people here? -- Or JS wizards

Is anyone familiar around here with Cognex DMCC scripting?

I am trying to send a heartbeat. Maybe auto re-booting down the road… I am running 60 scanners over TCP connections drivers. And they hang up a lot. It’d be really cool if they lost connection to reboot. But, you’d have to know the port of server? And its random

Figured it was worth a shot asking here. :man_shrugging: Cause I have no idea lol I’ll just keep playing with it till something happens.

Thanks!

// Data Formatting:
var comm_handler = new Array(0);
// Converts read data to all upper case. Single code only.
function onResult (decodeResults, readerProperties, output) {
if (decodeResults[0].decoded) {
output.content = decodeResults[0].content+'\r\n';
for (var i = 0; i < comm_handler.length; i++)
{
comm_handler[i].resetHeartBeat();
}
}
}
//Output different results to various protocols
function onResult (decodeResults, readerProperties, output)
{
	if (decodeResults[0].decoded)
	{
		var mymsg = decodeResults[0].content;

		// output['Serial'] is identical to output.Serial
		//output['Serial'] = "serial: " + mymsg;
		output.Telnet = "telnet: " + mymsg;

		output.content = mymsg;
	}
	else
	{
		output.content = "bad read";
	}
}

// Communication:
// Heart beat example without disturbing the DMCC communication function CommHandler() 
{
	var beat_timer = 10.0; // beat timer in sec
	var peer_name;
	return {
		onConnect: function (peerName)
		{
			peer_name = peerName;
			this.resetHeartBeat(); // initial timer
			this.expectFramed("\0", "\0", 128); // some pattern
			unlikely to happen
			comm_handler.push(this); // register the handler for results
			// enable the handler for this connection:
			return true;
		},
		onDisconnect: function ()
		{
			var index = comm_handler.indexOf(this)
			comm_handler.splice(index, 1);
		},
		onError: function (errorMsg)
		{
		},
		onExpectedData: function (inputString) {
		return false;
		},
		onUnexpectedData: function (inputString) {
		return false;
		},
		onTimer: function () {
			today = new Date();
		var msg = today.getSeconds() * 1000 + today.getMilliseconds();
		num_send = this.send(peer_name + ': time is: ' + msg + '\r\n');
		this.resetHeartBeat(); // schedule next timer event [sec]

		},
		resetHeartBeat: function () {
		this.setTimer(beat_timer); // schedule next timer event [sec]
		}
		};
}

		

Looks like a pain in the [expletive]. Sorry, not helpful. /:

Not very much luck lol

But, for future readers if there is one. On cognex you can write “||>REBOOT\r\n” to the tell-net port and reboot them. That’ll do for me. For now. You can send any DMCC commands like that as well.