def findAvailableMicroflySerialPorts(self):
        portsFound = []
        comPorts = list_ports.comports()
        
        for comPort in comPorts:
            try:
                self.debugFunc("Trying: " + comPort[0])
                serialConnection = serial.Serial(comPort[0], 115200, timeout=0.2)
                self.debugFunc("Connected to " + comPort[0])
            except Exception, e:
                self.debugFunc("Could not open port, ignoring")
            else:
                currentProtocolState = mfcore.protocol_create_state_malloc(2048, lambda: None, lambda data:serialConnection.write(chr(data)), lambda: None);
                mfcore.protocol_usb_init(currentProtocolState);
                mfcore.protocol_usb_send_get_device_name(currentProtocolState);
		continueOn = 0
                timeout = 3
                while(continueOn == 0 and timeout > 0):
                    self.yieldFunc()
                    timeout -= 1
                    dataRead = serialConnection.read()
                    dataRead = bytearray(dataRead)
                    for data in dataRead:
                        timeout = 3
                        mfcore.protocol_receive_packet_byte(currentProtocolState, data);
                        if(mfcore.protocol_receive_is_packet_available(currentProtocolState) == 1):
                            if(mfcore.protocol_usb_receive_is_get_settings_response_device_name(currentProtocolState) == 1):
				name = mfcore.protocol_usb_receive_get_settings_response_device_name_get_name(currentProtocolState)
                                portsFound.append(comPort[0] + " (" + name + ")");
                                continueOn = 1
    def pumpUntilPacketAvailable(self):
        if(self.activeSerialConnection == None):
            return 0;
        
        while(1):
            self.yieldFunc()
            dataRead = self.activeSerialConnection.read()
            dataRead = bytearray(dataRead)
            for data in dataRead:
		mfcore.protocol_receive_packet_byte(self.activeProtocolState, data);
		if(mfcore.protocol_receive_is_packet_available(self.activeProtocolState) == 1):
                    return 1;