mute console with USB Serial connection

Posted on
  • 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){
      } else if (indelay > 1 && indelay < 3) {
      } else if (indelay > 3) {
        digitalWrite(LED2, 1); // it's ON after power on, so need to put OFF in init
        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,

    short: B01

    longer: B02


    <- Serial1
    Uncaught InternalError: setDeviceClockCmd: Unknown Device 752
     at line 31 col 20
    in function "echoOut" called from line 1 col 26
    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.

  • Thanks - I just tried this, and it seems to be a bug in the firmware.

    It seems you can work around it by changing USB.setConsole(); to try { USB.setConsole(); } catch(e) {}. However I have just fixed it so it'll be in the 'cutting edge' builds, or 1v97

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

mute console with USB Serial connection

Posted by Avatar for 7oo1er @7oo1er