Dpu syntax to send od_90 / od_135 commands

Hi Zack,

We ended up first trying to get the system back into its previous state where recurring od_90 and od_135 commands show up on the SAMD21 controllers by flashing an image on the Raspberry Pi as you describe in this thread:

Just by flashing the image in the above thread, that seems to have fixed at least the issue of not seeing od_90 and od_135 commands on the SAMD21 controllers! Now, for example, when we use the default dpu server_test.py script with only the time_to_wait value changed so that stir and temp commands are sent together every 10 seconds, we can see the recurring od_135 command show up in the serial monitor for a SAMD21 controller that has been flashed with RS485_PD. Additionally, the evolver_si instance seems to process the recurring od_135 command correctly and initiate the photodiode logic based on recognizing the ‘od_135’ address.

There seems to now be a different issue however that appears related to the handshake between the Raspberry Pi and SAMD21 controller. Specifically, the logic in the RS485_PD code hangs at the line within the photodiode logic that waits for the OK from the Raspberry Pi to execute.In the serial monitor, we see the message

Waiting for OK to execute …

but not the message

PD Command Executed!

If we manually change the value of in.input_array[0] to the “a” character we then are able to see the rest of the photodiode logic executed and the “PD Command Executed!” message appear in the serial monitor. We then checked this behavior for the rest of the params (e.g. stir, temp, od_led and od_90) and they also have the same behavior of hanging on the Waiting for OK to execute … line in their respective SAMD21 scripts.

So it seems like the error is somewhere in the SAM21 controller message being sent back to the Raspberry Pi either not being received or not being correct?

In case it is helpful, here a representative snippet of the log file output for evolver_server.py when we run tail -f evolver showing the data that is being broadcast and a series of error output messages of having to do with EvolverSerialError:

Broadcasting data{‘data’: {}, ‘config’: {‘lxml’: {‘fields_expected_incoming’: 17, ‘fields_expected_outgoing’: 17, ‘recurring’: False, ‘value’: [‘4095’, ‘4095’, ‘4095’, ‘4095’, ‘4095’, ‘4095’, ‘4095’, ‘4095’, ‘4095’, ‘4095’, ‘4095’, ‘4095’, ‘4095’, ‘4095’, ‘4095’, ‘4095’]}, ‘od_135’: {‘fields_expected_incoming’: 17, ‘fields_expected_outgoing’: 2, ‘recurring’: True, ‘value’: ‘1000’}, ‘od_90’: {‘fields_expected_incoming’: 17, ‘fields_expected_outgoing’: 2, ‘recurring’: True, ‘value’: ‘1000’}, ‘od_led’: {‘fields_expected_incoming’: 17, ‘fields_expected_outgoing’: 17, ‘recurring’: True, ‘value’: [‘4095’, ‘4095’, ‘4095’, ‘4095’, ‘4095’, ‘4095’, ‘4095’, ‘4095’, ‘4095’, ‘4095’, ‘4095’, ‘4095’, ‘4095’, ‘4095’, ‘4095’, ‘4095’]}, ‘pump’: {‘fields_expected_incoming’: 49, ‘fields_expected_outgoing’: 49, ‘recurring’: False, ‘value’: [‘2’, ‘2’, ‘2’, ‘2’, ‘2’, ‘2’, ‘2’, ‘2’, ‘2’, ‘2’, ‘2’, ‘2’, ‘2’, ‘2’, ‘2’, ‘2’, ‘–’, ‘–’, ‘–’, ‘–’, ‘–’, ‘–’, ‘–’, ‘–’, ‘–’, ‘–’, ‘–’, ‘–’, ‘–’, ‘–’, ‘–’, ‘–’, ‘–’, ‘–’, ‘–’, ‘–’, ‘–’, ‘–’, ‘–’, ‘–’, ‘–’, ‘–’, ‘–’, ‘–’, ‘–’, ‘–’, ‘–’, ‘–’]}, ‘stir’: {‘fields_expected_incoming’: 17, ‘fields_expected_outgoing’: 17, ‘recurring’: True, ‘value’: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]}, ‘temp’: {‘fields_expected_incoming’: 17, ‘fields_expected_outgoing’: 17, ‘recurring’: True, ‘value’: [2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047]}}, ‘ip’: ‘192.168.1.90’, ‘timestamp’: 1641425713.1169145}
Received COMMAND
Received COMMAND
tempi,2047,2047,2047,2047,2047,2047,2047,2047,2047,2047,2047,2047,2047,2047,2047,2047,!
Traceback (most recent call last): File “/home/pi/evolver/evolver/evolver_server.py”, line 242, in run_commands
returned_data = serial_communication(command[‘param’], command[‘value’], command[‘type’])
File “/home/pi/evolver/evolver/evolver_server.py”, line 285, in serial_communication raise EvolverSerialError('Error: Response has incorrect address.\n\tExpected: ’ + param + ‘\n\tFound:’ + address)evolver_server.EvolverSerialError: Error: Response has incorrect address.
Expected: temp
Found:
stiri,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,
!
Traceback (most recent call last): File “/home/pi/evolver/evolver/evolver_server.py”, line 242, in run_commands
returned_data = serial_communication(command[‘param’], command[‘value’], command[‘type’]) File “/home/pi/evolver/evolver/evolver_server.py”, line 285, in serial_communication raise EvolverSerialError('Error: Response has incorrect address.\n\tExpected: ’ + param + ‘\n\tFound:’ + address)evolver_server.EvolverSerialError: Error: Response has incorrect address.
Expected: stir
Found:
Received COMMAND
Received COMMAND
tempi,2047,2047,2047,2047,2047,2047,2047,2047,2047,2047,2047,2047,2047,2047,2047,2047,!
Traceback (most recent call last): File “/home/pi/evolver/evolver/evolver_server.py”, line 242, in run_commands returned_data = serial_communication(command[‘param’], command[‘value’], command[‘type’]) File “/home/pi/evolver/evolver/evolver_server.py”, line 285, in serial_communication raise EvolverSerialError('Error: Response has incorrect address.\n\tExpected: ’ + param + ‘\n\tFound:’ + address)evolver_server.EvolverSerialError: Error: Response has incorrect address.
Expected: temp
Found:
stiri,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
!

In particular, it looks like the culprit has to do with line 242 and line 285 of evolver_server.py as it is telling us that there is an EvolverSerialError and that the Response has an incorrect address.

Is there a way that you might suggest to debug the Response to check the address that is being sent back from the SAMD21 controllers to the Raspberry Pi?

Also in case it is helpful, below is also the server_test.py code we are using:

import socket
from socketIO_client import SocketIO, BaseNamespace
import asyncio
from threading import Thread
import random
import time
STIR_VALUES = [[0] * 16, [8] * 16] # flip between on and off
TEMP_VALUES = [4095] * 16 # always off
EVOLVER_IP = ‘169.254.73.121’
EVOLVER_PORT = 8081
evolver_ns = NonesocketIO = None
class EvolverNamespace(BaseNamespace):
def on_connect(self, *args):
print(“Connected to eVOLVER as client”)
def on_disconnect(self, *args):
print(“Discconected from eVOLVER as client”)
def on_reconnect(self, *args):
print(“Reconnected to eVOLVER as client”)
def on_broadcast(self, data):
print(data)
def run_test(time_to_wait, selection):
print('time_to_wait = ', time_to_wait);
print('selection = ', selection);
time.sleep(time_to_wait)
print(‘Sending data…’)
# Send temp
data = {‘param’: ‘temp’, ‘value’: [2047] * 16, ‘immediate’: True}
print(data)
evolver_ns.emit(‘command’, data, namespace = ‘/dpu-evolver’)
# Send stir
data = {‘param’: ‘stir’, ‘value’: STIR_VALUES[selection], ‘immediate’: True}
print(data)
evolver_ns.emit(‘command’, data, namespace = ‘/dpu-evolver’)
# Set things for the next one
selection = 1 - selection
time_to_wait = 10
# time_to_wait = random.randint(1, 31)
print('Seconds to wait: ’ + str(time_to_wait))
run_test(time_to_wait, selection)
def start_background_loop(loop):
asyncio.set_event_loop(loop)
loop.run_forever()
def run_client():
global evolver_ns, socketIO
socketIO = SocketIO(EVOLVER_IP, EVOLVER_PORT)
evolver_ns = socketIO.define(EvolverNamespace, ‘/dpu-evolver’)
socketIO.wait()
if name == ‘main’:
try:
new_loop = asyncio.new_event_loop()
t = Thread(target = start_background_loop, args = (new_loop,))
t.daemon = True
t.start()
new_loop.call_soon_threadsafe(run_client)
time.sleep(5)
run_test(0, 0)
except KeyboardInterrupt:
socketIO.disconnect()

The only relevant change we have made to the code is altering time_to_wait to 10 seconds. Please just let me know if it would be helpful to include any other information.

Thanks again for your help and eager to test out any debugging suggestions that come to mind!

Sincerely,
James