only:cast enum to int for data logging

This commit is contained in:
rusefillc 2023-11-26 12:56:47 -05:00
parent 4fff20bcbf
commit 4309e5f759
2 changed files with 20 additions and 2 deletions

View File

@ -74,6 +74,19 @@ public class SdCardFieldsGeneratorTest {
}, true);
}
@Test
public void enumField() {
processAndAssert("struct_no_prefix output_channels_s\n" +
" custom idle_state_e 4 bits, S32, @OFFSET@, [0:2], \"not important\"\n" +
" idle_state_e idleState\n" +
"end_struct",
"",
readerState -> {
}, true);
}
interface Actor {
void act(ReaderStateImpl readerState);
}

View File

@ -50,17 +50,22 @@ public class SdCardFieldsContent {
private String getLine(ConfigField configField, String prefix, String name) {
String categoryStr = configField.getCategory();
if(categoryStr == null) {
if (categoryStr == null) {
categoryStr = "";
} else {
categoryStr = ", " + categoryStr;
}
boolean isEnum = configField.getType().contains("_e");
if (isEnum)
return "";
String before = conditional == null ? "" : "#if " + conditional + "\n";
String after = conditional == null ? "" : "#endif\n";
return before
+ "\t{" + home + (isPtr ? "->" : ".") + name +
+ "\t{" +
home + (isPtr ? "->" : ".") + name +
", "
+ DataLogConsumer.getHumanGaugeName(prefix, configField) +
", " +