private void StartBootloaderMode() { m_oBootloaderConnection = new Bootloader(SerialPort, MyPrinterProfile.ProductConstants.m_yPaddingByte, MyPrinterProfile.ProductConstants.chipData, MyPrinterProfile.EEPROMConstants.EndOfBootloaderReadableEEPROM, MyPrinterProfile.EEPROMConstants.BytesPerEEPROMAddress); CurrentBootloaderStep = BootloaderController.BootLoaderStep.Startup; Status = PrinterStatus.Bootloader_StartingUp; m_oBootloaderConnection.FlushIncomingBytes(); }
public void GotoFirmware() { if (Status != PrinterStatus.Bootloader_Ready) { return; } CurrentBootloaderStep = BootloaderController.BootLoaderStep.GotoApp; }
private void UpdateFirmwareStep() { var flag = false; foreach (KeyValuePair <char, FirmwareDetails> firmware in MyPrinterProfile.ProductConstants.FirmwareList) { FirmwareDetails firmwareDetails = firmware.Value; var key = firmware.Key; if (!mCheckedFirmwareStatus.ContainsKey(key) || mCheckedFirmwareStatus[key] != BootloaderController.FirmwareStatus.Good && mCheckedFirmwareStatus[key] != BootloaderController.FirmwareStatus.GoodQuit) { if (mInterfaceVersion == BootloaderController.BootloaderInterfaceVersion.V2) { SetBootloader(key); } try { var stopwatch = new Stopwatch(); stopwatch.Reset(); stopwatch.Start(); flag = BootloaderUpdateFirmware(firmwareDetails); stopwatch.Stop(); WriteLog("<< time: " + stopwatch.Elapsed, Logger.TextType.Write); } catch (Exception ex) { ErrorLogger.LogException("Exception in BootloaderConnection.DoBootLoop " + ex.Message, ex); flag = true; } if (!flag) { mCheckedFirmwareStatus[key] = BootloaderController.FirmwareStatus.Good; } if (flag) { break; } } } if (flag) { BroadcastServer.BroadcastMessage(new SpoolerMessage(MessageType.FirmwareUpdateFailed, MySerialNumber, "null").Serialize()); CurrentBootloaderStep = BootloaderController.BootLoaderStep.Waiting; Status = PrinterStatus.Bootloader_FirmwareUpdateFailed; } else { BroadcastServer.BroadcastMessage(new SpoolerMessage(MessageType.FirmwareUpdateComplete, MySerialNumber, "null").Serialize()); CurrentBootloaderStep = BootloaderController.BootLoaderStep.GotoApp; } }
public bool WriteSerialdata(byte[] data) { lock (m_oLockBootloaderWait) { if (CurrentBootloaderStep == BootloaderController.BootLoaderStep.Waiting) { CurrentBootloaderStep = BootloaderController.BootLoaderStep.ProcessingRequest; m_oBootloaderConnection.FlushIncomingBytes(); foreach (var output in data) { m_oBootloaderConnection.SPout(output); } CurrentBootloaderStep = BootloaderController.BootLoaderStep.Waiting; } } return(true); }
public string WriteSerialdata(byte[] data, int getbytes) { lock (m_oLockBootloaderWait) { if (CurrentBootloaderStep == BootloaderController.BootLoaderStep.Waiting) { CurrentBootloaderStep = BootloaderController.BootLoaderStep.ProcessingRequest; Thread.Sleep(500); m_oBootloaderConnection.FlushIncomingBytes(); foreach (var output in data) { m_oBootloaderConnection.SPout(output); } byte[] numArray1 = new byte[1]; byte[] inArray = new byte[getbytes]; for (var index = 0; index < getbytes; ++index) { byte[] numArray2 = m_oBootloaderConnection.ReadBytes(1); if (index != 0 || numArray2[0] != 13) { inArray[index] = numArray2[0]; } else { --index; } } if (m_oBootloaderConnection.ReadBytes(1)[0] != 13) { return("FAIL"); } BroadcastServer.BroadcastMessage(new SpoolerMessage(MessageType.RawData, MySerialNumber, Convert.ToBase64String(inArray)).Serialize()); } CurrentBootloaderStep = BootloaderController.BootLoaderStep.Waiting; } return("OK"); }
private void SetNextActionFromFirmwareStatus(bool bFirmwareIsInvalid) { if (!bFirmwareIsInvalid) { if (!SpoolerServer.StayInBootloader) { CurrentBootloaderStep = BootloaderController.BootLoaderStep.GotoApp; } else { CurrentBootloaderStep = BootloaderController.BootLoaderStep.Waiting; Status = PrinterStatus.Bootloader_Ready; } } else if (SpoolerServer.AUTO_UPDATE_FIRMWARE) { CurrentBootloaderStep = BootloaderController.BootLoaderStep.UpdateFirmware; } else { CurrentBootloaderStep = BootloaderController.BootLoaderStep.Waiting; } }
public override void UpdateFirmware() { CurrentBootloaderStep = BootloaderController.BootLoaderStep.UpdateFirmware; }
private void BootLoaderStartup() { FirmwareDetails firmware = MyPrinterProfile.ProductConstants.FirmwareList['M']; if (mInterfaceVersion == BootloaderController.BootloaderInterfaceVersion.V2) { SetBootloader('M'); } MyPrinterInfo.hardware.machine_type = "The_Micro"; var eepromMapping = new EEPROMMapping(m_oBootloaderConnection.ReadAllReadableEEPROM(), MyPrinterProfile.EEPROMConstants); var flag = false; var str = ""; byte[] bytesFromLocation = eepromMapping.GetBytesFromLocation("SerialNumber", 16); for (var index = 0; index < 16; ++index) { if (bytesFromLocation[index] == byte.MaxValue) { flag = true; } str += ((char)bytesFromLocation[index]).ToString(); } if (flag) { BroadcastServer.BroadcastMessage(new SpoolerMessage(MessageType.UserDefined, MySerialNumber, "There was a major error in your printer. Please reset the printer. If the problem persist, contact M3D.").Serialize()); Status = PrinterStatus.Error_PrinterNotAlive; } else { MySerialNumber = new PrinterSerialNumber(str); foreach (IFirstRunUpdater updater in MyPrinterProfile.FirstRunConstants.updater_list) { updater.CheckForUpdate(str, eepromMapping.GetAllEEPROMData(), m_oBootloaderConnection, MyPrinterProfile); } logger.ResetWithSerialNumber(MySerialNumber.ToString()); LoadPersistantData(); PersistantDetails.hours_used = eepromMapping.GetFloat("HoursCounterSpooler"); HardwareDetails.firmware_version = eepromMapping.GetUInt32("FirmwareVersion"); PersistantData.RestartOptions restartOptions = PersistantDetails.PopRestartAction(); SavePersistantData(); CurrentBootloaderStep = BootloaderController.BootLoaderStep.CheckFirmware; if (restartOptions.RestartAction == PersistantData.RestartAction.SetExtruderCurrent) { SetExtruderCurrent((ushort)restartOptions.RestartActionParam); } else if (restartOptions.RestartAction == PersistantData.RestartAction.SetFan) { SetFanConstants((FanConstValues.FanType)restartOptions.RestartActionParam); } else if (restartOptions.RestartAction == PersistantData.RestartAction.ForceStayBootloader) { Status = PrinterStatus.Bootloader_Ready; CurrentBootloaderStep = BootloaderController.BootLoaderStep.Waiting; } else { if (restartOptions.RestartAction != PersistantData.RestartAction.ForceUpdateFirmware) { return; } CurrentBootloaderStep = BootloaderController.BootLoaderStep.ForceFirmwareUpdate; } } }