Exemplo n.º 1
0
 /// <summary>
 /// </summary>
 /// <param name="c">the byte received</param>
 public void SignalRecievedChar(byte c)
 {
     // TODO: DAVIDM: we don't really have timeout support in here anymore
     if ((curStewieState == stewieState.waitForStewieAck) && (c == syncChar))
     {
         // Send the header
         UpdateMessage("SendStewieFile -> Downloading " + stewFile.FileName + " (" + stewFile.FileSize + " bytes)");
         this.SendBytes(StewieFile.Header());
         curStewieState = stewieState.waitForHeaderAck;
     }
     else if ((curStewieState == stewieState.waitForHeaderAck) && (c == '{'))
     {
         // Send the first record
         this.nRecordIndex = 0;
         this.SendBytes(stewFile.GetRecord(nRecordIndex));
         curStewieState = stewieState.waitForRecordAck;
     }
     else if ((curStewieState == stewieState.waitForRecordAck) && (c == '~'))
     {
         this.nRecordIndex++;
         if (this.nRecordIndex < stewFile.RecordCount)
         {
             this.SendBytes(stewFile.GetRecord(nRecordIndex));
         }
         else
         {
             this.SendBytes(StewieFile.Footer());
             curStewieState = stewieState.waitForFooterAck;
         }
     }
     else if ((curStewieState == stewieState.waitForFooterAck) && (c == '}'))
     {
         // We are done
         this.UpdateMessage("SendStewieFile -> Download complete!!!");
         this.eTransferComplete();
     }
     else
     {
         UpdateMessage("SignalReceivedChar in state " + curStewieState + " unexpectedly received " + c);
     }
 }
Exemplo n.º 2
0
 //private byte[] StewieBytes = { (byte)'@', (byte)'#', (byte)'~', (byte)'!', (byte)'}', (byte)'{' };
 /// <summary>
 /// Initializes the stewiefile to be sent.
 /// </summary>
 /// <param name="fileName">the name of the .icr file</param>
 /// <param name="image">the .icr file's bytes</param>
 /// <param name="syncChar">the character recieved in synchronization</param>
 public StewieFileSender(string fileName, byte[] image, char syncChar)
 {
     this.stewFile = new StewieFile(fileName, image);
     this.syncChar = syncChar;
 }