public void Run() { thisUSB.adjustBaudRate(Parameters.BaudRate_SSL); //InsertCustomParameters(); //load ssl using RAMLoader RAMLoader loadSSL = new RAMLoader(parameters, thisUSB, parameters.SSLfilepath, mf_parent); loadSSL.Run(true); thisUSB.adjustBaudRate(Parameters.BaudRate_SSL); //increase the baud rate 8x, saves six seconds on loading (goes from 14 to 8) mf_parent.UpdateOutputText("Loading production firmware, filename \"" + parameters.FWimagefilename + "\"..."); SSLInterface sslinterface = new SSLInterface(parameters, thisUSB); try { //Read the firmware image into memory and check its length int filesize = 0; byte[] fullfilebuffer = readimagefromfile(parameters.FWimagefilepath, ref filesize); try { sslinterface.SSL_FULLERASE(); //cut this out before giving to controltek, this is here just to clear the hw info pars out while we're debugging. } catch (Exception_Yellow exc) { if (!exc.Message.Contains("retry failed")) throw new Exception_Yellow(exc.Message); //if it's some other exception, don't catch it else sslinterface.SSL_FULLERASE(); //retry once, if the exception comes back again, we won't catch it and it'll go on to be displayed as "retry failed" } LoadFW(sslinterface, fullfilebuffer, filesize); LoadHardwareSettings(sslinterface); Commit(sslinterface, filesize); } catch (Exception_Yellow ey) { if (ey.Message.Contains("CRC")) { mf_parent.UpdateOutputText("Error! Reverting to empty state, do not unplug..."); sslinterface.SSL_FULLERASE(); throw new Exception_Yellow("SSL throws CRC check error; packet was corrupted over UART. Memory has been erased, please try again."); } else if (ey.Message.Contains("Write")) { mf_parent.UpdateOutputText("Error! Reverting to empty state, do not unplug..."); sslinterface.SSL_FULLERASE(); throw new Exception_Yellow("SSL throws write error; write operation fails. Memory has been erased, please try again."); } else throw ey; } thisUSB.adjustBaudRate(Parameters.BaudRate_UARTandTesting); }
private void LoadTestingFirmware() { thisUSB.adjustBaudRate(Parameters.BaudRate_UARTandTesting); //thisUSB.adjustBaudRate(Parameters.loadingBaudRate); //increase the baud rate 8x, saves about 2 seconds on loading UpdateOutputText("Loading testing firmware..."); RAMLoader loadZTC = new RAMLoader(parameters, thisUSB, parameters.ZTCfilepath, this); loadZTC.Run(false); UpdateProgressBar_Overall(38); System.Threading.Thread.Sleep(10); //for some reason this is necessary or else radio test fails, don't know why :-/ thisUSB.adjustBaudRate(Parameters.BaudRate_UARTandTesting); //return to baud rate that the ZTC is written for for testing. consider speeding ZTC up later and testing to see if it affects quality/speed. }
//THIS IS THE MAIN CODE THAT RUNS WHEN THE BUTTON IS CLICKED public void MainProcess() { int BufferErrorIncrementer = 0; GoToForBufferingErrorRetry: try { Setup(); ReadCounterID(); CheckRequirements(); //check that necessary stuff is plugged in ReadBarcode(); //come back to this //read scanned barcode (MAC address) from text box parameters.SetSerialNumber(); UpdateOutputText("Opening USB port..."); thisUSB.OpenPort(parameters.USB_under_test_pid, 6000); //open up the usb port enableResetLine(); //enable control of the reset line on the dongle by applying new EEPROM settings to the FTDI chip (takes a few sec) thisUSB.ChipReset(); //load ssl using RAMLoader thisUSB.adjustBaudRate(Parameters.BaudRate_SSL); RAMLoader loadSSL = new RAMLoader(parameters, thisUSB, parameters.SSLfilepath, this); loadSSL.Run(true); thisUSB.adjustBaudRate(Parameters.BaudRate_SSL); //increase the baud rate 8x, saves six seconds on loading (goes from 14 to 8) SSLInterface ssl = new SSLInterface(parameters, thisUSB); FirmwareLoader fwloader = new FirmwareLoader(parameters, thisUSB, this); fwloader.EraseSector24(ssl); SetCrystalTrim(); //program the trim adjustment values for the crystal clock (depending on options set in Settings.txt) fwloader.LoadTrimsOnly(ssl); thisUSB.Close(); Finish(); //items to only do once totally successful: Logger(); UpdateProgressBar_Overall(progressBar_overall.Maximum); SaveSerialNumber(); UpdateColorDisplay("green"); UpdatePictureDisplay("pass");//add pic @20120402 by Nino Liu //add serial number @20120328 by nino if (parameters.testing && parameters.loading) UpdateOutputText("Test and load with MAC: " + parameters.MAC + '\n' + "Serial number: " + parameters.SN + '\n' + "Spent time: " + parameters.totaltesttime + " seconds."+ '\n' + "Optimal Frequency: " + parameters.frequency_measured); else if (parameters.loading) UpdateOutputText("Loading with MAC: " + parameters.MAC + '\n' + "Serial number: " + parameters.SN + '\n' + "Spent time: " + parameters.totaltesttime + " seconds." + '\n' + "Optimal Frequency: " + parameters.frequency_measured); else UpdateOutputText("Testing with MAC: " + parameters.MAC + '\n' + "Serial number: " + parameters.SN + '\n' + "Spent time: " + parameters.totaltesttime + " seconds." + '\n' + "Optimal Frequency: " + parameters.frequency_measured); } catch (Exception_Yellow e) { ExceptionHandler(e, "yellow"); } catch (Exception_Red e) { ExceptionHandler(e, "red"); } catch (Exception e) { if (e.Message.Contains("supplied buffer is not big enough")) { BufferErrorIncrementer++; if (BufferErrorIncrementer > 3) Output.Text = "Persistent buffering error -- unplug and replug dongle and try again. If error persists, dongle fails."; else { Output.Text = "Buffering error -- restarting after 2 seconds."; UpdateColorDisplay("orange"); System.Windows.Forms.Application.DoEvents(); System.Threading.Thread.Sleep(2000); goto GoToForBufferingErrorRetry; } } ExceptionHandler(e, "generic"); } }