Im working with MFRC522-Python library, I READ the RFid Uid then I open a webbrowser with a specific URL composed by the uid of each card.
The thing is in Raspbian Buster (RPI 3b+) cannot run Chrome-Browser as SUDO from a python script.
I would like to know if is there any way to read the RC522 without SUDO
CODE:
#!/usr/bin/python
import signal
import time
import sys
import os
import webbrowser
from pirc522 import RFID
#chrome = chromium-browser()
run = True
rdr = RFID()
util = rdr.util()
util.debug = True
def end_read(signal,frame):
global run
print("\nCtrl+C captured, ending read.")
run = False
rdr.cleanup()
sys.exit()
signal.signal(signal.SIGINT, end_read)
print("Starting")
os.system('chromium-browser --app=http://localhost/ --kiosk --user-data-dir /home/pi & ')
while run:
rdr.wait_for_tag()
(error, data) = rdr.request()
if not error:
print("\nDetected: " + format(data, "02x"))
(error, uid) = rdr.anticoll()
if not error:
print("Card read UID: "+str(uid[0])+","+str(uid[1])+","+str(uid[2])+","+str(uid[3]))
print("Setting tag")
util.set_tag(uid)
os.system('chromium-browser --app=http://localhost/verperfil/rfid.php?rfid='+str(uid[0])+''+str(uid[1])+''+str(uid[2])+''+str(uid[3])+'')
print("\nAuthorizing")
#util.auth(rdr.auth_a, [0x12, 0x34, 0x56, 0x78, 0x96, 0x92])
#util.auth(rdr.auth_b, [0x74, 0x00, 0x52, 0x35, 0x00, 0xFF])
print("\nReading")
util.read_out(4)
print("\nDeauthorizing")
util.deauth()
time.sleep(1)
THE OUTPUT WITHOUT SUDO:
pi@raspberrypi:~ $ python /var/www/html/pi-rc522/examples/asigna.py
Traceback (most recent call last):
File "/var/www/html/pi-rc522/examples/asigna.py", line 11, in <module>
rdr = RFID()
File "build/bdist.linux-armv7l/egg/pirc522/rfid.py", line 78, in __init__
RuntimeError: No access to /dev/mem. Try running as root!
pi@raspberrypi:~ $
THE OUTPUT WITH SUDO
sudo python /var/www/html/pi-rc522/examples/asigna.py
/usr/local/lib/python2.7/dist-packages/pi_rc522-2.2.1-py2.7.egg/pirc522/rfid.py:78: RuntimeWarning: This channel is already in use, continuing anyway. Use GPIO.setwarnings(False) to disable warnings.
Starting
--user-data-dir --disable-quic --enable-tcp-fast-open --ppapi-flash-path=/usr/lib/chromium-browser/libpepflashplayer.so --ppapi-flash-args=enable_stagevideo_auto=0 --ppapi-flash-version=
No protocol specified
[4692:4692:0807/011632.383841:ERROR:browser_main_loop.cc(596)] Failed to put Xlib into threaded mode.
No protocol specified
(chromium-browser-v7:4692): Gtk-WARNING **: 01:16:32.388: cannot open display: :10.0