User rights
Posted: Wed Feb 22, 2023 5:40 pm
I had posted this in Python, but realize it fits better in this topic.
After several evenings trying everything I can find, I still can't get my Phidget code to run without sudo on my Raspberry Pi. Or rather, sometimes it does for a while, but then it doesn't again.
Every time it can be solved by running it with sudo. But a web page doesn't run like that, so I can't get the web page to consistently attach to the phidget.
All descriptions I find make this seem like a very simple thing! I have really not done anything special on this Raspberry other than installing Phidgets.
I have copied the 99-libphidget22.rules to etc/udev/rules.d/ and tried reinstalling udev.
And this used to work fine with one Phidget. But then I updated things and added another Phidget, that I want to control from a web page. No I can't get the first one to run properly without sudo anymore.
phidget22admin -d shows that the phidgets are there and work in principle. I'm quite sure this is some user right software problem, but don't know how to fix it.
When I open the web page with the below code, it says:
Phidget attached
Output0 false
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Test Phidget 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 onPhidgetError(code, description) {
document.getElementById("dataLabel").innerHTML = code + " " + description;
};
function initDigitalOutput(channel) {
Output0 = new phidget22.DigitalOutput();
Output0.onError = onPhidgetError;
Output0.setDeviceSerialNumber(phidgetSerialNumber);
Output0.setChannel(channel);
Output0.open(0);
};
function runExample() {
initDigitalOutput(0);
document.getElementById("mainLabel").innerHTML = "Phidget attached";
var state0 = "Output0 " + Output0.attached;
document.getElementById("dataLabel").innerHTML = state0;
};
</script>
<body onload="connectPhidgets()">
<div>
<h1 id="mainLabel">?</h1>
<h1 id="dataLabel">?</h1>
</div>
</body>
</html>
After several evenings trying everything I can find, I still can't get my Phidget code to run without sudo on my Raspberry Pi. Or rather, sometimes it does for a while, but then it doesn't again.
Every time it can be solved by running it with sudo. But a web page doesn't run like that, so I can't get the web page to consistently attach to the phidget.
All descriptions I find make this seem like a very simple thing! I have really not done anything special on this Raspberry other than installing Phidgets.
I have copied the 99-libphidget22.rules to etc/udev/rules.d/ and tried reinstalling udev.
And this used to work fine with one Phidget. But then I updated things and added another Phidget, that I want to control from a web page. No I can't get the first one to run properly without sudo anymore.
phidget22admin -d shows that the phidgets are there and work in principle. I'm quite sure this is some user right software problem, but don't know how to fix it.
When I open the web page with the below code, it says:
Phidget attached
Output0 false
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Test Phidget 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 onPhidgetError(code, description) {
document.getElementById("dataLabel").innerHTML = code + " " + description;
};
function initDigitalOutput(channel) {
Output0 = new phidget22.DigitalOutput();
Output0.onError = onPhidgetError;
Output0.setDeviceSerialNumber(phidgetSerialNumber);
Output0.setChannel(channel);
Output0.open(0);
};
function runExample() {
initDigitalOutput(0);
document.getElementById("mainLabel").innerHTML = "Phidget attached";
var state0 = "Output0 " + Output0.attached;
document.getElementById("dataLabel").innerHTML = state0;
};
</script>
<body onload="connectPhidgets()">
<div>
<h1 id="mainLabel">?</h1>
<h1 id="dataLabel">?</h1>
</div>
</body>
</html>