Skip to content

Commit

Permalink
fix: Got the data flowing in the NG-Profinet driver.
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisdutz committed Dec 10, 2023
1 parent 48f8e65 commit 6df0fa5
Show file tree
Hide file tree
Showing 17 changed files with 521 additions and 536 deletions.
16 changes: 10 additions & 6 deletions plc4j/drivers/profinet-ng/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,9 @@ A connection string would look like this in this case:
## GSD Device Profiles

A Profinet device is described by a GSD file.

A GSD file is an XML file containing a description of the device.

Only with this information can we provide browsing functionality, verify requests and reduce the amount of information passed to the driver to an absolute minimum.

There are multiple coordinates needed to identify which resources a PN device offers.
Expand All @@ -53,23 +55,24 @@ The most important ones are the vendor-id and the device-id. This tuple uniquely
When connecting to a remote device, we execute a PN-DCP Identification request is sent to the device.
This is the same type of request used in the Auto-Discovery of PLC4X to find PN devices.
The main difference in this case however is that we don't send it to the broadcast MAC address, but send it to the devices MAC address instead.

In the response we can get the vendor-id and the device-id along with a number of additional information (IP settings, name of the device, type of device).
With this information we then iterate over the GSD files in our "gsd directory" (Which defaults to "~/.gsd").
As soon as we found an XML file with a matching pair of vendor-id and product-id we use that device profile for this connection.

A PN device always had one fixed component, the so-called DAP (Device Access Point).
A PN device always has one fixed component, the so-called DAP (Device Access Point).
This is always located in "slot 0" and you can think of this as the IO component that provides the connection between the network and the devices, using the Profinet protocol.
Most device profiles only have one DAP and in this case, we simply use that.
However, there are some devices where the manufacturer updated the device over time and didn't give the new device a new product id.
In this case, device profiles can contain a variety of DAPs.

If we are connecting to such a device it is important to know which DAP the devices provides.

Next to the DAP in Slot 0 come the actual devices.
In some devices they are integrated into the same housing, only logically having multiple slots.
This is the case for my Advantec Adam modules belong to this category the same way my Siemens Simodode Pro V PN device does.
After the DAP in Slot 0 come the actual devices slots.
In some devices these are integrated into the same housing, only logically having multiple slots.
This is the case for my Advantec Adam modules also my Siemens Simodode Pro V PN device.

Others however allow understanding this concept a bit better though.
Other types of devices however allow understanding this concept a bit better though.
So-called Bus-Couplers for example provide PN access to IO devices.
Here you have the bus-coupler in slot 0 (which is the left-most element) and then you add on IO modules by sliding them onto the right.
When adding a new module to the existing, the new module is always added to the right.
Expand Down Expand Up @@ -101,7 +104,8 @@ In case of a Wago bus-coupler for example this looks like this:

You can see that the bus-coupler generally allows adding 250 devices.
Each entry in this list being one IO module Product Wago has to offer.
"0606_0000" being a "Power Supply 24 V DC, max. 1.0 A; Ex i; diagnostics" and "0403_0000" being a "4-channel digital input; 24 V DC; 0.2 ms input filter; 2- to 3-conductor connection; high-side switching"
- "0606_0000" being a "Power Supply 24 V DC, max. 1.0 A; Ex i; diagnostics" and
- "0403_0000" being a "4-channel digital input; 24 V DC; 0.2 ms input filter; 2- to 3-conductor connection; high-side switching"

## Auto-Configuring the connection

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public PnIoCm_BlockType getBlockType() {
protected final MacAddress cmInitiatorMacAddr;
protected final DceRpc_ObjectUuid cmInitiatorObjectUuid;
protected final boolean pullModuleAlarmAllowed;
protected final boolean nonLegacyStartupMode;
protected final boolean advancedStartupMode;
protected final boolean combinedObjectContainerUsed;
protected final boolean acknowledgeCompanionAr;
protected final PnIoCm_CompanionArType companionArType;
Expand All @@ -76,7 +76,7 @@ public PnIoCm_Block_ArReq(
MacAddress cmInitiatorMacAddr,
DceRpc_ObjectUuid cmInitiatorObjectUuid,
boolean pullModuleAlarmAllowed,
boolean nonLegacyStartupMode,
boolean advancedStartupMode,
boolean combinedObjectContainerUsed,
boolean acknowledgeCompanionAr,
PnIoCm_CompanionArType companionArType,
Expand All @@ -96,7 +96,7 @@ public PnIoCm_Block_ArReq(
this.cmInitiatorMacAddr = cmInitiatorMacAddr;
this.cmInitiatorObjectUuid = cmInitiatorObjectUuid;
this.pullModuleAlarmAllowed = pullModuleAlarmAllowed;
this.nonLegacyStartupMode = nonLegacyStartupMode;
this.advancedStartupMode = advancedStartupMode;
this.combinedObjectContainerUsed = combinedObjectContainerUsed;
this.acknowledgeCompanionAr = acknowledgeCompanionAr;
this.companionArType = companionArType;
Expand Down Expand Up @@ -141,8 +141,8 @@ public boolean getPullModuleAlarmAllowed() {
return pullModuleAlarmAllowed;
}

public boolean getNonLegacyStartupMode() {
return nonLegacyStartupMode;
public boolean getAdvancedStartupMode() {
return advancedStartupMode;
}

public boolean getCombinedObjectContainerUsed() {
Expand Down Expand Up @@ -258,10 +258,10 @@ protected void serializePnIoCm_BlockChild(WriteBuffer writeBuffer) throws Serial
writeBoolean(writeBuffer),
WithOption.WithByteOrder(ByteOrder.BIG_ENDIAN));

// Simple Field (nonLegacyStartupMode)
// Simple Field (advancedStartupMode)
writeSimpleField(
"nonLegacyStartupMode",
nonLegacyStartupMode,
"advancedStartupMode",
advancedStartupMode,
writeBoolean(writeBuffer),
WithOption.WithByteOrder(ByteOrder.BIG_ENDIAN));

Expand Down Expand Up @@ -405,7 +405,7 @@ public int getLengthInBits() {
// Simple field (pullModuleAlarmAllowed)
lengthInBits += 1;

// Simple field (nonLegacyStartupMode)
// Simple field (advancedStartupMode)
lengthInBits += 1;

// Simple field (combinedObjectContainerUsed)
Expand Down Expand Up @@ -513,9 +513,9 @@ public static PnIoCm_BlockBuilder staticParsePnIoCm_BlockBuilder(ReadBuffer read
readBoolean(readBuffer),
WithOption.WithByteOrder(ByteOrder.BIG_ENDIAN));

boolean nonLegacyStartupMode =
boolean advancedStartupMode =
readSimpleField(
"nonLegacyStartupMode",
"advancedStartupMode",
readBoolean(readBuffer),
WithOption.WithByteOrder(ByteOrder.BIG_ENDIAN));

Expand Down Expand Up @@ -612,7 +612,7 @@ public static PnIoCm_BlockBuilder staticParsePnIoCm_BlockBuilder(ReadBuffer read
cmInitiatorMacAddr,
cmInitiatorObjectUuid,
pullModuleAlarmAllowed,
nonLegacyStartupMode,
advancedStartupMode,
combinedObjectContainerUsed,
acknowledgeCompanionAr,
companionArType,
Expand All @@ -636,7 +636,7 @@ public static class PnIoCm_Block_ArReqBuilderImpl implements PnIoCm_Block.PnIoCm
private final MacAddress cmInitiatorMacAddr;
private final DceRpc_ObjectUuid cmInitiatorObjectUuid;
private final boolean pullModuleAlarmAllowed;
private final boolean nonLegacyStartupMode;
private final boolean advancedStartupMode;
private final boolean combinedObjectContainerUsed;
private final boolean acknowledgeCompanionAr;
private final PnIoCm_CompanionArType companionArType;
Expand All @@ -659,7 +659,7 @@ public PnIoCm_Block_ArReqBuilderImpl(
MacAddress cmInitiatorMacAddr,
DceRpc_ObjectUuid cmInitiatorObjectUuid,
boolean pullModuleAlarmAllowed,
boolean nonLegacyStartupMode,
boolean advancedStartupMode,
boolean combinedObjectContainerUsed,
boolean acknowledgeCompanionAr,
PnIoCm_CompanionArType companionArType,
Expand All @@ -680,7 +680,7 @@ public PnIoCm_Block_ArReqBuilderImpl(
this.cmInitiatorMacAddr = cmInitiatorMacAddr;
this.cmInitiatorObjectUuid = cmInitiatorObjectUuid;
this.pullModuleAlarmAllowed = pullModuleAlarmAllowed;
this.nonLegacyStartupMode = nonLegacyStartupMode;
this.advancedStartupMode = advancedStartupMode;
this.combinedObjectContainerUsed = combinedObjectContainerUsed;
this.acknowledgeCompanionAr = acknowledgeCompanionAr;
this.companionArType = companionArType;
Expand All @@ -706,7 +706,7 @@ public PnIoCm_Block_ArReq build() {
cmInitiatorMacAddr,
cmInitiatorObjectUuid,
pullModuleAlarmAllowed,
nonLegacyStartupMode,
advancedStartupMode,
combinedObjectContainerUsed,
acknowledgeCompanionAr,
companionArType,
Expand Down Expand Up @@ -740,7 +740,7 @@ public boolean equals(Object o) {
&& (getCmInitiatorMacAddr() == that.getCmInitiatorMacAddr())
&& (getCmInitiatorObjectUuid() == that.getCmInitiatorObjectUuid())
&& (getPullModuleAlarmAllowed() == that.getPullModuleAlarmAllowed())
&& (getNonLegacyStartupMode() == that.getNonLegacyStartupMode())
&& (getAdvancedStartupMode() == that.getAdvancedStartupMode())
&& (getCombinedObjectContainerUsed() == that.getCombinedObjectContainerUsed())
&& (getAcknowledgeCompanionAr() == that.getAcknowledgeCompanionAr())
&& (getCompanionArType() == that.getCompanionArType())
Expand All @@ -767,7 +767,7 @@ public int hashCode() {
getCmInitiatorMacAddr(),
getCmInitiatorObjectUuid(),
getPullModuleAlarmAllowed(),
getNonLegacyStartupMode(),
getAdvancedStartupMode(),
getCombinedObjectContainerUsed(),
getAcknowledgeCompanionAr(),
getCompanionArType(),
Expand Down
Loading

0 comments on commit 6df0fa5

Please sign in to comment.