summaryrefslogtreecommitdiff
path: root/protocol.tex
blob: 3f8eb1091e2a5b552c500630c6b2a618a4798604 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
\documentclass[11pt]{article}
\usepackage[usenames,dvipsnames]{xcolor}
\usepackage{hyperref}
\hypersetup{colorlinks=true,linkcolor=blue}
\usepackage{xltxtra}
\usepackage{graphicx}
\DeclareGraphicsExtensions{.eps}
\usepackage{wrapfig}
\usepackage{longtable}
\usepackage[font=small,labelfont=bf]{caption}
\setmainfont[Mapping=tex-text]{Delicious-Roman}
\setlength{\parindent}{0pt}
\setlength{\parskip}{6pt}

\newsavebox\TBox
\def\textoverline#1{\savebox\TBox{#1}%
  \makebox[0pt][l]{#1}\rule[1.1\ht\TBox]{\wd\TBox}{0.4pt}}

\begin{document}
\title{subbus protocol}
\maketitle

\tableofcontents

\section{packet types}

\begin{table}[h]
  \caption{subbus packets}
  \begin{tabular}{rll}
  	address (hex) & usage & mode \\
	\hline
	\texttt{100-00000} &	time 					& src-periodic \\
	\texttt{4c0-0\textcolor{blue}{B}\textcolor{blue}{AAA}} &
				discovery/info (request)		& request/response \\
	\texttt{cc0-\textcolor{blue}{SS}\textcolor{blue}{AAA}} &
				light (data transport to destination)	& src-event, dst-periodic \\
	\texttt{e60-00\textcolor{blue}{AAA}} &
				sensors (data transport from source)	& src-periodic
  \end{tabular}
\end{table}

\begin{wrapfigure}{l}{50mm}
\includegraphics{svg/proto-sensor}
\end{wrapfigure}

\begin{wrapfigure}{l}{60mm}
\includegraphics{svg/proto-actor}
\end{wrapfigure}

\section{addressing}

Sensors and lights share a 12-bit address space, located in the CAN address at
the final 12 bit of the extended ID.  The address contained in the CAN extended
ID specifies the device address concerned with the first byte of the data, the
following bytes are associated with the addresses following after.  It is
therefore possible to set 8 lights with one packet.

Information about the device can be requested with the discovery protocol.  One
sensor/light may occupy more than one byte of data space, the device then
occupies multiple addresses because otherwise there would be a collision. The
discovery information indicates the number of bytes used by the device.

\section{time protocol}

TBA

\section{discovery protocol}

The discovery protocol uses a CAN Remote Frame/RTR based request-response
protocol. The querier sends an RTR frame to the discovery address; the device
responds with the same address and the data payload.

(Future extension: the querier could send a regular frame to the discovery
address to write configuration/set options.)

Discovery data consists of 16 information sub-blocks that are addressed with
bit 16-19 of the CAN extended ID.  Block 0 is the root information block and
describes generic device properties.  Block 8-15 carry a string description
of the device.  The meaning of the remaining blocks depends on the root
information block.

\subsection{packet format}

Information request (RTR frame):
\begin{verbatim}
0100 1100 000_ / 00 bbbb aaaa aaaa aaaa / RTR
4    c    0    / 0  sub  deviceaddr
\end{verbatim}

Information response:
\begin{verbatim}
0100 1100 000_ / 00 bbbb aaaa aaaa aaaa / <data>
4    c    0    / 0  sub  deviceaddr
\end{verbatim}

\begin{itemize}
\item \texttt{bbbb} selects one of the 16 information sub-blocks.
\item \texttt{aaaa aaaa aaaa} is the device address.
\end{itemize}

\subsection{information blocks}

The following information blocks can be requested from a node through the
discovery protocol:

\begin{table}[h]\tt
  \caption{\textnormal{information blocks}}
  \begin{tabular}{rl}
	block & usage\\
	\hline
	0	& \textnormal{root information block} \\
	1-3	& \textnormal{reserved} \\
	4-7	& \textnormal{device specific} \\
	8-15	& \textnormal{text description of the sensor (64 bytes max, 0-padded)}
  \end{tabular}
\end{table}

\newpage
\subsection{block 0: root block}

The root information block describes generic device properties and should
always be queried to determine device characteristics:

\begin{table}[h]\tt
  \caption{\textnormal{information block 0 contents (root)}}
  \begin{tabular}{rll}
  	offset & type & field \\
	\hline
	0	& uint8\_t & \textnormal{actor type} \\
	1	& uint8\_t & \textnormal{sensor type} \\
	2	& uint8\_t & \textnormal{block 4-7 usage} \\
	3	& uint8\_t & \textnormal{data size (1-8 bytes)} \\
	4	& uint16\_t & \textnormal{sublab grid location} \\
	6	& uint16\_t & \textnormal{reserved for future use}
  \end{tabular}
\end{table}

Actor type codes (byte 0):

\begin{longtable}{rl}
	type code & type \\
	\hline
	\texttt{00}	& none (sensor or no function) \\
	\hline
	\texttt{01}	& light fixture, dimmable \\
	\texttt{02}	& light fixture, not dimmable \\
	\texttt{03}	& relais \\
	\hline
	\texttt{ff}	& custom / broken / ...
\end{longtable}

Sensor type codes (byte 1):

\begin{longtable}{rl}
	type code & type \\
	\hline
	\texttt{00}	& none (actor or no function) \\
	\hline
	\texttt{01}	& light dimming readback sensor \\
	\texttt{02}	& temperature sensor \\
	\texttt{03}	& generic single-bit digital input \\
	\hline
	\texttt{ff}	& custom / broken / ...
\end{longtable}

Block 4-7 usage (byte 2):

\begin{longtable}{rl}
	type code & type \\
	\hline
	\texttt{00}	& none (unused) \\
	\hline
	\texttt{01}	& DALI device information \\
\end{longtable}

\subsection{DALI (subtype 0x01) information blocks}

\subsubsection{block 4: reserved}

Block 4 is not currently used with DALI devices.

\subsubsection{block 5: direct bus access}
Direct DALI bus access. TBA.

\subsubsection{block 6: device ROM information}

Requesting information block 6 from a DALI device acquires ROM information and the random search
address from the device.  The request will take about 0.3s to complete since the information is
not cached.

\begin{table}[h]\tt
  \caption{\textnormal{DALI information block 6 contents (6 bytes)}}
  \begin{tabular}{rll}
  	offset & type & field \\
	\hline
	0	& uint8\_t	& \textnormal{DALI version number} \\
	1	& uint8\_t	& \textnormal{DALI device type} \\
	2	& uint8\_t	& \textnormal{DALI physical minimum dimming level} \\
	3	& uint8\_t[3]	& \textnormal{DALI device search address} \\
  \end{tabular}
\end{table}

\subsubsection{block 7: device state}

Requesting information block 7 from a DALI device polls all volatile and writable nonvolatile state.
The request will take about 0.3s to complete since the information is not cached.  It is intended
that this block can be written to.

\begin{table}[h]\tt
  \caption{\textnormal{DALI information block 7 contents (8 bytes)}}
  \begin{tabular}{rll}
  	offset & type & field \\
	\hline
	0	& uint8\_t	& \textnormal{DALI current actual power level} \\
	1	& uint8\_t	& \textnormal{DALI maximum level} \\
	2	& uint8\_t	& \textnormal{DALI minimum level} \\
	3	& uint8\_t	& \textnormal{DALI power on level} \\
	4	& uint8\_t	& \textnormal{DALI system failure level} \\
	5	& uint8\_t	& \textnormal{DALI fade rate / fade time} \\
	6	& uint8\_t	& \textnormal{DALI status information} \\
	7	& uint8\_t	& \textnormal{DALI short address} \\
  \end{tabular}
\end{table}

\newpage

\section{sublab running nodes}
\begin{longtable}{rlll}
	address & actor type & sensor type & node \\
	\hline
	\texttt{100}	& \texttt{00}: ---	& \texttt{03}: digital		& door: left wing \\	% & {\footnotesize \parbox{5em}{0: open,\\1: closed}} \\
	\texttt{101}	& \texttt{00}: ---	& \texttt{03}: digital		& door: light barrier \\% & {\footnotesize \parbox{5em}{0: blocked,\\1: normal}} \\
	\texttt{102}	& \texttt{00}: ---	& \texttt{03}: digital		& door: lock bolt \\	% & {\footnotesize \parbox{5em}{0: open,\\1: closed}} \\
	\texttt{103}	& \texttt{00}: ---	& \texttt{03}: digital		& door: right wing \\	% & {\footnotesize \parbox{5em}{0: open,\\1: closed}} \\
	\hline
	\texttt{440}-\texttt{47f} & \texttt{01}: dimmable & \texttt{01}: dimread	& DALI bus mapping
\end{longtable}


\end{document}