diff --git a/README.md b/README.md index 8ecdea2a0c6fc20af360966d5aa3f3f051ffe96d..9955510f40030f343f2c2d82e26c3ca6b3f6d5ea 100644 --- a/README.md +++ b/README.md @@ -115,6 +115,8 @@ Call `init_python_communication()` within `void setup()` to begin the communicat Call `latest_received_msg()` to fetch the most recent message from the python side. Note: This does not actually _read_ the message from the python side, but rather is an interface the store message on the arduino to be accessed. To actually receive messages, you must call `sync()` (see below). - Parameters: - _int_ `index`: If specified, it will fetch the message sent on that particular index from the python side. If unspecified, it will fetch the full message. + - Return: + - String of the received message 3. **Prepare to send a message to python side**: Call `load_msg_to_python()` to load the message which will be sent to the python side. You must specify the name of each message and the payload itself. A good way of doing this is shown in the example code. Example: `load_msg_to_python(msgName, dataCarrier, size_of_array(msgName));` diff --git a/comms_wrapper.py b/comms_wrapper.py index ec1264ce1bad8dfd3b3c7c12fed1494648794551..a2b6df7fe97130a195f21736336efefe47dfd641 100644 --- a/comms_wrapper.py +++ b/comms_wrapper.py @@ -95,6 +95,17 @@ class Arduino: self.receivedMessages = receivedMessageTemp return True + + def _current_status(self): + status = { + "Device name" : self.descriptiveDeviceName, + "Baudrate: ": self.baudrate, + "Portname: ": self.portName, + "Connection: ": self.connectionStatus, + "Handshake: ": self.handshakeStatus + } + + return status # Public methods def connect_and_handshake(self): @@ -135,14 +146,11 @@ class Arduino: print("Successfull handshake with " + self.descriptiveDeviceName) else: print("!! Handshake failed with " + self.descriptiveDeviceName + " !!") + self.handshakeStatus = False return self.handshakeStatus - def disconnect_arduino(self): - self.arduino.close() - - def send_message(self, msg): # If we are sending multiple messages if type(msg) == list: @@ -199,18 +207,6 @@ class Arduino: time.sleep(0.0001) return isMessageValid - - - def current_status(self): - status = { - "Device name" : self.descriptiveDeviceName, - "Baudrate: ": self.baudrate, - "Portname: ": self.portName, - "Connection: ": self.connectionStatus, - "Handshake: ": self.handshakeStatus - } - - return status def debug(self, verbose = False): @@ -219,7 +215,7 @@ class Arduino: print("Message from arduino is somehow not valid") print("Current status of this device:") - print(self.current_status()) + print(self._current_status()) else: print("----------------------") diff --git a/function_reference.md b/function_reference.md deleted file mode 100644 index 7bb257ab6c219de2d737d82cd698c22231749d0d..0000000000000000000000000000000000000000 --- a/function_reference.md +++ /dev/null @@ -1,5 +0,0 @@ -# Python side - - - -# Arduino side