forked from dmroeder/pylogix
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added apache boilerplate to eip, updated README
- Loading branch information
Dustin
committed
Jul 19, 2016
1 parent
1875954
commit 4438999
Showing
2 changed files
with
59 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,43 +1,20 @@ | ||
''' | ||
Initially created by Burt Peterson | ||
Updated and maintained by Dustin Roeder ([email protected]) | ||
Several things take place when making a connection to a PLC. | ||
1) Standard TCP connection | ||
2) Session Registration, PLC will respond with a Session Handle | ||
3) Forward Open. Using the Session Handle, this establishes | ||
the parameters for connection | ||
4) Command (read/write/etc) and payload | ||
The initial connections (TCP, Session Registration, Forward Open) | ||
only need to be made once, after that, we can exchange data | ||
until the connection is closed or lost. | ||
A number events that take place on the command end, they should | ||
be invisible to the user, but it's good to know (and a reminder for me). | ||
The user can be reading/writing simple tags, UDT's arrays, bits of a word, | ||
bools out of atomic arrays, custom length strings, array reads that | ||
won't fit in a single reply and so on. Each has to be handled in a | ||
different way. | ||
It basically happens like this: Figure out if its a single tag to be | ||
read/written or an array. Open the connection to the PLC (1,2,3 above), | ||
parse the tag name, add the command (read/write), send the data to the PLC, | ||
handle the reply | ||
In order to perform a typical read/write, the data type needs to be known, or | ||
more specifically, the number of bytes the tag is. It would be pretty | ||
annoying for the user to have to specify this each time, so to get around | ||
this, we have the InitialRead function. This is called on any data exchange | ||
where the tag name has never been read/written before. It uses a different | ||
CIP command than a typical read (0x52 vs 0x4C) which will respond with the | ||
data type. This helps us in two ways: First, the user won't need to specify | ||
the data type. Second, we can keep track of this information so the next | ||
time the particular tag is called, we already know it's type so we can just | ||
do the normal read/write (0x4C/0x4D/0x4E). | ||
Originally created by Burt Peterson | ||
Updated and maintained by Dustin Roeder ([email protected]) | ||
Copyright 2016 Dustin Roeder | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
''' | ||
|
||
from datetime import datetime, timedelta | ||
|