Hi,
I'm creating a thread in my python android application which reads and writes to Bluetooth. Bluetooth functionality is obtained through Pyjnius. Everything works OK, but when the thread closes I get the message:
native thread exited without detaching.
If I don't use Pyjnius, the thread opens and closes without problem.
I get the following output when the thread closes:
V/BluetoothSocket.cpp(10961): availableNative
V/BluetoothSocket.cpp(10961): abortNative
V/BluetoothSocket.cpp(10961): ...asocket_abort(57) complete
V/BluetoothSocket.cpp(10961): destroyNative
V/BluetoothSocket.cpp(10961): ...asocket_destroy(57) complete
D/dalvikvm(10961): threadid=13: thread exiting, not yet detached (count=0)
D/dalvikvm(10961): threadid=13: thread exiting, not yet detached (count=1)
E/dalvikvm(10961): threadid=13: native thread exited without detaching
E/dalvikvm(10961): VM aborting
F/libc (10961): Fatal signal 11 (SIGSEGV) at 0x00bed330 (code=13805624)
I/DEBUG (10957): SET
I/DEBUG (10957): *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
I/DEBUG (10957): Build fingerprint: 'samsung/espressorfxx/espressorf:4.0.4/IMM76D/P3100XWBLJ1:user/release-keys'
I/DEBUG (10957): pid: 10961, tid: 10979 >>> org.kivy.pygame:python <<<
I/DEBUG (10957): signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr deadd00d
I/DEBUG (10957): r0 00000000 r1 00be2e58 r2 00000000 r3 00000000So my questions are:
Can you post the code you're running?
Regards
--
You received this message because you are subscribed to the Google Groups "PyJNIus development ML" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pyjnius-dev...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
from kivy.lang import Builder from kivy.app import App from kivy.logger import Logger import time import threading from jnius import autoclass BluetoothAdapter = autoclass('android.bluetooth.BluetoothAdapter') BluetoothDevice = autoclass('android.bluetooth.BluetoothDevice') BluetoothSocket = autoclass('android.bluetooth.BluetoothSocket') UUID = autoclass('java.util.UUID') dev_name = 'DEWALD-PC' strUUID = '94f39d29-7d6d-437d-973b-fba39e49d4ee' class CommLinkAndroidBT(object): def __init__(self, dev_name, strUUID): self.dev_name = dev_name self.strUUID = strUUID self.open() def open(self): paired_devices = BluetoothAdapter.getDefaultAdapter().getBondedDevices().toArray() for device in paired_devices: if device.getName() == self.dev_name: self.socket = device.createRfcommSocketToServiceRecord(UUID.fromString(self.strUUID)) self.send_stream = self.socket.getOutputStream() self.socket.connect() def write(self, mesg): self.send_stream.write(mesg) self.send_stream.flush() #necessary? def close(self): self.socket.close() Logger.info('closing') class UpdateThread(threading.Thread): def __init__(self, threadID, name, driver): threading.Thread.__init__(self) self.exitFlag = False self.commLink = CommLinkAndroidBT(dev_name, strUUID) def run(self): while not self.exitFlag: self.commLink.write("A") time.sleep(1) self.commLink.close() if __name__ == '__main__': kv = ''' BoxLayout: Button: text: 'Disconnect' on_release: app.disconnect() ''' class Bluetooth(App): def on_start(self): self.updateThread = UpdateThread(1, "UpdateThread", self) self.updateThread.start() def build(self): return Builder.load_string(kv) def disconnect(self): Logger.info('Calling disconnect') self.updateThread.exitFlag = True self.updateThread.join() Bluetooth().run()
--
You received this message because you are subscribed to a topic in the Google Groups "PyJNIus development ML" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/pyjnius-dev/lCxC4If2Sbg/unsubscribe.
To unsubscribe from this group and all its topics, send an email to pyjnius-dev...@googlegroups.com.