/// <summary> /// Sends the initial message to a station indicating that it should prepare to be reprogrammed. /// </summary> /// <param name="destinationStationID">The station to reprogram. /// This can be <code>0</code>, which will instruct all stations to prepare for reprogramming.</param> /// <param name="demandrelay">Indicates whether every station should relay the message</param> /// <param name="token"></param> /// <returns></returns> public byte InitUploadToStation(byte destinationStationID, bool demandrelay) { using MemoryStream ms = new MemoryStream(); using BinaryWriter writer = new BinaryWriter(ms, Encoding.ASCII); byte cmdByte = demandrelay ? (byte)('C' | 0x80) : (byte)'C'; var unID = _communicator.GetNextUniqueID(); writer.Write(cmdByte); writer.Write(destinationStationID); writer.Write(unID); writer.Write((byte)'P'); //Programming writer.Write((byte)'B'); //Begin writer.Write((byte)PacketCount); writer.Write((byte)PacketSize); writer.Write((UInt16)CRC); writer.Flush(); var data = AppendCommandCrc(destinationStationID, ms); _communicator.Write(data); return(unID); }