Page 1 of 1

Phidget Dial: JavaScript example not working

Posted: Fri Feb 19, 2021 5:21 am
by MZL
Hi there,

I have a problem with the JavaScript example for my HIN1101_0.
The device is connected to a HUB5000_0.
I used the example from https://www.phidgets.com/?view=code_sam ... JavaScript

If guess, I have to choose the encoder input in the code generator, so my code is as follows:

Code: Select all

function runExample() {
	var encoder0 = new phidget22.Encoder();
    	encoder0.setIsHubPortDevice(true);
	encoder0.setHubPort(5);
	encoder0.setDeviceSerialNumber(618405);

	encoder0.onPositionChange = function onEncoder0_Error(positionChange, timeChange, indexTriggered) {
		console.log('PositionChange: ' + positionChange.toString())
		console.log('TimeChange: ' + timeChange.toString())
		console.log('IndexTriggered: ' + indexTriggered.toString())
		console.log('----------');
	};

	encoder0.onError = function onEncoder0_Error(code, description) {
		console.log('Description: ' + description.toString())
		console.log('----------');
	};

	encoder0.open(5000).then(function() {

		setTimeout(function () {
			encoder0.close();
			process.exit(0);
		}, 5000);
	}).catch(function (err){
		console.error('Error during open:', err);
		//process.exit(1);
	})
}

var conn = new phidget22.Connection(8080, '192.168.1.32');
conn.connect().then(runExample).catch(function (err) {
	console.error('Error during connect:', err);
	//process.exit(1);
});
But here I´m getting the error:
dial.html:39 Error during open: Pt {name: "PhidgetError", errorCode: 3, message: "Open timed out", stack: "Error↵

My other Phidgets (voltage phidgets) are working well at the hub, so is there a working example for this device anywhere?

Re: Phidget Dial: JavaScript example not working

Posted: Mon Feb 22, 2021 10:30 am
by mparadis
Open isn't matching to your HIN1101 because setHubPortDevice is set to 'true'.

setHubPortDevice should only be set to 'true' if you're using it to open a VINT port as a stand-alone digital input, digital output, voltage input, or voltageratio input.

Re: Phidget Dial: JavaScript example not working

Posted: Sat Feb 27, 2021 1:52 am
by MZL
mparadis wrote:Open isn't matching to your HIN1101 because setHubPortDevice is set to 'true'.

setHubPortDevice should only be set to 'true' if you're using it to open a VINT port as a stand-alone digital input, digital output, voltage input, or voltageratio input.
Thanks a lot, this works.