Reads and returns messages that have been sent from the main application.
This function is used by the host program to communicate with the script by sending a message name and an associated value.
There can be multiple messages waiting. This function transfers all pending messages into the provided dictionary and returns the number of messages read.
planetcnc.read_message(dict)
#! /usr/bin/env python import planetcnc # Create an empty dictionary to receive messages. messages = {} # Read messages from the module. num_messages = planetcnc.read_message(messages) if num_messages > 0: print("Received messages:") for key, value in messages.items(): print(f" {key}: {value}") else: print("No messages received.")