use of net.sourceforge.usbdm.jni.UsbdmException in project usbdm-eclipse-plugins by podonoghue.
the class ExampleList method parseVariables.
/**
* @param projectInfo project info
*
* @param exampleElement <example> element
*
* @throws UsbdmException
*/
private void parseVariables(ProjectInformation projectInfo, Element exampleElement) throws UsbdmException {
for (Node node = exampleElement.getFirstChild(); node != null; node = node.getNextSibling()) {
// element node for <example>
if (node.getNodeType() != Node.ELEMENT_NODE) {
continue;
}
Element element = (Element) node;
if (element.getTagName() != "variable") {
throw new UsbdmException("parseExampleList(" + node.getNodeName() + ") - not variable element");
}
String key = element.getAttribute("name");
String value = element.getTextContent();
projectInfo.addAttribute(key, value);
}
}
use of net.sourceforge.usbdm.jni.UsbdmException in project usbdm-eclipse-plugins by podonoghue.
the class ParseMenuXML method parseSignalsOption.
/**
* Parse the pin associated with the peripheral
*
* @param parentModel
* @param element
* @throws UsbdmException
*/
private void parseSignalsOption(BaseModel parentModel, Element element) throws UsbdmException {
// Initially assume pins refer to current peripheral
Peripheral peripheral = fPeripheral;
boolean optional = Boolean.valueOf(element.getAttribute("optional"));
String peripheralName = element.getAttribute("name");
if (!peripheralName.isEmpty()) {
// Change to referenced peripheral
peripheral = fPeripheral.getDeviceInfo().getPeripherals().get(peripheralName);
}
if (peripheral == null) {
if (!optional) {
throw new UsbdmException("Unable to find peripheral '" + peripheralName + "' for pins");
}
return;
}
fPeripheral.addSignals(parentModel, peripheral);
}
use of net.sourceforge.usbdm.jni.UsbdmException in project usbdm-eclipse-plugins by podonoghue.
the class ParseFamilyCSV method parseFile.
/**
* Process file
*
* @param filePath File to process
*
* @return Class containing information from file
*
* @throws IOException
*/
public void parseFile(Path filePath) throws Exception {
// Open source file
BufferedReader sourceFile = Files.newBufferedReader(filePath, StandardCharsets.UTF_8);
parsePreliminaryInformation(sourceFile);
sourceFile.close();
fDeviceInfo.initialiseTemplates();
// Re-open source file
sourceFile = Files.newBufferedReader(filePath, StandardCharsets.UTF_8);
parseFile(sourceFile);
sourceFile.close();
// Information from device database
final DevicePeripherals fDevicePeripherals = fDeviceInfo.getDevicePeripherals();
// Create map to allow peripheral lookup
final Map<String, net.sourceforge.usbdm.peripheralDatabase.Peripheral> fPeripheralMap = createPeripheralsMap(fDevicePeripherals);
// Attach information from device database
for (Entry<String, Peripheral> entry : fDeviceInfo.getPeripherals().entrySet()) {
Peripheral peripheral = entry.getValue();
// Get database peripheral entry
net.sourceforge.usbdm.peripheralDatabase.Peripheral dbPeripheral = fPeripheralMap.get(entry.getKey());
if ((dbPeripheral == null)) {
if (!peripheral.isSynthetic()) {
throw new UsbdmException("Peripheral " + entry.getKey() + " not found");
}
continue;
}
// Get peripheral version
peripheral.setVersion(dbPeripheral.getBasePeripheral().getSourceFilename().toLowerCase());
// Attach DMAMUX information from database
String[] dmaMuxInputs = dbPeripheral.getDmaMuxInputs();
if (dmaMuxInputs != null) {
if ((dmaMuxInputs.length != 64) && (dmaMuxInputs.length != 128)) {
throw new UsbdmException("Illegal dma table size");
}
int slotNum = 0;
for (String dmaMuxInput : dmaMuxInputs) {
if (!dmaMuxInput.startsWith("Reserved")) {
fDeviceInfo.createDmaInfo("0", slotNum, dmaMuxInput);
}
slotNum++;
}
}
// Attach interrupt information
final Pattern p = Pattern.compile("^GPIO([A-Z]).*$");
Matcher m = p.matcher(entry.getKey());
if (m.matches()) {
dbPeripheral = fPeripheralMap.get(m.replaceAll("PORT$1"));
}
if (dbPeripheral == null) {
throw new UsbdmException("Peripheral " + m.replaceAll("PORT$1") + " not found");
}
ArrayList<InterruptEntry> interruptEntries = dbPeripheral.getInterruptEntries();
if (interruptEntries != null) {
for (InterruptEntry interruptEntry : interruptEntries) {
peripheral.addIrqNum(interruptEntry.getName() + "_IRQn");
}
}
}
fDeviceInfo.consistencyCheck();
}
use of net.sourceforge.usbdm.jni.UsbdmException in project usbdm-eclipse-plugins by podonoghue.
the class DeviceInfo method getDevicePeripherals.
/**
* Get peripheral information from SVD file<br>
* This is a time consuming operation.
*
* @return Peripheral information
*
* @throws UsbdmException
*/
public DevicePeripherals getDevicePeripherals() throws UsbdmException {
DevicePeripheralsFactory factory = new DevicePeripheralsFactory();
DevicePeripherals devicePeripherals = factory.getDevicePeripherals(fDeviceSubFamily);
if (devicePeripherals == null) {
throw new UsbdmException("Failed to create devicePeripherals from SVD for \'" + fDeviceSubFamily + "\'");
}
return devicePeripherals;
}
use of net.sourceforge.usbdm.jni.UsbdmException in project usbdm-eclipse-plugins by podonoghue.
the class UsbdmJniPluginTest method main.
/**
* @param args
* @throws InterruptedException
* @throws UsbdmException
*/
public static void main(String[] args) throws InterruptedException, UsbdmException {
String errorMessage = null;
// testDatabase();
try {
listEnvironment();
// CustomClassLoader ccl = new CustomClassLoader();
//
// Class<?> ca = ccl.findClass("net.sourceforge.usbdm.jni.Usbdm");
// Object a = ca.newInstance();
// ccl = null;
// System.gc();
// Print USBDM paths
System.err.println("Application Path : " + Usbdm.getApplicationPath().toOSString());
System.err.println("Resource Path : " + Usbdm.getResourcePath().toOSString());
System.err.println("Data Path : " + Usbdm.getDataPath().toOSString());
// listDevices();
// Get count of devices (creates internal list)
int deviceCount = Usbdm.findDevices();
if (deviceCount == 0) {
System.err.println("No USBDM devices found");
return;
}
System.err.println("No of USBDM devices found " + deviceCount);
// Open last device
Usbdm.open(deviceCount - 1);
System.err.println("Opened device: " + Usbdm.getBDMDescription());
// testCFV1();
testKinetis();
Usbdm.close();
} catch (Exception e) {
e.printStackTrace();
errorMessage = e.getMessage();
if (errorMessage == null) {
errorMessage = e.toString();
}
if (errorMessage == null) {
errorMessage = "Unknown exception";
}
} finally {
Usbdm.exit();
if (errorMessage != null) {
Shell shell;
// Find the default display and get the active shell
final Display disp = Display.getDefault();
if (disp == null) {
shell = new Shell(new Display());
} else {
shell = new Shell(disp);
}
MessageBox msgbox = new MessageBox(shell, SWT.OK);
msgbox.setText("USBDM Error");
msgbox.setMessage(errorMessage);
msgbox.open();
}
}
}
Aggregations