From ee942da5a0d3925db936a32b8ea651fb588f0365 Mon Sep 17 00:00:00 2001
From: Kai Junge <kai.junge@epfl.ch>
Date: Sun, 17 Apr 2022 18:06:45 +0200
Subject: [PATCH] More clean up for release.

---
 README.md             |  2 ++
 comms_wrapper.py      | 30 +++++++++++++-----------------
 function_reference.md |  5 -----
 3 files changed, 15 insertions(+), 22 deletions(-)
 delete mode 100644 function_reference.md

diff --git a/README.md b/README.md
index 8ecdea2..9955510 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 ec1264c..a2b6df7 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 7bb257a..0000000
--- a/function_reference.md
+++ /dev/null
@@ -1,5 +0,0 @@
-# Python side
-
-
-
-# Arduino side
-- 
GitLab