Reads and returns a raw message as a bytes object from the PLC, not including the firmware reserved Control Bytes. This function performs a destructive read of the data coming from the PLC and returns ‘None’ if no new data is available. Read() always returns the whole process image message (254 bytes).
Sends a raw byte object message (msg) to the PLC. The firmware reserved Status and Error Byte cannot be written by the application. Write() always writes to the whole process image message (254 Bytes) starting at Byte [0] (== Byte[2] in the process image).
The write process works acyclically regarding the PROFINET cycle. The written message is collected from the backplane bus in cyclic events and is not directly triggered by the write() function. Please be aware that calling write() multiple times in close succession can result in the prior information being overwritten before it was delivered to the PLC.
Destroys an existing plc instance. Before creating a new plc object, call this function first. It frees underlying resources. Afterwards call the standard delete function (using the keyword ‘del’) to fully release the plc object. This procedure ensures only one valid plc instance at a time.
Only calling ‘del’ but not ‘destroy’ on the object causes the reference counter of the plc object to be reduced by one, while not freeing the resources for the object. Using the garbage collection in this case causes the plc module to remain in a blocked state where no further plc instances can be created.
Procedure for safely freeing resources:
plc = plc_without_protocol.plc() |
plc.destroy() |
del plc |