Skocz do zawartości

Biblioteka wiimote Raspberry Pi 3B


Pomocna odpowiedź

Napisano

Dzień dobry,

Mam problem z biblioteką cwiid ponieważ biblioteka ta nie jest wykrywana przez program napisany w pythonie na raspberry pi 3B.

(biblioteka cwiid służy do zdalnego sterowania pilotem wimote)

1. Próbowałem zmieniać lokalizacje czyli np. program wklejałem do folderu z biblioteką i na odwrót ale nic to nie pomogło.
2. Usunąłem i zainstalowałem jeszcze raz i też nie pomogło.

Bardzo proszę o pomoc i z góry przepraszam za kłopot.

Poniżej przesyłam proces konfiguracji bluetooth , biblioteki przez konsole SSH

login as: artur
artur(malpa)192.168.101.230's password:
Linux raspberrypi 5.15.74-v7+ #1595 SMP Wed Oct 26 11:03:05 BST 2022 armv7l

The programs included with the Debian GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.

Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
Last login: Sun Nov 6 13:46:07 2022 from 192.168.101.190
artur@raspberrypi:~ $ sudo apt-get update
Stary:1 http://raspbian.raspberrypi.org/raspbian bullseye InRelease
Stary:2 http://archive.raspberrypi.org/debian bullseye InRelease
Czytanie list pakietów... Gotowe
artur@raspberrypi:~ $ sudo apt-get install bluetooth
Czytanie list pakietów... Gotowe
Budowanie drzewa zależności... Gotowe
Odczyt informacji o stanie... Gotowe
bluetooth is already the newest version (5.55-3.1+rpt2).
0 aktualizowanych, 0 nowo instalowanych, 0 usuwanych i 15 nieaktualizowanych.
artur@raspberrypi:~ $ git clone https://github.com/azzra/python3-wiimote
Klonowanie do „python3-wiimote”...
remote: Enumerating objects: 1278, done.
remote: Total 1278 (delta 0), reused 0 (delta 0), pack-reused 1278
Pobieranie obiektów: 100% (1278/1278), 511.53 KiB | 1.06 MiB/s, gotowe.
Rozwiązywanie delt: 100% (726/726), gotowe.
artur@raspberrypi:~ $ sudo apt-get install bison flex automake libbluetooth-dev
Czytanie list pakietów... Gotowe
Budowanie drzewa zależności... Gotowe
Odczyt informacji o stanie... Gotowe
automake is already the newest version (1:1.16.3-2).
bison is already the newest version (2:3.7.5+dfsg-1).
flex is already the newest version (2.6.4-8).
libbluetooth-dev is already the newest version (5.55-3.1+rpt2).
0 aktualizowanych, 0 nowo instalowanych, 0 usuwanych i 15 nieaktualizowanych.
artur@raspberrypi:~ $ cd python3-wiimote
artur@raspberrypi:~/python3-wiimote $ aclocal
artur@raspberrypi:~/python3-wiimote $ autoconf
artur@raspberrypi:~/python3-wiimote $ ./configure
checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking for gawk... no
checking for mawk... mawk
checking for flex... flex
checking lex output file root... lex.yy
checking lex library... -lfl
checking whether yytext is a pointer... yes
checking for bison... bison -y
checking for python3... python3
checking for pthread_create in -lpthread... yes
checking for hci_devid in -lbluetooth... yes
checking for dlopen in -ldl... yes
checking how to run the C preprocessor... gcc -E
checking for grep that handles long lines and -e... /usr/bin/grep
checking for egrep... /usr/bin/grep -E
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking for stdint.h... (cached) yes
checking bluetooth/bluetooth.h usability... yes
checking bluetooth/bluetooth.h presence... yes
checking for bluetooth/bluetooth.h... yes
checking for bluetooth/l2cap.h... yes
checking for bluetooth/hci.h... yes
checking linux/input.h usability... yes
checking linux/input.h presence... yes
checking for linux/input.h... yes
checking for linux/uinput.h... yes
checking for library containing strerror... none required
configure: creating ./config.status
config.status: creating Makefile
config.status: creating defs.mak
config.status: creating common/include/lib.mak
config.status: creating libcwiid/Makefile
config.status: creating libcwiid/cwiid.pc
config.status: creating python/Makefile
config.status: creating common/include/config.h
artur@raspberrypi:~/python3-wiimote $ make
make -C libcwiid
make[1]: Wejście do katalogu '/home/artur/python3-wiimote/libcwiid'
gcc -g -Wall -W -DHAVE_CONFIG_H -I/home/artur/python3-wiimote/common/include -fp ic -c -o bluetooth.o bluetooth.c
gcc -g -Wall -W -DHAVE_CONFIG_H -I/home/artur/python3-wiimote/common/include -fp ic -c -o command.o command.c
gcc -g -Wall -W -DHAVE_CONFIG_H -I/home/artur/python3-wiimote/common/include -fp ic -c -o connect.o connect.c
gcc -g -Wall -W -DHAVE_CONFIG_H -I/home/artur/python3-wiimote/common/include -fp ic -c -o interface.o interface.c
gcc -g -Wall -W -DHAVE_CONFIG_H -I/home/artur/python3-wiimote/common/include -fp ic -c -o process.o process.c
process.c: In function ‘process_status’:
process.c:43:39: warning: unused parameter ‘ma’ [-Wunused-parameter]
43 | struct mesg_array *ma)
| ~~~~~~~~~~~~~~~~~~~^~
process.c: In function ‘process_ext’:
process.c:175:31: warning: unused parameter ‘len’ [-Wunused-parameter]
175 | unsigned char len, struct mesg_array *ma)
| ~~~~~~~~~~~~~~^~~
gcc -g -Wall -W -DHAVE_CONFIG_H -I/home/artur/python3-wiimote/common/include -fp ic -c -o state.o state.c
gcc -g -Wall -W -DHAVE_CONFIG_H -I/home/artur/python3-wiimote/common/include -fp ic -c -o thread.o thread.c
gcc -g -Wall -W -DHAVE_CONFIG_H -I/home/artur/python3-wiimote/common/include -fp ic -c -o util.o util.c
util.c: In function ‘cwiid_err_default’:
util.c:42:40: warning: unused parameter ‘wiimote’ [-Wunused-parameter]
42 | void cwiid_err_default(struct wiimote *wiimote, const char *str, va_list ap)
| ~~~~~~~~~~~~~~~~^~~~~~~
ar rcs libcwiid.a bluetooth.o command.o connect.o interface.o process.o state.o thread.o util.o
ln -sf libcwiid.so.1.0 libcwiid.so.1
ln -sf libcwiid.so.1 libcwiid.so
gcc -shared -Wl,-soname,libcwiid.so.1 -o libcwiid.so.1.0 \
bluetooth.o command.o connect.o interface.o process.o state.o thread.o uti l.o -lbluetooth -lpthread -lrt
make[1]: Opuszczenie katalogu '/home/artur/python3-wiimote/libcwiid'
make -C python
make[1]: Wejście do katalogu '/home/artur/python3-wiimote/python'
python3 setup.py build_ext -g -I../libcwiid -L../libcwiid
running build_ext
building 'cwiid' extension
creating build
creating build/temp.linux-armv7l-3.9
arm-linux-gnueabihf-gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g - fwrapv -O2 -Wall -g -ffile-prefix-map=/python3.9-3.9.2=. -fstack-protector-stron g -Wformat -Werror=format-security -g -fwrapv -O2 -g -ffile-prefix-map=/python3. 9-3.9.2=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -g -I../libcwiid -I/usr/include/python3.9 -c Wiimote.c -o build/temp.linux-armv7l-3.9/Wiimote.o
Wiimote.c: In function ‘Wiimote_init’:
Wiimote.c:212:13: warning: ‘PyEval_InitThreads’ is deprecated [-Wdeprecated-decl arations]
212 | PyEval_InitThreads();
| ^~~~~~~~~~~~~~~~~~
In file included from /usr/include/python3.9/Python.h:145,
from Wiimote.c:23:
/usr/include/python3.9/ceval.h:130:37: note: declared here
130 | Py_DEPRECATED(3.9) PyAPI_FUNC(void) PyEval_InitThreads(void);
| ^~~~~~~~~~~~~~~~~~
Wiimote.c: In function ‘Wiimote_read’:
Wiimote.c:804:2: warning: ‘PyObject_AsWriteBuffer’ is deprecated [-Wdeprecated-d eclarations]
804 | if (PyObject_AsWriteBuffer(pyRetBuf, &buf, &len)) {
| ^~
In file included from /usr/include/python3.9/Python.h:151,
from Wiimote.c:23:
/usr/include/python3.9/abstract.h:354:17: note: declared here
354 | PyAPI_FUNC(int) PyObject_AsWriteBuffer(PyObject *obj,
| ^~~~~~~~~~~~~~~~~~~~~~
arm-linux-gnueabihf-gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g - fwrapv -O2 -Wall -g -ffile-prefix-map=/python3.9-3.9.2=. -fstack-protector-stron g -Wformat -Werror=format-security -g -fwrapv -O2 -g -ffile-prefix-map=/python3. 9-3.9.2=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -g -I../libcwiid -I/usr/include/python3.9 -c cwiidmodu le.c -o build/temp.linux-armv7l-3.9/cwiidmodule.o
creating build/lib.linux-armv7l-3.9
arm-linux-gnueabihf-gcc -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions -Wl,-z ,relro -g -fwrapv -O2 -Wl,-z,relro -g -fwrapv -O2 -g -ffile-prefix-map=/python3. 9-3.9.2=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g build/temp.linux-armv7l-3.9/Wiimote.o build/temp.linux-ar mv7l-3.9/cwiidmodule.o -L../libcwiid -lcwiid -lbluetooth -o build/lib.linux-armv 7l-3.9/cwiid.cpython-39-arm-linux-gnueabihf.so
make[1]: Opuszczenie katalogu '/home/artur/python3-wiimote/python'





URUCHAMIANIE PROGRAMU:




artur@raspberrypi:~/python3-wiimote $ cd
artur@raspberrypi:~ $ cd Dokumenty
artur@raspberrypi:~/Dokumenty $ cd robot
artur@raspberrypi:~/Dokumenty/robot $ python3 remote_control.py
Traceback (most recent call last):
File "/home/artur/Dokumenty/robot/remote_control.py", line 2, in <module>
import cwiid
ModuleNotFoundError: No module named 'cwiid'

oraz Program 

import gpiozero
import cwiid <------------------ tutaj wyskakuje błąd

robot=gpiozero.Robot(left=(17,18),right=(27,22))
print("Press and hold the 1+2 buttons on your wiimote simultaneoously")
wii=cwiid.Wiimote()
print("Connection established")
wii.rpt_mode=cwiid.RPT_BTN

while True:
buttons=wii.state["buttons"]
if(buttons & cwiid.BTN_LEFT):
robot.left()
if(buttons & cwiid.BTN_RIGHT):
robot.right()
if(buttons & cwiid.BTN_UP):
robot.forward()
if(buttons & cwiid.BTN_DOWN):
robot.backward()
if(buttons & cwiid.BTN_B):
robot.stop()

przesyłam również zdjęcia gdzie dokładnie co się znajduje w folderach ( sorki za zdjęcia telefonem )

 

lokalizacja biblioteki.jpg

lokalizacja programu.jpg

Bądź aktywny - zaloguj się lub utwórz konto!

Tylko zarejestrowani użytkownicy mogą komentować zawartość tej strony

Utwórz konto w ~20 sekund!

Zarejestruj nowe konto, to proste!

Zarejestruj się »

Zaloguj się

Posiadasz własne konto? Użyj go!

Zaloguj się »
×
×
  • Utwórz nowe...