Skip to content
Snippets Groups Projects
Commit ee942da5 authored by Kai Junge's avatar Kai Junge
Browse files

More clean up for release.

parent 9d648fe1
No related branches found
No related tags found
No related merge requests found
......@@ -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));`
......
......@@ -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("----------------------")
......
# Python side
# Arduino side
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment