![]() |
||
| Python |
Material
Installation
Dokumentation
PythonKara
Grundlagen
Namensräume
Funktionen
Testen
Strings
Dictionary
Listen
Zeitmessungen
Zufall
Bits+Bytes
Module
Sockets
xml
serielle Schnittstelle
Python in HTML
Turtle
xturtle
Tkinter
OOP
Threads
Zusicherungen
exe
Patterns
GnuPlot
Goto
MySQL
CGI
Dateien
Exceptions
Grafik
Mathematik
Fischertechnik
Unicode
funktional
Iterator
Sound
C
Debugger
regex
Pfade
Docstrings
Django
format
Bytecode
signal
|
|
|
Bluetooth |
Nach
sudo apt-get install python-dev sudo apt-get install libbluetooth-dev
gelingt die Installation mit
mk@x2:~/Downloads/PyBluez-0.18$ sudo python setup.py install
Python2.7
>>> import bluetooth
>>> nd = bluetooth.discover_devices()
>>> print(nd)
['00:16:53:11:25:41']
>>> nd = bluetooth.discover_devices(lookup_names=True)
>>> nd
[('00:16:53:11:25:41', 'NXT')]
>>> s = bluetooth.find_service(address='00:16:53:11:25:41')
>>> s
[]
>>> bd_addr = '00:16:53:11:25:41'
>>> bd_addr
'00:16:53:11:25:41'
>>> port=1
>>> s=bluetooth.BluetoothSocket(bluetooth.RFCOMM)
>>> s.connect((bd_addr,port))
>>> s.send('hallo')
5
>>> s.close()
>>>
Offensichtlich läuft auf einem Mindstorms-NXT ein RFCOMM-Server. Man kann auf dem Display des NXT sehen wie aus < <> wird und beim Schließen wieder < .