Skip to content

Commit

Permalink
fix(plc4j/profinet): Updated magic numbers in discovery packets
Browse files Browse the repository at this point in the history
  • Loading branch information
hutcheb committed Jan 31, 2023
1 parent b32e9f4 commit cb8402f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -308,23 +308,21 @@ public void startPnDcpPoll(long period) {
Collections.singletonList(
new PnDcp_Block_ALLSelector()
)))));
WriteBufferByteBased buffer = new WriteBufferByteBased(34);
WriteBufferByteBased buffer = new WriteBufferByteBased(identificationRequest.getLengthInBytes());
try {
identificationRequest.serialize(buffer);
} catch (SerializationException e) {
throw new RuntimeException(e);
}
Packet packet = null;
try {
packet = EthernetPacket.newPacket(buffer.getData(), 0, 34);
packet = EthernetPacket.newPacket(buffer.getBytes(), 0, identificationRequest.getLengthInBytes());
} catch (IllegalRawDataException e) {
throw new RuntimeException(e);
}
try {
handle.sendPacket(packet);
} catch (PcapNativeException e) {
throw new RuntimeException(e);
} catch (NotOpenException e) {
} catch (PcapNativeException | NotOpenException e) {
throw new RuntimeException(e);
}
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -553,8 +553,7 @@
[array byte deviceVendorValue count 'blockLength-2' ]
[padding uint 8 pad '0x00' 'STATIC_CALL("arrayLength", deviceVendorValue) % 2']
]
['DEVICE_PROPERTIES_OPTION','2' PnDcp_Block_DevicePropertiesNameOfStation(uint 16 blockLength)
[reserved uint 16 '0x0000' ]
['DEVICE_PROPERTIES_OPTION','2' PnDcp_Block_DevicePropertiesNameOfStation(uint 16 blockLength) ]
[array byte nameOfStation count 'blockLength-2' ]
[padding uint 8 pad '0x00' 'STATIC_CALL("arrayLength", nameOfStation) % 2']
]
Expand Down

0 comments on commit cb8402f

Please sign in to comment.