8000 fix(plc4py/umas): Write Support by hutcheb · Pull Request #1463 · apache/plc4x · GitHub
[go: up one dir, main page]

Skip to content
Merged
Show file tree
Hide file tree
10000 Changes from all commits
Commits
Show all changes
166 commits
Select commit Hold shift + click to select a range
a5d746d
fix(plc4py/umas): Start to add write support
hutcheb Mar 7, 2024
ebfe381
build(deps): bump github.com/stretchr/testify in /plc4go (#1439)
dependabot[bot] Mar 11, 2024
02a6f24
build(deps): bump golang.org/x/tools from 0.18.0 to 0.19.0 in /plc4go…
dependabot[bot] Mar 11, 2024
4e1f5bc
build(deps): bump logback.version from 1.5.0 to 1.5.1 (#1435)
dependabot[bot] Mar 11, 2024
f65dbd7
build(deps): bump github.com/gdamore/tcell/v2 in /plc4go (#1438)
dependabot[bot] Mar 11, 2024
eb662d4
build(deps): bump golang.org/x/net from 0.21.0 to 0.22.0 in /plc4go (…
dependabot[bot] Mar 11, 2024
061ebfc
build(deps): bump jakarta.activation:jakarta.activation-api (#1436)
dependabot[bot] Mar 11, 2024
39538e0
fix(plc4j/genericcan) Fix of generic CAN driver and CAN transports af…
splatch Mar 11, 2024
9352b0a
chore: Disabled a flaky test in GO
chrisdutz Mar 13, 2024
539d252
docs: Updated the url for the opie tool
chrisdutz Mar 13, 2024
604ba8a
chore: Updated vendor ids
chrisdutz Mar 13, 2024
22b3099
docs: Added some information on the site plugin and the asciidoctor p…
chrisdutz Mar 13, 2024
0f5f2f4
chore: Updated vendor ids
chrisdutz Mar 13, 2024
5723fad
build: Continued fine-tuning the reproducible build release-scripts.
chrisdutz Mar 13, 2024
52009e3
chore: Updated vendor ids
chrisdutz Mar 13, 2024
8323caf
feat: The S7 driver now returns supporting S7, if the connected devic…
chrisdutz Mar 13, 2024
53adbaf
fix: Fixed logging in the example.
chrisdutz Mar 13, 2024
ba11ff1
refactor: Made the "protocol" accessible in the AbstractPlcConnection
chrisdutz Mar 13, 2024
215d1bf
refactor: Added S7-400 to the list of supported devices.
chrisdutz Mar 13, 2024
49b882d
fix: Fixed the dependency usage error.
chrisdutz Mar 13, 2024
bc874ea
Fix/s7async (#1451)
glcj Mar 15, 2024
575bf83
build(deps): bump com.google.googlejavaformat:google-java-format (#1449)
dependabot[bot] Mar 18, 2024
3a15b84
build(deps): bump logback.version from 1.5.1 to 1.5.3 (#1448)
dependabot[bot] Mar 18, 2024
e295259
build(deps): bump com.gradle:common-custom-user-data-maven-extension …
dependabot[bot] Mar 18, 2024
3b21a8c
Update PlcRawByteArray.java (#1453)
mrwhy-orig Mar 18, 2024
a90e492
chore: Disabled some OPC-UA tests, that were continuously failing the…
chrisdutz Mar 18, 2024
1f20465
chore: Disabled some OPC-UA tests, that were continuously failing the…
chrisdutz Mar 18, 2024
55efeec
feat: Added a new flag allowing to disable tests on Jenkins. Added th…
chrisdutz Mar 18, 2024
f596a26
build(deps-dev): bump org.apache.commons:commons-compress (#1456)
dependabot[bot] Mar 20, 2024
f694abf
build(deps): bump org.awaitility:awaitility from 4.2.0 to 4.2.1 (#1455)
dependabot[bot] Mar 20, 2024
8933491
docs: Added "slave-id" to the description of the unit-identifier.
chrisdutz Mar 21, 2024
195e4ad
chore: Disabled the OpcuaPlcDriverTest as it also seems to regularly …
chrisdutz Mar 21, 2024
0b68f16
build(deps): bump org.springframework.boot:spring-boot-maven-plugin (…
dependabot[bot] Mar 22, 2024
0511e3c
build(deps): bump com.google.errorprone:error_prone_annotations (#1461)
dependabot[bot] Mar 22, 2024
07350bd
build(deps): bump org.springframework.boot:spring-boot-dependencies (…
dependabot[bot] Mar 22, 2024
11920e1
docs: Updated some documentation on the code-generation.
chrisdutz Mar 22, 2024
e594988
refactor: Renamed the paddingField paddingCondition to timesPadding
chrisdutz Mar 22, 2024
ed8dae0
chore: Removed some unneeded code.
chrisdutz Mar 22, 2024
934aa11
chore: Updated vendor ids
chrisdutz Mar 22, 2024
ae38064
chore: Cleaned up in the sandbox
chrisdutz Mar 23, 2024
016ad77
fix(plc4py): type extensions module added to setup.py
hutcheb Mar 23, 2024
80b75aa
fix(plc4py): Move out of sandbox
hutcheb Mar 23, 2024
dab01f0
chore(sandbox): Remove the Sandbox Directory
hutcheb Mar 23, 2024
90d671b
chore(plc4px): Remove manual test
hutcheb Mar 23, 2024
cb5714b
feat(plc4x/modbus): Add support for unit-id option for modbus tags.
splatch Mar 27, 2024
2ea34de
build(deps): bump nl.jqno.equalsverifier:equalsverifier (#1467)
dependabot[bot] Apr 2, 2024
71fb92f
build(deps): bump org.cyclonedx:cyclonedx-maven-plugin (#1466)
dependabot[bot] Apr 2, 2024
508a18c
build(deps): bump org.apache.maven.plugins:maven-remote-resources-plu…
dependabot[bot] Apr 2, 2024
3c03181
build(deps): bump org.aspectj:aspectjweaver from 1.9.21.1 to 1.9.22 (…
dependabot[bot] Apr 3, 2024
3652bb4
build(deps): bump jakarta.xml.bind:jakarta.xml.bind-api (#1474)
dependabot[bot] Apr 3, 2024
86060a1
build(deps): bump com.google.guava:guava from 33.0.0-jre to 33.1.0-jr…
dependabot[bot] Apr 3, 2024
efc10e9
build(deps): bump golang.org/x/net from 0.22.0 to 0.23.0 in /plc4go (…
dependabot[bot] Apr 4, 2024
3c2b30c
build(deps): bump mockito.version from 5.10.0 to 5.11.0 (#1478)
dependabot[bot] Apr 4, 2024
0157fe0
build(deps): bump io.swagger:swagger-annotations from 1.6.13 to 1.6.1…
dependabot[bot] Apr 4, 2024
a47ea37
build(deps): bump org.sonarsource.scanner.maven:sonar-maven-plugin (#…
dependabot[bot] Apr 4, 2024
2489556
Update PlcCHAR.java add Character type check to of method (#1489)
mrwhy-orig Apr 5, 2024
2e3d44b
build(deps): bump golang.org/x/net from 0.23.0 to 0.24.0 in /plc4go (…
dependabot[bot] Apr 5, 2024
da2aa30
build(deps): bump groovy.version from 4.0.18 to 4.0.20 (#1486)
dependabot[bot] Apr 5, 2024
2da79f2
build(deps): bump org.jacoco:jacoco-maven-plugin from 0.8.11 to 0.8.1…
dependabot[bot] Apr 5, 2024
03a2588
build(deps): bump org.apache.maven.plugins:maven-source-plugin (#1484)
dependabot[bot] Apr 5, 2024
6f9bcce
build(deps): bump golang.org/x/tools from 0.19.0 to 0.20.0 in /plc4go…
dependabot[bot] Apr 5, 2024
fb0e145
fix: A compilation error.
chrisdutz Apr 5, 2024
cc17fe5
refactor: Moved the examples, integrations and other extra stuff into…
chrisdutz Apr 5, 2024
820d3aa
fix: Disabling "Trivy Scan" workflow as it's randomy failing and I ca…
chrisdutz Apr 5, 2024
b67f559
chore: Updated the issue-tracker settings to point to GitHub instead …
chrisdutz Apr 5, 2024
33030f9
build(deps): bump nl.jqno.equalsverifier:equalsverifier (#1490)
dependabot[bot] Apr 8, 2024
373fd86
build(deps): bump org.apache.maven.plugins:maven-assembly-plugin (#1491)
dependabot[bot] Apr 8, 2024
e818b67
fix(plc4py): Fix exception on closing the connection
hutcheb Apr 9, 2024
c41e3a3
fix(plc4py): Fix connection lost exception being raised
hutcheb Apr 9, 2024
57c52e6
fix(plc4py): set test to manual
hutcheb Apr 9, 2024
e229c54
fix(plc4py): Got rid of returning future, starting to understand it a…
hutcheb Apr 9, 2024
a238c00
build(deps): bump jakarta.annotation:jakarta.annotation-api (#1494)
dependabot[bot] Apr 9, 2024
a0d41fd
build(deps): bump io.netty:netty-bom from 4.1.107.Final to 4.1.108.Fi…
dependabot[bot] Apr 9, 2024
24e59ef
fix(plc4py): Add to dependabot
hutcheb Apr 9, 2024
bdaacf2
build(deps): bump pytest-mock from 3.12.0 to 3.14.0 in /plc4py (#1501)
dependabot[bot] Apr 9, 2024
65a2325
build(deps): bump identify from 2.5.33 to 2.5.35 in /plc4py (#1500)
dependabot[bot] Apr 9, 2024
9e2fd21
build(deps): bump packaging from 23.2 to 24.0 in /plc4py (#1499)
dependabot[bot] Apr 9, 2024
debb8a6
build(deps): bump pytest-asyncio from 0.23.5 to 0.23.6 in /plc4py (#1…
dependabot[bot] Apr 9, 2024
1c27f79
build(deps): bump build from 1.0.3 to 1.2.1 in /plc4py (#1496)
dependabot[bot] Apr 9, 2024
004c2f8
fix(plc4py): Use packet length estimator to be able to handle multipl…
hutcheb Apr 12, 2024
ecfadf9
Update apache-kafka links to plc4x extra
ottlukas Apr 10, 2024
adf1568
feat(plc4go): change to TestingLog interface for TestLogger
sruehl Apr 10, 2024
2599310
build(deps): bump com.fasterxml.jackson.datatype:jackson-datatype-jsr…
dependabot[bot] Apr 11, 2024
a095a17
build(deps): bump com.gradle:common-custom-user-data-maven-extension …
dependabot[bot] Apr 11, 2024
84d6802
build(deps): bump mypy from 1.8.0 to 1.9.0 in /plc4py (#1502)
dependabot[bot] Apr 11, 2024
b85c765
build(deps): bump black from 24.1.1 to 24.3.0 in /plc4py (#1503)
dependabot[bot] Apr 11, 2024
6a6bade
build(deps): bump filelock from 3.13.1 to 3.13.4 in /plc4py (#1504)
dependabot[bot] Apr 11, 2024
6911bc9
build(deps): bump virtualenv from 20.25.0 to 20.25.1 in /plc4py (#1506)
dependabot[bot] Apr 11, 2024
7fb8b42
build(deps): bump typing-extensions from 4.9.0 to 4.11.0 in /plc4py (…
dependabot[bot] Apr 11, 2024
6f4bed9
build(deps): bump org.apache.maven.plugins:maven-invoker-plugin (#1514)
dependabot[bot] Apr 12, 2024
e5b90c6
build(deps): bump org.asciidoctor:asciidoctorj from 2.5.11 to 2.5.12 …
dependabot[bot] Apr 12, 2024
0f9520a
build(deps): bump com.google.googlejavaformat:google-java-format (#1516)
dependabot[bot] Apr 12, 2024
5fa88da
build(deps): bump coverage from 7.4.1 to 7.4.4 in /plc4py (#1511)
dependabot[bot] Apr 12, 2024
cb15079
build(deps): bump pytest from 8.0.0 to 8.1.1 in /plc4py (#1510)
dependabot[bot] Apr 12, 2024
906fa87
build(deps): bump pre-commit from 3.6.0 to 3.7.0 in /plc4py (#1512)
dependabot[bot] Apr 12, 2024
e551fb7
build(deps): bump pip-tools from 7.3.0 to 7.4.1 in /plc4py (#1513)
dependabot[bot] Apr 12, 2024
4da7244
fix(plc4j/ads): Fixed List serialization passing invalid datatype for…
IsmoLeszczynski Apr 12, 2024
b7529aa
feat: Changed the ManualTest to allow enabling read and write request…
chrisdutz Apr 12, 2024
dd5aad4
fix(plc4j/opcua): Cleanup discovery connection resources.
splatch Apr 12, 2024
3589478
fix(plc4j/ads): Invalid size writing multiple tags (#1524)
IsmoLeszczynski Apr 13, 2024
d4c2066
fix: Added the struct back to the manual ads test.
chrisdutz Apr 13, 2024
8a2f138
fix(plc4j/opcua): Make sure UA subscription acknowledges are retained…
splatch Apr 14, 2024
c98e9fc
chore: Updated vendor ids
chrisdutz Apr 14, 2024
ea61a35
chore: Addressed most high severity sonarcloud issues
chrisdutz Apr 14, 2024
257aff4
build(deps): bump black from 24.3.0 to 24.4.0 in /plc4py (#1528)
dependabot[bot] Apr 15, 2024
beaf82b
build(deps): bump org.apache.maven.plugins:maven-compiler-plugin (#1525)
dependabot[bot] Apr 15, 2024
1faae83
build(deps): bump org.codehaus.plexus:plexus-compiler-api (#1526)
dependabot[bot] Apr 15, 2024
11267a2
build(deps): bump com.google.errorprone:error_prone_annotations (#1527)
dependabot[bot] Apr 15, 2024
73913e0
build(deps): bump logback.version from 1.5.3 to 1.5.5 (#1531)
dependabot[bot] Apr 16, 2024
0872d89
build(deps): bump io.netty:netty-bom from 4.1.108.Final to 4.1.109.Fi…
dependabot[bot] Apr 16, 2024
384471f
build(deps): bump groovy.version from 4.0.20 to 4.0.21 (#1533)
dependabot[bot] Apr 16, 2024
cd38cb0
fix(plc4j/ads): Fixed connection hang on exception (#1530)
IsmoLeszczynski Apr 16, 2024
08f9260
build(deps): bump virtualenv from 20.25.1 to 20.25.2 in /plc4py (#1537)
dependabot[bot] Apr 17, 2024
6d42733
Remove Protocols section in developers section (duplicate from
ottlukas Apr 17, 2024
af6a4b8
Delete src/site/asciidoc/developers/protocols directory
ottlukas Apr 17, 2024
0ab6465
chore: Updated vendor ids
chrisdutz Apr 17, 2024
1c320f5
feat: Added a default-payload-byte-order option to the modbus driver …
chrisdutz Apr 17, 2024
63094a3
chore: Addressed more of the high severity sonarcloud issues
chrisdutz Apr 17, 2024
d8720ad
build(deps): bump slf4j.version from 2.0.12 to 2.0.13 (#1536)
dependabot[bot] Apr 17, 2024
b9846ed
build(deps): bump org.jetbrains.kotlin:kotlin-stdlib-jdk8 (#1534)
dependabot[bot] Apr 17, 2024
60f079d
Revert "Remove Protocols section in developers section (duplicate from "
ottlukas Apr 17, 2024
ab46e7a
Revert "Delete src/site/asciidoc/developers/protocols directory"
ottlukas Apr 17, 2024
c8bb411
Modbus in progress
ottlukas Apr 18, 2024
8e59aec
add index for protocol usage page
ottlukas Apr 18, 2024
12e646f
Add eip
ottlukas Apr 18, 2024
0d3ee01
fixing URLs
ottlukas Apr 18, 2024
5256375
build(deps): bump org.apache.commons:commons-configuration2 (#1541)
dependabot[bot] Apr 18, 2024
663034d
build(deps): bump org.apache.karaf.tooling:karaf-maven-plugin (#1539)
dependabot[bot] Apr 18, 2024
06cda0f
build(deps): bump com.googlecode.maven-download-plugin:download-maven…
dependabot[bot] Apr 18, 2024
ea50932
build(deps): bump virtualenv from 20.25.2 to 20.25.3 in /plc4py (#1542)
dependabot[bot] Apr 18, 2024
4cdd64a
build(deps): bump net.bytebuddy:byte-buddy from 1.14.12 to 1.14.13 (#…
dependabot[bot] Apr 19, 2024
71121e3
build(deps-dev): bump commons-io:commons-io from 2.15.1 to 2.16.1 (#1…
dependabot[bot] Apr 19, 2024
6212b0a
build(deps): bump org.apache.commons:commons-text from 1.11.0 to 1.12…
dependabot[bot] Apr 19, 2024
a95115d
chore: Made line-breaks in the configuration option descriptions get …
chrisdutz Apr 19, 2024
4dd77dd
chore: Updated vendor ids
chrisdutz Apr 19, 2024
834ab08
feat: Added device-group options for local, remote and remote2 to the…
chrisdutz Apr 19, 2024
8efab49
chore: Disabled the OpcuaSubscriptionHandleTest all together as it al…
chrisdutz Apr 19, 2024
4fffc88
feat: Added a "Since" annotation that provides information on when a …
chrisdutz Apr 19, 2024
75342ba
feat: Create a source bundle for PLC4C
chrisdutz Apr 19, 2024
8c87b04
chore: Added newly generated files.
chrisdutz Apr 19, 2024
f346f9f
build(deps): bump org.codehaus.mojo:extra-enforcer-rules (#1548)
dependabot[bot] Apr 22, 2024
85ee0bc
build(deps): bump logback.version from 1.5.5 to 1.5.6 (#1549)
dependabot[bot] Apr 22, 2024
6981261
build(deps): bump bouncycastle.version from 1.77 to 1.78.1 (#1550)
dependabot[bot] Apr 22, 2024
b1fabc9
build(deps): bump identify from 2.5.35 to 2.5.36 in /plc4py (#1546)
dependabot[bot] Apr 22, 2024
6c514bf
build(deps): bump pluggy from 1.4.0 to 1.5.0 in /plc4py (#1547)
dependabot[bot] Apr 22, 2024
431b9e3
build(deps): bump com.fazecast:jSerialComm from 2.10.4 to 2.11.0 (#1554)
dependabot[bot] Apr 23, 2024
104313f
feat(plc4j/api): Convert the string address into a PlcTag (#1468)
qtvbwfn Apr 23, 2024
fcfa85e
build(deps): bump commons-logging:commons-logging from 1.3.0 to 1.3.1…
dependabot[bot] Apr 23, 2024
b0aa7aa
build(deps-dev): bump org.json:json from 20240205 to 20240303 (#1552)
dependabot[bot] Apr 23, 2024
0fcc8b2
build(deps): bump org.apache.maven.plugins:maven-jar-plugin (#1559)
dependabot[bot] Apr 24, 2024
5762d51
build(deps): bump virtualenv from 20.25.3 to 20.26.0 in /plc4py (#1555)
dependabot[bot] Apr 24, 2024
8abefe6
build(deps): bump platformdirs from 4.2.0 to 4.2.1 in /plc4py (#1556)
dependabot[bot] Apr 24, 2024
109efa1
build(deps): bump coverage from 7.4.4 to 7.5.0 in /plc4py (#1557)
dependabot[bot] Apr 24, 2024
435edd7
build(deps): bump net.bytebuddy:byte-buddy from 1.14.13 to 1.14.14 (#…
dependabot[bot] Apr 25, 2024
1c684a8
build(deps): bump commons-cli:commons-cli from 1.6.0 to 1.7.0 (#1563)
dependabot[bot] Apr 25, 2024
720cdc9
build(deps): bump org.apache:apache from 31 to 32 (#1558)
dependabot[bot] Apr 25, 2024
453eef4
Change Python version to 3.10+
ottlukas Apr 25, 2024
bb63281
fix(plc4py/umas): Start to add write support
hutcheb Mar 7, 2024
c0f0f67
rebase umas
ottlukas Apr 25, 2024
67274f5
Merge branch 'develop' into feat/plc4py/umas_write_support
ottlukas May 1, 2024
bad932f
Merge branch 'develop' into feat/plc4py/umas_write_support
ottlukas May 15, 2024
27ad031
fix(plc4py): Enable integration tests (#1588)
hutcheb May 7, 2024
ca74b7f
build(deps): bump golang.org/x/net from 0.24.0 to 0.25.0 in /plc4go (…
dependabot[bot] May 7, 2024
d70d809
Refactor / improve python modbus (#1581)
ottlukas May 15, 2024
c4878b9
improve python code readability with comments and logging statements
ottlukas May 17, 2024
ef951de
Update PlcResponse.py
ottlukas May 17, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions plc4py/plc4py/PlcDriverManager.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,7 @@ def __post_init__(self):
defined in the "plc4py.drivers" namespace.
"""
# Log the class loader used
logging.info(
f"Instantiating new PLC Driver Manager with class loader {self.class_loader}"
)
logging.info("Instantiating new PLC Driver Manager with class loader %s", self.class_loader)

# Add the PlcDriverClassLoader hookspecs to the class loader
self.class_loader.add_hookspecs(PlcDriverClassLoader)
Expand All @@ -73,7 +71,7 @@ def __post_init__(self):

# Log the successful registration of each driver
for driver in self._driver_map:
logging.info(f"... {driver} .. OK")
logging.info("... %s .. OK", driver)

# Check for any pending plugins
self.class_loader.check_pending()
Expand Down
5 changes: 5 additions & 0 deletions plc4py/plc4py/api/messages/PlcMessage.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,9 @@


class PlcMessage(Serializable):
"""
A class representing a PLC message.

Add more details about the class and its functionality here.
"""
pass
9 changes: 9 additions & 0 deletions plc4py/plc4py/protocols/umas/readwrite/UmasPDUItem.py
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,15 @@ def static_parse_context(
UmasPDUWriteVariableResponse,
)

if umas_function_key == int(0xFE) and umas_request_function_key == int(0x23):

builder = UmasPDUWriteVariableResponse.static_parse_builder(
read_buffer, umas_request_function_key, byte_length
)
from plc4py.protocols.umas.readwrite.UmasPDUWriteVariableResponse import (
UmasPDUWriteVariableResponse,
)

if umas_function_key == int(0xFE) and umas_request_function_key == int(0x23):

builder = UmasPDUWriteVariableResponse.static_parse_builder(
Expand Down
18 changes: 0 additions & 18 deletions plc4py/tests/test_plc4py.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,6 @@ def test_version():
`__version__` constant at the top of the file. If the versions do not match,
the test will fail.

:return: None
"""
"""
This test verifies the version of the package.

The version is a string that is expected to match the version specified in the
`__version__` constant at the top of the file. If the versions do not match,
the test will fail.

:return: None
"""
assert __version__ == "0.1.0"
Expand All @@ -59,15 +50,6 @@ async def test_plc_driver_manager_init():
successfully.

:return: None
"""
"""
This test verifies that the PlcDriverManager class is able to create a connection
successfully.

The test creates a PlcDriverManager object and then uses the connection method
to get a connection to a mock PLC. The connection should be an instance of
the PlcConnection class.

"""
driver_manager = PlcDriverManager()
async with driver_manager.connection("mock:tcp://127.0.0.1:502") as connection:
Expand Down
30 changes: 27 additions & 3 deletions plc4py/tests/unit/plc4py/drivers/modbus/test_modbus_codegen.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,23 @@


@pytest.mark.asyncio
async def test_modbus_discrete_inputs_request():
request = ModbusPDUReadDiscreteInputsRequestBuilder(0, 10).build()
assert request is not None
async def test_modbus_discrete_inputs_request_standardized():
"""
Test case for Modbus PDU Read Discrete Inputs Request
"""
# Create a Modbus PDU Read Discrete Inputs Request with address 0 and quantity 10
discrete_inputs_request = ModbusPDUReadDiscreteInputsRequestBuilder(0, 10).build()

# Ensure the request object is not None
assert discrete_inputs_request is not None


@pytest.mark.asyncio
async def test_modbus_discrete_inputs_request_serialize():
"""
Test case for serializing Modbus PDU Read Discrete Inputs Request
"""
# Create a Modbus PDU Read Discrete Inputs Request
request = ModbusPDUReadDiscreteInputsRequestBuilder(5, 2).build()
size = request.length_in_bytes()
write_buffer = WriteBufferByteBased(size, ByteOrder.BIG_ENDIAN)
Expand All @@ -49,11 +59,25 @@ async def test_modbus_discrete_inputs_request_serialize():

@pytest.mark.asyncio
async def test_modbus_ModbusTcpADUBuilder_serialize():
"""
Test case for serializing Modbus TCP ADU
"""
# Create a Modbus PDU Read Discrete Inputs
pdu = ModbusPDUReadDiscreteInputsRequestBuilder(5, 2).build()

# Build Modbus TCP ADU
request = ModbusTcpADUBuilder(10, 5, pdu).build(False)

# Get the size of the request
size = request.length_in_bytes()

# Create a write buffer
write_buffer = WriteBufferByteBased(size, ByteOrder.BIG_ENDIAN)

# Serialize the request
serialize = request.serialize(write_buffer)

# Get the serialized bytes
bytes_array = write_buffer.get_bytes().tobytes()

assert request is not None
Original file line number Diff line number Diff line change
Expand Up @@ -29,27 +29,43 @@

@pytest.mark.asyncio
async def manual_test_plc_driver_modbus_connect():
"""
Test the connection to a Modbus PLC using PlcDriverManager.
"""
# Initialize the PlcDriverManager
driver_manager = PlcDriverManager()

# Establish a connection to the Modbus PLC
async with driver_manager.connection("modbus://1") as connection:
# Check if the connection is successful
assert connection.is_connected()

# Ensure the connection is closed after exiting the context manager
assert not connection.is_connected()


@pytest.mark.asyncio
@pytest.mark.xfail
async def test_plc_driver_modbus_read():
"""
Test reading data from a Modbus PLC.
"""
log = logging.getLogger(__name__)

# Initialize the PlcDriverManager
driver_manager = PlcDriverManager()

# Establish a connection to the Modbus PLC
async with driver_manager.connection("modbus://127.0.0.1:5020") as connection:
with connection.read_request_builder() as builder:
builder.add_item("Random Tag", "4x00001[10]")
request = builder.build()

# Execute the read request
future = connection.execute(request)
await future
response = future.result()
value = response.tags["Random Tag"].value
log.error(f"Read tag 4x00001[10] - {value}")
log.error("Read tag 4x00001[10] - %s", value)

pass
0