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.
Partner(active: bool = False)¶
A snap7 partner.
as_b_send() → int¶
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¶
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¶
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_recv_completion() → int¶
Checks if a packed received was received.
check_as_b_send_completion() → Tuple[str, ctypes.c_int]¶
Checks if the current asynchronous send job was completed and terminates immediately.
create(active: bool = False)¶
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 a Partner of given handle. Before destruction the Partner is stopped, all clients disconnected and all shared memory blocks released.
get_last_error() → ctypes.c_int¶
Returns the last job result.
get_param(number) → int¶
Reads an internal Partner object parameter.
get_stats() → Tuple[ctypes.c_uint, ctypes.c_uint, ctypes.c_uint, ctypes.c_uint]¶
Returns some statistics.
Returns: a tuple containing bytes send, received, send errors, recv errors
get_status() → ctypes.c_int¶
Returns the Partner status.
get_times() → Tuple[ctypes.c_int, ctypes.c_int]¶
Returns the last send and recv jobs execution time in milliseconds.
set_recv_callback() → int¶
Sets the user callback that the Partner object has to call when a data packet is incoming.
set_send_callback() → int¶
Sets the user callback that the Partner object has to call when the asynchronous data sent is complete.
stop() → int¶
Stops the Partner, disconnects gracefully the remote partner.
Parses a s7 error code returned the decorated function.