H64 uses GPIOD_12 twice why does it not fail? #2877
only code clean-up no functional changes
This commit is contained in:
parent
53e4908497
commit
5608caf6fc
|
@ -1,30 +1,29 @@
|
||||||
package com.rusefi;
|
package com.rusefi;
|
||||||
|
|
||||||
import com.rusefi.generated.*;
|
import com.rusefi.enum_reader.Value;
|
||||||
|
import com.rusefi.generated.RusefiConfigGrammarLexer;
|
||||||
|
import com.rusefi.generated.RusefiConfigGrammarParser;
|
||||||
import com.rusefi.newparse.ParseState;
|
import com.rusefi.newparse.ParseState;
|
||||||
import com.rusefi.newparse.outputs.CStructWriter;
|
|
||||||
import com.rusefi.newparse.outputs.TsWriter;
|
|
||||||
import com.rusefi.newparse.parsing.Definition;
|
import com.rusefi.newparse.parsing.Definition;
|
||||||
import com.rusefi.output.*;
|
import com.rusefi.output.*;
|
||||||
import com.rusefi.util.*;
|
import com.rusefi.util.CachingStrategy;
|
||||||
|
import com.rusefi.util.IoUtils;
|
||||||
|
import com.rusefi.util.LazyFile;
|
||||||
|
import com.rusefi.util.SystemOut;
|
||||||
import org.antlr.v4.runtime.*;
|
import org.antlr.v4.runtime.*;
|
||||||
import org.antlr.v4.runtime.tree.ParseTree;
|
import org.antlr.v4.runtime.tree.ParseTree;
|
||||||
import org.antlr.v4.runtime.tree.ParseTreeWalker;
|
import org.antlr.v4.runtime.tree.ParseTreeWalker;
|
||||||
|
|
||||||
import com.rusefi.enum_reader.Value;
|
|
||||||
import org.yaml.snakeyaml.Yaml;
|
import org.yaml.snakeyaml.Yaml;
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.math.BigInteger;
|
import java.nio.file.Files;
|
||||||
import java.nio.file.*;
|
|
||||||
import java.security.MessageDigest;
|
|
||||||
import java.security.NoSuchAlgorithmException;
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.zip.CRC32;
|
import java.util.zip.CRC32;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Andrey Belomutskiy, (c) 2013-2020
|
* Andrey Belomutskiy, (c) 2013-2020
|
||||||
* 1/12/15
|
* 1/12/15
|
||||||
|
*
|
||||||
* @see ConfigurationConsumer
|
* @see ConfigurationConsumer
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("StringConcatenationInsideStringBufferAppend")
|
@SuppressWarnings("StringConcatenationInsideStringBufferAppend")
|
||||||
|
@ -205,8 +204,8 @@ public class ConfigDefinition {
|
||||||
FilenameFilter filter = (f, name) -> name.endsWith(".yaml");
|
FilenameFilter filter = (f, name) -> name.endsWith(".yaml");
|
||||||
yamlFiles = dirName.listFiles(filter);
|
yamlFiles = dirName.listFiles(filter);
|
||||||
if (yamlFiles != null) {
|
if (yamlFiles != null) {
|
||||||
for (int f = 0; f < yamlFiles.length; f++) {
|
for (File yamlFile : yamlFiles) {
|
||||||
inputFiles.add("config/boards/" + boardName + "/connectors/" + yamlFiles[f].getName());
|
inputFiles.add("config/boards/" + boardName + "/connectors/" + yamlFile.getName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -265,10 +264,10 @@ public class ConfigDefinition {
|
||||||
// Ignore duplicates of definitions made during prepend phase
|
// Ignore duplicates of definitions made during prepend phase
|
||||||
listener.setDefinitionPolicy(Definition.OverwritePolicy.IgnoreNew);
|
listener.setDefinitionPolicy(Definition.OverwritePolicy.IgnoreNew);
|
||||||
|
|
||||||
for (String prependFile : prependFiles) {
|
//for (String prependFile : prependFiles) {
|
||||||
// TODO: fix signature define file parsing
|
// TODO: fix signature define file parsing
|
||||||
//parseFile(listener, prependFile);
|
//parseFile(listener, prependFile);
|
||||||
}
|
//}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Now load the main config file
|
// Now load the main config file
|
||||||
|
@ -392,15 +391,15 @@ public class ConfigDefinition {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void processYamls(VariableRegistry registry, File[] yamlFiles, ReaderState state) throws IOException {
|
public static void processYamls(VariableRegistry registry, File[] yamlFiles, ReaderState state) throws IOException {
|
||||||
ArrayList<Map<String, Object>> listPins = new ArrayList();
|
ArrayList<Map<String, Object>> listPins = new ArrayList<>();
|
||||||
for (File yamlFile : yamlFiles) {
|
for (File yamlFile : yamlFiles) {
|
||||||
processYamlFile(yamlFile, state, listPins);
|
processYamlFile(yamlFile, listPins);
|
||||||
}
|
}
|
||||||
registerPins(listPins, registry, state);
|
registerPins(listPins, registry, state);
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
private static void processYamlFile(File yamlFile, ReaderState state,
|
private static void processYamlFile(File yamlFile,
|
||||||
ArrayList<Map<String, Object>> listPins) throws IOException {
|
ArrayList<Map<String, Object>> listPins) throws IOException {
|
||||||
Yaml yaml = new Yaml();
|
Yaml yaml = new Yaml();
|
||||||
Map<String, Object> yamlData = yaml.load(new FileReader(yamlFile));
|
Map<String, Object> yamlData = yaml.load(new FileReader(yamlFile));
|
||||||
|
@ -419,19 +418,19 @@ public class ConfigDefinition {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (pinId instanceof ArrayList) {
|
if (pinId instanceof ArrayList) {
|
||||||
ArrayList pinIds = (ArrayList) pinId;
|
ArrayList<String> pinIds = (ArrayList<String>) pinId;
|
||||||
if (!(pinClass instanceof ArrayList))
|
if (!(pinClass instanceof ArrayList))
|
||||||
throw new IllegalStateException("Expected multiple classes for " + pinIds);
|
throw new IllegalStateException("Expected multiple classes for " + pinIds);
|
||||||
for (int i = 0; i < pinIds.size(); i++) {
|
for (int i = 0; i < pinIds.size(); i++) {
|
||||||
String id = (String) pinIds.get(i);
|
String id = pinIds.get(i);
|
||||||
Map<String, Object> thisPin = new HashMap();
|
Map<String, Object> thisPin = new HashMap<>();
|
||||||
thisPin.put("id", pinIds.get(i));
|
thisPin.put("id", id);
|
||||||
thisPin.put("ts_name", pinName);
|
thisPin.put("ts_name", pinName);
|
||||||
thisPin.put("class", ((ArrayList) pinClass).get(i));
|
thisPin.put("class", ((ArrayList<String>) pinClass).get(i));
|
||||||
listPins.add(thisPin);
|
listPins.add(thisPin);
|
||||||
}
|
}
|
||||||
} else if (pinId instanceof String) {
|
} else if (pinId instanceof String) {
|
||||||
Map<String, Object> thisPin = new HashMap();
|
Map<String, Object> thisPin = new HashMap<>();
|
||||||
thisPin.put("id", pinId);
|
thisPin.put("id", pinId);
|
||||||
thisPin.put("ts_name", pinName);
|
thisPin.put("ts_name", pinName);
|
||||||
thisPin.put("class", pinClass);
|
thisPin.put("class", pinClass);
|
||||||
|
@ -446,11 +445,11 @@ public class ConfigDefinition {
|
||||||
if (listPins == null || listPins.isEmpty()) {
|
if (listPins == null || listPins.isEmpty()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Map<String, ArrayList<String>> names = new HashMap();
|
Map<String, ArrayList<String>> names = new HashMap<>();
|
||||||
names.put("outputs", new ArrayList<String>());
|
names.put("outputs", new ArrayList<>());
|
||||||
names.put("analog_inputs", new ArrayList<String>());
|
names.put("analog_inputs", new ArrayList<>());
|
||||||
names.put("event_inputs", new ArrayList<String>());
|
names.put("event_inputs", new ArrayList<>());
|
||||||
names.put("switch_inputs", new ArrayList<String>());
|
names.put("switch_inputs", new ArrayList<>());
|
||||||
for (int i = 0; i < listPins.size(); i++) {
|
for (int i = 0; i < listPins.size(); i++) {
|
||||||
for (int ii = i + 1; ii < listPins.size(); ii++) {
|
for (int ii = i + 1; ii < listPins.size(); ii++) {
|
||||||
if (listPins.get(i).get("id") == listPins.get(ii).get("id")) {
|
if (listPins.get(i).get("id") == listPins.get(ii).get("id")) {
|
||||||
|
@ -578,37 +577,13 @@ public class ConfigDefinition {
|
||||||
line = line.substring(index).trim();
|
line = line.substring(index).trim();
|
||||||
}
|
}
|
||||||
if (VariableRegistry.isNumeric(line)) {
|
if (VariableRegistry.isNumeric(line)) {
|
||||||
Integer v = Integer.valueOf(line);
|
int v = Integer.parseInt(line);
|
||||||
registry.register(name, v);
|
registry.register(name, v);
|
||||||
} else {
|
} else {
|
||||||
registry.register(name, line);
|
registry.register(name, line);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String getMd5(byte[] content) {
|
|
||||||
try {
|
|
||||||
// Static getInstance method is called with hashing MD5
|
|
||||||
MessageDigest md = MessageDigest.getInstance("MD5");
|
|
||||||
|
|
||||||
// digest() method is called to calculate message digest
|
|
||||||
// of an input digest() return array of byte
|
|
||||||
byte[] messageDigest = md.digest(content);
|
|
||||||
|
|
||||||
// Convert byte array into signum representation
|
|
||||||
BigInteger no = new BigInteger(1, messageDigest);
|
|
||||||
|
|
||||||
// Convert message digest into hex value
|
|
||||||
String hashtext = no.toString(16);
|
|
||||||
while (hashtext.length() < 32) {
|
|
||||||
hashtext = "0" + hashtext;
|
|
||||||
}
|
|
||||||
return hashtext;
|
|
||||||
} catch (NoSuchAlgorithmException e) {
|
|
||||||
// For specifying wrong message digest algorithms
|
|
||||||
throw new RuntimeException(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static long getCrc32(String fileName) throws IOException {
|
private static long getCrc32(String fileName) throws IOException {
|
||||||
File file = new File(fileName);
|
File file = new File(fileName);
|
||||||
byte[] fileContent = Files.readAllBytes(file.toPath());
|
byte[] fileContent = Files.readAllBytes(file.toPath());
|
||||||
|
@ -644,7 +619,7 @@ public class ConfigDefinition {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void parseFile(ParseState listener, String filePath) throws FileNotFoundException, IOException {
|
private static void parseFile(ParseState listener, String filePath) throws IOException {
|
||||||
SystemOut.println("Parsing file (Antlr) " + filePath);
|
SystemOut.println("Parsing file (Antlr) " + filePath);
|
||||||
|
|
||||||
CharStream in = new ANTLRInputStream(new FileInputStream(filePath));
|
CharStream in = new ANTLRInputStream(new FileInputStream(filePath));
|
||||||
|
|
Loading…
Reference in New Issue