• Hello!
    Need to kill any console messages that appear after Serial is open with a terminal app. I reconnect Pico before opening Serial with PuTTY evry time. Used Troubleshooting code, but it works halfway. I need to get "B01" and "B02" messages only, but some errors happened.

    function onInit() {
      setTimeout(function() { Serial1.setConsole(); }, 1000);
      digitalWrite(LED2, 0);
    }
    
    var on = true;
    
    function echoOut(indelay) {
      if (indelay < 1){
        USB.print("B01\r\n");
      } else if (indelay > 1 && indelay < 3) {
        USB.print("B02\r\n");
      } else if (indelay > 3) {
        digitalWrite(LED2, 1); // it's ON after power on, so need to put OFF in init
        USB.setConsole();
        USB.print("move to USB\r\n"); //this stops LED blink if USB Serial is not connected
        console.log("console is moved");
      }}
    
    setInterval(function () {
      on = !on;
      LED1.write(on); // Just to check Pico is alive
    }, 500);
    
    setWatch(function (e) {echoOut(e.time-e.lastTime);},
      BTN1, { repeat:true,
      edge:'falling'
    });
    
    

    short: B01

    longer: B02

    longest:

    <- Serial1
    Uncaught InternalError: setDeviceClockCmd: Unknown Device 752
     at line 31 col 20
        USB.setConsole();
                       ^
    in function "echoOut" called from line 1 col 26
    echoOut(e.time-e.lastTime);
                                 ^
    in function called from system
    

    Same errors "Unknown Device" I got with and LoopbackA too. Second longest press in same session makes no error, just output "move to USB" and second message.
    So, I got a clean output, and move back to USB is working. But I want to point all that errors.

About

Avatar for 7oo1er @7oo1er started