User rights for Phidget

Supporting Browser-based Javascript and Node.js
Post Reply
khun
Phidgetly
Posts: 29
Joined: Tue Oct 27, 2020 8:44 am
Contact:

User rights for Phidget

Post by khun »

Hi!

I can't get my web page to connect to the Phidget. I'm guessing because of user rights somehow. What user rights does the web server have? Do I need to do something special to let it access Phidgets?

And that code in connectPhidgets, what does it do? Is it needed at all?

When I look at this web page, it shows that the onAttach is never called. I can see the Phidghet with phidget22admin, so it _is_ there and working!

<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Test DigitalOutput</title>
<script src="sha256.min.js"></script>
<script src="phidget22.min.js"></script>
</head>

<script>
const phidgetSerialNumber = 31404;
var Output0;

function connectPhidgets() {
var local = location.hostname; //get host location
var conn = new phidget22.Connection(8080, local);
conn.connect().then(runExample);
}

function onDigitalOutput_Attach(self) {
document.getElementById("mainLabel").innerHTML = "Phidgets - Attached";
};


function initDigitalOutput() {
Output0 = new phidget22.DigitalOutput();
Output0.setDeviceSerialNumber(phidgetSerialNumber);
Output0.setChannel(0);
Output0.onAttach = onDigitalOutput_Attach;
Output0.open(5000);
};

function runExample() {
initDigitalOutput(0);
Output0.setState(true);
document.getElementById("dataLabel").innerHTML = "Phidgets - Set " + Output0.getAttached();
};

</script>
<body onload="connectPhidgets()">
<div>
<h1 id="mainLabel">No Phidget attached</h1>
<h2 id="dataLabel">?</h2>
</div>
</body>
</html>
khun
Phidgetly
Posts: 29
Joined: Tue Oct 27, 2020 8:44 am
Contact:

Re: User rights for Phidget

Post by khun »

I forgot to mention that I _do_ have a file called:

/etc/udev/rules.d/99-libphidget22.rules

with the content:

SUBSYSTEMS=="usb", ACTION=="add", ATTRS{idVendor}=="06c2", ATTRS{idProduct}=="00[3-a][0-f]", MODE="666"

should allow all users access to the Phidgets, according to this page: https://www.phidgets.com/docs/OS_-_Linu ... with_Linux

Only thing is, it doesn't seem to work for me. It did earlier, but at some time after some update, it doesn't.
khun
Phidgetly
Posts: 29
Joined: Tue Oct 27, 2020 8:44 am
Contact:

Re: User rights for Phidget

Post by khun »

I finally found a discussion about this in the "Linux" topic on this forum.

All that is needed, was to run:

sudo apt-get install --reinstall udev

and restart! Why? No idea, seems very strange to me, I haven't quite gotten the hang of linux yet, I realize...
khun
Phidgetly
Posts: 29
Joined: Tue Oct 27, 2020 8:44 am
Contact:

Re: User rights for Phidget

Post by khun »

Too quick: it worked for a little while, now it doesn't again. And the same trick doesn't help anymore. This is getting really annoying!

A hope someone can help!
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest