Logging
Logging messages from device
- Subscribe to
BehaviorEvents - Add a
GroupBy(Bonsai.Harp)operator - Add a
MessageWriteroperator. Set theFileNameproperty toMyDevice.harp/Behavior.bin
Ask for a device register read-dump
It is critical that the messages logged from the device are sufficient to reconstruct its state history. For that to be true, we need to know the initial state of all registers. This can be asked via a special register in the protocol core: OperationControl. This register has a single bit that, when set, will trigger the device to send a dump all the values of all its registers.
- To the previous example, in a different branch:
- Add a
Timeroperator with itsDueTimeproperty set to 2 seconds. This will mimic the delayed start of an experiment. - Add a
CreateMessage(Bonsai.Harp)operator after theTimer - Select
OperationControlPayloadunderPayload. Depending on your use case, you might want to change some of the settings, but we recommend:DumpRegistersset toTrue(Required for the dump)Heartbeatset toTrue(Useful to know the device is still alive)MuteRepliesset toFalseOperationLedset toTrueOperationModeset toActiveVisualIndicatorset toOn
- Add a
Multicastoperator to send the message to the device
Important
In your experiments, always validate that your logging routine has fully initialized before requesting a reading dump from the device. Failure to do so may result in missing data.
Completing the logging pattern with the device.yml configuration file
In order to use harp-python data interface to its full extent, we need to provide a device.yml configuration file. This file will contain the device's register map, which is necessary to interpret the data logged from the device.
This file can be manually added to the root of the logged data folder, or it can be saved in Bonsai:
- To the previous examples, in a different branch:
- Add a
DeviceMetadata(Harp.Behavior)operator - Add a
WriteAllTextoperator to save the metadata to a file nameddevice.yml
We can wrap all the previous patterns in a single grouped node:
Stay tuned for updates as, while the logging spec has been defined, the Bonsai.Harp library will soon be updated to include operators to more easily implement these patterns!