/// <summary> /// Write specified report type to target and fill rts with parsed response /// </summary> /// <param name="r">Report type</param> /// <param name="rts">Target</param> /// <returns>Return code</returns> private ReturnCode internalGetStatus(PhoenixStatusRequests r, StatusReport rts) { // PP-82 : Phoenix does not support the error status command if (r == PhoenixStatusRequests.ErrorStatus) { return(ReturnCode.UnsupportedCommand); } // Send the real time status command, r is the argument var command = new byte[] { 0x10, 0x04, (byte)r }; int respLen = 1; var data = new byte[0]; try { Connection.Open(); var written = Connection.Write(command); System.Threading.Thread.Sleep(250); // Collect the response data = Connection.Read(respLen); } catch { /* Do nothing */ } finally { Connection.Close(); } // Invalid response if (data.Length != respLen) { return(ReturnCode.ExecutionFailure); } switch (r) { case PhoenixStatusRequests.Status: // bit 3: 0- online, 1- offline rts.IsOnline = (data[0] & 0x08) == 0; break; case PhoenixStatusRequests.OffLineStatus: // bit 6: 0- no error, 1- error rts.HasError = (data[0] & 0x40) == 0; break; case PhoenixStatusRequests.ErrorStatus: // bit 3: 0- okay, 1- Not okay rts.IsCutterOkay = (data[0] & 8) == 0; // bit 5: 0- No fatal (non-recoverable) error, 1- Fatal error rts.HasFatalError = (data[0] & 8) == 0; // bit 6: 0- No recoverable error, 1- Recoverable error rts.HasRecoverableError = (data[0] & 0x40) == 1; break; case PhoenixStatusRequests.PaperRollStatus: // bit 5,6: 0- okay, 96- Not okay rts.IsPaperPresent = (data[0] & 0x60) == 0; break; default: rts.IsInvalidReport = true; break; } return(ReturnCode.Success); }