好的,我有2个Xbee设备可以通信。第一次我从Number1发送数据并运行另一个接受数据的程序并进行打印,然后将其他数据发送回去进行回答。但是Number2数据运行包含回调方法的while循环。而且我的方法是获得无限循环。我该如何避免呢?
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()