I have an device connected over "/dev/ttyUSB0" to my RaspberryPi. In Chromium I want to set it on "Remote" with a python-serial script:
import serial
ser = serial.Serial()
ser.baudrate = 9600
ser.port = "/dev/ttyUSB0"
ser.open()
ser.write("REM".encode("utf-8"))
ser.close()
this executes on a HTML ButtonClick Event compared with some js code:
function goPython() {
$.ajax({
url: "serial.py",
context: document.body
}).done(function) {
alert('finished python script');;
});
}
HTML:
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
</head>
<body>
<button id="click" onclick="goPython()">GO!</button>
</body>
It runs on my Chromium Browser at the RasPi and says:
finished python script
But the device, sadly isnt in Remote Access. Anybody got a hint? Since I had very positive experiences at StackOverflow I wanted to post it here. Thanks a lot people!