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

K3Engraver ACK handling wrong? #200

Open
mgmax opened this issue Dec 22, 2023 · 0 comments
Open

K3Engraver ACK handling wrong? #200

mgmax opened this issue Dec 22, 2023 · 0 comments
Labels

Comments

@mgmax
Copy link
Collaborator

mgmax commented Dec 22, 2023

The code for the ACK handling of K3Engraver looks wrong.

I would have expected the following behavior in waitForACK():

  • wait until the expected ACK response is received or a timeout occurs
  • on timeout, raise an Exception so that the whole lasercutting process stops

The actual code does the following:

In the standard case, waitForACK() waits for 0x09 ("OK") and then returns this value to the caller.
If it does not receive this value after several tries, then it simply returns whatever byte was received last, or 0 if nothing was received at all.

while (trys < WAIT_FOR_ACK_RETRIES)
{
Thread.sleep(WAIT_FOR_ACK_TIME);
trys++;
rec = inStream.read(inBuf);
if (inBuf[0] == (byte) 0x09)
{
return rec;
}
}
System.out.println("ACK Timeout");
return rec;
}

On timeout, only a warning is printed but the code does not seem to react to the timeout in most cases.

In most cases the return value of waitForACK() is ignored.
In rare cases the code checks for a return value of 1 (not 0x09!) and does something special.

protected int sendHomeCommand() throws IOException, Exception
{
int ret = send4ByteCommand((byte) 0x17);
if (ret == 1)
{
head_abs_pos_x = 0;
head_abs_pos_y = 0;
}

I don't have such a lasercutter. Maybe @mariolukas can help?

@mgmax mgmax added the bug label Dec 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant