t-oster / LibLaserCut

a platform independant library to control Lasercutters. This is the base library for VisiCut
http://visicut.org
Other
60 stars 55 forks source link

K3Engraver ACK handling wrong? #200

Open mgmax opened 11 months ago

mgmax commented 11 months ago

The code for the ACK handling of K3Engraver looks wrong.

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

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.

https://github.com/t-oster/LibLaserCut/blob/c2bee3a153aa17d48b4e559ee10ab4d816b336eb/src/main/java/de/thomas_oster/liblasercut/drivers/K3EngraverDriver.java#L289-L303

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. https://github.com/t-oster/LibLaserCut/blob/c2bee3a153aa17d48b4e559ee10ab4d816b336eb/src/main/java/de/thomas_oster/liblasercut/drivers/K3EngraverDriver.java#L340-L347

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