Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #8: WebSerial Communication Issues with Ender 3 v2 #9

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

nkymut
Copy link

@nkymut nkymut commented Dec 6, 2024

Changes Made

  1. Added async port handling

    • New connectPrinter() method for explicit connection
      • Clearer API for connecting to printer (fab.connectPrinter())
    • added async/await for port opening
    async connectPrinter() {
      try {
        await this.serial.requestPort();
        // Port selection triggers portavailable event handler
      } catch (err) {
        console.error("Failed to request port:", err);
        this.emit("error", err);
      }
    }
  2. Improved port opening event handlers

    • Convert callbacks to async/await
    • Added error handling
    this.serial.on("portavailable", async () => {
      try {
        await this.serial.open({ baudRate: this.baudRate });
        console.log("Port opened successfully");
      } catch (err) {
        console.error("Failed to open port:", err);
      }
    });
  3. Added a message buffer for command queue management

    • Clear command buffer after copying
    this.commandStream = [...this.commands];
    this.commands = []; // Clear commands after copying
  4. Improved message processing

    • Added basic logging for received messages
    • Added handlers for responses
    • Fixed position reporting parsing

Testing

Tested with Ender 3 v2:

  • Connection process
  • Control panel example
  • Multiple commands execute in sequence
  • Position reporting works throughout operation
  • Auto-home and movement commands
  • Nozzle and headbed temp control
  • midi thingy
  • fabscribe

Fixes #8

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

WebSerial connection not working with Ender 3 v2
1 participant