コード例 #1
0
 private void FileChannelHandler(byte[] segment)
 {
     if (segment.Length == 3 && Encoding.Default.GetString(segment) == "EOF")
     {
         string file_name = UserAssignedFile.Name;
         Console.WriteLine("Received file with size: {0}", UserAssignedFile.Length);
         UserAssignedFile.Close();
         try
         {
             Task <string> t = FirmwareLoader.RunQuartusCommandAsync($"quartus_pgm -m jtag –o \"p;{file_name}@1\"");
             t.ContinueWith((task) => {
                 File.Delete(file_name);
                 FileCreated = false;
             });
         }
         catch (Exception ex)
         {
             Console.WriteLine("Exception: {0}", ex.Message);
         }
     }
     else
     {
         WriteFileSegment(segment, UserAssignedFile);
     }
 }
コード例 #2
0
        public override void RemoveRemoteControlling(PeerConnection Connection)
        {
            // Removing handler of data channel adding
            Connection.DataChannelAdded -= DataChannelAddedHandler;

            // Closing opened file, destroying Arduino input emulator and Quartus firmware loader
            InputEmulator?.Close();
            UserAssignedFile?.Close();
            FirmwareLoader?.Close();
        }