Giter Club home page Giter Club logo

Comments (5)

nanbuwks avatar nanbuwks commented on August 15, 2024

In pirc522/rfid.py, lines 191 and 221, we have the corresponding code.

print("E1")

so we have
print("E1", file=sys.stderr)
should be

from pi-rc522.

LateAtGit avatar LateAtGit commented on August 15, 2024

I have a similar problem, sometimes I read a tag and I get "E2" error, I tried to read the code but I have no Idea what the reason is.

Can someone help me please?

Thank you

from pi-rc522.

nanbuwks avatar nanbuwks commented on August 15, 2024

There are several ways to solve this, but if you do not want to rewrite lines 191 and 221 of the library, you can use
You can use redirect_stdout.
In Python 3.5 or later, this can be achieved as follows:


import io
import os
from contextlib import redirect_stdout

from pirc522 import RFID
rdr = RFID()

f = io.StringIO()

while True:
  rdr.wait_for_tag()
  with redirect_stdout(f):
      (error, tag_type) = rdr.request()
  # print(f.getvalue())  # if need print "E1" or "E2"
  if not error:
    print("Tag detected")
    with redirect_stdout(f):
      (error, uid) = rdr.anticoll()
    # print(f.getvalue())  # if need print "E1" or "E2"
    if not error:
       print("UID: " + str(uid))

# Calls GPIO cleanup
rdr.cleanup()

If you do not need to capture E1 and E2, you can use


f = open(os.devnull,'w')

instead of


f = io.StringIO()

.

from pi-rc522.

LateAtGit avatar LateAtGit commented on August 15, 2024

Hi nanbuwks,
thank you for the answer, but I'm more interested in knowing why the error occours (and maybe solve or manage it) than suppress the message.

from pi-rc522.

nanbuwks avatar nanbuwks commented on August 15, 2024

Since we are using radio waves, there will always be errors at the boundary of the reaction.

However, aren't you plagued by a large number of errors?

IMG_20200304_153805.jpg

When I used such a module as it is, it was quite unstable as shown below.


Detected
Card read UID: 242,195,43,51
Selecting UID [242, 195, 43, 51, 41].
Changing used auth key to [255, 255, 255, 255, 255, 255] using method B
Calling card_auth on UID [242, 195, 43, 51, 41].
E2
Error on S1.0B0
Not calling card_auth - already authed
S1.0B0: [2] B
Calling card_auth on UID [242, 195, 43, 51, 41].
Error on S1.0B2
Changing used auth key to [255, 255, 255, 255, 255, 255] using method A
Calling card_auth on UID [242, 195, 43, 51, 41].
Not calling card_auth - already authed
Not calling card_auth - already authed
S2.0B1: []
Calling card_auth on UID [242, 195, 43, 51, 41].
Error on S0.0B0
Calling card_auth on UID [242, 195, 43, 51, 41] Error on S0.0B0
Error on S0.0B1
Calling card_auth on UID [242, 195, 43, 51, 41] Error on S0.0B1
Error on S0.0B2
.
.
.
Calling card_auth on UID [242, 195, 43, 51, 41]
Error on S15.0B2
Calling card_auth on UID [242, 195, 43, 51, 41] Error on S15.0B2
Error on S15.0B3
Changing auth key and method to None

To solve this problem, adding a capacitor was effective.

IMG_20200312_130200.jpg

In the picture, a 47μF capacitor has been installed to improve the 3.3V power supply.

from pi-rc522.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.