Example #1
0
        /*
         * Methods
         */
        /// <summary>
        /// Writes stewiefile to device
        /// </summary>
        public void SendFile()
        {
            // Sync with receiver
            UpdateMessage("SendFile ->  Sending \'?\' to the target!");
            SendByte((byte)'?');
            curStewieState = stewieState.waitForStewieAck;

            // Then when the receiver responds, we will send the file
        }
Example #2
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);
     }
 }