acm-uiuc / twilight-old

Underglow for the Ceiling
4 stars 3 forks source link

Automatically detect connected panels' serial ports and map to hardware ID #6

Open wchill opened 7 years ago

wchill commented 7 years ago

To enumerate available serial ports, we can use this code: http://stackoverflow.com/a/33664096

Mapping to hardware ID is not feasible with the current Arduino Uno setup and cannot be completed until the Teensy LCs arrive, but when they do, this forum thread has information on obtaining a MAC from the connected Teensy: https://forum.pjrc.com/threads/25522-Serial-Number-of-Teensy-3-1

The goal is to be able to detect which/how many panels are networked without having to hardcode serial ports on each Raspberry Pi as serial port device files may change.

wchill commented 7 years ago

Code to acquire the hardware ID has been merged in #10 (at least the code from the Teensy side). In order to request the hardware ID, this Python code can be used:

import serial
port = serial.Serial('/dev/ttyACM0', 460800)
port.write(b'\xDE\xAD\xBE\xEF\x00')
id = port.read(4)
print(id)