maemo.org - Talk

maemo.org - Talk (https://talk.maemo.org/index.php)
-   Development (https://talk.maemo.org/forumdisplay.php?f=13)
-   -   Python: Serial (https://talk.maemo.org/showthread.php?t=24106)

thopiekar 2008-10-06 13:49

BlueSixty: Get Connected with PyS60
 
hi mæmo users^^

As the thread is called I would know from you, where to get the
package "python-serial" for diablo, which is important for my future
project to work with serial ports...


I registred a project at garage today:
b60 ( just waiting for the feedback)

The goal of this project is to offer a special module to get connected with the pyS60'S bluetooth console and keep it easy and quickly.

I look foreward to see programms of these:
http://de.youtube.com/watch?v=JPf5-r7dl5U
using the motion-sensor (here of the n95).

greeez


__________________________________________________ _____________________
| Thread "Python: Serial" renamed as "BlueSixty: Get Connected with PyS60" |

jethro.itt 2008-10-07 07:49

Re: Python: Serial
 
Quote:

Originally Posted by thopiekar (Post 230987)
The goal of this project is to offer a special module to get connected with the pyS60'S bluetooth console and keep it easy and quickly.

You don't need python-serial to create an RFCOMM Bluetooth socket. Package python2.5-bluez enables you to do that. It gets installed automatically when you install Python (python2.5-runtime) on your tablet. RFCOMM sockets act like serial port sockets: example.

You need python-serial to connect a real serial port adapter to the tablet in USB host mode. There's no ready-made package that I know of, but python-serial is a pure Python module and can easily copied around. See my earlier post about the subject.

hvacengi 2008-10-07 13:35

Re: Python: Serial
 
python-serial is indeed pure python and works on OS2008. I have used it, and dbus, to connect to my roomba and other projects over bluetooth without much issue. You may want to incorporate turning the bluetooth on and off as well into your project, which can be done over dbus.

download python-serial from the source forge page listed above, use an archive program to unpack the contents, and then just copy the folder from the archive's ./usr/lib/python2.5/site-packages/serial to the same path in your file structure.

frethop 2008-10-07 14:23

Re: Python: Serial
 
hvacengi: Do you have the Roomba access code available? I've been wanting to access my Roomba, but was waiting for some time to dig into the BlueZ access.

Thanks.

hvacengi 2008-10-07 23:34

Re: Python: Serial
 
Below is the code I used. You have to know the address of the device you want to connect to, or offer an option to select it. You can have bluez do a search, and/or list the saved paired devices I think. I didn't do it when I wrote this section cause I was just messing around with the concept. I think that if you want to use a pass code you have to have the n8x0 paired with your receiver.

Once you connect, "self.port" acts just like a regular serial port. Reading stream data doesn't work so well (automated every 15ms is a bunch of data and at least in python things seemed to get bogged down some where). But I could send commands and read responses fine. I've used this same trick to talk to my arduino board, my laptop, and a gps receiver, all without any problems (other than remembering to change the bluesmirf's data rate). You might notice that I check to see if the bluetooth adapter is on (trying to use it when it's off throws an exception), and if not I set a bool to true when I turn on the adapter so that I can turn it off again at application close.

Good luck with your program, I'd be interested to see anything you come up with.

-Brad

Code:

self.bus = dbus.SystemBus();
self.bmgr = dbus.Interface(self.bus.get_object('org.bluez', '/org/bluez'), 'org.bluez.Manager')
self.bus_id = self.bmgr.ActivateService('serial')
self.adapter_add = self.bmgr.DefaultAdapter()
print self.adapter_add
self.adapter = dbus.Interface(self.bus.get_object('org.bluez', self.adapter_add), 'org.bluez.Adapter')
mode = self.adapter.GetMode()
print mode
self.disable_bt = False
if mode == "off":
    print "setting adapter on"
    self.adapter.SetMode("connectable")
    self.disable_bt = True
self.ser_int = dbus.Interface(self.bus.get_object(self.bus_id, '/org/bluez/serial'), 'org.bluez.serial.Manager')
self.device = self.ser_int.ConnectService("00:06:66:00:D4:0C", "spp")
print self.device;
self.port = serial.Serial(str(self.device), 115200, timeout=1)


thopiekar 2008-10-08 09:16

Re: Python: Serial
 
thanks for your posts ;)

I just have asked for this module because a project (niime.com)
used this module too..

a module, which uses rfcomm, for python is the main thing for my new project: BlueSixty

greeez

frethop 2008-10-08 11:47

Re: Python: Serial
 
Very cool! Many thanks.

thopiekar 2008-10-09 11:42

Re: Python: Serial
 
I thried the rfcomm-server of code.google.com and removed the lines 29 to 35, insert

Code:

client_sock.send("import audio)
client_sock.send("audio.say('Hallo World!')")

, because in this case the bluetooth console of pyS60 acts like a client.

But my N95 doesn't react.

Do you have some solutions?
It seems that I'm a little bit helpless in bluetooth-things..

EDIT: Fixed


All times are GMT. The time now is 19:45.

vBulletin® Version 3.8.8