Partner¶
Snap7 code for partnering with a siemens 7 server.
This allows you to create a S7 peer to peer communication. Unlike the client-server model, where the client makes a request and the server replies to it, the peer to peer model sees two components with same rights, each of them can send data asynchronously. The only difference between them is the one who is requesting the connection.
- class snap7.partner.Partner(active: bool = False)[source]¶
A snap7 partner.
- as_b_send() int [source]¶
Sends a data packet to the partner. This function is asynchronous, i.e. it terminates immediately, a completion method is needed to know when the transfer is complete.
- b_recv() int [source]¶
Receives a data packet from the partner. This function is synchronous, it waits until a packet is received or the timeout supplied expires.
- b_send() int [source]¶
Sends a data packet to the partner. This function is synchronous, i.e. it terminates when the transfer job (send+ack) is complete.
- check_as_b_send_completion() Tuple[str, c_int] [source]¶
Checks if the current asynchronous send job was completed and terminates immediately.
- create(active: bool = False) None [source]¶
Creates a Partner and returns its handle, which is the reference that you have to use every time you refer to that Partner.
- Parameters:
active – 0
- Returns:
a pointer to the partner object
- destroy() int | None [source]¶
Destroy a Partner of given handle. Before destruction the Partner is stopped, all clients disconnected and all shared memory blocks released.
- get_stats() Tuple[c_uint, c_uint, c_uint, c_uint] [source]¶
Returns some statistics.
- Returns:
a tuple containing bytes send, received, send errors, recv errors
- get_times() Tuple[c_int, c_int] [source]¶
Returns the last send and recv jobs execution time in milliseconds.
- set_recv_callback() int [source]¶
Sets the user callback that the Partner object has to call when a data packet is incoming.