Update
Ok! Thanks to the advice of @Gerben and @chrisl I ended up routing everything around with PySerial, and (for the extremely limited purposes of this little project) it works well! Here's what is currently working:
import serial
from time import sleep
import os
# Connect to each Arduino individually
serialUno = serial.Serial("/dev/cu.usbmodem141101", 9600, timeout=0)
serialTrinket1 = serial.Serial("/dev/cu.usbmodem1414401", 9600, timeout=0)
# (+ 6 more. serialTrinket2, serialTrinket3, etc)
# Open a text file to save the encoder value in
f = open("encoderVal.txt", "w")
while True:
# Read encoderVal from the UNO
data = serialUno.read(9999)
if len(data) > 0:
# Send data to each trinket
serialTrinket1.write(data)
# Save val to text file to Unity
with open('encoderVal.txt', 'r+') as f:
# Wipe the file so it's only the most recent value
f.truncate()
dataStripped = data.strip()
# Return the last int in the data stream
dataSplit = dataStripped.split('\n')
f.write(dataSplit[-1])
sleep(0.05)
# Close serial connections & file on interrupt
serialUno.close()
serialTrinket1.close()
f.close()
As for the laptop end of the equation, I abandoned the serial library that I had been using in favor of this Unity-to-Python tool, which works perfectly.
The only issue thus far is that PySerial loses the occasional few bytes here and there, which outputs a wonky number ever 30 or so. That'll be tomorrow's project. Thanks everyone for your help!
