Ok, I have 2 Xbee devices to communicate. First time I send data from Number1 and run the other program which accepts data and print it, then send back other data to answer. But Number2 data run while loop which contains the callback method. And the way I do is getting an infinite loop. How can I avoid it?
def send(self):
try:
self.currentlocal.open()
remotestr=self.listw.currentItem().text()
li=remotestr.split("-")
xbee_network=self.currentlocal.get_network()
remote=xbee_network.get_device_by_64(XBee64BitAddress.from_hex_string(li[0]))
arr_64=self.currentlocal.get_64bit_addr()
self.currentlocal.send_data_async(remote,str(arr_64)+"-"+str(self.spin.value()))
def my_data_received_callback(xbee_message):
print('has been got back')
data=xbee_message.data.decode()
print(data)
self.loop_check=1
print('..................................')
while(self.loop_check==0):
self.currentlocal.add_data_received_callback(my_data_received_callback)
self.loop_check=0
self.currentlocal.close()
except:
self.currentlocal.close()