Page 1 of 1

User rights for Phidget

Posted: Sun Feb 19, 2023 11:19 am
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>

Re: User rights for Phidget

Posted: Sun Feb 19, 2023 11:30 am
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.

Re: User rights for Phidget

Posted: Sun Feb 19, 2023 11:45 am
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...

Re: User rights for Phidget

Posted: Sun Feb 19, 2023 2:02 pm
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!