Example #1
0
        // TODO Delete this. This was an old implementation of sending ROM to Intellicart.
#if IMPLEMENT_DOWNLOAD
        /// <summary>
        /// Loads the ROM at the given path onto the Intellicart.
        /// </summary>
        /// <remarks>The ROM at <paramref name="romPath"/> must be in the .rom format
        /// specified by the Intellicart documentation.</remarks>
        public void DownloadRom(string romPath)
        {
            using (var rom = FileUtilities.OpenFileStream(romPath))
            {
                using (var port = new SerialPortConnection(SerialPort))
                {
                    port.Port.BaudRate = BaudRate;
                    port.WriteTimeout  = Timeout;
                    // default port settings are 8,N,1 with no handshaking
                    port.Open();
                    rom.CopyTo(port.WriteStream);

                    // If we close the port too soon after writing, the Intellicart
                    // will time out reading data from the stream. This is likely
                    // due to buffering, and that the streams get disposed when
                    // the port and file streams are disposed.
                    System.Threading.Thread.Sleep(4000);
                }
            }
        }