private byte[] CommandFormation(string command, string data) { DataToPrinter = MHelper.GetByteArrayFromString(data); _seq++; if (_seq == MaxSeq) { _seq = MinSeq; } List <byte> commToPrinter = new List <byte>(); byte leng = (byte)(0x04 + 0x20 + data.Length); commToPrinter.Add(Preamb); commToPrinter.Add(leng); commToPrinter.Add(_seq); commToPrinter.Add(MHelper.StringToByte(command)); byte[] tempByte = MHelper.GetByteArrayFromString(data); commToPrinter.AddRange(tempByte); commToPrinter.Add(Enquiry); tempByte = CsCount(MHelper.ByteListToArray(commToPrinter)); commToPrinter.AddRange(tempByte); commToPrinter.Add(Postamb); CommandToPrinter = MHelper.ByteListToArray(commToPrinter); return(CommandToPrinter); }
private void RefreshData() { if (PortAnswer != null) { DataToHost = DataFromPrinter(PortAnswer); Status = CurrentStatus(PortAnswer); } else { DataToHost = MHelper.GetByteArrayFromString("F,F,F,F,F,F"); Status = _emptyByteArray; } }
private bool ReadPort() { string str = string.Empty; char temp = (char)Syn; if (!ReadAnswerFirstByte(ref temp)) { return(false); } str += temp; str += _port.ReadExisting(); byte[] ans = MHelper.GetByteArrayFromString(str); while (ans[ans.Length - 1] != Terminator) { str += _port.ReadExisting(); ans = MHelper.GetByteArrayFromString(str); } if (!AnswerLenghtCount(ans)) { return(false); } PortAnswer = ans; return(true); }