-
Notifications
You must be signed in to change notification settings - Fork 6
setEnv.m
aortega255 edited this page Jul 22, 2020
·
4 revisions
[env,error] = setEnv(devinfo)
This function sets the “hardware environment” for the selected hardware device, that is, specifies how the GUI should interact with the serial fNIRS device. After the cfg file is loaded the name of the hardware device is sent to another function ‘device_functions\setEnv.m’. setEnv returns an environment variable and an error variable. In the current version, the error is just a binary variable that has the value of 1 if the function encounters an error, or a value of 0 if there was no error. The environment variable env is a structure which contains three sub-structures:
- SPparams. This structure specifies the communication parameters for the serial ports (such as baud rate, etc)
- commands. This structure specifies human-friendly names for low level serial commands specific to the particular hardware
- functions. This structure sets several anonymous functions pointing to hardware specific scripts in the subfolder ‘device_functions\HARDWARENAME’ where HARDWARENAME is the name of the device. These scripts are meant to be more complex sets of instructions than just sending a serial command, and are meant to do things like processing the byte stream received from the hardware or flush the serial buffer For all of these, the script checks what device name was passed as an argument. If the device name is recognized, the script sets the environment variable with the appropriate environment and returns an error of 0. Otherwise, the device is considered non-compatible and error returns a 1.