-
Notifications
You must be signed in to change notification settings - Fork 1
5. Testing and Debugging the GEM
The code is distributed with the DEBUG definition for the Metronome and Tapper Arduinos turned off, assuming that everything will work, i.e. that one can run the GEM from the Python GUI by invoking a file containing a dictionary of presets that specifies various GEM parameters, e.g.
python gem_example.py
However, it may be desired to modify aspects of the Arduino or Python code, at which point things may stop working as expected and it becomes necessary to start debugging.
In order to test whether sketches are being properly loaded for both the metronome and tapper Arduinos, it is helpful to run through the steps of the setup procedure with the DEBUG global defined in GEMGlobals.h
. This will enable the printing of various messages via the Serial interface, which can be monitored using the Serial Monitor.
Note that the Serial Monitor operates only for one USB port at a time. It is useful to have the Serial Monitor when uploading the sketch for each Tapper to verify that it has been assigned the correct ADDRESS for the I2C communications. When using DEBUG mode with the Metronome Arduino, the messages provide sufficient guidance to verify that the all of the tappers have been identified and connected as well as starting and stopping a sequence of metronome tones by:
- issuing the command to transition the Metronome state (GEM_CURRENT_STATE) from the idle state (GEM_STATE_IDLE) to a running state (GEM_STATE_RUN): 4
- issuing the command to start the run, i.e. the playing of metronome sounds and registering of taps (GEM_START): 1
- issuing the command to stop the metronome tones (GEM_STOP) and enter the idle state: 0
NOTE: In DEBUG mode, the bytes arriving via the Serial interface are parsed as integers and thus keyboard character values corresponding to numbers are converted to corresponding numeric byte values that are used to set state, etc. Otherwise, the raw byte stream is read and interpreted, so numeric keyboard values can no longer be used to control the device via the Serial Monitor interface. The Python GUI must be used instead.
- Activate the virtualenv that you've created for your GEM project.
- Within a shell program, e.g. Terminal, navigate to the GUI directory.
- Set the
metronome_serial_num
variable in the Python script in which the presets are set, e.g. gem_example.py. The serial number can be found by looking at the USB port information in your computer's operating system. Find the port to which your Arduino is connected and copy the serial number associated with that Arduino device. If your Metronome and Tapper Arduinos are all visible on your USB bus, confirm that you are selecting the correct device. One way to do that is to make sure that only the Metronome Arduino is connected. - Set any other parameters you wish to set
- Invoke the preset-containing script you wish to run, e.g.
python GEM_example.py
- Within the GUI
- Enter an Experimenter ID (any string will do)
- Append two letters to the Subject 1 ID entry
- Start the run
Output will be written to file in specified in the data_dir entry of the presets.
SerialSpoof allows for limited simulation of the hardware, so as to debug the Python software. To enable SerialSpoof mode, make sure the following entry exists in the presets dictionary of the Python script that is invoked, e.g. gem_example.py:
"spoof_mode": True,
serial.serialutil.PortNotOpenError: Attempting to use a port that is not open
- this means that the Metronome Arduino was probably not found. Check to make sure that the correct Arduino serial number specified in metronome_serial_num
is being sought.
- Make sure that the volume is turned on/up.
- Make sure that a version of WaveHC but no more recent than 1.0.2 is installed and that the sketch has been compiled/uploaded against that version.