# Import driver package
import syncmaster
Initialisation
The software drivers provide a simple interface to communicate with the device in order to send event signals from behavioural tasks to synchronise with recorded data.
Importing the drivers
Once installed, the drivers can be imported into the task script like any package.
All contents of the driver package can then be accessed using the prefix syncmaster.
, i.e. the SyncMaster
object is accessed using syncmaster.SyncMaster()
.
Alternatively, all contents of the package can be imported directly into the present script’s namespace:
# Import all package contents into current namespace
from syncmaster import *
Package contents can then be accessed using their names directly without the need for a prefix, i.e. SyncMaster()
.
While slightly more convenient, this runs the risk of colliding with function and object names imported from other packages, so we recommend using the package prefix where possible.
Creating the device object
The software communicates with the device hardware using a software object. All device commands are controlled using this object.
SyncMaster
SyncMaster ()
Device object for controlling synchronisation
In order to use the device in a task script, we must first create the device object. This should be done once at the beginning of the script.
# Create device object
= syncmaster.SyncMaster() device
This automatically carries out all initialisation procedures, including locating the device on the host system and ensuring the device is communicating correctly.
Note that an error will be produced on attempting to create the device object if the device is not connected to the host system.
Once the device has been initialised once in this way, it is ready to send event signals to the recording system as outlined in the triggering
section.
Shutting down the device
On completing the task, the communicating channel between the host system and the device should be shut down.
SyncMaster.close
SyncMaster.close ()
Closes device connection
The device should be shut down using the close
command at the end of the task.
# Close device
device.close()
It can then be disconnected from the host system.
This ensures that all communications ports are closed correctly to avoid any errors.