Phidget Dial: JavaScript example not working

Supporting Browser-based Javascript and Node.js
Post Reply
MZL
Phidgetsian
Posts: 8
Joined: Mon Feb 08, 2021 11:22 am
Contact:

Phidget Dial: JavaScript example not working

Post 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?
User avatar
mparadis
Site Admin
Posts: 959
Joined: Fri Oct 28, 2011 12:17 pm
Contact:

Re: Phidget Dial: JavaScript example not working

Post 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.
MZL
Phidgetsian
Posts: 8
Joined: Mon Feb 08, 2021 11:22 am
Contact:

Re: Phidget Dial: JavaScript example not working

Post 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.
Post Reply

Who is online

Users browsing this forum: No registered users and 3 guests