4refr0nt / ESPlorer

Integrated Development Environment (IDE) for ESP8266 developers
http://esp8266.ru/esplorer/
GNU General Public License v2.0
1.22k stars 327 forks source link

How does the autodetect work? #49

Closed jhoogeboom closed 7 years ago

jhoogeboom commented 7 years ago

I'm having a bit of trouble getting ESPlorer to autodetect my NodeMCU firmware, what is the expected handshake? It seems to be a caret distance of more than 10? The thing is, this only seems to happen when the device is restarted, not when opening the port. So when opening the port it just hangs unless resetted. Unless autodetect is disabled, then it works fine. I'm a bit new, in earlier versions upon opening the port it printed out the firmware version?

This seems to be the section responsible for autodetecting the firmware:

public void CheckComm() {
        if (!AutodetectFirmware.isSelected()) {
            portJustOpen = false;
            return;
        }
        portJustOpen = true;
        TerminalAdd("\r\nCommunication with MCU..");
        checker = new ActionListener() {
            public void actionPerformed(ActionEvent evt) {
                if (portJustOpen) {
                    btnSend("");  // only CR+LF
                    TerminalAdd(".");
                    if (Terminal.getCaretOffsetFromLineStart() >= 10) {
                        TerminalAdd("\r\n");
                    }
                } else {
                    try {
                        openTimeout.stop();
                    } catch (Exception e) {
                        log(e.toString());
                    }
                }
            }
        };
        openTimeout = new Timer(3000, watchDog);
        openTimeout.setRepeats(false);
        openTimeout.setInitialDelay(3000);
        openTimeout.start();
    }

This is the 'error' message I'm getting:

PORT OPEN 115200

Communication with MCU..<this is the point I've resetted!>Got answer! Communication with MCU established.
AutoDetect firmware...

Can't autodetect firmware, because proper answer not received (may be unknown firmware). 
Please, reset module or continue.
lnn���bp�lrlrlp�n��lbn�|�l�|��b��nn�l��l`�nnl`nr���nr��`p�n�r�����bn�|���b��nn�l`�nnl�l`nr���nbl``�n��b�nl���nn��lp�n�r�����l�bn�|b��nn�l�l`�nnl`nr���n��lr��n��l����n��r��n|�llll`��r�l�l��

NodeMCU 1.5.4.1 build unspecified powered by Lua 5.1.4 on SDK 1.5.4.1(39cb9a32)
lua: cannot open init.lua - See more at: http://www.esp8266.com/viewtopic.php?f=23&t=13378#sthash.kMMJglx5.dpuf

So I've resetted the device, otherwise it would hang on the ..

4refr0nt commented 7 years ago
                      if (data.contains("\r\n>>>")) {
                            TerminalAdd("\r\nMicroPython firmware detected, try get version...\r\n\r\n");
                            btnSend("import sys; print(\"MicroPython ver:\",sys.version_info)");
                            LeftTab.setSelectedIndex(0);
                            SetFirmwareType(FIRMWARE_MPYTHON);
                        } else if (data.contains("\r\n>")) {
                            TerminalAdd("\r\nNodeMCU firmware detected.\r\n");
                            btnSend("=node.heap()");
                            LeftTab.setSelectedIndex(0);
                            SetFirmwareType(FIRMWARE_NODEMCU);
                        } else if (data.contains("\r\nERR")) {
                            TerminalAdd("\r\nAT-based firmware detected.\r\n");
                            btnSend("AT+GMR");
                            LeftTab.setSelectedIndex(1);
                            RightExtraButtons.setVisible(false);
                            RightSnippetsPane.setVisible(false);
                            NodeFileManagerPane.setVisible(false);
                            FirmwareType = FIRMWARE_AT;
                        } else {
                            TerminalAdd("\r\nCan't autodetect firmware, because proper answer not received (may be unknown firmware). \r\nPlease, reset module or continue.\r\n");
                        }

We expect lua console \r\n> after firmware start.

jhoogeboom commented 7 years ago

Thanks, that makes sense, any idea why ESPlorer is not finding the \r\n> ? screen /dev/tty.SLAB_USBtoUART 115200 yields a \r\n> just fine when presented a CR+LF

4refr0nt commented 7 years ago

not all version NodeMCU firmware has identical start screen. Early, all version has answer \r\n> on \r\n (empty command), but now not.

jhoogeboom commented 7 years ago

This is on the most recent build of NodeMCU 1.5.4.1, both ESPlorer and screen were used with the same version. ESPlorer hangs, screen does not.

4refr0nt commented 7 years ago

At now many version of NodeMCU with different answers. I can't test ALL versions for his answers, but if you know what you doing then you can make new PR for properly autodetect your version of NodeMCU.

jhoogeboom commented 7 years ago

Sorry I'm not sure where it's going wrong yet, and I understand you can't test all versions. Do you know of a known working NodeMCU firmware version?