Repository navigation
New features
-
U-SEND and U-RECV communication with up to 4 data blocks. Sending is performed using the function
u_send(number of blocks).b_recv()andas_b_recv()process both b_send and u_send data. Since the payload of
u_send transmissions can be split into up to 4 parts, new helpers are required for the data buffers:set_u_send_data(data_1, data_2, data_3, data_4).
The data_1 is shared with the data for b_send. Data 2-4 can be None when not needed.get_u_recv_data()returns a tuple with:- data_1: Received data from b_send or u_send transmissions
- data_2: Received data from u_send transmissions
- data_3: Received data from u_send transmissions
- data_4: Received data from u_send transmissions
- datablock_count: 0 for b_send or 1-4 for u_send transmissions.
(#998)
-
set_s5time()writes anS5TIMEvalue from atimedelta, or from the string thatget_s5time()returns. It picks
the smallest time base that holds the value and truncates to that base's resolution, as STEP 7 does for anS5T#
constant.S5TIMEtags can now be written withwrite_tagandencode_tag, andRowsetsS5TIMEfields.
Previously writing anS5TIMEtag raisedValueError(#1002).
Bug fixes
set_param(Parameter.RecvTimeout, ms)sets how longClientandAsyncClientwait for a reply, before or after
connecting, and after an automatic reconnect. Previously the value was stored but never used: every reply wait was
5 seconds, whileget_param()reported 3000. The default is now 5000 ms, the wait the clients already used, so a
client that never sets it behaves as before. A value of 0 or less raisesValueError.connect_routed()still waits
itstimeoutargument untilRecvTimeoutis set after connecting (#1011).get_cp_info()reads SZL 0x0131 index 0x0001 andget_protection()SZL 0x0232 index 0x0004, the records Snap7
reads, and both decode them after the SZL header and record index.S7CpInfo.MaxMpiRateandMaxBusRateare
32-bit, as in the record. Previouslyget_cp_info()failed with 0xD402 on an S7-1500 (CPU 1511-1 PN FW V2.9,
1512SP F-1 PN FW V4.1), and against any real PLC both decoders returned the SZL header as the values (#1010).- Getters raise
BufferTooShortErrorwhen the buffer holds fewer bytes than the value needs frombyte_index, with
the setters' message (2 bytes at index 0 do not fit in a buffer of 1 bytes). Setters raise it too. It subclasses
ValueError,IndexErrorandstruct.error, so code that caught what a getter raised before still catches it.
Previously getters raised one of those three depending on the type, andget_s5time(),get_time()and
get_fstring()returned a wrong value;get_time()could turn a negativeTIMEpositive (#1008, #1009). get_s5time()ignores bits 14 and 15 of the word, which are not part of anS5TIMEvalue. Previously a value with
either bit set raisedValueError: This value should not be greater than 3. A count digit that is not BCD now
raises aValueErrorthat says so, instead of anint()parse error (#1005).get_ltime()truncates a negative value towards zero to whole microseconds, as it already did for a positive one.
PreviouslyLTIME#-1500NSread as -2 µs andLTIME#-999NSas -1 µs (#1006).Rowreads and writesLINT,ULINT,LWORD,LTIME,LTODandLDTfields, and acceptsDTas a short name for
DATE_AND_TIME, as tags already do. Previously a layout with one of these types raised a bareValueErroron read
and write, although the getters and setters exist (#1004).disconnect()no longer sends a COTP disconnect request, in both clients. It closes its sending side of the TCP
connection, waits up to one second for the PLC to close its own, and then closes the socket; RFC 1006 releases a
connection that way. A CP 343-1 answered the disconnect request with a reset and kept the connection's resource
until the PLC restarted. The reporter confirmed on a CPU 313C behind a CP 343-1 that the resource is now
released (#972, #987).- get_status(): A lost connection drops the status from 2 (connected) to 1 (started). Previously, the status remained
at 2. (#1000). b_recv()returns 1 and not -1 on a timeout, as documented (#1000).ISOTCPConnection._recv_exact(): If a timeout occurs before the first byte of a frame, the connection remains
intact. If a frame is incomplete, an S7ConnectionError is raised and the connection state is reset (#1000).