×

Discussion Board

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

    Obex permission denied

    I was trying following code to create temporary files and send it between phones. I have avoided RFCOMM specifically for the purposes of my project.

    http://pastebin.com/f34c4f676

    I ask user to enter the text message. Save it in a temporary file and then send it to other phone using obex. I got the error
    Code:
    socket.error (13, 'Permission denied')
    I have saved the temporary file in E:\\Images folder to avoid the clash with directory permissions. However I am using 2nd edition devices which do not require special capabilities.

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

    Re: Obex permission denied

    I figured it out. I have to close the file before sending it. But this has given me another problem.

    How do I use inbox to recieve files sent using OBEX. I can use bt_obex_recieve_file() but this is a blocking call and and whole application freezes. I want to keep the application alive while waiting for network messages. How do I do this?

  3. #3
    Regular Contributor
    Join Date
    Mar 2003
    Location
    UK
    Posts
    125

    Re: Obex permission denied

    Quote Originally Posted by ra.ravi.rav View Post
    I can use bt_obex_recieve_file() but this is a blocking call and and whole application freezes. I want to keep the application alive while waiting for network messages. How do I do this?
    Depends if the bt_obex_recieve_file() will work with a socket which has been set non-blocking. If not, you'll have to run it blocking in another thread. If you choose the latter approach, make sure you create the socket in the same thread which calls bt_obex_recieve_file().

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

    Sending/Reieveing simultaneoulsy using bluetooth

    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
    Last edited by ra.ravi.rav; 2009-03-21 at 12:03. Reason: change of topic

  5. #5
    Regular Contributor
    Join Date
    Mar 2003
    Location
    UK
    Posts
    125

    Re: Sending/Reieveing simultaneoulsy using bluetooth

    Quote Originally Posted by ra.ravi.rav View Post
    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.
    Please post the code which you're having problems with.

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

    Re: Sending/Reieveing simultaneoulsy using bluetooth

    Here is the code:

    http://pastebin.com/f4a84e11c

    The problem is again the same when I select the option to send the message, ans its the permission denied error. However when in the line 15 I change the channel to 9 which is the standard OBEX Object Push service it works fine, but the messages are tranferred to inbox whose contents I cannot read.

    P.S. threading module is taken from the desktop version of python and installed as lib module.

  7. #7
    Regular Contributor
    Join Date
    Mar 2003
    Location
    UK
    Posts
    125

    Re: Sending/Reieveing simultaneoulsy using bluetooth

    Quote Originally Posted by ra.ravi.rav View Post
    The problem is again the same when I select the option to send the message, ans its the permission denied error. However when in the line 15 I change the channel to 9 which is the standard OBEX Object Push service it works fine, but the messages are tranferred to inbox whose contents I cannot read.
    Sadly I don't have two S60 devices to test on, unless there's some way I can get my phone to connect to itself via Bluetooth. It might be that you have to bypass OBEX, and use the low-level RFCOMM interface.

    With regards to the threading issue, you can 'kill' one thread from another like this:

    Code:
    import e32, thread
    
    def thread1():
        global thread2running
        thread2running = True
        thread.start_new_thread(thread2, ())
        e32.ao_sleep(5)
        thread2running = False
    
    def thread2():
        global thread2running
        while thread2running:
            do_something()
    
    thread1()

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

    Re: Sending/Reieveing simultaneoulsy using bluetooth

    import e32, thread

    def thread1():
    global thread2running
    thread2running = True
    thread.start_new_thread(thread2, ())
    e32.ao_sleep(5)
    thread2running = False

    def thread2():
    global thread2running
    while thread2running:
    do_something()

    thread1()
    How do I kill the thread this way? Because do_something() is a blocking wait to receieve the data. So the while loop's condtition is not checked next time.

  9. #9
    Regular Contributor
    Join Date
    Mar 2003
    Location
    UK
    Posts
    125

    Re: Sending/Reieveing simultaneoulsy using bluetooth

    Quote Originally Posted by ra.ravi.rav View Post
    How do I kill the thread this way? Because do_something() is a blocking wait to receieve the data. So the while loop's condtition is not checked next time.
    Simple answer: you can't.

    There is no way to forcibly kill a thread in Python. And even if there were, it's generally not a good idea to do so.

    However, as I said before, I don't think you can achieve what you want with the OBEX protocol, so it's a non-issue.
    Use the low-level interface with non-blocking IO, and you won't even need to start a new thread. There's an example in http://wiki.opensource.nokia.com/ima..._PyS60_1_2.pdf.

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

    Re: Sending/Reieveing simultaneoulsy using bluetooth

    Well I can't understand the code! Can you please help.

  11. #11
    Regular Contributor
    Join Date
    Mar 2003
    Location
    UK
    Posts
    125

    Re: Sending/Reieveing simultaneoulsy using bluetooth

    Quote Originally Posted by ra.ravi.rav View Post
    Well I can't understand the code! Can you please help.
    I'm still trying to get a working solution. There seem to be some bugs in non-blocking IO.

    In the meantime, have a look at: http://discussion.forum.nokia.com/fo...83&postcount=2.

Similar Threads

  1. Replies: 8
    Last Post: 2011-06-29, 06:34
  2. java.lang.SecurityException: Permission Denied -- btgoep
    By lamyici in forum Mobile Java Networking & Messaging & Security
    Replies: 20
    Last Post: 2010-07-13, 13:56
  3. why socket connect function return 13(EACCES)/* Permission denied */
    By bigbencat in forum Symbian Networking & Messaging (Closed)
    Replies: 2
    Last Post: 2007-09-21, 02:46
  4. Permission denied
    By manugarrote in forum Symbian
    Replies: 4
    Last Post: 2007-05-29, 23:25
  5. Permission Denied
    By saiful_nokia in forum Symbian
    Replies: 1
    Last Post: 2007-01-17, 08:21

Posting Permissions

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