package org.reprap.comms.port.testhandlers; import java.io.PipedOutputStream; import org.reprap.comms.snap.SNAPPacket; import org.reprap.devices.GenericStepperMotor; public class TestStepper extends TestDevice { protected boolean notifications = false; public void receivePacket(PipedOutputStream out, SNAPPacket packet) throws Exception { byte payload [] = packet.getPayload(); switch(payload[0]) { case GenericStepperMotor.MSG_GetPosition: reply(out, packet, new byte[] { GenericStepperMotor.MSG_GetPosition, 0, 0 }); return; case GenericStepperMotor.MSG_SetNotification: notifications = (payload[1] != 255); System.out.println("Notifications " + notifications); return; case GenericStepperMotor.MSG_SetSyncMode: case GenericStepperMotor.MSG_SetPower: // Ignore these return; case GenericStepperMotor.MSG_DDAMaster: if (notifications) // For now, just reply with movement completion reply(out, packet, new byte[] { GenericStepperMotor.MSG_DDAMaster, 0, 0 }); return; } super.receivePacket(out, packet); } }