Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gen2 Select Filtering #113

Open
tberndt5 opened this issue Jun 30, 2020 · 2 comments
Open

Gen2 Select Filtering #113

tberndt5 opened this issue Jun 30, 2020 · 2 comments

Comments

@tberndt5
Copy link

Hello,
I am trying to use the gen2 select filtering as described in the documentation, but I keep getting "TypeError:reserved, epc, tid or user mask expected". I am not sure what I am doing wrong. Is there anyone that could present an example of the gen2 select filtering with all of the associated items in the dict.

Thanks

@n8cutler
Copy link

n8cutler commented Jul 14, 2020

Hi,

I'm also struggling to get the Gen2 Select filtering working and could really use a working example.
I've tried building a dictionary and list of dictionaries according to the fields defined.
However, I can't seem to get the format right and I'm sure I'm missing something simple.

Any help would be appreciated.
Thanks.


Update

I was able to get a single Gen2 Select filter to work when masking by EPC. See example below.
However, I am not able to get this to work when using a mask for the user memory.

device = "/dev/ttyUSB2"
reader = mercury.Reader("tmr://{}".format(device), baudrate=115200, protocol="GEN2")
reader.set_region("NA2")

# Showing filtering by epc. This works.
# Showing a mask that doesn't match my tags beyond 16 bits to show that the offset and length work for EPC filter.
gen2_select = {
    'epc': b'E200FF',
    'bit': 32,
    'len': 16,
    }
reader.set_read_plan([1], "GEN2", epc_target=gen2_select, bank="user")
print("Filter using EPC:")
print(reader.read())

# Showing filtering by user bank mask. I can't get this to work.
# User bank offset starts at 0 instead of 32. Just trying to match the first 16 bits.
gen2_select = {
    'user': b'ABCD',
    'bit': 0,
    'len': 16,
    }
reader.set_read_plan([1], "GEN2", epc_target=gen2_select, bank="user")
print("Filter using user data:")
print(reader.read())

# Showing that the first 16 bits of the user memory data matches the filter I am attempting.
target = b'E200001C121501031080489B'
result = reader.read_tag_mem(3, 0x00, 16, epc_target=target)
print("Show user memory data:")
print(result)
reader.destroy()

Output:

Filter using EPC:
[EPC(b'E200001C121501031080489B'), EPC(b'E200001C121500931080405A')]
Filter using user data:
[]
Show user memory data:
bytearray(b'ABCDEF\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00')

I would really appreciate a working example of filtering by user memory mask. Thanks.

@amsimon
Copy link

amsimon commented Sep 10, 2020

@n8cutler Did you get this to work?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants