2

I'm having problems with my raspberry pi 3b. I will try to explain it in the best way, I have several raspy working with a script in python that I did, in the script it establishes a communication to android. The problem is that in some boards (raspy 3) it works without problems but in others (raspy 3b) after a while it stops working the wifi module, but the raspy is still working correctly, for example, I try to do "ifconfig" and it does not return anything, not even error. The crazy thing is that if I do not run my script the wifi never fails. The only clue I got is that when doing a dmesg the last line returns me "mmc1: Timeout waiting for hardware interrup"

I copy part of my script in case it helps.

    cmd = 'ifconfig wlan0 up'
    error = os.system(cmd)
    if not error:
        print "WiFI OK"
        if not error:
            cmd = "ifup wlan0"
            error = os.system(cmd)

wifi_connected = False

ip = 0

# Wifi Library

def desconecto_wifi(ssid, password=None):
    scheme = savewpa.SchemeWPA('wlan0', ssid, {"ssid": "\"" + ssid + "\"", "psk": "\"" + password + "\""})
    scheme.delete()


def conectar_wifi(ssid, password=None):
    exito = False

    try:
        subprocess.check_output("nmcli", shell = True)
        print "NMCLI"
        try:
            oldip = get_ip_address('wlan0')
        except:
            oldip = 0
        if password =="":
            cmd = "nmcli dev wifi connect '%s'"%(ssid)
        else:
            cmd = "nmcli dev wifi connect '%s' password '%s'"%(ssid,password)
        try:
            exito = False
            subprocess.check_output(cmd, shell=True)
            print "Sin error cambio conexion"
            #time.sleep(1)
            old_time = time.time()
            tiempo = time.time()
            while (tiempo - old_time) < 5:
                tiempo = time.time()
                try:
                    ip = get_ip_address('wlan0')
                    print ip, oldip

                    if ip!=oldip:
                        exito = True
                        break
                except Exception as e:
                    print (e)

##                try:
##                    socket_servidor = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
##                    print ip
##                    socket_servidor.bind((ip, 5000))
##                    socket_servidor.setblocking(0)
##
##                    socket_servidor.listen(1)
##                    inputs.append(socket_servidor)
##                except:
##                    log.write("Wifi Failed")
##                    print "Wifi Failed"


            return exito

        except:
            print "Con error cambio conexion"
            exito = False
            #time.sleep(1)

            old_time = time.time()
            tiempo = time.time()
            while (tiempo - old_time) < 5:
                tiempo = time.time()
                try:
                    ip = get_ip_address('wlan0')
                    print ip, oldip

                    if ip!=oldip:
                        exito = True
                        print "Encontro"
                        break
                except Exception as e:
                    print (e)

##                try:
##                    socket_servidor = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
##                    print ip
##                    socket_servidor.bind((ip, 5000))
##                    socket_servidor.setblocking(0)
##
##                    socket_servidor.listen(1)
##                    inputs.append(socket_servidor)
##                except:
##                    log.write("Wifi Failed")
##                    print "Wifi Failed"

            print "aca"
            return exito

    except:
        print "No NMCLI"
        if password == "":
            print "No Password"
            scheme = savewpa.SchemeWPA('wlan0', ssid, {"ssid": "\"" + ssid + "\"", "key_mgmt": "NONE"})
        else:
            scheme = savewpa.SchemeWPA('wlan0', ssid, {"ssid": "\"" + ssid + "\"", "psk": "\"" + password + "\""})
        scheme.grabar()

        for i in range(3):
            command = ('wpa_cli reconfigure')
            os.system(command)
            print "CONFIGURANDO WPA"
            time.sleep(1)
            try:
                ip = get_ip_address('wlan0')
                exito = True
                break
            except:
                print ("ERROR CONEXION")
                exito = False

    return exito

    def get_ip_address(ifname):
        s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
        return socket.inet_ntoa(fcntl.ioctl(
            s.fileno(),
            0x8915,  # SIOCGIFADDR
            struct.pack('256s', ifname[:15])
        )[20:24])


I hope you can help me. regards

  • Sorry but I don't see how your problem could be diagnosed remotely using the information provided. We don't even know that is the difference between the boards that work and the boards that don't. – Dmitry Grigoryev Mar 6 at 16:53
  • What script is there running? – Ingo Mar 7 at 9:28
  • Excuse me if I did not do well my question is the first time I ask in a forum. The boards in which they fail are raspi 3b, in raspi 3 it works correctly. The script is quite extensive but I can post it. Thanks! – Juan Gasulla Mar 7 at 13:29
1

If your router doesn't have MIMOMU(multi input multi output multi user)(it means that the devices connected to the router don't have to 'take turns') then it could be that it takes too long for the router to get around to communicating with the pi's. It would have to process more requests when the script is running. Unfortunately, there is no way round this that I know of other than disconnecting some boards or upgrading to router that does have MIMOMU.

  • And there is no MIMOMU on the router when the script is not running on the client? – Ingo Mar 7 at 9:26
  • It would have to process more requests when the script is running – ThisRandomGuy Mar 7 at 9:47
  • And this will block the hardware interrupt on the client? – Ingo Mar 7 at 9:57
  • If there is no reason to interrupt it won't. – ThisRandomGuy Mar 7 at 10:38
  • Of course, that's trivial and isn't a meaningful answer, something like 1=1. I cannot see a reason on the router that will trigger a hardware interrupt on the client. Please explain it to me: what is this reason? – Ingo Mar 7 at 18:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.