public void ProcessResponse(char[] response) { // check that the first two chars are 'M' and 'S' if (response[0] != Command[0] || response[1] != Command[1]) { throw new SweepProtocolErrorException("Expected answer to MS command, received different header", response); } // validate the checksum if (!SweepProtocolHelpers.StatusChecksumValid(response)) { throw new SweepProtocolErrorException("Checksum is not valid", response); } // check if the echoed motor speed code matches what we sent var echoedSpeedcode = (SweepMotorSpeed)SweepProtocolHelpers.AsciiBytesToInt(response, 2, 2); if (echoedSpeedcode != this.TargetSpeed) { throw new SweepProtocolErrorException("Echoed speed code missmatched", response); } // analyze the status this.Status = (AdjustMotorSpeedResult)SweepProtocolHelpers.AsciiBytesToInt(response, 5, 2); }
public void ProcessResponse(char[] response) { // check that the first two chars are 'M' and 'Z' if (response[0] != Command[0] || response[1] != Command[1]) { throw new SweepProtocolErrorException("Expected answer to IV command, received different header", response); } // decode the frame this.Model = new string(response, 2, 5); this.ProtocolVersion = SweepProtocolHelpers.AsciiBytesToInt(response, 7, 2) / 10.0f; this.FirmwareVersion = SweepProtocolHelpers.AsciiBytesToInt(response, 9, 2) / 10.0f; this.HardwareVersion = SweepProtocolHelpers.AsciiBytesToInt(response, 11, 1); this.SerialNumber = SweepProtocolHelpers.AsciiBytesToInt(response, 12, 8); }
public void ProcessResponse(char[] response) { // check that the first two chars are 'M' and 'Z' if (response[0] != Command[0] || response[1] != Command[1]) { throw new SweepProtocolErrorException("Expected answer to LI command, received different header", response); } // decode the status var speedInfo = SweepProtocolHelpers.AsciiBytesToInt(response, 2, 2); if (speedInfo < 1 && speedInfo > 3) { throw new SweepProtocolErrorException("Received sample rate info is out of range ([1;3])", response); } this.SampleRate = (SweepSampleRate)speedInfo; }
public void ProcessResponse(char[] response) { // check that the first two chars are 'M' and 'Z' if (response[0] != Command[0] || response[1] != Command[1]) { throw new SweepProtocolErrorException("Expected answer to MZ command, received different header", response); } // decode the status var speedInfo = SweepProtocolHelpers.AsciiBytesToInt(response, 2, 2); if (speedInfo < 0 && speedInfo > 11) { throw new SweepProtocolErrorException("Received speed info is out of range ([0;10]Hz)", response); } this.MotorSpeed = (SweepMotorSpeed)speedInfo; }
public void ProcessResponse(char[] response) { // check that the first two chars are 'M' and 'Z' if (response[0] != Command[0] || response[1] != Command[1]) { throw new SweepProtocolErrorException("Expected answer to ID command, received different header", response); } // decode the frame this.SerialBitrate = SweepProtocolHelpers.AsciiBytesToInt(response, 2, 6); this.LaserState = SweepProtocolHelpers.AsciiByteToChar(response, 8); this.Mode = SweepProtocolHelpers.AsciiByteToChar(response, 9); this.Diagnostic = SweepProtocolHelpers.AsciiByteToChar(response, 10); var speedInfo = SweepProtocolHelpers.AsciiBytesToInt(response, 11, 2); if (speedInfo < 0 && speedInfo > 11) { throw new SweepProtocolErrorException("Received speed info is out of range ([0;10]Hz)", response); } this.MotorSpeed = (SweepMotorSpeed)speedInfo; this.SampleRate = SweepProtocolHelpers.AsciiBytesToInt(response, 13, 4); }