Update Network Control Computer: Links & Code authored by Fabian Berg's avatar Fabian Berg
This chapter contains functions you can use for the communication from the control computer to the experimental computer. This comprises the transmission of commands or a whole experimental script. More detailed guidelines for the implementation of this communication you can find in chapter 2.2. Coding device interfaces.
This chapter contains functions you can use for the communication from the control computer to the experimental computer. This comprises the transmission of commands or a whole experimental script. More detailed guidelines for the implementation of this communication you can find in [chapter 2.2. Coding device interfaces](/How-tos#using-a-raspberry-pi-as-local).
[[_TOC_]]
## connect2Host
function: num = connect2Host(singleHosts)
function: num = [connect2Host(singleHosts)](https://gitlab.ruhr-uni-bochum.de/ikn/OTBR/-/blob/master/Network/ControlComputer/connect2Host.m)
**Description**
This is the main function that handles the communication to the experimental computer. Make sure that all IP addresses are entered correctly in myHardwareSetup.m.
This is the main function that handles the communication to the experimental computer. Make sure that all IP addresses are entered correctly in [myHardwareSetup.m](https://gitlab.ruhr-uni-bochum.de/ikn/OTBR/-/blob/master/myHardwareSetup.m).
Expert mode: This function is able to connect to single hosts that are not mentioned in myHardwareSetup.m. The optional argument is a cell that contains the IP addresses e.g. {'192.168.0.50', '192.168.0.51'}.
Expert mode: This function is able to connect to single hosts that are not mentioned in [myHardwareSetup.m](https://gitlab.ruhr-uni-bochum.de/ikn/OTBR/-/blob/master/myHardwareSetup.m). The optional argument is a cell that contains the IP addresses e.g. {'192.168.0.50', '192.168.0.51'}.
All experimental files have to be present in the directory "RemoteExperiment" on the remote experimental computer!
......@@ -25,10 +25,10 @@ All experimental files have to be present in the directory "RemoteExperiment" on
## sendExperiment2Host
function: sendExperiment2Host(host, localFolder, keepRemoteFiles)
function: [sendExperiment2Host(host, localFolder, keepRemoteFiles)](https://gitlab.ruhr-uni-bochum.de/ikn/OTBR/-/blob/master/Network/ControlComputer/sendExperiment2Host.m)
**Description**
This function copies a complete experiment to a remote host on the network! The remote host (e.g. a Raspberry Pi3) has to be accessible via a windows share that is named "OTBRToolboxShare". The experimental files are copied to a folder "Experiment" within the share. Please make sure the folder exists on the remote computer.
This function copies a complete experiment to a remote host on the network! The remote host (e.g. a [Raspberry Pi3](/How-tos#using-a-raspberry-pi-as-local-or-remote-computer)) has to be accessible via a windows share that is named "OTBRToolboxShare". The experimental files are copied to a folder "Experiment" within the share. Please make sure the folder exists on the remote computer.
Before the local files are copied to the remote host all files on the share on the remote host will be deleted! Folders however will be kept since they may contain result files. Make sure to delete folders manually if not needed.
......@@ -50,15 +50,15 @@ Running experiments on a remote machine requires some essential files and folder
**Examples**
~~~matlab
1. sendExperiment2Host(192.168.0.20, d:\myExperiment)
1. sendExperiment2Host('192.168.0.20', 'd:\myExperiment')
~~~
## printCmd
function: cmd = printCmd(output, command, varargin)
function: cmd = [printCmd(output, command, varargin)](https://gitlab.ruhr-uni-bochum.de/ikn/OTBR/-/blob/master/Tools/printCmd.m)
**Description**
Use this function to assemble commands as strings. Output from this function can be used as command input in the sendCommand2Host function.
Use this function to assemble commands as strings. Output from this function can be used as command input in the [sendCommand2Host](/Network-control-computer#sendcommand2host) function.
**Inputs**
~~~
......@@ -70,29 +70,29 @@ Use this function to assemble commands as strings. Output from this function can
**Examples**
~~~matlab
1. printCmd([], keyBuffer, 10, goodkey, (1:3), badkey, 4)
ans = [] = keyBuffer(10, goodkey, [1 2 3], badkey, 4);
1. printCmd([], 'keyBuffer', 10, 'goodkey', (1:3), 'badkey', 4)
ans = '[] = keyBuffer(10, goodkey, [1 2 3], badkey, 4);'
2. printCmd(result, keyBuffer, 10, goodkey, (1:3), badkey, 4)
ans = [result] =keyBuffer(10, goodkey, [1 2 3], badkey, 4);
2. printCmd('result', 'keyBuffer', 10, 'goodkey', (1:3), 'badkey', 4)
ans = '[result] =keyBuffer(10, goodkey, [1 2 3], badkey, 4);'
~~~
## sendCommand2Host
function: sendCommand2Host(hostHandle, command, wait4Feedback)
function: [sendCommand2Host(hostHandle, command, wait4Feedback)](https://gitlab.ruhr-uni-bochum.de/ikn/OTBR/-/blob/master/Network/ControlComputer/sendCommand2Host.m)
**Description**
This function sends commands to the remote computer that will be executed. Make sure that the paradigm files exist on the remote computer before calling the files. Use sendExperiment2Host for this.
This function sends commands to the remote computer that will be executed. Make sure that the paradigm files exist on the remote computer before calling the files. Use [sendExperiment2Host](/Network-control-computer#sendexperiment2host) for this.
By default the function does not wait for feedback from the host. Call wait4Feedback as third argument for this option.
This function enables you to execute any command you like on the remote host. Functions that not need to be called with sendCommand2Host are included in this chapter.
This function enables you to execute any command you like on the remote host. Functions that not need to be called with [sendCommand2Host](https://gitlab.ruhr-uni-bochum.de/ikn/OTBR/-/blob/master/Network/ControlComputer/sendCommand2Host.m) are included in this chapter.
**Inputs**
~~~
hostHandle ID for the remote computer, corresponds to the given number in
myHardwareSetup (e.g. send command to the second defined
raspberry: enter ‘2’), you can also use the output from connect2Host
raspberry: enter '2'), you can also use the output from connect2Host
command command you want to execute on the remote computer (can be
any command from matlab or the toolbox), needs to be written
......@@ -108,36 +108,36 @@ This function enables you to execute any command you like on the remote host. Fu
## getKeyBufferResult
function: out = getKeyBufferResult(hostHandle, varName)
function: out = [getKeyBufferResult(hostHandle, varName)](https://gitlab.ruhr-uni-bochum.de/ikn/OTBR/-/blob/master/Network/ControlComputer/getKeyBufferResult.m)
**Description**
Use this function to get the results of a keyBuffer call on a remote system. This function expects the variable name of the keyBuffer results as argument. The variables have to exist on the remote computer!
Use this function to get the results of a [keyBuffer](/User-or-animal-response#keybuffer-animal) call on a remote system. This function expects the variable name of the [keyBuffer](/User-or-animal-response#keybuffer-animal) results as argument. The variables have to exist on the remote computer!
**Inputs**
~~~
hostHandle ID for the remote computer, corresponds to the given number in
myHardwareSetup (e.g. send command to the second defined
raspberry: enter ‘2’)
varName variable name of the keyBuffer results (e.g. result or out)
raspberry: enter '2')
varName variable name of the keyBuffer results (e.g. 'result' or 'out')
~~~
## stopRemoteKeyBuffer
function: out = stopRemoteKeyBuffer(h)
function: out = [stopRemoteKeyBuffer(h)](https://gitlab.ruhr-uni-bochum.de/ikn/OTBR/-/blob/master/Network/ControlComputer/stopRemoteKeyBuffer.m)
**Description**
Use this function to stop the execution of keyBuffer on a remote computer. A valid network connection is required!
Use this function to stop the execution of [keyBuffer](/User-or-animal-response#keybuffer-animal) on a remote computer. A valid network connection is required!
**Inputs**
~~~
h ID for the remote computer, corresponds to the given number in
myHardwareSetup (e.g. send command to the second defined
raspberry: enter ‘2’)
raspberry: enter '2')
~~~
## wait4NetworkResponse
function: out = wait4NetworkResponse(time2wait)
function: out = [wait4NetworkResponse(time2wait)](https://gitlab.ruhr-uni-bochum.de/ikn/OTBR/-/blob/master/Network/ControlComputer/wait4NetworkResponse.m)
**Description**
This function needs one input argument and a valid network connection to at least one remote client.
......@@ -158,7 +158,7 @@ This function needs one input argument and a valid network connection to at leas
## disconnectFromHost
function: disconnectFromHost(varargin)
function: [disconnectFromHost(varargin)](https://gitlab.ruhr-uni-bochum.de/ikn/OTBR/-/blob/master/Network/ControlComputer/disconnectFromHost.m)
**Description**
This function closes the connection from the experimental computer to the control computer(s).
......@@ -167,21 +167,21 @@ Different optional input arguments can be used in different situations during th
**Inputs-optional**
~~~
varargin reboot reboots the client computer(s) listed in
varargin 'reboot' reboots the client computer(s) listed in
myHardwareSetup.m!
helpful to establish clear connection after sending
experiments or when starting a new experiment
shutdown shuts the client computer(s) listed in
'shutdown' shuts the client computer(s) listed in
myHardwareSetup.m down!
should be used at the end of a communication or the experiment
forceReboot reboots the raspberry client(s) listed in
'forceReboot' reboots the raspberry client(s) listed in
myHardwareSetup.m even if the application on the
Raspberry hangs or a new connection isn’t possible
can be used when simple shutdown isn’t possible
can be used when simple 'shutdown' isn’t possible
host allows to disconnect/shutdown/reboot hosts that are not
'host' allows to disconnect/shutdown/reboot hosts that are not
mentioned in myHardwareSetup.m -> For experts only!
needs to be followed by a cell containing the IP
addresses e.g. {'192.168.0.50', '192.168.0.51'}
......@@ -189,6 +189,9 @@ Different optional input arguments can be used in different situations during th
## rebootRaspberry
function: [rebootRaspberry(host)](https://gitlab.ruhr-uni-bochum.de/ikn/OTBR/-/blob/master/Network/ControlComputer/rebootRaspberry.m)
**Description**
This is a helper function that reboots the Raspberry without a valid connection in MATLAB or Octave. This function calls plink.exe an external program from the PuTTY MSI installer distribution.
See http://www.chiark.greenend.org.uk/~sgtatham/putty/ for more details!
......@@ -199,5 +202,5 @@ In most cases you will use disconnect from host instead.
~~~
host ID for the remote computer, corresponds to the given number in
myHardwareSetup (e.g. send command to the second defined
raspberry: enter ‘2’)
raspberry: enter '2')
~~~
\ No newline at end of file