Uncaught SyntaxError: Got EOF expected

Posted on
  • Hello,

    I'm having trouble getting any Wifi examples to work. I know I had similar examples working a few years ago but now when I try I have no luck. I can apply simple programs to read pins and flash LEDs but I was wanting to add more.

    https://www.espruino.com/WiFi#using-wifi

    I've simplified it to this for now with an old spare router and no password...

    var WIFI_NAME = "dlink";
    var WIFI_OPTIONS = { password : "" };
    
    var wifi = require("Wifi");
    wifi.connect(WIFI_NAME, WIFI_OPTIONS, function(err) {
      if (err) {
        console.log("Connection error: "+err);
        return;
      }
      console.log("Connected!");
      getPage();
    });
    

    Here's the error I get once the above is uploaded to the Espruino Wifi. But I don't have 42 lines of code.

    
    Uncaught SyntaxError: Got EOF expected '}'
     at line 42 col 112
    ...cted:p,socks:f,sockData:k}}
                                  ^
    Uncaught Error: Can't read property 'connect' of undefined
     at line 5 col 5
    wifi.connect(WIFI_NAME, WIFI_OPTIONS, function(err) {
        ^
    

    I flashed the board to 2v25 and it's an Espruino Wifi. I have verified that the Wifi module is on it.

    I have also tried to re-flash the built in ESP8266 with Chrome and the Web IDE version 0.79.10.
    This was with the built in flasher but I ran into the sync error even after trying a 2nd cable. It currently has v 0.40.0.
    Here's two images of that. Images are attached since I don't think attaching inline is working for me.

    So then I tried this method: https://www.espruino.com/WiFi#advanced-esp8266-reflashing
    This shows what I get for output from that...

    C:\Users\Owner\Downloads\espruino>esptool.py --no-stub --port COM3 --baud 74880 write_flash --flash_mode dio 0 AiThinker_ESP8266_DIO_32M_32M_20160615_V1.5.4.bin
    esptool.py v2.0
    Traceback (most recent call last):
      File "C:\Users\Owner\Downloads\espruino\esptool.py", line 2405, in <module>
        _main()
        ~~~~~^^
      File "C:\Users\Owner\Downloads\espruino\esptool.py", line 2398, in _main
        main()
        ~~~~^^
      File "C:\Users\Owner\Downloads\espruino\esptool.py", line 2117, in main
        operation_args,_,_,_ = inspect.getargspec(operation_func)
                               ^^^^^^^^^^^^^^^^^^
    AttributeError: module 'inspect' has no attribute 'getargspec'. Did you mean: 'getargs'?
    

    For this I've put the esptool.py files and bin file in the directory

    C:\Users\Owner\Downloads\espruino 
    

    and then ran this command...

    esptool.py --no-stub --port COM3 --baud 74880 write_flash --flash_mode dio 0 AiThinker_ESP8266_DIO_32M_32M_20160615_V1.5.4.bin
    

    I'm looking for suggestions of what to try next. ChatGPT can only do so much.
    Cheers,
    Robin


    2 Attachments

    • Screenshot_540.jpg
    • Screenshot_541.jpg
  • Sorry, I'm just looking into this and it appears to be a problem in the 2v25 build - probably related to our switch to using pretokenised modules. I'm amazed I didn't spot it. I'll try and get a fix in in the next few hours.

    In the mean time if you install 2v24 by pasting the link https://www.espruino.com/binaries/espruino_2v24_wifi.bin in on the Web IDE's flasher page that should fix it. You shouldn't have to worry about updating the ESP8266 firmware

    I tried with your code and the following getPage and it seems to work ok on 2v24:

    function getPage() {
      require("http").get("http://www.pur3.co.uk/hello.txt", function(res) {
        console.log("Response: ",res);
        res.on('data', function(d) {
          console.log("--->"+d);
        });
      });
    }
    
  • Ok, just fixed. I've fixed it in cutting edge builds but have also updated the 2v25 wifi firmware to the cutting edge build, so folks trying to upgrade won't end up with broken firmwares.

  • Works now, thanks.

  • Post a reply
    • Bold
    • Italics
    • Link
    • Image
    • List
    • Quote
    • code
    • Preview
About

Uncaught SyntaxError: Got EOF expected

Posted by Avatar for robins @robins

Actions