×

Discussion Board

Results 1 to 11 of 11
  1. #1
    Regular Contributor
    Join Date
    Aug 2008
    Posts
    87

    Exclamation Bluetooth program crashes when it selects device from menu

    I wrote the following code to try for trying to share th sockets over multiple threads:

    http://pastebin.com/f2eb54ce5

    I start the chat_client() on the second phone, line 22 shows me the options to select from the list of available devices. As soon as I select one from the list the whole program including the python interpreter crashes.

    Then, I used the raw_input() function as a breakpoint, but even here I can see that the program crashes again. So what do I do now?

  2. #2
    Regular Contributor
    Join Date
    Aug 2008
    Posts
    87

    Re: Bluetooth program crashes when it selects device from menu

    I recognized the error in my previous code. It was due to the fact that in lines 14 and 29 the second argument must be a tuple so its (fd, ) . I posted the modified code as

    http://pastebin.com/f76189841

    However no I have got a serious problem. I can't send a single message. When I enter the message to send I get a popup that application is busy and it just waits in that loop.

  3. #3
    Super Contributor
    Join Date
    Nov 2007
    Location
    Sertaozinho/Brazil
    Posts
    768

    Re: Bluetooth program crashes when it selects device from menu

    hi

    I will try to help you later, running the code (after my son goes sleep).
    Just one point: are you sure that it is permitted to put print statements inside a thread? I am trying to remember but I think I had a problem related to this.

    Marcelo

  4. #4
    Regular Contributor
    Join Date
    Aug 2008
    Posts
    87

    Re: Bluetooth program crashes when it selects device from menu

    Thanks for your reply. Well print can be discarded. I am making a game over bluetooth. So you can see I can't just block the game to read a message.

  5. #5
    Super Contributor
    Join Date
    Nov 2007
    Location
    Sertaozinho/Brazil
    Posts
    768

    Re: Bluetooth program crashes when it selects device from menu

    One question at line 27: why makefile with r+ instead rw ? I think you want to write and read using this socket.

    Looking for another phone now ... :-/

  6. #6
    Super Contributor
    Join Date
    Nov 2007
    Location
    Sertaozinho/Brazil
    Posts
    768

    Re: Bluetooth program crashes when it selects device from menu

    First thing i noted: client is raising an exception at bt_discover and exits with
    kern exec 3. This post says that it can not find any server in such situation

    http://discussion.forum.nokia.com/fo...ad.php?t=55102

    However I could not find any error in server ... how to check if it is really advertising the service ?

    I used E71 and N95

  7. #7
    Regular Contributor
    Join Date
    Aug 2008
    Posts
    87

    Re: Bluetooth program crashes when it selects device from menu

    Why should it be "rw"? I initially contested the idea. I asked it here:
    http://stackoverflow.com/questions/6...e-modes-detail

    Python docs say that the file modes are same as taken by fopen() in C.
    http://www.opengroup.org/onlinepubs/...ons/fopen.html

    "rw" is not here.

    Well bt_discover(0 my deivces work fine (Nokia 7610 and Nokia 3230, both 2nd Edition). Well you have to start slave first then search for it using bt_discover() .

  8. #8
    Super Contributor
    Join Date
    Nov 2007
    Location
    Sertaozinho/Brazil
    Posts
    768

    Re: Bluetooth program crashes when it selects device from menu

    Quote Originally Posted by ra.ravi.rav View Post
    Why should it be "rw"? I initially contested the idea. I asked it here:
    http://stackoverflow.com/questions/6...e-modes-detail
    In my understanding you need to specify one mode for each direction. I have seen "rw" in books and used it this way. But I decided to test "r", "w" and "rw". All worked
    Looking in the source code:

    Code:
    # socket.py, python 2.5.x
    self.mode = mode # Not actually used in this version


    Quote Originally Posted by ra.ravi.rav View Post
    Well bt_discover(0 my deivces work fine (Nokia 7610 and Nokia 3230, both 2nd Edition). Well you have to start slave first then search for it using bt_discover() .
    Using bluez in my PC I can see the service btchat:

    Code:
    >>> import bluetooth
    >>> services = bluetooth.find_service(name="Trojan.exe")
    >>> services[5]
    {'protocol': 'RFCOMM', 'description': 'Rfcomm Transfer', 'service-id': '', 'profiles': [], 'service-classes': [], 'host': '00:21:FE:B4:54:E1', 'provider': '', 'port': 5, 'name': 'btchat'}
    So, I stucked here. bt_discover() is causing an exception.

    Not helping you in anyway ...

  9. #9
    Regular Contributor
    Join Date
    Aug 2008
    Posts
    87

    Re: Bluetooth program crashes when it selects device from menu

    self.mode = mode # Not actually used in this version
    Actually says it. But really "rw" is not a valid mode.

    http://pastebin.com/f76189841

    In the above code try cy commeting out the lines 15 to 17. I think bt_discover() won't crash then. Somehow I feel that Bluetooth in PyS60 is crippled compared to S60 C++.

  10. #10
    Super Contributor
    Join Date
    Nov 2007
    Location
    Sertaozinho/Brazil
    Posts
    768

    Re: Bluetooth program crashes when it selects device from menu

    Quote Originally Posted by ra.ravi.rav View Post
    Actually says it. But really "rw" is not a valid mode.
    Yes, new lesson learned: do not trust in books always... Internet (and some dibo guys) may be better
    You can see the "rw" in Foundations of Python Network Programming. As a C programmer, I knew that "rw" did not exist, but I was thinking about full duplex channel and a makefile special mode.

    I checked that makefile seems to be introduced in python 2.0.x and mode parameter was not used since its first implementation. In the C implementation, a call to fdopen is executed, using mode as "r". So, thanks.


    Quote Originally Posted by ra.ravi.rav View Post

    http://pastebin.com/f76189841

    In the above code try cy commeting out the lines 15 to 17. I think bt_discover() won't crash then. Somehow I feel that Bluetooth in PyS60 is crippled compared to S60 C++.
    I will try again ASAP, ok ? Thanks !

  11. #11
    Regular Contributor
    Join Date
    Aug 2008
    Posts
    87

    Re: Bluetooth program crashes when it selects device from menu

    I learned a bit about Active objects. Requests to read and write are sent to Blutooth server. But there is a limitation of only one request at a time.

    I create a new thread (say t1) and call it in the context of the main thread using ao_e32.callgate(). In that I wait for the incoming message. When I want to send a mesaage over bluetooth I should stop this thread, send the message and start the thread again. But now the problem is how do I stop a thread in Python.

    P.S. thread module is available in Python for S60 and threding can be installed over it using threading.py from the PC version of Python

Similar Threads

  1. There is no voice from any device when switch on bluetooth
    By liulihua in forum Bluetooth Technology
    Replies: 2
    Last Post: 2008-07-11, 09:06
  2. Local bluetooth device
    By noxo in forum Symbian Networking & Messaging (Closed)
    Replies: 1
    Last Post: 2007-07-21, 16:18
  3. Problem in connectivity with BlueTooth Device
    By puneetsharma728 in forum Symbian
    Replies: 2
    Last Post: 2007-02-25, 00:19
  4. creating menu and sub menu
    By hasiamar in forum Symbian User Interface
    Replies: 3
    Last Post: 2006-10-23, 16:21
  5. Which phones can I program when I want to use Bluetooth
    By tvollmer in forum Bluetooth Technology
    Replies: 1
    Last Post: 2003-09-03, 19:16

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×