Something went wrong. Try again.
Completely reimplimented in zig (eventually)
Something went wrong. Try again.
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105package com.microchip.mplab.ipelib;
import com.microchip.crownking.Pair;import com.microchip.crownking.edc.edcDendron;import com.microchip.crownking.mplabinfo.DeviceSupport.ToolSupport;import com.microchip.crownking.mplabinfo.FamilyDefinitions.Family;import com.microchip.crownking.opt.OptionLanguage.Signature;import com.microchip.mplab.crownkingx.xPIC;import com.microchip.mplab.ipelib.common.SharedData;import com.microchip.mplab.ipelib.device.CDevice;import com.microchip.mplab.ipelib.device.PgmRangeStringValidator;import com.microchip.mplab.ipelib.device.PreserveEERangeValidator;import com.microchip.mplab.ipelib.device.PreservePGMRangeValidator;import com.microchip.mplab.ipelib.device.PreserveProgramMemoryEndOptionValidator;import com.microchip.mplab.ipelib.device.PreserveProgramMemoryStartOptionValidator;import com.microchip.mplab.ipelib.device.ProgramMemoryEndOptionValidator;import com.microchip.mplab.ipelib.device.ProgramMemoryStartOptionValidator;import com.microchip.mplab.ipelib.device.ToolsLookup;import com.microchip.mplab.ipelib.tools.IPENotifier;import com.microchip.mplab.ipelib.toolsupport.ToolType;import com.microchip.mplab.lib.scripting.ScriptOptValidator;import com.microchip.mplab.libs.MPLABDocumentLocator.MPLABDocumentLocator;import com.microchip.mplab.libs.RI4ToolsController.DataClasses.PtgImageInfo;import com.microchip.mplab.libs.atmelice.device.DeviceInfoFactory;import com.microchip.mplab.libs.atmelice.device.DeviceQuery;import com.microchip.mplab.libs.atmelice.device.atdf.AvrToolsDeviceFileType;import com.microchip.mplab.libs.scripting.runner.ScriptControllerException;import com.microchip.mplab.libs.scripting.runner.ScriptRunner;import com.microchip.mplab.libs.scripting.runner.ScriptRunner.Type;import com.microchip.mplab.libs.toolpacksupport.factory.ToolPackManager;import com.microchip.mplab.libs.toolpacksupport.interfaces.ToolPack;import com.microchip.mplab.libs.toolpacksupport.interfaces.ToolPackCapabilitiesProvider;import com.microchip.mplab.libs.toolpacksupport.interfaces.ToolPackRelease;import com.microchip.mplab.libs.toolpacksupport.interfaces.ToolPackReleaseFinder;import com.microchip.mplab.logger.MPLABLogger;import com.microchip.mplab.mdbcore.CodeGuardMediator.CodeGuardMediatorInterface;import com.microchip.mplab.mdbcore.ConfigBitsChecker.ConfigBitsCheckerInterface;import com.microchip.mplab.mdbcore.MessageMediator.Message;import com.microchip.mplab.mdbcore.RealICETool.utils.RIExceptions;import com.microchip.mplab.mdbcore.assemblies.Assembly;import com.microchip.mplab.mdbcore.checksum.common.BufferChecksumHelper.MemoryRegion;import com.microchip.mplab.mdbcore.common.debug.interfaces.PtgDetails;import com.microchip.mplab.mdbcore.common.debug.interfaces.ScriptMediator;import com.microchip.mplab.mdbcore.debugger.DebugException;import com.microchip.mplab.mdbcore.debugger.Debugger;import com.microchip.mplab.mdbcore.debugger.Debugger.CONNECTION_TYPE;import com.microchip.mplab.mdbcore.debugger.internal.Debugger2;import com.microchip.mplab.mdbcore.loader.LoadException;import com.microchip.mplab.mdbcore.loader.Loader;import com.microchip.mplab.mdbcore.loader.Loader.Output;import com.microchip.mplab.mdbcore.memory.PhysicalMemory;import com.microchip.mplab.mdbcore.memory.memorytypes.ProgramMemory;import com.microchip.mplab.mdbcore.pa.service.commands.FirmwareInfo;import com.microchip.mplab.mdbcore.platformtool.PlatformToolMeta;import com.microchip.mplab.mdbcore.platformtool.PlatformToolMetaManager;import com.microchip.mplab.mdbcore.platformtool.PlatformToolMeta.DocumentChanger;import com.microchip.mplab.mdbcore.platformtool.PlatformToolMeta.OptionLanguageSignatureProxy;import com.microchip.mplab.mdbcore.pm5.service.commands.responses.Pm5Versions;import com.microchip.mplab.mdbcore.pm5.service.utils.ServiceQueryException;import com.microchip.mplab.mdbcore.sqtpenv.SQTPEnvironment.SQTPError;import com.microchip.mplab.mdbcore.sqtpenv.pm3EnvExtractor.EnvStructure;import java.awt.Color;import java.io.File;import java.io.IOException;import java.io.RandomAccessFile;import java.io.UnsupportedEncodingException;import java.util.ArrayList;import java.util.HashMap;import java.util.LinkedList;import java.util.List;import java.util.Map;import java.util.Optional;import java.util.Properties;import java.util.logging.Level;import java.util.prefs.Preferences;import java.util.regex.Matcher;import java.util.regex.Pattern;import java.util.stream.Collectors;import org.openide.util.Exceptions;import org.openide.util.NbBundle;import org.w3c.dom.Document;import org.w3c.dom.Element;import org.w3c.dom.NamedNodeMap;import org.w3c.dom.Node;
public class IPELibrary { private ToolsLookup toolsLookup = null; private SharedData shareData; private CDevice deviceInfo; private PreserveProgramMemoryStartOptionValidator preserveStart; private PreserveProgramMemoryEndOptionValidator preserveEnd; private ProgramMemoryStartOptionValidator pgmStart; private ProgramMemoryEndOptionValidator pgmEnd; private PreservePGMRangeValidator prvPgmRange; private PreserveEERangeValidator prvEERange; private PgmRangeStringValidator pgmRange; private boolean isPartitionMisMatchError; private String parttnMisMatchErrorMsg = ""; private PlatformToolMeta toolMeta = null; private String toolID = ""; private Signature sig = null; public ScriptRunner runner; private ScriptMediator mediator; int runnerId = -1; public final IPELibrary.CommandLoader cmdloader = new IPELibrary.CommandLoader(); private boolean checkForPythonFileExists = false; private Map<String, String> deviceActions = new HashMap<>(); private long pgmMemBeginAddr = 0L; private long pgmMemEndAddr = 0L; private Debugger2 mdb2;
public IPELibrary() { this.toolsLookup = new ToolsLookup(); this.deviceInfo = new CDevice(); this.shareData = SharedData.getSingletonObject(); this.isPartitionMisMatchError = false; }
public IPELibrary(boolean noDoScan) { this.toolsLookup = new ToolsLookup(noDoScan); this.deviceInfo = new CDevice(); this.shareData = SharedData.getSingletonObject(); this.isPartitionMisMatchError = false; }
public Pair<Long, Long> getMemoryRange(String memType) { return this.deviceInfo.getMemoryRange(memType); }
public boolean isValidRange(long startAddr, long endAddr, String memoryType) { boolean retVal = false; if (memoryType.compareToIgnoreCase("program") == 0) { retVal = this.deviceInfo.isValidProgramMemoryRange(startAddr, endAddr); } else if (memoryType.compareToIgnoreCase("eeprom") == 0) { retVal = this.deviceInfo.isValidEEMemoryRange(startAddr, endAddr); } else if (memoryType.compareToIgnoreCase("userid") != 0 && memoryType.compareToIgnoreCase("config") != 0) { if (memoryType.compareToIgnoreCase("flash") == 0) { retVal = this.deviceInfo.isValidFlashMemoryRange(startAddr, endAddr); } else if (memoryType.compareToIgnoreCase("auxiliary") == 0) { retVal = this.deviceInfo.isValidAuxiliaryRange(startAddr, endAddr); } }
return retVal; }
public boolean isDeviceCodeProtected() { boolean retVal = false; ConfigBitsCheckerInterface CF = (ConfigBitsCheckerInterface)this.shareData.getAssemblySession().getLookup().lookup(ConfigBitsCheckerInterface.class);
try { retVal = CF.CheckField(106, true); } catch (NoSuchFieldException var4) { }
return retVal; }
public void setCalibrationdatatoMemory(long addrs, int bytesPW, byte[] data) { PhysicalMemory pm = this.getMemory(ProgramMemory.class); pm.Write(addrs, bytesPW, data); this.setProgramMemory(pm); }
public String getToolIDFromToolInfo(String toolAsShown) { return this.toolsLookup.getToolIDFromMapInfo(toolAsShown); }
public List<ToolSupport> getSupport(String tool, String device) { return this.toolsLookup.getSupport(tool, device); }
public ArrayList queryToolList() { return this.toolsLookup.getActiveToolList(); }
public ArrayList querySerialToolList() { return this.toolsLookup.getSerialToolsList(); }
public ArrayList getCurrentAvailableToolList() { return this.toolsLookup.getCurrentAvailableToolList(); }
public boolean createAssemblySession(String deviceName) { boolean retVal = this.toolsLookup.createAssemblySession(deviceName); if (retVal) { retVal = this.deviceInfo.getDeviceInfo(); }
return retVal; }
public boolean createAssemblySession(String deviceSelected, String packName, String packVersion, String packVendor, ToolPackRelease toolPackRelease) { boolean retVal = this.toolsLookup.createAssemblySession(deviceSelected, packName, packVersion, packVendor, toolPackRelease); if (retVal) { retVal = this.deviceInfo.getDeviceInfo(); }
return retVal; }
public void load_like_mplab8(boolean t) { this.shareData.getSQTPEnvironment().Load_like_MPLAB8(t); }
public boolean createSQTPEnvironmentSession() { return this.toolsLookup.setSQTPEnvironment(); }
public boolean CreateSQTPFile(RandomAccessFile sqtp, Properties props) { return this.shareData.getSQTPEnvironment().CreateSQTPFile(sqtp, props); }
public void UnloadSQTP() { this.shareData.getSQTPEnvironment().UnloadSQTPFile(); }
public boolean deleteEnvironment(String path) { return this.toolsLookup.deleteEnvironment(path); }
public boolean viewEnvironment(String path) { return this.toolsLookup.viewEnviroment(path); }
public boolean loadEnvironment(String path) { return this.toolsLookup.loadEnvironment(path); }
public boolean copyEnvironment(String srcPath, String destPath, String srcEnvName, String dstEnvName) { return this.toolsLookup.copyEnviroment(srcPath, destPath, srcEnvName, dstEnvName); }
public boolean saveEnvironment(String envPath, String envName, boolean isPM3File, String sqtpFile, String miscFile, String envDesc) { return this.toolsLookup.saveEnvironment(envPath, envName, isPM3File, sqtpFile, miscFile, envDesc); }
public SQTPError loadSQTPFile(String numFilePath) { this.toolsLookup.UnloadSQTPFile(); return this.toolsLookup.setSQTPSequence(numFilePath); }
public SQTPError loadNextSQTPSequence(String numFilePath) { return this.toolsLookup.loadNextSQTPSequence(numFilePath); }
public boolean createDebuggerSession(String toolName) { boolean retVal = false;
try { retVal = this.toolsLookup.createDebuggerSession(toolName); } catch (Exception var4) { retVal = false; }
return retVal; }
public void setUI(boolean isUI) { this.shareData.setUIMode(isUI); }
public void setDebugBitFlag(boolean flag) { this.shareData.setDebugBitFlag(flag); }
public int loadHexFile(ArrayList<String> files, boolean resetDebugBit) { int retVal = -1; boolean isCoordinatedResetFlagSet = false; Assembly mdbSession = this.shareData.getAssemblySession(); Loader loader = (Loader)mdbSession.getLookup().lookup(Loader.class);
try { if (this.isCoordinatedResetAndProgramOpRequired()) { isCoordinatedResetFlagSet = true; }
loader.ResetInvalidConfigurationBits(resetDebugBit); this.shareData.setInvalidHexFlag(false); int dbgBit = loader.Load(files, null, isCoordinatedResetFlagSet, new Output() { Message message = new Message();
public void PrintMessage(String msg) { this.message.setMessageString(msg); if (IPELibrary.this.shareData.getUIMode()) { this.message.setTextColorForOutputWindow(Color.BLACK); }
if (msg.startsWith("Warning:")) { this.message.setTextColorForOutputWindow(Color.RED); System.out.println("IPE:" + msg); IPELibrary.this.shareData.setInvalidHexFlag(false); }
IPENotifier.getIPENotifierController().SetMessageObjectNotify(this.message, 1); }
public void PrintError(String msg) { this.message.setTextColorForOutputWindow(Color.RED); IPENotifier.getIPENotifierController().setMessageNotification(msg + "\n"); } }); retVal = dbgBit; if (this.shareData.getInvalidHexFlag()) { retVal = -1; }
return retVal; } catch (LoadException var9) { int var10 = -1; if (this.shareData.getUIMode()) { Message message = new Message(); message.setTextColorForOutputWindow(Color.RED); message.setMessageString(var9.getMessage()); IPENotifier.getIPENotifierController().SetMessageObjectNotify(message, 1); }
return var10; } }
public boolean exportHexFile(String filePath) { boolean retVal = true; Assembly mdbSession = this.shareData.getAssemblySession(); Loader loader = (Loader)mdbSession.getLookup().lookup(Loader.class);
try { loader.Save(filePath, true); } catch (LoadException var6) { retVal = false; }
return retVal; }
public boolean programTarget() { if (this.isMaintainActiveConnectionSupport() && !this.isCoordinatedResetAndProgramOpRequired()) { this.toolsLookup.Connect(); }
return this.toolsLookup.WriteMemory(); }
public boolean isMaintainActiveConnectionSupport() { boolean isMaintainConnectionDisabled = false; Boolean isMaintainConnection = this.toolMeta.hasCapability("disable-maintain-connection"); if (isMaintainConnection != null && this.isATDeviceInAssembly() && (isMaintainConnection || this.getXPICDeviceInfo().getFamily().equals(Family.ARM32BIT) && !isMaintainConnection)) { isMaintainConnectionDisabled = isMaintainConnection; }
return isMaintainConnectionDisabled; }
public CodeGuardMediatorInterface getCodeGuardInstance() { return (CodeGuardMediatorInterface)this.shareData.getAssemblySession().getLookup().lookup(CodeGuardMediatorInterface.class); }
public boolean readTarget() { boolean retVal = false; if (this.isMaintainActiveConnectionSupport()) { this.toolsLookup.Connect(); }
try { if (this.useAllExecutableRegions() && "auto".equals(this.shareData.getCoreParameters().getProperty("AutoSelectMemRanges"))) { this.shareData.getCoreParameters().setProperty("AutoSelectMemRanges", "manual"); }
retVal = this.toolsLookup.readMemory(); if (this.isMaintainActiveConnectionSupport()) { this.toolsLookup.disconnectTarget(); } } catch (Exception var3) { if (((DebugException)var3).Code() == 11) { this.isPartitionMisMatchError = true; this.parttnMisMatchErrorMsg = var3.getMessage(); retVal = false; } }
return retVal; }
public boolean useAllExecutableRegions() { boolean retVal = false; String DevName = this.shareData.getAssemblySession().GetDeviceName(); xPIC picdevicedb = this.shareData.getAssemblySession().GetDevice(); if (picdevicedb.getArchitecture() != null && (picdevicedb.getArchitecture().toUpperCase().startsWith("CORTEX") || picdevicedb.getArchitecture().toUpperCase().startsWith("ARM9")) || DevName.startsWith("PIC32CZ") || DevName.startsWith("PIC32CX") || DevName.startsWith("PIC32MZ") || DevName.contains("WBZ")) { retVal = true; }
return retVal; }
public String getPartitionMisMatchErrorMsg() { return this.parttnMisMatchErrorMsg; }
public boolean eraseTarget() { if (this.isMaintainActiveConnectionSupport()) { this.toolsLookup.Connect(); }
boolean retVal = this.toolsLookup.eraseMemory(); if (this.isMaintainActiveConnectionSupport()) { this.toolsLookup.disconnectTarget(); }
return retVal; }
public boolean verifyTarget() { return this.toolsLookup.verifyMemory(); }
public boolean blankCheck() { return this.toolsLookup.blankCheck(); }
public boolean justConnect() { return this.toolsLookup.justConnect(); }
public boolean disconnectTarget() { return this.toolsLookup.disconnectTarget(); }
public boolean ConnectTarget() { return this.toolsLookup.Connect(); }
public Debugger getDebugerSession() { return this.shareData.getDebugger(); }
public String getErrorString() { return this.toolsLookup.getErrorString(); }
public void HoldInReset() { try { if (this.isMaintainActiveConnectionSupport()) { this.toolsLookup.Connect(); }
this.toolsLookup.holdInReset(); if (this.isMaintainActiveConnectionSupport()) { this.toolsLookup.disconnectTarget(); } } catch (DebugException var2) { Exceptions.printStackTrace(var2); } }
public void UpdateSerialTools() { this.toolsLookup.getPM3SerialInformation(); }
public void ReleaseFromReset() { try { if (this.isMaintainActiveConnectionSupport()) { this.toolsLookup.Connect(); }
this.toolsLookup.releaseFromReset(); if (this.isMaintainActiveConnectionSupport()) { this.toolsLookup.disconnectTarget(); } } catch (DebugException var2) { Exceptions.printStackTrace(var2); } }
public boolean hasVPPfirst() { return this.deviceInfo.hasVPPFirst(); }
public long getDataFlashAddrs() { return this.deviceInfo.getDataFlashEndAddrs(); }
public boolean hasLVP() { return this.shareData.getAssemblySession().GetDevice().getProgramming().haslvp2(); }
public boolean hasHighVoltageMCLR() { return this.deviceInfo.getXPICDeviceInfo().getPower().hasHighVoltageMCLR2(); }
protected boolean HasPin(xPIC pic, String PinName) { boolean HasPin = false; edcDendron edcUtil = new edcDendron(); Node pinList = pic.first("PinList"); if (pinList != null) { for (Node pin = edcUtil.first(pinList, "Pin"); pin != null; pin = edcUtil.next(pin, "Pin")) { String name = null;
for (Node virtualPin = edcUtil.first(pin, "VirtualPin"); virtualPin != null; virtualPin = edcUtil.next(virtualPin, "VirtualPin")) { name = edcUtil.get(virtualPin, "name"); if (name.equals(PinName)) { HasPin = true; return HasPin; } } } }
return HasPin; }
public String getcrc32FileChecksum(File file) { String retVal = "N/A";
try { long cksum = this.toolsLookup.getCRC32(file); if (cksum != -1L) { retVal = String.format("%8X", cksum).trim(); if (retVal.length() >= 8) { retVal = retVal.substring(retVal.length() - 8); } } else { retVal = "N/A"; } } catch (Exception var5) { retVal = "N/A"; }
return retVal; }
public String getChecksum() { String retVal = "N/A";
try { long cksum = this.toolsLookup.getChecksum(); if (cksum != -1L) { retVal = Long.toHexString(cksum).toUpperCase(); } else { retVal = "N/A"; } } catch (Exception var4) { retVal = "N/A"; }
return retVal; }
public String getUnprotectedCsum() { String retVal = "N/A";
try { long cksum = this.toolsLookup.getUnprotectedCsum(); if (cksum != -1L) { retVal = Long.toHexString(cksum).toUpperCase(); } else { retVal = "N/A"; } } catch (Exception var4) { retVal = "N/A"; }
return retVal; }
public String getEEChecksum() { String retVal = "N/A";
try { long cksum = this.toolsLookup.getEEChecksum(); if (cksum != -1L) { retVal = Long.toHexString(cksum).toUpperCase(); } else { retVal = "N/A"; } } catch (Exception var4) { retVal = "N/A"; }
return retVal; }
public boolean hasChecksum() { boolean retVal = false;
try { retVal = this.toolsLookup.hasChecksum(); } catch (Exception var3) { MPLABLogger.mplog.log(Level.INFO, var3.getMessage()); }
return retVal; }
public String getFlashdataChecksum() { String retVal = "N/A";
try { long cksum = this.toolsLookup.getFlashdataChecksum(); if (cksum != -1L) { retVal = Long.toHexString(cksum).toUpperCase(); } else { retVal = "N/A"; } } catch (Exception var4) { retVal = "N/A"; }
return retVal; }
public Map<MemoryRegion, Long> getBufferChecksum() { new HashMap();
Map bufCkSum; try { bufCkSum = this.toolsLookup.getBufferChecksum(); } catch (Exception var3) { bufCkSum = null; }
return bufCkSum; }
public boolean setCorePropertiesInSession(Properties coreProps) { this.shareData.setCoreParameters(coreProps); if (this.shareData.getAssemblySession() != null) { this.shareData.getassemblyFactory().SetToolProperties(this.shareData.getAssemblySession(), coreProps); return true; } else { return false; } }
public void setPowerProperties(Preferences usrProperties) { this.shareData.setUserParameters(usrProperties); }
public void setOTPForCECDevice(boolean isOTPSet) { this.shareData.setOTPForCECDevice(isOTPSet); }
public boolean isEEMemory() { return this.deviceInfo.isEEMemory(); }
public boolean isBootMem() { return this.deviceInfo.isBootMem(); }
public boolean isConfigMemory() { return this.deviceInfo.isConfigMemory(); }
public boolean isProgramMemory() { return this.deviceInfo.isProgramMemory(); }
public boolean isDataFlash() { return this.deviceInfo.isDataFlash(); }
public boolean isAuxMem() { return this.deviceInfo.isAuxMem(); }
public boolean isDeviceID() { return this.deviceInfo.isDeviceID(); }
public boolean isUserID() { return this.deviceInfo.isUserID(); }
public boolean isOTPmemory() { return this.deviceInfo.hasOTPMemory(); }
public boolean isFlashData() { return this.deviceInfo.isFlashData(); }
public String getPM3DeviceChecksum() { String retVal = "N/A";
try { int cksum = this.toolsLookup.getPM3Checksum(); if (cksum != -1) { retVal = Integer.toHexString(cksum).toUpperCase(); } } catch (Exception var3) { retVal = "N/A"; }
return retVal; }
public int getPM3ErrorCode() { return this.toolsLookup.getPM3ErrorCode(); }
public void setUserProperties(Preferences usrProperties) { this.shareData.setUserParameters(usrProperties); }
public boolean checkVoltageSlab(float voltage) { return this.deviceInfo.checkVoltageSlab(voltage); }
public String getPM3DeviceID() { String retVal = "N/A";
try { int devid = this.toolsLookup.getPM3DeviceID(); if (devid >= 0) { retVal = Integer.toHexString(devid).toUpperCase(); } else if (devid == -2) { retVal = "FFFF"; } else { retVal = "0"; } } catch (Exception var3) { retVal = "N/A"; }
return retVal; }
public String getPM3DeviceIDRevision() { String retVal = "N/A"; retVal = this.toolsLookup.getDeviceID(); Pattern p = Pattern.compile("(?<=Device Rev= )\\d+"); Matcher m = p.matcher(retVal); if (m.find()) { retVal = m.group(); }
return retVal; }
public xPIC getXPICDeviceInfo() { return this.deviceInfo.getXPICDeviceInfo(); }
public PhysicalMemory getMemory(Class cMemory) { return this.deviceInfo.getMemory(cMemory); }
public void clearAll() { this.deviceInfo.clearAll(); }
public void setProgramMemory(PhysicalMemory pm) { this.deviceInfo.setProgramMemory(pm); }
public String getProgramMemoryRange() { String rangeVal = ""; xPIC picdevicedb = this.shareData.getAssemblySession().GetDevice(); Pair<Long, Long> ePgmMemRange = picdevicedb.getInstRange(); if (picdevicedb.getMainPartition().hasAuxCode()) { ePgmMemRange = picdevicedb.getCodeRange(); }
if (!picdevicedb.getIDOntoPartition().isEmpty()) { ePgmMemRange = picdevicedb.getMainPartition().getFileRange(); }
if (ePgmMemRange != null && (Long)ePgmMemRange.second != 0L) { this.pgmMemBeginAddr = (Long)ePgmMemRange.first; this.pgmMemEndAddr = (Long)ePgmMemRange.second; if (this.getAssemblySession().GetDeviceName().startsWith("PIC32CZ")) { List<Node> nodes = picdevicedb.getMainPartition().getCodeRegions(); NamedNodeMap p = nodes.get(1).getAttributes(); String be = p.getNamedItem("edc:beginaddr").getNodeValue(); String en = p.getNamedItem("edc:endaddr").getNodeValue(); be = be.substring(2); en = en.substring(2); this.pgmMemBeginAddr = Long.parseLong(be, 16); this.pgmMemEndAddr = Long.parseLong(en, 16); }
rangeVal = String.format("%x-%x", this.pgmMemBeginAddr, this.pgmMemEndAddr - 1L); }
return rangeVal; }
public void setEEMemory(PhysicalMemory eem) { this.deviceInfo.setEEMemory(eem); }
public void setBootMem(PhysicalMemory boot) { this.deviceInfo.setBootMem(boot); }
public void setFlashMemory(PhysicalMemory fd) { this.deviceInfo.setFlashMemory(fd); }
public void setDataFlashMemory(PhysicalMemory fd) { this.deviceInfo.setDataFlashMemory(fd); }
public void setIDMem(PhysicalMemory IDMem) { this.deviceInfo.setIDMem(IDMem); }
public void setConfigMem(PhysicalMemory configMem) { this.deviceInfo.setConfigMem(configMem); }
public boolean connectAsPTG() { return this.toolsLookup.connectAsPTG(); }
public Assembly getAssemblySession() { return this.shareData.getAssemblySession(); }
public void setUSerResponse(int i) { this.shareData.setUserResponseFlag(true); this.shareData.setUserResponseCode(i); }
public boolean transferImageToPM3() { boolean hasImage = false;
try { hasImage = this.toolsLookup.transferImageToPM3(); } catch (Exception var3) { hasImage = false; }
return hasImage; }
public boolean transferImageFromPM3() { boolean hasImage = false;
try { hasImage = this.toolsLookup.transferImageFromPM3(); } catch (Exception var3) { hasImage = false; }
return hasImage; }
public boolean PM3hasSDCard() { boolean hasCard = false;
try { hasCard = this.toolsLookup.Pm3hasSDCard(); } catch (Exception var3) { hasCard = false; }
return hasCard; }
public void doscan() { this.toolsLookup.initAttachTool(); this.toolsLookup.UpdateToolList(); }
public boolean DownloadOS(String path) { return this.toolsLookup.DownloadOS(path); }
public boolean DownloadBIOS(String path) { return this.toolsLookup.DownloadBIOS(path); }
public boolean DownloadDB(String path) { return this.toolsLookup.DownloadDB(path); }
public String GetPM3EnvironmentFromPM3SDCard(String path, boolean Futureflag) { return this.toolsLookup.GetPM3EnvironmentFromPM3SDCard(path.replace("\\", "/"), false); }
public boolean FormatSDCard() { return this.toolsLookup.FormatPM3SDCard(); }
public EnvStructure getEnvStructure() { return this.toolsLookup.getEnvStructure(); }
public String getDeviceNameInEnv(String pm3File) { String deviceName = ""; String actualPath = pm3File; pm3File = pm3File.replace("\\", "/"); if (pm3File.contains(";")) { String tempPath = pm3File.split(";")[0]; actualPath = tempPath; }
File pm3 = new File(actualPath); RandomAccessFile envFile = null; if (pm3.exists()) { try { envFile = new RandomAccessFile(pm3, "r"); envFile.seek(560L); } catch (IOException var10) { Exceptions.printStackTrace(var10); }
byte[] device = new byte[100];
try { envFile.read(device); } catch (IOException var9) { Exceptions.printStackTrace(var9); }
try { deviceName = new String(device, "UTF-16LE"); } catch (UnsupportedEncodingException var8) { Exceptions.printStackTrace(var8); }
deviceName = deviceName.trim(); } else { System.out.print("IPE:Could not open environment file for read."); }
return deviceName; }
public String getToolNameInEnv(String pm3File) { String toolName = ""; String actualPath = pm3File; pm3File = pm3File.replace("\\", "/"); if (pm3File.contains(";")) { String tempPath = pm3File.split(";")[0]; actualPath = tempPath; }
File pm3 = new File(actualPath); RandomAccessFile envFile = null; if (pm3.exists()) { try { envFile = new RandomAccessFile(pm3, "r"); envFile.seek(6583L); } catch (IOException var9) { Exceptions.printStackTrace(var9); }
byte[] tool = new byte[30];
try { envFile.read(tool); } catch (IOException var8) { Exceptions.printStackTrace(var8); }
toolName = new String(tool); toolName = toolName.trim(); } else { System.out.print("IPE:Could not open environment file for read."); }
return toolName; }
public String getSqtpFileNameInEnv(String pm3File) throws UnsupportedEncodingException { String sqtpFileName = ""; String actualPath = pm3File; pm3File = pm3File.replace("\\", "/"); if (pm3File.contains(";")) { String tempPath = pm3File.split(";")[0]; actualPath = tempPath; }
File pm3 = new File(actualPath); RandomAccessFile envFile = null; if (pm3.exists()) { try { envFile = new RandomAccessFile(pm3, "rw"); envFile.seek(6328L); } catch (IOException var10) { Exceptions.printStackTrace(var10); }
byte[] sqtpFile = new byte[255];
try { envFile.read(sqtpFile); } catch (IOException var9) { Exceptions.printStackTrace(var9); }
String numFile = new String(sqtpFile, "UTF-16LE"); numFile = numFile.trim(); String ext = ".NUM"; if (numFile.contains(".num")) { ext = ".num"; numFile = numFile.substring(0, numFile.lastIndexOf(ext)).concat(ext); numFile = numFile.replace("\\", ""); if (!pm3File.contains(";")) { sqtpFileName = pm3.getAbsolutePath() .substring(0, pm3.getAbsolutePath().lastIndexOf(System.getProperty("file.separator"))) .concat(System.getProperty("file.separator") + numFile); } } }
return sqtpFileName; }
public List<PtgImageInfo> getPK5PTGImageList() throws RIExceptions { List<PtgImageInfo> retList = null; if (!this.shareData.isConnected()) { try { this.getDebugerSession().Connect(CONNECTION_TYPE.PROGRAMMER_TO_GO); } catch (DebugException var3) { MPLABLogger.mplog.log(Level.INFO, var3.getMessage()); } }
Optional<PtgDetails> ptgD = this.getPTGDetailsProvider(); if (ptgD.isPresent()) { retList = ptgD.get().getPTGImageList(); }
return retList; }
public void runPtgGoButton() throws Exception { try { Optional<PtgDetails> ptgD = this.getPTGDetailsProvider(); if (ptgD.isPresent()) { ptgD.get().ptgGoButtonPress(); } } catch (Exception var2) { MPLABLogger.mplog.log(Level.INFO, var2.getMessage()); } }
public Optional<PtgDetails> getPTGDetailsProvider() { Optional<PtgDetails> ptgD = null; if (this.shareData.getDebugger() != null) { try { this.setDebugger2(this.shareData.getDebugger()); } catch (Exception var3) { MPLABLogger.mplog.log(Level.INFO, var3.getMessage()); } }
if (this.mdb2 != null) { ptgD = this.mdb2.getPTGDetailsProvider(); }
return ptgD; }
private void setDebugger2(Debugger mdb) throws Exception { if (Debugger2.class.isAssignableFrom(mdb.getClass())) { this.mdb2 = (Debugger2)mdb; } else { throw new Exception("Internal fatal error. Could not get access to Debugger2 interface"); } }
public PtgImageInfo getPK5PTGActiveImage() { PtgImageInfo prtActiveimage = null; Optional<PtgDetails> ptgD = this.getPTGDetailsProvider(); if (ptgD.isPresent()) { prtActiveimage = ptgD.get().getPTGActiveImage(); }
return prtActiveimage; }
public void setPK5PTGActiveImage(PtgImageInfo img) { Optional<PtgDetails> ptgD = this.getPTGDetailsProvider(); if (ptgD.isPresent()) { ptgD.get().setPTGActiveImage(img); } }
public void deletePK5PTGImage(PtgImageInfo img) { Optional<PtgDetails> ptgD = this.getPTGDetailsProvider(); if (ptgD.isPresent()) { ptgD.get().deletePTGImage(img); } }
public void resetPK5PTGStats(PtgImageInfo img) { Optional<PtgDetails> ptgD = this.getPTGDetailsProvider(); if (ptgD.isPresent()) { ptgD.get().resetPTGProgrammingStatistics(img); } }
public void setSafeMode(boolean safemode) { this.toolsLookup.setPM3toSafeMode(safemode); }
public void setPlatformMeta(String toolID) { this.toolID = toolID; List<PlatformToolMeta> listOfAllTools = PlatformToolMetaManager.getAllTools(); List<String> platformTools = new LinkedList<>();
for (PlatformToolMeta meta : listOfAllTools) { platformTools.add(meta.getID()); }
for (String platformTool : platformTools) { if (platformTool.toLowerCase().contains(toolID.toLowerCase())) { this.toolMeta = PlatformToolMetaManager.getTool(platformTool); break; } } }
public PlatformToolMeta GetPlatformMeta() { return this.toolMeta; }
public String getActualToolFromShortToolName(String shortToolName) { String actualToolName = null; IPELibrary.ToolShortName[] toolList = IPELibrary.ToolShortName.values();
for (int i = 0; i < IPELibrary.ToolShortName.values().length; i++) { if (shortToolName.equalsIgnoreCase(toolList[i].name())) { actualToolName = toolList[i].getToolId(); break; } }
return actualToolName; }
public String getPlatformToolIDFromActualTool(String actualToolName) { String platformToolID = null; actualToolName = this.getActualToolFromShortToolName(actualToolName); ToolType[] toolList = ToolType.values();
for (int i = 0; i < ToolType.values().length; i++) { if (actualToolName.equalsIgnoreCase(toolList[i].name())) { platformToolID = toolList[i].getToolId(); break; } }
return platformToolID; }
public Pair<Boolean, String> isValidPreservepgmStartAddress(String startAddr) { this.preserveStart = new PreserveProgramMemoryStartOptionValidator(); return this.preserveStart.validate(startAddr); }
public Pair<Boolean, String> isValidPreservepgmRangeAddresses(String Str) { this.prvPgmRange = new PreservePGMRangeValidator(); return this.prvPgmRange.validate(Str); }
public Pair<Boolean, String> isValidEERangeAddresses(String Str) { this.prvEERange = new PreserveEERangeValidator(); return this.prvEERange.validate(Str); }
public Pair<Boolean, String> isValidpgmRangeAddresses(String Str) { this.pgmRange = new PgmRangeStringValidator(); return this.pgmRange.validate(Str); }
public String getPgmRangeHint() { this.pgmRange = new PgmRangeStringValidator(); return this.pgmRange.getHint(); }
public String getPreservePgmRangeHint() { this.prvPgmRange = new PreservePGMRangeValidator(); return this.prvPgmRange.getHint(); }
public String getPreserveEERangeHint() { this.prvEERange = new PreserveEERangeValidator(); return this.prvEERange.getHint(); }
public Pair<Boolean, String> isValidPreservepgmEndAddress(String endAddr) { this.preserveEnd = new PreserveProgramMemoryEndOptionValidator(); return this.preserveEnd.validate(endAddr); }
public Pair<Boolean, String> isValidpgmStartAddress(String startAddr) { this.pgmStart = new ProgramMemoryStartOptionValidator(); return this.pgmStart.validate(startAddr); }
public String getDeviceID() { return this.toolsLookup.getDeviceID(); }
public Pair<Boolean, String> isValidpgmEndAddress(String endAddr) { this.pgmEnd = new ProgramMemoryEndOptionValidator(); return this.pgmEnd.validate(endAddr); }
public boolean setLoggerLocation() { if (System.getProperty("os.name").contains("Windows")) { String tempPath = System.getProperty("java.io.tmpdir"); tempPath = tempPath + "/MPLABLog.xml"; MPLABLogger.setLogFileName(tempPath); return true; } else { return false; } }
public String getASCIIValuefor1Values(byte msb) { return this.validate(msb); }
public String getASCIIValuefor2Values(byte msb, byte lsb) { byte[] byteArray = new byte[]{msb, lsb}; String result = "";
for (int i = 0; i < byteArray.length; i++) { result = result + this.validate(byteArray[i]); }
return result; }
public String getASCIIValue(byte msb1, byte msb2, byte lsb1, byte lsb2) { byte[] byteArray = new byte[]{msb1, msb2, lsb1, lsb2}; String result = "";
for (int i = 0; i < byteArray.length; i++) { result = result + this.validate(byteArray[i]); }
return result; }
private String validate(byte value) { byte[] byteArray = new byte[]{value}; String result = ""; int temp = 0; String s = String.format("%x", value); temp = Integer.valueOf(s, 16); if (temp >= 32 && temp < 127) { try { result = new String(byteArray, "ASCII"); } catch (UnsupportedEncodingException var7) { MPLABLogger.mplog.log(Level.INFO, var7.getMessage()); }
return result; } else { return "."; } }
public void setIPEMetricsToServer(String IPEVersion, String toolInfo, String devInfo) { this.shareData.setIPEMetricsToServer(IPEVersion, toolInfo, devInfo); }
public boolean isPartitionMisMatch() { return this.isPartitionMisMatchError; }
public boolean hasDIA_DCI_Memory() { return this.deviceInfo.hasDIA_DCI_Memory(); }
public boolean hasDIAMemory() { return this.deviceInfo.hasDIAMemory(); }
public boolean isToolConnected() { return this.shareData.isConnected(); }
public String[] GetDevice_Tool() { return this.shareData == null ? null : this.shareData.getDevice_Tool(); }
public String[] gettools() { return this.toolsLookup.doScan_matlab(); }
public boolean CheckAssemblySessionActive() { return this.shareData == null ? false : this.shareData.isAssemblySessionActive(); }
public boolean SaveOStoPM3Card() { return this.toolsLookup.SaveOStoPM3Card(); }
public boolean isUserIDSQTP(String path) { return this.shareData.getSQTPEnvironment().isUserIDSQTP(path); }
public CDevice getDeviceInfo() { return this.deviceInfo; }
public boolean isPartitioned() { return this.deviceInfo.isPartitioned(); }
public boolean isCoordinatedResetAndProgramOpRequired() { return this.toolsLookup.isCoordinatedResetAndProgramOpRequired(); }
public boolean isATDeviceInAssembly() { boolean retVal = false;
try { if (this.getXPICDeviceInfo().getFamily() != null && (this.getXPICDeviceInfo().getFamily().equals(Family.AVR) || this.getXPICDeviceInfo().getFamily().equals(Family.ARM32BIT))) { retVal = true; } } catch (Exception var3) { MPLABLogger.mplog.log(Level.INFO, var3.getMessage()); }
return retVal; }
public boolean isARMDeviceInAssembly() { boolean retVal = false; if (this.getXPICDeviceInfo().getFamily() != null && this.getXPICDeviceInfo().getFamily().equals(Family.ARM32BIT)) { retVal = true; }
return retVal; }
public boolean isAVRDeviceInAssembly() { boolean retVal = false; if (this.getXPICDeviceInfo().getFamily() != null && this.getXPICDeviceInfo().getFamily().equals(Family.AVR)) { retVal = true; }
return retVal; }
public boolean isPIC32DeviceInAssembly() { boolean retVal = false; if (this.getXPICDeviceInfo().getFamily() != null && this.getXPICDeviceInfo().getFamily().equals(Family.PIC32)) { retVal = true; }
return retVal; }
public List<String> getAtmelDeviceInterfaceList(String deviceName) { List<String> interfaceTypes = null; if (this.getXPICDeviceInfo().getFamily().equals(Family.AVR) || this.getXPICDeviceInfo().getFamily().equals(Family.ARM32BIT)) { Optional<AvrToolsDeviceFileType> atdf = DeviceInfoFactory.get(deviceName); if (atdf.isPresent()) { DeviceQuery query = new DeviceQuery(atdf.get()); interfaceTypes = query.getInterfaces().stream().map(i -> i.getType()).map(i -> i.toString().toLowerCase()).collect(Collectors.toList()); } }
return interfaceTypes; }
public boolean programAVR_ARMFuses(Optional start, Optional end) { boolean retVal = false; if (this.isARMDeviceInAssembly()) { this.toolsLookup.Connect(); long startAddr = (Long)this.deviceInfo.getXPICDeviceInfo().getMainPartition().getDCRRange().first; long endAddr = (Long)this.deviceInfo.getXPICDeviceInfo().getMainPartition().getDCRRange().second; start = Optional.of(startAddr); end = Optional.of(endAddr); retVal = this.toolsLookup.WriteAVR_ARMFuses(start, end); this.toolsLookup.disconnectTarget(); } else { this.toolsLookup.Connect(); }
return this.toolsLookup.WriteAVR_ARMFuses(start, end); }
public boolean readAVR_SAMFuses(Optional start, Optional end) { boolean retVal = false; if (this.isATDeviceInAssembly()) { this.toolsLookup.Connect(); retVal = this.toolsLookup.readAVR_SAMFuses(start, end); this.toolsLookup.disconnectTarget(); } else { retVal = this.toolsLookup.readAVR_SAMFuses(start, end); }
return retVal; }
public Map<String, ToolsLookup.ToolDetails> getToolsMap() { return this.toolsLookup.getToolsMap(); }
public String getToolNameBasedOnID(String id) { List<PlatformToolMeta> listOfAllTools = PlatformToolMetaManager.getAllTools(); String name = "";
for (PlatformToolMeta meta : listOfAllTools) { if (meta.getID().equalsIgnoreCase(id)) { name = meta.getName(); break; } }
return name; }
public IPELibrary.ToolPackReleaseWithReasonIfNotFound getToolPackRelease(Properties properties, String deviceName) { ToolPackRelease toolPackRelease = null; String errorString = null; if (!MPLABDocumentLocator.isReadingFromDFPFeatureEnabled()) { return null; } else if (this.GetPlatformMeta() == null) { errorString = getString("NO_TOOL_PACK_INTERNAL_ERROR_NO_META"); return new IPELibrary.ToolPackReleaseWithReasonIfNotFound(toolPackRelease, errorString); } else { ToolPackCapabilitiesProvider toolPackCapabilitiesProvider = this.GetPlatformMeta().getToolPackCapabilitiesProvider(); if (toolPackCapabilitiesProvider == null) { return null; } else { ToolPackReleaseFinder toolPackReleaseFinder = ToolPackManager.getToolPackReleaseFinder(); if (!toolPackCapabilitiesProvider.isUseToolPacks(properties)) { return null; } else if (toolPackCapabilitiesProvider.isUseLatestToolPack(properties)) { ToolPack toolPack = ToolPackManager.createMicrochipToolPack(this.toolID); toolPackRelease = toolPackReleaseFinder.getLatestToolPackRelease(toolPack, deviceName); if (toolPackRelease == null) { errorString = getString("COULD_NOT_FIND_LATEST_TOOL_PACK", this.toolID); }
return new IPELibrary.ToolPackReleaseWithReasonIfNotFound(toolPackRelease, errorString); } else { String toolPackVersion = toolPackCapabilitiesProvider.getToolPackVersion(properties); if (toolPackVersion != null && !toolPackVersion.isEmpty()) { ToolPack toolPack = ToolPackManager.createMicrochipToolPack(this.toolID); toolPackRelease = toolPackReleaseFinder.getToolPackRelease(toolPack, toolPackVersion, deviceName); if (toolPackRelease != null) { return new IPELibrary.ToolPackReleaseWithReasonIfNotFound(toolPackRelease, errorString); } else if (toolPackReleaseFinder.isToolPackReleasePresent(toolPack, toolPackVersion)) { errorString = getString("PACK_DOES_NOT_HAVE_SUPPORT_FOR_DEVICE", toolPackVersion, deviceName); return new IPELibrary.ToolPackReleaseWithReasonIfNotFound(toolPackRelease, errorString); } else { errorString = getString("COULD_NOT_FIND_SPECIFIC_TOOL_PACK", this.toolID, toolPackVersion); return new IPELibrary.ToolPackReleaseWithReasonIfNotFound(toolPackRelease, errorString); } } else { errorString = getString("COULD_NOT_FIND_SPECIFIC_TOOL_PACK", this.toolID); return new IPELibrary.ToolPackReleaseWithReasonIfNotFound(toolPackRelease, errorString); } } } } }
private static String getString(String s) { return NbBundle.getMessage(IPELibrary.class, s); }
private static String getString(String s, Object o) { return NbBundle.getMessage(IPELibrary.class, s, o); }
private static String getString(String s, Object o1, Object o2) { return NbBundle.getMessage(IPELibrary.class, s, o1, o2); }
public String[] showMPLABCommVerInfo() { String[] sCommver = new String[2]; if (this.shareData.getUIMode()) { sCommver[0] = System.getProperty("com.microchip.mplab.comm.USBAccess.version", "N/A"); sCommver[1] = System.getProperty("com.microchip.mplab.comm.SerialAccess.version", "N/A"); }
return sCommver; }
public DocumentChanger getChanger() { return new IPELibrary.OptModifier(); }
public Map getDeviceActionsMap() { return this.deviceActions; }
public void loadScriptCommands() { Thread t = new Thread(new Runnable() { @Override public void run() { IPELibrary.this.loadToolScripts(); } }); t.start(); }
private void loadToolScripts() { try { File f = this.runner.getToolDeviceFile(); if (f != null) { this.runner.loadModule(f); this.runner.loadFileIfExists(this.runner.getRepoLocation(), "properties_" + f.toString()); }
this.runner.loadFileIfExists(this.runner.getRepoLocation(), "properties_device.py"); this.loadScriptCommands("onloadDFP"); } catch (NullPointerException | ScriptControllerException var2) { MPLABLogger.mplog.log(Level.INFO, var2.getMessage()); } }
private void loadScriptCommands(String loadFuncName) { try { this.cmdloader.setCommandsKey(loadFuncName); this.runner.executeFunctionIfPresent(loadFuncName, new Object[]{this.cmdloader}); } catch (Exception var3) { MPLABLogger.mplog.log(Level.INFO, var3.getMessage()); } }
public boolean initPlatformTool(String toolConnected) { boolean retVal = true; this.toolMeta = null; List<PlatformToolMeta> listOfAllTools = PlatformToolMetaManager.getAllTools(); List<String> platformTools = new LinkedList<>();
for (PlatformToolMeta meta : listOfAllTools) { platformTools.add(meta.getID()); }
for (String platformTool : platformTools) { if (platformTool.equalsIgnoreCase(toolConnected)) { this.toolMeta = PlatformToolMetaManager.getTool(platformTool); break; } }
return retVal; }
public void initScript() { this.deviceActions.clear(); this.mediator = (ScriptMediator)this.shareData.getAssemblySession().getLookup().lookup(ScriptMediator.class); String platformID = this.toolMeta.getID(); String platformName = this.toolMeta.getName();
try { this.runner = this.mediator.setupRunner(platformID, platformName); if (this.runner != null) { File toolDeviceFile = this.runner.getToolDeviceFile(); if (toolDeviceFile != null) { if (toolDeviceFile.exists()) { this.checkForPythonFileExists = true; } } else { this.checkForPythonFileExists = false; } } } catch (Exception var4) { this.runner = this.mediator.getScriptRunner(Type.JYTHON2_7); }
if (this.runnerId < 0) { this.runnerId = ScriptOptValidator.addNewRunner(this.runner); }
this.runner.put("ide", this.cmdloader); this.loadToolScripts(); this.sig = this.toolMeta.getSignature(platformID); OptionLanguageSignatureProxy osp = (OptionLanguageSignatureProxy)this.sig; osp.setDocChanger(this.getChanger()); }
public boolean getPythonFileStatus() { return this.checkForPythonFileExists; }
public List<String> listAdapters() throws ServiceQueryException { new ArrayList();
try { this.toolsLookup.Connect(); return this.toolsLookup.listAdapters(); } catch (ServiceQueryException var3) { throw new ServiceQueryException(var3.getErrorMessage()); } }
public Map<String, List<String>> listEnvironments(List<String> adapters) throws ServiceQueryException { new HashMap();
try { if (!this.shareData.isConnected()) { this.toolsLookup.Connect(); }
return this.toolsLookup.listEnvironments(adapters); } catch (ServiceQueryException var4) { throw new ServiceQueryException(var4.getErrorMessage()); } }
public Map<String, String> getActiveEnvironments(List<String> adapters) throws ServiceQueryException { new HashMap();
try { if (!this.shareData.isConnected()) { this.toolsLookup.Connect(); }
return this.toolsLookup.getActiveEnvironments(adapters); } catch (ServiceQueryException var4) { throw new ServiceQueryException(var4.getErrorMessage()); } }
public Map<String, FirmwareInfo> getFirmwareInfo(List<String> adapters) throws ServiceQueryException { new HashMap();
try { if (!this.shareData.isConnected()) { this.toolsLookup.Connect(); }
return this.toolsLookup.getFirmwareInfo(adapters); } catch (ServiceQueryException var4) { throw new ServiceQueryException(var4.getErrorMessage()); } }
public void setActiveEnvironments(List<String> adapters, String environment) throws ServiceQueryException { try { if (!this.shareData.isConnected()) { this.toolsLookup.Connect(); }
this.toolsLookup.setActiveEnvironments(adapters, environment); } catch (ServiceQueryException var4) { throw new ServiceQueryException(var4.getErrorMessage()); } }
public void deleteEnvironments(String environment, List<String> adapters) throws ServiceQueryException { try { if (!this.shareData.isConnected()) { this.toolsLookup.Connect(); }
this.toolsLookup.deleteEnvironments(environment, adapters); } catch (ServiceQueryException var4) { throw new ServiceQueryException(var4.getErrorMessage()); } }
public void transferEnvironment(String environment, List<String> adapters) throws ServiceQueryException { try { if (!this.shareData.isConnected()) { this.toolsLookup.Connect(); }
this.toolsLookup.transferEnvironment(environment, adapters); } catch (ServiceQueryException var4) { throw new ServiceQueryException(var4.getErrorMessage()); } }
public List<String> listPM5Units() throws ServiceQueryException { new ArrayList();
try { if (!this.shareData.isConnected()) { this.toolsLookup.Connect(); }
return this.toolsLookup.listPM5Units(); } catch (ServiceQueryException var3) { throw new ServiceQueryException(var3.getErrorMessage()); } }
public List<String> listPM5MainSubUnits(String serialNum) throws ServiceQueryException { new ArrayList();
try { if (!this.shareData.isConnected()) { this.toolsLookup.Connect(); }
return this.toolsLookup.listPM5MainSubUnits(serialNum); } catch (ServiceQueryException var4) { throw new ServiceQueryException(var4.getErrorMessage()); } }
public List<String> listPM5MainEnvironments(String serialNum) throws ServiceQueryException { new ArrayList();
try { if (!this.shareData.isConnected()) { this.toolsLookup.Connect(); }
return this.toolsLookup.listPM5MainEnvironments(serialNum); } catch (ServiceQueryException var4) { throw new ServiceQueryException(var4.getErrorMessage()); } }
public Map<String, List<String>> listPM5MainSubEnvironments(String serialNum, List<String> adapters) throws ServiceQueryException { new HashMap();
try { if (!this.shareData.isConnected()) { this.toolsLookup.Connect(); }
return this.toolsLookup.listPM5MainSubEnvironments(serialNum, adapters); } catch (ServiceQueryException var5) { throw new ServiceQueryException(var5.getErrorMessage()); } }
public Map<String, String> getPM5MainSubActiveEnvironments(String serialNum, List<String> adapters) throws ServiceQueryException { new HashMap();
try { if (!this.shareData.isConnected()) { this.toolsLookup.Connect(); }
return this.toolsLookup.getPM5MainSubActiveEnvironments(serialNum, adapters); } catch (ServiceQueryException var5) { throw new ServiceQueryException(var5.getErrorMessage()); } }
public void setPM5MainSubActiveEnvironments(String serialNum, List<String> adapters, String environment) throws ServiceQueryException { try { if (!this.shareData.isConnected()) { this.toolsLookup.Connect(); }
this.toolsLookup.setPM5MainSubActiveEnvironments(serialNum, adapters, environment); } catch (ServiceQueryException var5) { throw new ServiceQueryException(var5.getErrorMessage()); } }
public void deletePM5MainEnvironments(String environment, String serialNum) throws ServiceQueryException { try { if (!this.shareData.isConnected()) { this.toolsLookup.Connect(); }
this.toolsLookup.deletePM5MainEnvironments(environment, serialNum); } catch (ServiceQueryException var4) { throw new ServiceQueryException(var4.getErrorMessage()); } }
public void deletePM5MainSubEnvironments(String environment, String serialNum, List<String> adapters) throws ServiceQueryException { try { if (!this.shareData.isConnected()) { this.toolsLookup.Connect(); }
this.toolsLookup.deletePM5MainSubEnvironments(environment, serialNum, adapters); } catch (ServiceQueryException var5) { throw new ServiceQueryException(var5.getErrorMessage()); } }
public Pm5Versions getPM5MainFirmwareInfo(String serialNum) throws ServiceQueryException { Pm5Versions pm5Version = null;
try { if (!this.shareData.isConnected()) { this.toolsLookup.Connect(); }
return this.toolsLookup.getPM5MainFirmwareInfo(serialNum); } catch (ServiceQueryException var4) { throw new ServiceQueryException(var4.getErrorMessage()); } }
public Map<String, FirmwareInfo> getPM5MainSubFirmwareInfo(String serialNum, List<String> adapters) throws ServiceQueryException { new HashMap();
try { if (!this.shareData.isConnected()) { this.toolsLookup.Connect(); }
return this.toolsLookup.getPM5MainSubFirmwareInfo(serialNum, adapters); } catch (ServiceQueryException var5) { throw new ServiceQueryException(var5.getErrorMessage()); } }
public void transferPM5MainEnvironment(String environment, String serialNum) throws ServiceQueryException { try { if (!this.shareData.isConnected()) { this.toolsLookup.Connect(); }
this.toolsLookup.transferPM5MainEnvironment(environment, serialNum); } catch (ServiceQueryException var4) { throw new ServiceQueryException(var4.getErrorMessage()); } }
public void transferEnvironmentToPM5MainSub(String environment, String serialNum, List<String> adapters) throws ServiceQueryException { try { if (!this.shareData.isConnected()) { this.toolsLookup.Connect(); }
this.toolsLookup.transferEnvironmentToPM5MainSub(environment, serialNum, adapters); } catch (ServiceQueryException var5) { throw new ServiceQueryException(var5.getErrorMessage()); } }
public Map<String, String> listPM5MainSubPgmStats(String environment, String serialNum, List<String> adapters) throws ServiceQueryException { new HashMap();
try { if (!this.shareData.isConnected()) { this.toolsLookup.Connect(); }
return this.toolsLookup.listPM5MainSubPgmStats(environment, serialNum, adapters); } catch (ServiceQueryException var6) { throw new ServiceQueryException(var6.getErrorMessage()); } }
public String getPM5Logs(String serialNum) throws ServiceQueryException { String results = "";
try { if (!this.shareData.isConnected()) { this.toolsLookup.Connect(); }
return this.toolsLookup.getPM5Logs(serialNum); } catch (ServiceQueryException var4) { throw new ServiceQueryException(var4.getErrorMessage()); } }
public class CommandLoader { private String source; String uri = "http://crownking/opt";
public void addEnumProperty(Document tree, String id, String location, String name, String desc, String defaultVal, String choicesString) { IPELibrary.CommandLoader.InsertionPoint n = this.findInsertionPoint(tree, location); if (n != null) { String[] choices = choicesString.split("\n"); if (choices.length == 0) { IPELibrary.this.runner .printErrorMessage( "No selections were provided in <" + choicesString + ">. Please state selection list as \n separated selections , e.g. <text1|name1|desc1\ntext2|name2|desc2> or <text|name|desc>", "Script error" ); } else { Element newNode = tree.createElementNS(this.uri, "opt:enumOption"); newNode.setAttributeNS(this.uri, "opt:id", id); newNode.setAttributeNS(this.uri, "opt:name", name); newNode.setAttributeNS(this.uri, "opt:textdefault", defaultVal); if (!"".equals(desc)) { newNode.setTextContent(desc); }
for (String c : choices) { String[] options = c.split("\\|"); if (options.length < 2) { IPELibrary.this.runner .printErrorMessage("Selection <" + c + "> is incomplete. Please describe as <text|name> or <text|name|desc>", "Script error"); } else { Element selectionNode = tree.createElementNS(this.uri, "opt:selection"); selectionNode.setAttributeNS(this.uri, "opt:text", options[0]); selectionNode.setAttributeNS(this.uri, "opt:name", options[1]); if (options.length > 2) { selectionNode.setTextContent(options[2]); }
newNode.insertBefore(selectionNode, null); } }
this.insertOrReplaceNodeBefore(n, newNode, id, true); } } }
public String expandProjectMacros(String projectName, String params) { return this.expandProjectMacrosEx(projectName, null, params, true); }
public String expandProjectMacrosEx(String projectName, String conf, String params, boolean debugMode) { return "board.xboard"; }
public void addTextProperty(Document tree, String id, String location, String name, String desc, String defaultVal) { this.addTextPropertyExt(tree, id, location, name, desc, defaultVal, null); }
public void addBooleanProperty(Document tree, String id, String location, String name, String desc, boolean defaultVal) { IPELibrary.CommandLoader.InsertionPoint n = this.findInsertionPoint(tree, location); if (n != null) { Element newNode = tree.createElementNS(this.uri, "opt:booleanOption"); newNode.setAttributeNS(this.uri, "opt:id", id); newNode.setAttributeNS(this.uri, "opt:name", name); newNode.setAttributeNS(this.uri, "opt:booldefault", defaultVal ? "true" : "false"); newNode.setTextContent(desc); this.insertOrReplaceNodeBefore(n, newNode, id, true); } }
public void addCommand(String directory, String func) { this.addCommandWithArgs(directory, func); }
public void addCommandWithArgs(String directory, String func) { String[] list = directory.split("\\|"); IPELibrary.this.deviceActions.put(list[list.length - 1], func); }
public void addPropCategory(Document tree, String id, String location, String name) { IPELibrary.CommandLoader.InsertionPoint n = this.findInsertionPoint(tree, location); if (n != null) { Element newNode = tree.createElementNS(this.uri, "opt:optionCategory"); newNode.setAttributeNS(this.uri, "opt:id", id); newNode.setAttributeNS(this.uri, "opt:name", name); this.insertOrReplaceNodeBefore(n, newNode, id, false); Element dummyChild = tree.createElementNS(this.uri, "opt:stringOption"); dummyChild.setAttributeNS(this.uri, "opt:id", "lastid"); dummyChild.setAttributeNS(this.uri, "opt:name", "last"); dummyChild.setAttributeNS(this.uri, "opt:showif", "${dummy}"); newNode.appendChild(dummyChild); } }
private IPELibrary.CommandLoader.InsertionPoint findInsertionPoint(Document tree, String location) { String[] path = location.split("\\|"); int pathLength = path.length; IPELibrary.CommandLoader.InsertionPoint p = new IPELibrary.CommandLoader.InsertionPoint(); p.parent = this.searchNode(tree, path, 0, pathLength - 1); if (p.parent == null) { IPELibrary.this.runner.printErrorMessage("Location " + location + " was not found in the opt file ", "Script error"); }
p.child = this.searchNode(p.parent, path, pathLength - 1, pathLength); return p; }
Node searchNode(Node n, String[] kw, int idx, int maxL) { if (idx == maxL) { return n; } else { for (Node var8 = n.getFirstChild(); var8 != null; var8 = var8.getNextSibling()) { if (var8.getNodeType() == 1) { Element e = (Element)var8; String id = e.getAttribute("opt:id"); if (kw[idx].equals("*") || id.equals(kw[idx])) { Node answer = this.searchNode(var8, kw, idx + 1, maxL); if (answer != null) { return answer; } } } }
return null; } }
public void addTextPropertyExt(Document tree, String id, String location, String name, String desc, String defaultVal, String validator) { IPELibrary.CommandLoader.InsertionPoint n = this.findInsertionPoint(tree, location); if (n != null) { Element newNode = tree.createElementNS(this.uri, "opt:stringOption"); newNode.setAttributeNS(this.uri, "opt:id", id); newNode.setAttributeNS(this.uri, "opt:name", name); if (validator != null) { newNode.setAttributeNS(this.uri, "opt:a0", Integer.toString(IPELibrary.this.runnerId)); newNode.setAttributeNS(this.uri, "opt:a1", validator); newNode.setAttributeNS(this.uri, "opt:validatorclass", "com.microchip.mplab.lib.scripting.ScriptOptValidator"); }
newNode.setAttributeNS(this.uri, "opt:textpreferred", defaultVal); newNode.setTextContent(desc); this.insertOrReplaceNodeBefore(n, newNode, id, true); } }
public void setCommandsKey(String s) { this.source = s; }
private void insertOrReplaceNodeBefore(IPELibrary.CommandLoader.InsertionPoint ip, Node newNode, String id, boolean replace) { Node pn = ip.parent; Node n = ip.child;
for (Node cn = pn.getFirstChild(); cn != null; cn = cn.getNextSibling()) { if (cn.getNodeType() == 1) { Element prevElement = (Element)cn; String nodeId = prevElement.getAttribute("opt:id"); if (nodeId.equals(id)) { if (n == cn) { n = n.getNextSibling(); }
if (!replace) { return; }
pn.removeChild(cn); break; } } }
if (n == null) { pn.appendChild(newNode); } else { pn.insertBefore(newNode, n); } }
class InsertionPoint { Node parent; Node child; } }
class OptModifier implements DocumentChanger { public Document change(Document in) { IPELibrary.this.runner.executeFunctionIfPresent("onShowPropsDFP", new Object[]{in}); IPELibrary.this.runner.executeFunctionIfPresent("onShowProps", new Object[]{in}); return in; } }
public final class ToolPackReleaseWithReasonIfNotFound { public final ToolPackRelease toolPackRelease; public final String reasonNotFound;
public ToolPackReleaseWithReasonIfNotFound(ToolPackRelease toolPackRelease, String reasonNotFound) { this.toolPackRelease = toolPackRelease; this.reasonNotFound = reasonNotFound; } }
public static enum ToolShortName { SNAP("snap"), ICD4("ICD_4_2"), ICD5("ICD_5"), PK4("PICkit_4"), PK5("PICkit_5"), PKOB4("Curiosity_Starter_Kits"), PKOB("Starter_Kits"), AICE("AtmelIce"), PM3("PM3"), PK3("PICkit3"), ICD3("ICD3"), Edbg("Edbg"), MEdbg("MEdbg"), NEdbg("NEdbg"), RICE("RealIce"), ICE4("ICE_4"), J32("j32"), PKBASIC("PICKITBasic"), PM5PA("PM5PA"), PM5("PM5");
private final String toolId;
private ToolShortName(String toolId) { this.toolId = toolId; }
public String getToolId() { return this.toolId; } }}