Program not responding PYQT5, when I need it to stand still for a few seconds (WIFI,UART,ESP32)

Asked

Viewed 70 times

1

I am facing the following problem, my program sends when the object, modemlist which is a Qcombobox is in the WIFI option I send a request to the esp show me the available networks and it takes a little, so I have to for a team.Sleep(x) or any way to hold the program so it awaits the answer of esp32, the problem is in the following, it is connected in a following function

self.modemlist.currentIndexChanged.connect(
                        lambda: self.trata_dropmenus(1))

def trata_dropmenus(self, dropmenu):
    print("a")
    #Inicio do tratamento das opções do Modem#
    if (dropmenu == 1):
       text = "Modem: "
       text = text + self.modemlist.currentText()
       if(text == "Modem: Wifi"):
          self.wifiwindow.recebe_serial(self.srch, self.cbport, self.textBrowser_1, self.textBrowser_2, self.textBrowser_3)
          self.wifiwindow.pedelista()
          self.wifiwindow.show()
          

The pedelist() function will send the command to the esp via uart and wait for the answer and that’s what it hangs on, but it shows the screen is not responding but after the esp32 responds I just click on hold and it comes back normally

 self.ser = serial.Serial(
                self.writePort.currentText(), 115200, timeout=3)
 self.ser.write(text.encode())
 packet_not_complete = 1
 tm = time.time()
 while(packet_not_complete!=0):
                try:
                    while(self.ser.in_waiting<=0 and time.time()-tm< 12):
                        print("Is waiting")
                        time.sleep(1)
                    packet_not_complete = 0
                except:
                    pass
self.line = self.ser.readline()
self.line = self.line.decode()
print("Resposta recebida :")
print(self.line)

I tried to create a thread so that it is waiting in the background but there was no difference because it still gave the error of not this responding, the solution I had but just to test was to create a button to ask the wifi list, what worked

self.atualizawifi.clicked.connect(
            lambda: self.pedelista())

Already thank you I am willing to send pictures of the error and etc, if someone can help me understand why I can not do this with the combobox, and if there is some way I thank you

Note: The pedelista function, is in the wifi class that I put wifiwindow = wifi () it is working perfectly, this actualizwifi button is also within this class

  • Two suggestions: (i) strip Try/except to see if there are any exceptions being generated. Since except is only doing pass, (ii) Use the debug import pdb; pdb.set_trace() and see what’s happening.

  • 1

    HI Paul all right , I did your two tests but they did not solve my problem, I did another test to havaliar how the Qcombbox links work, I made a simple menu list and because linked to a function that would only count time, and from the same error, so for some reason menu lists may not take long in the functions, I decided to exchange for a boot to update wifi even kkkkkkkkkkkkk

  • You don’t need to put "solved" in the title. I know it’s common in many forums, but here it works different. In your case, as you found the solution yourself, just use the field of answers below (the textarea "Your Answer"), and then mark it as accepted, That’s enough to indicate that it’s been resolved.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.