Skip to content

Commit

Permalink
fix(plc4j): Made the bacnet RandomPackagesTest.java execute on Window…
Browse files Browse the repository at this point in the history
…s and updated the documentation on setting up libpcap on Windows.
  • Loading branch information
chrisdutz committed Feb 26, 2022
1 parent 4fc0433 commit 0b7605e
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -116,10 +116,14 @@ public void enterIdentifierSegment(ExpressionParser.IdentifierSegmentContext ctx
String propertyName = ctx.name.getText();

CompletableFuture<TypeReference> typeReferenceFuture = new CompletableFuture<>();
// If this is the root of a variable expression, the stack is "null".
if (futureStack == null) {
schedulePropertyResolution(propertyName, typeReferenceFuture, rootTypeName);
futureStack = new Stack<>();
} else {
}
// If the stack is not null, we're in one of the children levels. We need to wait
// till the parent is resolved first. So we delay the resolution till that's done.
else {
futureStack.peek().whenComplete((typeReference, throwable) -> {
if (throwable != null) {
LOGGER.debug("Error processing variables", throwable);
Expand All @@ -134,11 +138,13 @@ public void enterIdentifierSegment(ExpressionParser.IdentifierSegmentContext ctx
}

private void schedulePropertyResolution(String propertyName, CompletableFuture<TypeReference> typeReferenceFuture, String typeName) {
// As soon as the type with the given name is resolved ...
lazyTypeDefinitionConsumer.setOrScheduleTypeDefinitionConsumer(typeName, (TypeDefinition typeDefinition) -> {
if (!typeDefinition.isComplexTypeDefinition()) {
typeReferenceFuture.completeExceptionally(new RuntimeException("is not a complex type"));
return;
}
// Get the definition of the field with the given property name.
final ComplexTypeDefinition complexTypeDefinition = typeDefinition
.asComplexTypeDefinition()
.orElseThrow();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
import org.apache.plc4x.plugins.codegenerator.language.mspec.model.terms.DefaultBooleanLiteral;
import org.apache.plc4x.plugins.codegenerator.language.mspec.model.terms.DefaultVariableLiteral;
import org.apache.plc4x.plugins.codegenerator.protocol.TypeContext;
import org.apache.plc4x.plugins.codegenerator.types.definitions.TypeDefinition;
import org.apache.plc4x.plugins.codegenerator.types.enums.EnumValue;
import org.apache.plc4x.plugins.codegenerator.types.references.SimpleTypeReference;
import org.junit.jupiter.api.Test;
Expand Down
11 changes: 9 additions & 2 deletions src/site/asciidoc/developers/preparing/windows.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,18 @@ In order to install it, please download end execute the installer from https://g
A special version of LibPCAP is available for Windows, which is called Npcap.
It is available from https://npcap.com/[here].

Additional tasks to enable Java to find the pcap executables may need to be done.
Follow the instructions https://github.com/kaitoy/pcap4j#about-native-library-loading[here]
So in order to install things correctly:

1. install the version Npcap from above location.
2. Add `%SystemRoot%\System32\Npcap\` to your System's `PATH`
3. Possibly reboot

After this all should be working.

If not, have a look here for possible help: https://github.com/kaitoy/pcap4j#about-native-library-loading[here]

NOTE: If you had WinPcap installed, you need to uninstall this and make sure the files `Packet.dll` and `wpcap.dll` are deleted in the `%SystemRoot%\System32\` directory. Otherwise `pcap4j` will incorrectly detect a wrong version.

=== gcc

Checking:
Expand Down

0 comments on commit 0b7605e

Please sign in to comment.