add relevant research
[msc-thesis1617.git] / results.arch.tex
1 \section{Devices}
2 The client code for the devices is compiled from one codebase. For a device to
3 be eligible for \glspl{mTask} it must be able to compile the shared codebase
4 and implement (part of) the device specific interface. The shared codebase only
5 uses standard \gls{C} and no special libraries or tricks are used. Therefore
6 the code is compilable for almost any device or system. Note that it is not
7 needed to implement a full interface. The full interface excluding the device
8 specific settings is listed in Appendix~\ref{app:device-interface}. The
9 interface works in a similar fashion as the \gls{EDSL}. Devices do not have to
10 implement all functionality, this is analogous to the fact that views do not
11 have to implement all type classes in the \gls{EDSL}. When the device connects
12 for the first time with a server the specifications of what is implemented is
13 communicated.
14
15 At the time of writing the following device families are supported and can run
16 the device software.
17 \begin{itemize}
18 \item \texttt{POSIX} compatible systems
19
20 This includes systems running \emph{Linux} and \emph{MacOS}.
21 \item \texttt{STM32} family microcontrollers supported by \texttt{ChibiOS}.
22
23 This is tested in particular on the \texttt{STM32f7x} series \gls{ARM}
24 development board.
25 \item Microcontrollers programmable by the \emph{Arduino} \gls{IDE}.\\
26
27 This does not only include \emph{Arduino} compatible boards but also
28 other boards capable of running \emph{Arduino} code. The code
29 has been found working on the \texttt{ESP8266} powered \emph{NodeMCU}.
30 It is tested on devices as small as the regular \emph{Arduino UNO}
31 board that only boasts a meager \emph{2K} of \emph{RAM}.
32 \end{itemize}
33
34 \section{Specification}
35 Devices are stored in a record type and all devices in the system are stored in
36 a \gls{SDS} containing all devices. From the macro settings in the interface
37 file a profile is created for the device that describes the specification. When
38 a connection between the server and a client is established the server will
39 send a request for specification. The client will serialize his specification
40 and send it to the server so that the server knows what the client is capable
41 of. The exact specification is listed in Listing~\ref{lst:devicespec}
42
43 \begin{lstlisting}[language=Clean,label={lst:devicespec},
44 caption={Device specification for \glspl{mTask}}]
45 :: MTaskDeviceSpec =
46 {haveLed :: Bool
47 ,haveAio :: Bool
48 ,haveDio :: Bool
49 ,bytesMemory :: Int
50 }
51 \end{lstlisting}
52
53 \section{Communication}
54 The communication to and fro a device runs via a single \gls{SDS}. Every
55 device has a specific resource that is used to connect to the device. The
56 current system supports connecting devices via a serial connection and via a
57 \gls{TCP} connection. Every device has the type \CI{MTaskDevice} and which
58 is listed in Listing~\ref{lst:mtaskdevice}. When a device is added a background
59 task is started that runs the \CI{synFun}. The \CI{synFun} is the task that
60 synchronizes the channel \gls{SDS} with the actual device. For the \gls{TCP}
61 device this is a simple \CI{tcpconnect}. The \CI{TaskId} of the background task
62 is saved to be able to stop the task in the future. When the task is unable to
63 connect it will set the \CI{deviceError} field to notify the user.
64 \todo{netter maken}
65
66 \begin{lstlisting}[language=Clean,caption={Device type},label={lst:mtaskdevice}]
67 :: Channels :== ([MTaskMSGRecv], [MTaskMSGSend], Bool)
68 :: MTaskResource
69 = TCPDevice TCPSettings
70 | SerialDevice TTYSettings
71 :: MTaskDevice =
72 { deviceTask :: Maybe TaskId
73 , deviceError :: Maybe String
74 , deviceChannels :: String
75 , deviceName :: String
76 , deviceTasks :: [MTaskTask]
77 , deviceData :: MTaskResource
78 , deviceSpec :: Maybe MTaskDeviceSpec
79 }
80
81 class MTaskDuplex a where
82 synFun :: a (Shared Channels) -> Task ()
83 \end{lstlisting}