pcdshub / ads-async Goto Github PK
View Code? Open in Web Editor NEWAsyncio (or sans-i/o) TwinCAT AMS/ADS client + test server in pure Python
License: Other
Asyncio (or sans-i/o) TwinCAT AMS/ADS client + test server in pure Python
License: Other
The following will never raise, even if the PLC disconnects and fails to reconnect:
async for header, _, sample in circuit.enable_log_system():
...
Using the following:
add_route_to_plc(
their_host,
source_net_id=our_net_id,
source_name=LOG_DAEMON_HOST,
route_name=LOG_DAEMON_ROUTE_NAME
)
with a route name ends up causing adding a route:
Route: LOG_DAEMON_HOST
Net ID: our_net_id
Address: LOG_DAEMON_ROUTE_NAME
Temporary fix is to use route_name=LOG_DAEMON_HOST
. Need to look into where this is getting switched up.
Apologies for submitting a false issue as a means to communicate with creators. I'm intrigued about what this tool does. I cloned and installed but can't get it to do 'something'.
Would anyone care to share a bit more info?
this is my output:
INFO:ads_async.bin.utils:Got PLC net ID through service port: BLOCKED.1.1 ERROR:ads_async.protocol:Deserialization of <class 'ads_async.structs.AoEReadResponse'> failed: Buffer size too small (0 instead of at least 8 bytes) bytes=b'' (length=0); this may be fatal. (Header=AmsTcpHeader(reserved=0, length=32) + AoEHeader(target=BLOCKEDa.1.1:851(R0_PLC_TC3), source=BLOCKED.1.1:851(R0_PLC_TC3), command_id=<AdsCommandId.READ_WRITE: 9>, state_flags=<AoEHeaderFlag.ADS_COMMAND|RESPONSE: 5>, length=0, error_code=18, invoke_id=101)) Traceback (most recent call last): File "C:\Users\BLOCKED\AppData\Roaming\Python\Python310\site-packages\ads_async\protocol.py", line 115, in from_wire cmd = cmd_cls.deserialize(view) File "C:\Users\BLOCKED\AppData\Roaming\Python\Python310\site-packages\ads_async\structs.py", line 175, in deserialize new_struct = cls.from_buffer(buf) ValueError: Buffer size too small (0 instead of at least 8 bytes) { "Global_Variables.bBlink": "(Exception) TimeoutError Response not received in 2.0 seconds" }
Use Python built-in support for TLS: https://docs.python.org/3/library/ssl.html , add a certificate, and see if TwinCAT will accept our communication.
Test suite is hitting into pytmc changes in TMC handling, specifically from this PR:
pcdshub/pytmc#311 (AMSNETID was actually part of the discussion there ๐ )
Looks like ads-async needs to dig down into the base type for AMSNETID and represent it as a string of bytes. My recollection of my implementation here for this is rather hazy though so fixing the test suite may take a bit.
That said, there's still other stuff to be done:
localhost
or 127.0.0.1
, let the user toggle it on)Originally posted by @klauer in #40 (comment)
Preface: so long as the client is used with only a single target net ID, there should be no problem using the current implementation.
I had thought I wanted a context manager for the existing client to set a target net_id/port for a given block, but what I think may be missing is a "PLC" - a per-(target net id) with a configurable port. A client can communicate to any number of target net IDs (assuming the routing happens on the target end).
Need to look more into this one day:
(source_addr, handle)
?)Messages may be truncated if over 255 characters (actually around 244 or so, as the packet also contains timestamps and other info)
(pcds-4.1.4) [klauer@psdev04 ~]$ ads-async
usage: ads-async [-h] [--version] [--log LOG_LEVEL] {get,info,monitor,route} ...
(pcds-4.1.4) [klauer@psdev04 ~]$ ads-async
usage: ads [-h] [--version] [--log LOG_LEVEL] {get,info,monitor,route} ...
Fix the tool to report it correctly.
ads-async/.pre-commit-config.yaml
Line 20 in d68246c
This should be from GitHub now
It should be easy to use the default ADS port without specifying it in a tuple.
Generally speaking, people aren't forwarding ADS over SSH as I do for testing.
Support their_address="host"
in addition to their_address=("host", port)
Requires ("host", port)
Do not base things on current client/server code until a large refactor goes through.
You will probably ignore this and continue with what's here.
Listen to this issue
Supporting PORT_SYSTEMSERVICE
would be useful (can add a route by way of UDP, determine AMS NET ID based on just IP address, etc.)
A logging example provided by Beckhoff proved the viability of an event system workaround, where the following steps could be taken to aggregate all log messages from every production PLC we have:
No client in codebase whatsoever
For the purposes of the new logging daemon, a simple client will be required. It will only need to:
AmsPort.LOGGER
is key here)AdsNotificationLogMessage
(which we'll define)caproto uses the concept of "ours" and "theirs" to good effect. ads-async should do something similar.
"server" and "client" are used liberally.
Rework and rename.
Current users (~0) should expect API thrashing
Turns out the undocumented things I was discovering with wireshark + TwinCAT may already have existing tools that I was just unaware of!
I made some good guesses on the parameters, but more complete information can be filled in based on these sources.
First 4 bytes are an error code.
msgCtrlMask
:
Constant | Description |
---|---|
ADSLOG_MSGTYPE_HINT | Message type is advice. |
ADSLOG_MSGTYPE_WARN | Message type is warning. |
ADSLOG_MSGTYPE_ERROR | Message type is error. |
ADSLOG_MSGTYPE_LOG | Message is written into the log. |
ADSLOG_MSGTYPE_MSGBOX | Message is output to a message box. |
ADSLOG_MSGTYPE_RESOURCE | Message is fetched from a resource file. (not currently supported) |
ADSLOG_MSGTYPE_STRING | Message is a directly given string (default). |
This seems consistent with the log messages I see. It should be easier to set log level messages appropriately with the above.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.