gotthardp / python-mercuryapi

Python wrapper for the ThingMagic Mercury API
MIT License
122 stars 63 forks source link

Help reading the tag data #143

Closed georgeExotic closed 9 months ago

georgeExotic commented 10 months ago

Commands I ran in the raspberry pi 4:

sudo apt update sudo apt upgrade sudo apt install git sudo apt-get install unzip patch xsltproc gcc libreadline-dev python3-dev python3-setuptools git clone https://github.com/gotthardp/python-mercuryapi.git

Download mercuryapi-BILBO-1.37.0.80.zip API from https://www.dropbox.com/sh/vy5og9bawg2mygk/AACguVDDJ1Cet8mlYTmANAbra?dl=0

Add API zip to python-mercuryapi.git

Modify Makefile to match zip file, here is my Makefile:


APIZIP ?= mercuryapi-BILBO-1.37.0.80.zip 

APIVER ?= 1.37.0.80 

PYTHON ?= $(shell { command -v python3 || command -v python; } 2>/dev/null) 

.PHONY: all mercuryapi install 

all: mercuryapi 

    $(PYTHON) setup.py build 

install: mercuryapi 

    $(PYTHON) setup.py install 

mercuryapi: mercuryapi-$(APIVER)/.done 

    make -C mercuryapi-$(APIVER)/c/src/api 

    mkdir -p build/mercuryapi/include 

    find mercuryapi-*/c/src/api -type f -name '*.h' ! -name '*_imp.h' ! -path '*ltkc_win32*' -exec cp {} build/mercuryapi/include/ \; 

    mkdir -p build/mercuryapi/lib 

    find mercuryapi-*/c/src/api -type f \( -name '*.a' -or -name '*.so.1' \) -exec cp {} build/mercuryapi/lib/ \; 

mercuryapi-$(APIVER)/.done: $(APIZIP) 

    unzip $(APIZIP) 

    patch -p0 -d mercuryapi-$(APIVER) < mercuryapi.patch 

    touch mercuryapi-$(APIVER)/.done 

This is how my folder looked:

./python-mercuryapi/ 

├── LICENSE 

├── long_description.txt 

├── Makefile 

├── MANIFEST.in 

├── mercuryapi-BILBO-1.37.0.80.zip 

├── mercuryapi_osx.patch 

├── mercuryapi.patch 

├── mercuryapi.pyproj 

├── mercuryapi.sln 

├── mercury.c 

├── README.md 

├── setup.py 

├── setup-win.py 

└── test.py 

make

This is the last bit from the terminal:

make[1]: Leaving directory '/home/pi/python-mercuryapi' 

running build_ext 

building 'mercury' extension 

creating build/temp.linux-aarch64-cpython-311 

aarch64-linux-gnu-gcc -Wsign-compare -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -g -fwrapv -O2 -fPIC -Ibuild/mercuryapi/include -I/usr/include/python3.11 -c mercury.c -o build/temp.linux-aarch64-cpython-311/mercury.o 

mercury.c: In function ‘parse_gen2filter’: 

mercury.c:441:86: warning: comparison of integer expressions of different signedness: ‘TMR_GEN2_Select_action’ and ‘int’ [-Wsign-compare] 

  441 |             else if ((tag_filter->u.gen2Select.action = str2action(object2str(obj))) == -1) 

      |                                                                                      ^~ 

mercury.c: In function ‘PyInit_mercury’: 

mercury.c:2362:5: warning: ‘PyEval_InitThreads’ is deprecated [-Wdeprecated-declarations] 

2362 |     PyEval_InitThreads(); 

      |     ^~~~~~~~~~~~~~~~~~ 

In file included from /usr/include/python3.11/Python.h:95, 

                 from mercury.c:25: 

/usr/include/python3.11/ceval.h:132:37: note: declared here 

  132 | Py_DEPRECATED(3.9) PyAPI_FUNC(void) PyEval_InitThreads(void); 

      |                                     ^~~~~~~~~~~~~~~~~~ 

creating build/lib.linux-aarch64-cpython-311 

aarch64-linux-gnu-gcc -shared -Wl,-O1 -Wl,-Bsymbolic-functions -g -fwrapv -O2 build/temp.linux-aarch64-cpython-311/mercury.o -Lbuild/mercuryapi/lib -L/usr/lib/aarch64-linux-gnu -lmercuryapi -lltkc -lltkctm -o build/lib.linux-aarch64-cpython-311/mercury.cpython-311-aarch64-linux-gnu.so 

Sudo make install


Installed /usr/local/lib/python3.11/dist-packages/python_mercuryapi-0.5.4-py3.11-linux-aarch64.egg 

Processing dependencies for python-mercuryapi==0.5.4 

Finished processing dependencies for python-mercuryapi==0.5.4 

When I run test.py I get the following error:

M6e Nano 

['NA2', 'NA3', 'IN', 'JP', 'PRC', 'EU3', 'KR2', 'AU', 'NZ', 'MY', 'ID', 'PH', 'TW', 'MO', 'RU', 'SG', 'JP2', 'JP3', 'VN', 'TH', 'AR', 'HK', 'BD', 'EU4', 'open'] 

Traceback (most recent call last): 

  File "/home/pi/python-mercuryapi/test.py", line 12, in <module> 

    reader.set_read_plan([1], "GEN2", read_power=1900) 

TypeError: Parameter to command is invalid 

I can't use any of the functions to actually get readings from the device. However, the code can access the device.

I need help with reading the tags data.

georgeExotic commented 9 months ago

This is what I did to successfully install the library on my raspberry pi.

sudo apt update sudo apt install git sudo apt-get install unzip patch xsltproc gcc libreadline-dev python3-dev python3-setuptools

git clone https://github.com/gotthardp/python-mercuryapi.git

cd python-mercuryapi/

nano Makefile - delete last two lines

download inside python-mercuryapi folder the API from Jadak (https://www.jadaktech.com/wp-content/uploads/2022/08/mercuryapi-AHAB-1.35.2.72-1.zip)

folder tree looks like this: . ├── LICENSE ├── long_description.txt ├── Makefile ├── MANIFEST.in ├── mercuryapi-AHAB-1.35.2.72-1.zip ├── mercuryapi_osx.patch ├── mercuryapi.patch ├── mercuryapi.pyproj ├── mercuryapi.sln ├── mercury.c ├── README.md ├── setup.py ├── setup-win.py └── test.py

make

sudo make install