fix: correcting proper bit to see when Steppir is moving
This commit is contained in:
@@ -253,10 +253,14 @@ func parseStatus(b []byte) (*Status, error) {
|
||||
freqHz := int(int32(binary.BigEndian.Uint32(b[2:6]))) * 10
|
||||
active := b[6]
|
||||
dir := decodeDir(b[7])
|
||||
// active==0xFF means "command just received" (not motion); the 0x01 bit is
|
||||
// documented as always set. Treat anything else non-zero as motors busy.
|
||||
// active-motors byte: one bit per element that is currently moving.
|
||||
// 0x04 driver · 0x08 DIR1 · 0x10 reflector · 0x20 DIR2 (mask 0x3C)
|
||||
// Bit 0 (0x01) is documented as always set — not a motor. 0xFF means the
|
||||
// controller just received a command, not motion. So "moving" is precisely
|
||||
// "any real motor bit set", ignoring the always-on bit and the ack value.
|
||||
const motorBits = 0x3C
|
||||
moving := 0
|
||||
if active != 0xFF && (active & ^byte(0x01)) != 0 {
|
||||
if active != 0xFF && active&motorBits != 0 {
|
||||
moving = 1
|
||||
}
|
||||
return &Status{Frequency: freqHz / 1000, Direction: dir, MotorsMoving: moving}, nil
|
||||
|
||||
Reference in New Issue
Block a user