public override bool UnPack(IOBuffer buffer) { if (!base.UnPack(buffer)) return false; return true; }
public override bool UnPack(IOBuffer buffer) { if (!base.UnPack(buffer)) return false; PageNumber = (buffer[6] << 21) + (buffer[5] << 14) + (buffer[4] << 7) + buffer[3]; return true; }
public virtual bool UnPack(IOBuffer buffer) { if (!checkSumManager.IsValid(buffer)) return false; if ((buffer[0] != Header) || (buffer[1] != Confirmation) || (buffer[2] != (byte)Regim)) return false; return true; }
public override bool UnPack(IOBuffer buffer) { if (!base.UnPack(buffer)) return false; Lock = (byte)((buffer[4] << 7) + buffer[3]); return true; }
public override bool UnPack(IOBuffer buffer) { if (!base.UnPack(buffer)) return false; if (buffer[3] != ExtendedConfirmation) return false; return true; }
public override bool UnPack(IOBuffer buffer) { if (!base.UnPack(buffer)) return false; ExtendedFuses = (byte)(buffer[3] + ((buffer[6] << 7) & 0x80)); HightFuses = (byte)(buffer[4] + ((buffer[6] << 6) & 0x80)); LowFuses = (byte)(buffer[5] + ((buffer[6] << 5) & 0x80)); return true; }
public override bool UnPack(IOBuffer buffer) { if (!base.UnPack(buffer)) return false; for (int i = 0; i < Request.Length; i++) if (buffer[3 + i] != Request[i]) return false; return true; }
private byte _Calculate(IOBuffer b) { byte checkSum = 0; for (int k = 0; k < b.Size - 1; k++) checkSum ^= b[k]; checkSum &= 0x7F; return checkSum; }
protected bool IfReceived(SerialPortManager sp, ProtocolBase protocol, IOBuffer buffer, SynchronizationContext syncContext) { byte receivedByte; if (sp.ReadByte(out receivedByte)) { switch (step) { case 0: if (receivedByte == protocol.Header) { step++; buffer[counterOfTheReceivedBytes++] = receivedByte; } break; case 1: if ((receivedByte & 0x80) == 0x80) RestartReceiv(); else { buffer[counterOfTheReceivedBytes++] = receivedByte; if (counterOfTheReceivedBytes == buffer.Size) { if (protocol.UnPack(buffer)) { syncContext.Post(delegate { logger.Log(string.Format("Rx: {0}", buffer.ToString()), Category.Debug, Priority.None); }, null); return true; } else RestartReceiv(); } } break; } } return false; }
public override bool UnPack(IOBuffer buffer) { if (!base.UnPack(buffer)) return false; PageNumber = (buffer[6] << 21) + (buffer[5] << 14) + (buffer[4] << 7) + buffer[3]; PageLineNumber = buffer[7]; for (int i = 0; i < PageLine.Size; i++) Line[i] = buffer[8 + i]; for (int m = 0; m < 7; m++) { Line[m] |= (byte)((buffer[24] << (7 - m)) & 0x80); Line[7 + m] |= (byte)((buffer[25] << (7 - m)) & 0x80); } Line[14] |= (byte)((buffer[26] << 7) & 0x80); Line[15] |= (byte)((buffer[26] << 6) & 0x80); return true; }
public override bool UnPack(IOBuffer buffer) { if (!base.UnPack(buffer)) return false; for (int i = 0; i < ConfirmationString.Length; i++) if (buffer[3 + i] != ConfirmationString[i]) return false; Version = Convert.ToInt32(new string(new char[] { (char)buffer[15], (char)buffer[16] })); int day = Convert.ToInt32(new string(new char[] { (char)buffer[17], (char)buffer[18] })); int month = Convert.ToInt32(new string(new char[] { (char)buffer[19], (char)buffer[20] })); int year = 2000 + Convert.ToInt32(new string(new char[] { (char)buffer[21], (char)buffer[22] })); Date = new DateTime(year, month, day); return true; }
public void Calculate(IOBuffer b) { b[b.Size - 1] = _Calculate(b); }
public bool IsValid(IOBuffer b) { return (_Calculate(b) == b[b.Size - 1]); }