1

thanks for your time.

Im getting some headhaches with a python script that takes the uID from RC522 tag reader then open a specific URL with the UID in a web browser..

It was working great on my RPI model B+ (Raspbian Wheezy) Now, i'been upgraded to a RPI 3 B+ (for a better performance) and the scripts read the uID but i can't get the browser open... i have been searching a lot of hours into google but no answer to my question.

Here is the output:

    Detected: 10
Card read UID: 23,96,179,17
Setting tag
Selecting UID [23, 96, 179, 17, 213]

Authorizing

Reading

Deauthorizing
Changing auth key and method to None
--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=
[3535:3535:0806/065332.412397:ERROR:zygote_host_impl_linux.cc(89)] Running as root without --no-sandbox is not supported. See https://crbug.com/638180.
--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=
[3557:3557:0806/065333.223510:ERROR:zygote_host_impl_linux.cc(89)] Running as root without --no-sandbox is not supported. See https://crbug.com/638180.
/usr/bin/xdg-open: 870: /usr/bin/xdg-open: firefox: not found
/usr/bin/xdg-open: 870: /usr/bin/xdg-open: iceweasel: not found
/usr/bin/xdg-open: 870: /usr/bin/xdg-open: seamonkey: not found
/usr/bin/xdg-open: 870: /usr/bin/xdg-open: mozilla: not found
No protocol specified
Unable to init server: Could not connect: Connection refused
Failed to parse arguments: Cannot open display: 
/usr/bin/xdg-open: 870: /usr/bin/xdg-open: konqueror: not found
/usr/bin/xdg-open: 870: /usr/bin/xdg-open: chromium: not found
--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=
[3594:3594:0806/065334.420571:ERROR:zygote_host_impl_linux.cc(89)] Running as root without --no-sandbox is not supported. See https://crbug.com/638180.
/usr/bin/xdg-open: 870: /usr/bin/xdg-open: google-chrome: not found
/usr/bin/xdg-open: 870: /usr/bin/xdg-open: www-browser: not found
/usr/bin/xdg-open: 870: /usr/bin/xdg-open: links2: not found
/usr/bin/xdg-open: 870: /usr/bin/xdg-open: elinks: not found
/usr/bin/xdg-open: 870: /usr/bin/xdg-open: links: not found
/usr/bin/xdg-open: 870: /usr/bin/xdg-open: lynx: not found
/usr/bin/xdg-open: 870: /usr/bin/xdg-open: w3m: not found
xdg-open: no method available for opening 'http://localhost/verperfil/rfid.php?rfid=239617917'

and here is the code

#!/usr/bin/python
import signal
import time
import sys
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")
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)

    webbrowser.open('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)

i can't run chromium with root permissions

  • 1
    You don't seem to have any browsers installed. – Dmitry Grigoryev Aug 6 at 9:30
  • Yes, i have installed (with sudo apt-get) chromium-browser and midori. – obdb Aug 6 at 13:34
1

Well, i was "closed-in-to-just-one-posibility" -or not thinking clear- The MFRC522-Python lib "Read.py" cannot be executed without sudo AND the chromium-browser CANNOT BE EXECUTED as SUDO, so... Afters a lot of Coffee and hours i found that i can execute the Read.py as SUDO and inside of it, the web browser directly with another username

basicly i have modified my script and replace this

webbrowser.open('http://localhost/verperfil/rfid.php?rfid='+str(uid[0])+''+str(uid[1])+''+str(uid[2])+''+str(uid[3])+'')

to this:

os.system('sudo -upi chromium-browser http://localhost/verperfil/rfid.php?rfid='+str(uid[0])+''+str(uid[1])+''+str(uid[2])+''+str(uid[3])+'')

Of course,

import os
import system

at the top+

and the browser just starts perfectly, one thing, is i dont know why the script get paused when browser is opened.. but this topic is ended :) THANKS TO ALL OF US

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.