-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.html
467 lines (467 loc) · 20.3 KB
/
index.html
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
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
<!--
Main page of the CAN overhead calculator.
Published under the terms of the BSD 3-Clause license.
See LICENSE.md for details.
-->
<!DOCTYPE html>
<html lang=en-US>
<head>
<meta charset=utf-8>
<title>CAN overhead, stuffing and bitrate calculator</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="author" content="Nicola Furlan, Matjaž Guštin"/>
<link rel="license" href="license.html"/>
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
<h1 id="main_title">
CAN overhead, stuffing and bitrate calculator
</h1>
<noscript id="noscript_warning">
<hr/>
<h3>
Please enable JavaScript for this website to work.
</h3>
<div>
If you don't trust the code (some paranoia is always good!),
you can inspect it first on
<a href="https://github.com/Nik89/CanOverhead">GitHub</a>.
The page works offline (no data is transmitted to any server),
so alternatively you can download the files and open the
<i>index.html</i> file in your browser even when not connected to the
internet.
</div>
<hr/>
</noscript>
<div id="input_form">
<div class="input">
<div id="input_frame_type_block">
<label for="input_frame_type">Frame type</label>
<select name="input_frame_type" id="input_frame_type"
class="dropdown_select" onchange="alterInputFormOnFrameTypeChange(this)">
<option value="can_data11" selected>Base data frame (11-bit ID)</option>
<option value="can_data29">Extended data frame (29-bit ID)</option>
<option value="can_rtr11">Base RTR frame (11-bit ID)</option>
<option value="can_rtr29">Extended RTR frame (29-bit ID)</option>
<option value="canfd_data11" hidden>FD base data frame (11-bit ID)</option>
<option value="canfd_data29" hidden>FD extended data frame (29-bit ID)</option>
</select>
</div>
<div id="input_can_identifier_block">
<label for="input_can_identifier">Frame identifier</label>
<input id="input_can_identifier"
name="input_can_identifier"
class="input_text"
type="text" placeholder="42" autofocus/>
<label for="input_can_identifier_base"
class="small_label">in base</label>
<select name="input_can_identifier_base"
id="input_can_identifier_base"
class="dropdown_select">
<option value="0b">Bin</option>
<option value="">Dec</option>
<option value="0x" selected>Hex</option>
</select>
</div>
<div id="input_can_payload_block">
<label for="input_can_payload">
Frame payload data
</label>
<span class="small_label">
(hex-only, ignoring spaces, commas and '0x' prefixes)
</span>
<input id="input_can_payload"
name="input_can_payload"
class="input_text"
type="text" placeholder="43 41 4E"/>
</div>
<div id="input_can_dlc_block">
<label for="input_can_dlc">RTR frame Data Length Code (DLC)</label>
<span
title="This should be the payload length of the frame transmitted by the receiver(s) of the RTR frame. RTR frames themselves have no payload."
class="help_popup">ⓘ
</span>
<select name="input_can_dlc" id="input_can_dlc"
class="dropdown_select">
<option value="0" selected>0</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>
</select>
</div>
<div id="input_can_bitrate_block">
<label for="input_can_bitrate">CAN bitrate</label>
<span
title="In KILObit (multiples of 1000), not KIBIbit (multiples of 1024)"
class="help_popup">ⓘ
</span>
<select name="input_can_bitrate" id="input_can_bitrate"
class="dropdown_select">
<option value="5e6">5 Mbit/s</option>
<option value="2e6">2 Mbit/s</option>
<option value="1e6">1 Mbit/s</option>
<option value="800e3">800 kbit/s</option>
<option value="500e3">500 kbit/s</option>
<option value="250e3">250 kbit/s</option>
<option value="125e3" selected>125 kbit/s</option>
<option value="50e3">50 kbit/s</option>
<option value="20e3">20 kbit/s</option>
<option value="10e3">10 kbit/s</option>
<option value="5e3">5 kbit/s</option>
</select>
</div>
<div id="input_error" class="input-error"></div>
</div>
<div class="buttons">
<button class="button" onclick="calculate()">Compute</button>
</div>
<div class="output">
<h4 id="output_list_title" class="output_section_title">
Whole frame
</h4>
<ul id="output_list">
<li>Whole frame without stuff bits
<span id="output_can_whole_frame_len"></span>
<div id="output_can_whole_frame"
class="output_can_text"></div>
</li>
<li>Whole frame with stuff bits
<span class="small_label">
(as appears on the bus)
</span>
<span id="output_can_whole_frame_stuffed_len"></span>
<div id="output_can_whole_frame_stuffed"
class="output_can_text"></div>
</li>
<li>Worst-case frame length after stuffing
<span class="small_label">
(assuming same ID and payload lengths)
</span>
<span
title="Some bit sequences require more stuff bits than others. If the CAN ID and also the payload of the same size as the provided inputs but their contents are the worst possible (in terms of stuffing requirements), this is the length of the whole frame after the stuffing."
class="help_popup">ⓘ
</span>
<div id="output_max_length" class="output_can_text"></div>
</li>
<li>Whole frame transfer time
<span class="small_label">
(including stuff bits)
</span>
<span
title="The time it takes to transfer the whole stuffed frame across the bus at the given bitrate, from the Start Of Frame bit (included) until the very first moment the next frame could be transmitted (next SOF excluded)."
class="help_popup">ⓘ
</span>
<div id="output_transfer_time" class="output_can_text"></div>
</li>
<li>Overhead
<span class="small_label">
(including stuff bits)
</span>
<span
title="Overhead = metadata-only bits / all bits. As the CAN ID may be itself already useful data and not only metadata (e.g. indicate a specific command for the receivers), an option where the ID is considered part of the metadata (thus adding to the overhead) is given as well as one where the ID is considered part of the data (thus not adding to the overhead)."
class="help_popup">ⓘ
</span>
<div id="output_overhead_no_id" class="output_can_text"></div>
<div id="output_overhead_with_id" class="output_can_text"></div>
</li>
<li>Effective bitrate to transfer the data
<span class="small_label">
(including stuff bits)
</span>
<span
title="Effective bitrate = data-only bits / whole frame transfer time. It is the bitrate at which the data is effectively transferred across the bus in case of continuous frame-after-frame transmission of the same frame. The same considerations for CAN ID as data or as metadata apply as for the Overhead field."
class="help_popup">ⓘ
</span>
<div id="output_effective_bitrate_no_id" class="output_can_text"></div>
<div id="output_effective_bitrate_with_id" class="output_can_text"></div>
</li>
</ul>
<h4 id="output_table_title" class="output_section_title">
Breakdown of frame fields
</h4>
<table class="output_table" id="output_table_data11bit">
<tr>
<th>#</th>
<th>Field name</th>
<th>Length<br/>[bits]</th>
<th>Content<br/>[bin]</th>
<th>Content<br/>[hex]</th>
</tr>
<tr>
<td>1</td>
<td class="cell_text">Start of Frame (SOF)</td>
<td id="output_can_data11_field01_len"></td>
<td id="output_can_data11_field01"></td>
<td id="output_can_data11_field01_hex"></td>
</tr>
<tr>
<td>2</td>
<td class="cell_text">Identifier (ID)</td>
<td id="output_can_data11_field02_len"></td>
<td id="output_can_data11_field02"></td>
<td id="output_can_data11_field02_hex"></td>
</tr>
<tr>
<td>3</td>
<td class="cell_text">Remote Transfer Request (RTR)</td>
<td id="output_can_data11_field03_len"></td>
<td id="output_can_data11_field03"></td>
<td id="output_can_data11_field03_hex"></td>
</tr>
<tr>
<td>4</td>
<td class="cell_text">Identifier Extension (IDE)</td>
<td id="output_can_data11_field04_len"></td>
<td id="output_can_data11_field04"></td>
<td id="output_can_data11_field04_hex"></td>
</tr>
<tr>
<td>5</td>
<td class="cell_text">Reserved 0 (R0)</td>
<td id="output_can_data11_field05_len"></td>
<td id="output_can_data11_field05"></td>
<td id="output_can_data11_field05_hex"></td>
</tr>
<tr>
<td>6</td>
<td class="cell_text">Data Length Code (DLC)</td>
<td id="output_can_data11_field06_len"></td>
<td id="output_can_data11_field06"></td>
<td id="output_can_data11_field06_hex"></td>
</tr>
<tr>
<td>7</td>
<td class="cell_text">Data (Payload)</td>
<td id="output_can_data11_field07_len"></td>
<td id="output_can_data11_field07"></td>
<td id="output_can_data11_field07_hex"></td>
</tr>
<tr>
<td>8</td>
<td class="cell_text">Cyclic Redundancy Check (CRC)</td>
<td id="output_can_data11_field08_len"></td>
<td id="output_can_data11_field08"></td>
<td id="output_can_data11_field08_hex"></td>
</tr>
<tr>
<td>9</td>
<td class="cell_text">CRC Delimiter</td>
<td id="output_can_data11_field09_len"></td>
<td id="output_can_data11_field09"></td>
<td id="output_can_data11_field09_hex"></td>
</tr>
<tr>
<td>10</td>
<td class="cell_text">Acknowledgement (ACK) Slot
<span
title="Set to 1 by transmitted, pulled to 0 by receiver(s) to acknowledge."
class="help_popup">ⓘ
</span>
</td>
<td id="output_can_data11_field10_len"></td>
<td id="output_can_data11_field10"></td>
<td id="output_can_data11_field10_hex"></td>
</tr>
<tr>
<td>11</td>
<td class="cell_text">Acknowledgement Delimiter</td>
<td id="output_can_data11_field11_len"></td>
<td id="output_can_data11_field11"></td>
<td id="output_can_data11_field11_hex"></td>
</tr>
<tr>
<td>12</td>
<td class="cell_text">End of Frame (EOF)</td>
<td id="output_can_data11_field12_len"></td>
<td id="output_can_data11_field12"></td>
<td id="output_can_data11_field12_hex"></td>
</tr>
<tr>
<td>13</td>
<td class="cell_text">Inter-Frame Space (IFS)
<span
title="Minimum silence required between 2 consecutive frames."
class="help_popup">ⓘ
</span>
</td>
<td id="output_can_data11_field13_len"></td>
<td id="output_can_data11_field13"></td>
<td id="output_can_data11_field13_hex"></td>
</tr>
</table>
<table class="output_table" id="output_table_data29bit">
<tr>
<th>#</th>
<th>Field name</th>
<th>Length<br/>[bits]</th>
<th>Content<br/>[bin]</th>
<th>Content<br/>[hex]</th>
</tr>
<tr>
<td>1</td>
<td class="cell_text">Start of Frame (SOF)</td>
<td id="output_can_data29_field01_len"></td>
<td id="output_can_data29_field01"></td>
<td id="output_can_data29_field01_hex"></td>
</tr>
<tr>
<td>2</td>
<td class="cell_text">Identifier part A (ID A)</td>
<td id="output_can_data29_field02_len"></td>
<td id="output_can_data29_field02"></td>
<td id="output_can_data29_field02_hex"></td>
</tr>
<tr>
<td>3</td>
<td class="cell_text">Substitute Remote Request (SRR)</td>
<td id="output_can_data29_field03_len"></td>
<td id="output_can_data29_field03"></td>
<td id="output_can_data29_field03_hex"></td>
</tr>
<tr>
<td>4</td>
<td class="cell_text">Identifier Extension (IDE)</td>
<td id="output_can_data29_field04_len"></td>
<td id="output_can_data29_field04"></td>
<td id="output_can_data29_field04_hex"></td>
</tr>
<tr>
<td>5</td>
<td class="cell_text">Identifier part B (ID B)</td>
<td id="output_can_data29_field05_len"></td>
<td id="output_can_data29_field05"></td>
<td id="output_can_data29_field05_hex"></td>
</tr>
<tr>
<td>6</td>
<td class="cell_text">Remote Transfer Request (RTR)</td>
<td id="output_can_data29_field06_len"></td>
<td id="output_can_data29_field06"></td>
<td id="output_can_data29_field06_hex"></td>
</tr>
<tr>
<td>7</td>
<td class="cell_text">Reserved Bit 1 (R1)</td>
<td id="output_can_data29_field07_len"></td>
<td id="output_can_data29_field07"></td>
<td id="output_can_data29_field07_hex"></td>
</tr>
<tr>
<td>8</td>
<td class="cell_text">Reserved Bit 0 (R0)</td>
<td id="output_can_data29_field08_len"></td>
<td id="output_can_data29_field08"></td>
<td id="output_can_data29_field08_hex"></td>
</tr>
<tr>
<td>9</td>
<td class="cell_text">Data Length Code (DLC)</td>
<td id="output_can_data29_field09_len"></td>
<td id="output_can_data29_field09"></td>
<td id="output_can_data29_field09_hex"></td>
</tr>
<tr>
<td>10</td>
<td class="cell_text">Data (Payload)</td>
<td id="output_can_data29_field10_len"></td>
<td id="output_can_data29_field10"></td>
<td id="output_can_data29_field10_hex"></td>
</tr>
<tr>
<td>11</td>
<td class="cell_text">Cyclic Redundancy Check (CRC)</td>
<td id="output_can_data29_field11_len"></td>
<td id="output_can_data29_field11"></td>
<td id="output_can_data29_field11_hex"></td>
</tr>
<tr>
<td>12</td>
<td class="cell_text">CRC Delimiter</td>
<td id="output_can_data29_field12_len"></td>
<td id="output_can_data29_field12"></td>
<td id="output_can_data29_field12_hex"></td>
</tr>
<tr>
<td>13</td>
<td class="cell_text">Acknowledgement (ACK) Slot
<span
title="Set to 1 by transmitted, pulled to 0 by receiver(s) to acknowledge."
class="help_popup">ⓘ
</span>
</td>
<td id="output_can_data29_field13_len"></td>
<td id="output_can_data29_field13"></td>
<td id="output_can_data29_field13_hex"></td>
</tr>
<tr>
<td>14</td>
<td class="cell_text">Acknowledgement Delimiter</td>
<td id="output_can_data29_field14_len"></td>
<td id="output_can_data29_field14"></td>
<td id="output_can_data29_field14_hex"></td>
</tr>
<tr>
<td>15</td>
<td class="cell_text">End of Frame (EOF)</td>
<td id="output_can_data29_field15_len"></td>
<td id="output_can_data29_field15"></td>
<td id="output_can_data29_field15_hex"></td>
</tr>
<tr>
<td>16</td>
<td class="cell_text">Inter-Frame Space (IFS)
<span
title="Minimum silence required between 2 consecutive frames."
class="help_popup">ⓘ
</span>
</td>
<td id="output_can_data29_field16_len"></td>
<td id="output_can_data29_field16"></td>
<td id="output_can_data29_field16_hex"></td>
</tr>
</table>
</div>
</div>
<footer>
<div>
Made with 💙 by
<a href="https://github.com/Nik89">Nicola Furlan</a>
and <a href="https://matjaz.it/">Matjaž Guštin</a>
</div>
<div>
Version 1.2.0
–
<a href="changelog.html">
Changelog
</a>
–
<a href="https://github.com/Nik89/CanOverhead">
Source code on GitHub
</a>
–
<a href="https://github.com/Nik89/CanOverhead/issues">
Found a bug?
</a>
</div>
<br>
<div>
This website does not use cookies, does not advertise nor track the
users. All calculations happen in your browser, no data is sent
to any server.
The results of the calculator are provided with best-effort
from the authors but with no guarantee of correctness, as stated
formally in the <a href="license.html">source code license</a>.
</div>
</footer>
<script type="text/javascript" src="CanOverhead.js" charset="utf-8"></script>
<script type="text/javascript" src="HtmlToLibAdapter.js"
charset="utf-8"></script>
<script type="text/javascript" src="TestCanOverhead.js"
charset="utf-8"></script>
</body>
</html>