Newby = Timed out on connection

Supporting Browser-based Javascript and Node.js
Post Reply
FredrikH
Phidgetsian
Posts: 7
Joined: Mon Jul 08, 2019 10:17 am
Contact:

Newby = Timed out on connection

Post by FredrikH »

Hi

I have the simple code bellow:

Code: Select all

var runExample = async () => {
    var phidgetsConn = new phidget22.NetworkConnection({
        hostname: serviceServerConfig["phidgets"]["hostname"],
        port: serviceServerConfig["phidgets"]["port"],
        name: "Phidget Server Connection",
        passwd: "",
        onAuthenticationNeeded: function() { return "password"; },
        onError: () => {
            console.log("Phidgets Networkserver - Connection Error:", msg);
        },
        onConnect: function() {
            console.log("Phidgets Networkserver - Connection is established and MTU is ready to work");
        },
        onDisconnect: function() { 
            console.log("Phidgets Networkserver - Disconnected");
        }
    });
    
    await phidgetsConn.connect().then(() => {})

    const bldcMotor0 = new phidget22.BLDCMotor();

	bldcMotor0.setHubPort(1);
    bldcMotor0.setChannel(0);
	bldcMotor0.setDeviceSerialNumber(668208);

	bldcMotor0.onAttach = () => {
		console.log('Attach!');
	}; 
 
	bldcMotor0.onDetach = () => {
		console.log('Detach!');
	};

	await bldcMotor0.open(5000);

	await bldcMotor0.setTargetVelocity(1);
}

runExample();

When running the code it says that:
"Phidgets Networkserver - Connection is established and MTU is ready to work"

That is fine :) But after it the program has timed out when the 5 sec has passed?

It feels that the program is failing when the software channel will match with its physical channel, does not it?

I am in Node js for ths exampel. The phidgets server is in the same computer!

Best regards Fredrik
Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests