UART init error

Posted on
  • Hello,

    I use Epruino Pico version 1.86.

    The source code is made of this unique line of code:

    Serial2.setup(9600, { rx: A3, tx : A2 });

    Running it leads to this error :

    echo(0);
    Uncaught Error: Function "b" not found!
    at line 1 col 9
    Serial2.b(9600,{a:A3,c:A2});

        ^
    

    =undefined

    Same story with:
    Serial2.setup(9600,{rx:A3, tx:A2,bytesize:8,parity:'even',stopbits:­1});

    I feel to be an idiot, since it seems so trivial to use...
    Is this normal ?
    Any advice is welcome.

    Best regards

    GeekBot

  • Try this

    //PICO v1.86
    var baudrate=9600;
    var Port=Serial1;
    //var Port=Serial2;
    Port.setup(baudrate);
    
    //loopback jumper the tx and rx pins together to test
    Port.on('data', function (data) { print("Serial> "+data); });
    Port.print("Hello World");
    
  • Are you using WEBIDE to access the PICO?
    Here's another example using the options:

    //PICO v1.86
    var baudrate=9600;
    var Port=Serial1;
    var P={rx:B7, tx:B6,bytesize:8,parity:'even',stopbits:­1};
    //var Port=Serial2;
    //var P={rx:A3, tx:A2,bytesize:8,parity:'even',stopbits:­1};
    Port.setup(baudrate,P);
    //loopback jumper the tx and rx pins together to test
    Port.on('data', function (data) { print("Serial> "+data); });
    Port.print("Hello World");
    

    The output:

    >echo(0);
    =undefined
    Serial> H
    Serial> e
    Serial> l
    Serial> l
    Serial> l
    Serial> o
    Serial>
    Serial> W
    Serial> o
    Serial> r
    Serial> l
    Serial> d
    > 
    

    1 Attachment

  • Thank you ClearMemory041063,
    Yes, I use WEBIDE to access the PICO
    I did your examples, and I get always the same error, either on Serial1 or on Serial2.
    For example, with the file you attached, on Serial2 the error is:

    Uncaught Error: Function "g" not found!
    at line 1 col 23
    var Port=Serial2;Port.g(9600,{f:A3,i:A2,a:8,­c:"even",h:1});P...

                      ^
    

    =undefined

    Any clue ?
    Thanks a lot
    GeekBot

  • Hello,
    Your question "Are you using WEBIDE to access the PICO?" inpired me to test on another environment.
    The problem is linked to Windows or Chrome on Windows.
    On a Chromium/Linux machine, all the demo codes work perfect.
    I updated the WEBIDE, still the same.
    I run Windows 10 Familly edition and my machine is up to date.
    Version: 1511, OS version: 10586.545
    If you need some more information, just ask.
    Best regards
    GeekBot

  • It looks like the minifier is going berserk and renaming builtin functions. What minification option are you using? Try changing it.

  • It looks like the minifier is going berserk and renaming builtin functions

    Yeah, I reckon you might have gone into settings and turned all the settings up to 'max'?

    Under minification in settings, just turn it all to no minification

  • Hi Guys
    You are right, for reasons I don't know, the minification was set to "max". I set it back to "simple optimizations" and it started to work as expected.
    Thanks a lot
    Regards
    GeekBot

  • Glad that you have found a solution.
    I'm running a Windows 7 system with WebIDE.
    I tried it at all levels of minification with no problem.
    The only way I could get an error is if my phat fingers missed the shift key when typing the pins. b7 instead of B7. I usually run the Esprima (offline) minification.
    I also tried the Serial stuff using the terminal program Putty with positive results.
    Welcome to the Art of computer programming. It's art when variables won't and constants aren't :)

  • Just tried it, and setting normal (not module) minification to:

    Closure (online) - Advanced Minification (not recommended)

    Definitely gives the error. The rest of them are probably fine.

  • Should the max minification option be removed? If it mangles builtin function names like that, it's not usable for even a simple task. Why have a setting that you know isn't usable?

  • In general: If you want to minify a JavaScript program with Google Closure Compiler in "Advanced Minification" mode then you need an *.externs file for every library which is not part of the minification step. The builtin functions are not part of the minification. So an extern file is required. Advanced minification is useless without an externs file.

    I've attached an espruino.externs file which I use for module minification. But it must be built into the WebIDE code to be sent to the minification service.

    I did it for module minification some time ago:
    https://github.com/espruino/EspruinoDocs­/blob/master/bin/minify.js#L18
    https://github.com/espruino/EspruinoDocs­/blob/master/bin/minify.js#L41

    The same simple logic must be built into the WebIDE. Then advanced minification would work there too. But I don't know the source code of the WebIDE. Sorry.


    1 Attachment

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

UART init error

Posted by Avatar for GeekBot @GeekBot

Actions