public void LoadHardwareSettings(SSLInterface sslinterface) { parameters.fillHardwarePars(); //thisUSB.poll(); //just in case we need to clear junk off the port try { sslinterface.SSL_WRITE(Parameters.HwInfAdr, parameters.HardwareParametersArray, (UInt16)parameters.HardwareParametersArray.Length); } 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_WRITE(Parameters.HwInfAdr, parameters.HardwareParametersArray, (UInt16)parameters.HardwareParametersArray.Length); //retry once, if the exception comes back again, we won't catch it and it'll go on to be displayed as "retry failed" } }
public void LoadTrimsOnly(SSLInterface sslinterface) { //parameters.fillHardwarePars(); //thisUSB.poll(); //just in case we need to clear junk off the port try { sslinterface.SSL_WRITE(Parameters.TrimAdr, parameters.TwoTrimBytes, (UInt16)parameters.TwoTrimBytes.Length); } 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_WRITE(Parameters.TrimAdr, parameters.TwoTrimBytes, (UInt16)parameters.TwoTrimBytes.Length); } }
private void LoadFW(SSLInterface sslinterface, byte[] fullfilebuffer, int filesize) { int currentReadAddress = 0; uint currentWriteAddress = FLASH_IMAGE_HEADER; //Initialize the write address with the first byte after the FLASH header UInt16 bytesToRead; //only used in testing to erase partially-cleared dongles: if (parameters.reprogramming_oldFW_HW3_SW2 || parameters.reprogramming_newFW) { try { mf_parent.UpdateOutputText("Finalizing erase of old firmware..."); sslinterface.SSL_FULLERASE(); } 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" } } mf_parent.UpdateOutputText("Loading production firmware, filename \"" + parameters.FWimagefilename + "\"..."); //now chop it up into chunks the SSL will be able to handle, and write each chunk to the ssl, which then writes it to RAM and sends back a confirm while (currentReadAddress != filesize) { if (filesize - currentReadAddress > Parameters.SSL_ENG_BUFFER_SIZE) bytesToRead = Parameters.SSL_ENG_BUFFER_SIZE; //make chunks in the max buffer size the SSL can take (512 bytes) else bytesToRead = (UInt16)(filesize - currentReadAddress); //the last chunk will be smaller than the max buffer size byte[] tempbuffer = new byte[bytesToRead]; for (int i = 0; i < bytesToRead; i++) { tempbuffer[i] = fullfilebuffer[currentReadAddress]; currentReadAddress++; } try { sslinterface.SSL_WRITE(currentWriteAddress, tempbuffer, bytesToRead); } 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_WRITE(currentWriteAddress, tempbuffer, bytesToRead); //retry once, if the exception comes back again, we won't catch it and it'll go on to be displayed as "retry failed" } //catch (Exception e) //{ // if (!e.Message.Contains("reference not set")) throw new Exception(e.Message); //if it's some other exception, don't catch it // else throw new Exception(e.Message + " it happened inside SSL_WRITE"); //} currentWriteAddress += bytesToRead; mf_parent.UpdateProgressBar_Detail((int)(100 * (currentWriteAddress - FLASH_IMAGE_HEADER) / filesize)); } }