コード例 #1
0
ファイル: BootloaderController.cs プロジェクト: urish/M3D
        public override void SetFanConstants(FanConstValues.FanType fanType)
        {
            var eepromMapping1 = new EEPROMMapping(m_oBootloaderConnection.ReadAllReadableEEPROM(), MyPrinterProfile.EEPROMConstants);
            var alignedByte1   = (int)eepromMapping1.GetAlignedByte("FANTYPE");
            var alignedByte2   = eepromMapping1.GetAlignedByte("FANOFFSET");
            var num1           = eepromMapping1.GetFloat("FANSCALE");

            FanConstValues.FanValues fanConstant = FanConstValues.FanConstants[fanType];
            var num2 = (int)(byte)fanType;

            if (alignedByte1 != num2)
            {
                m_oBootloaderConnection.WriteToEEPROM(GetEEPROMDataLocation("FANTYPE"), eepromMapping1.AlignedByteToBytaArray((ushort)fanType));
            }

            if (alignedByte2 != fanConstant.Offset)
            {
                m_oBootloaderConnection.WriteToEEPROM(GetEEPROMDataLocation("FANOFFSET"), eepromMapping1.AlignedByteToBytaArray((ushort)fanConstant.Offset));
            }

            if (num1 != (double)fanConstant.Scale)
            {
                m_oBootloaderConnection.WriteToEEPROM(GetEEPROMDataLocation("FANSCALE"), BitConverter.GetBytes(fanConstant.Scale));
            }

            var eepromMapping2 = new EEPROMMapping(m_oBootloaderConnection.ReadAllReadableEEPROM(), MyPrinterProfile.EEPROMConstants);
            var alignedByte3   = (int)eepromMapping1.GetAlignedByte("FANTYPE");
            var alignedByte4   = eepromMapping1.GetAlignedByte("FANOFFSET");
            var num3           = eepromMapping1.GetFloat("FANSCALE");
            var num4           = (int)(byte)fanType;

            if (alignedByte3 == num4 && alignedByte4 == fanConstant.Offset && num3 == (double)fanConstant.Scale)
            {
                WriteLog(">> ok", Logger.TextType.Read);
            }
            else
            {
                WriteLog(">> failed", Logger.TextType.Read);
            }
        }
コード例 #2
0
ファイル: BootloaderController.cs プロジェクト: urish/M3D
        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;
                }
            }
        }