Skip to content

3.7.0

Latest

Choose a tag to compare

@gijzelaerr gijzelaerr released this 30 Nov 07:16
· 3 commits to master since this release
6af4600

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() and as_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 an S5TIME value from a timedelta, or from the string that get_s5time() returns. It picks
    the smallest time base that holds the value and truncates to that base's resolution, as STEP 7 does for an S5T#
    constant. S5TIME tags can now be written with write_tag and encode_tag, and Row sets S5TIME fields.
    Previously writing an S5TIME tag raised ValueError (#1002).

Bug fixes

  • set_param(Parameter.RecvTimeout, ms) sets how long Client and AsyncClient wait 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, while get_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 raises ValueError. connect_routed() still waits
    its timeout argument until RecvTimeout is set after connecting (#1011).
  • get_cp_info() reads SZL 0x0131 index 0x0001 and get_protection() SZL 0x0232 index 0x0004, the records Snap7
    reads, and both decode them after the SZL header and record index. S7CpInfo.MaxMpiRate and MaxBusRate are
    32-bit, as in the record. Previously get_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 BufferTooShortError when the buffer holds fewer bytes than the value needs from byte_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, IndexError and struct.error, so code that caught what a getter raised before still catches it.
    Previously getters raised one of those three depending on the type, and get_s5time(), get_time() and
    get_fstring() returned a wrong value; get_time() could turn a negative TIME positive (#1008, #1009).
  • get_s5time() ignores bits 14 and 15 of the word, which are not part of an S5TIME value. Previously a value with
    either bit set raised ValueError: This value should not be greater than 3. A count digit that is not BCD now
    raises a ValueError that says so, instead of an int() parse error (#1005).
  • get_ltime() truncates a negative value towards zero to whole microseconds, as it already did for a positive one.
    Previously LTIME#-1500NS read as -2 µs and LTIME#-999NS as -1 µs (#1006).
  • Row reads and writes LINT, ULINT, LWORD, LTIME, LTOD and LDT fields, and accepts DT as a short name for
    DATE_AND_TIME, as tags already do. Previously a layout with one of these types raised a bare ValueError on 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).