Update Network Control Computer: Insert content authored by Fabian Berg's avatar Fabian Berg
......@@ -4,18 +4,200 @@ This chapter contains functions you can use for the communication from the contr
## connect2Host
function: num = connect2Host(singleHosts)
**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.
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'}.
All experimental files have to be present in the directory "RemoteExperiment" on the remote experimental computer!
**Inputs**
~~~
singleHost pin numbers or IP addresses of host that shall be connected to
~~~
**Output**
~~~
num handle for respective host(s), can be used as input for other functions (e.g. sendCommand2Host)
~~~
## sendExperiment2Host
function: sendExperiment2Host(host, localFolder, keepRemoteFiles)
**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.
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.
Running experiments on a remote machine requires some essential files and folders that are documented. CHECK THIS!!!
**Inputs**
~~~
host a string containing the IP address of the remote host
localFolder the local folder with *all* necessary files to run the experiment as string.
All files and folders are copied recursively to the remote host!
The IKN Toolbox itself is not needed
~~~
**Inputs-optional**
~~~
keepRemoteFiles set to 1 to keep the files on the remote system. By default all files are deleted before new files are copied
~~~
**Examples**
~~~matlab
1. sendExperiment2Host(192.168.0.20, d:\myExperiment)
~~~
## printCmd
function: cmd = printCmd(output, command, varargin)
**Description**
Use this function to assemble commands as strings. Output from this function can be used as command input in the sendCommand2Host function.
**Inputs**
~~~
output variable name for function output (empty bracket or one variable name)
command name of the (remote) function
varargin input(s) to the (remote) function can be string, numeric (scalar or
vector) cell or struct, matrices are not supported
~~~
**Examples**
~~~matlab
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);
~~~
## sendCommand2Host
function: sendCommand2Host(hostHandle, command, wait4Feedback)
**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.
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.
**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
command command you want to execute on the remote computer (can be
any command from matlab or the toolbox), needs to be written
as string: use the output from printCmd for easy usage, but can
also be written by hand (for advanced users)
~~~
**Inputs-optional**
~~~
wait4Feedback set to 1, wait for feedback but not display on local host (default)
set to 2, wait for feedback and display on local host.
~~~
## getKeyBufferResult
function: out = getKeyBufferResult(hostHandle, varName)
**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!
**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’)
~~~
## stopRemoteKeyBuffer
function: out = stopRemoteKeyBuffer(h)
**Description**
Use this function to stop the execution of keyBuffer 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’)
~~~
## wait4NetworkResponse
function: out = wait4NetworkResponse(time2wait)
**Description**
This function needs one input argument and a valid network connection to at least one remote client.
**Inputs**
~~~
time2wait this function waits the given time (in seconds) or until one client responded
~~~
**Outputs**
~~~
out a struct containing all possible information
.netID ID of raspberry system from myHardwareSetup
.time duration of the function
~~~
## disconnectFromHost
function: disconnectFromHost(varargin)
**Description**
This function closes the connection from the experimental computer to the control computer(s).
Different optional input arguments can be used in different situations during the experiment for simple closing of a connection, rebooting or fixing of a failed connection.
**Inputs-optional**
~~~
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
myHardwareSetup.m down!
should be used at the end of a communication or the experiment
‘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
‘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'}
~~~
## rebootRaspberry
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!
In most cases you will use disconnect from host instead.
**Inputs**
~~~
host ID for the remote computer, corresponds to the given number in
myHardwareSetup (e.g. send command to the second defined
raspberry: enter ‘2’)
~~~
\ No newline at end of file