-
Notifications
You must be signed in to change notification settings - Fork 73
/
Copy pathindex.html
173 lines (114 loc) · 5.37 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>JSDoc: Home</title>
<script src="scripts/prettify/prettify.js"> </script>
<script src="scripts/prettify/lang-css.js"> </script>
<!--[if lt IE 9]>
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css">
<link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css">
</head>
<body>
<div id="main">
<h1 class="page-title">Home</h1>
<h3> </h3>
<section>
<article><p><img src="https://github.com/sebi2k1/node-can/actions/workflows/cicd.yml/badge.svg?branch=master" alt="Build Status"></p>
<h1>node-can</h1>
<p>This is a NodeJS SocketCAN extension. SocketCAN is a socket-based implementation of the CANbus protocol for Linux system.</p>
<p>This extensions makes it possible to send and receive CAN messages (extended, remote transission) using simple Javascript/Typescript functions.</p>
<h2>Usage (JavaScript)</h2>
<p>Basic CAN example:</p>
<pre class="prettyprint source lang-javascript"><code>var can = require("socketcan");
var channel = can.createRawChannel("vcan0", true);
// Log any message
channel.addListener("onMessage", function(msg) { console.log(msg); } );
// Reply any message
channel.addListener("onMessage", channel.send, channel);
channel.start();
</code></pre>
<p>Working with message and signals:</p>
<pre class="prettyprint source lang-javascript"><code>var can = require("socketcan");
// Parse database
var network = can.parseNetworkDescription("samples/can_definition_sample.kcd");
var channel = can.createRawChannel("vcan0");
var db_motor = new can.DatabaseService(channel, network.buses["Motor"]);
var db_instr = new can.DatabaseService(channel, network.buses["Instrumentation"]);
channel.start();
// Register a listener to get any value changes
db_motor.messages["CruiseControlStatus"].signals["SpeedKm"].onChange(function(s) {
console.log("SpeedKm " + s.value);
});
// Register a listener to get any value updates
db_motor.messages["Emission"].signals["Enginespeed"].onUpdate(function(s) {
console.log("Enginespeed " + s.value);
});
// Update tank temperature
db_instr.messages["TankController"].signals["TankTemperature"].update(80);
// Trigger sending this message
db_instr.send("TankController");
channel.stop()
</code></pre>
<h2>Usage (TypeScript)</h2>
<p>Basic CAN example:</p>
<pre class="prettyprint source lang-typescript"><code>import {Message} from "*can.node";
import * as can from "socketcan";
const channel = can.createRawChannel("vcan0", true);
// Log any message
channel.addListener("onMessage", function (msg: Message) { console.log(msg); });
// Reply any message
channel.addListener("onMessage", channel.send, channel);
channel.start();
</code></pre>
<p>Working with message and signals:</p>
<pre class="prettyprint source lang-typescript"><code>import * as can from "socketcan"
// Parse database
const network = can.parseNetworkDescription("samples/can_definition_sample.kcd");
const channel = can.createRawChannel("vcan0");
const db_motor = new can.DatabaseService(channel, network.buses["Motor"]);
const db_instr = new can.DatabaseService(channel, network.buses["Instrumentation"]);
channel.start();
// Register a listener to get any value changes
db_motor.messages["CruiseControlStatus"].signals["SpeedKm"].onChange(function (s: can.Signal) {
console.log("SpeedKm " + s.value);
});
// Register a listener to get any value updates
db_motor.messages["Emission"].signals["Enginespeed"].onUpdate(function (s: can.Signal) {
console.log("Enginespeed " + s.value);
});
// Update tank temperature
db_instr.messages["TankController"].signals["TankTemperature"].update(80);
// Trigger sending this message
db_instr.send("TankController");
channel.stop();
</code></pre>
<h2>Install</h2>
<p>There are two options for installing node-can:</p>
<ol>
<li>Clone / download node-can from <a href="https://github.com/sebi2k1/node-can">GitHub</a>, then:</li>
</ol>
<pre class="prettyprint source lang-shell"><code> $ npm ci
$ npm run configure
$ npm run build:all
</code></pre>
<ol start="2">
<li>Install via npm:</li>
</ol>
<pre class="prettyprint source lang-shell"><code> $ npm install socketcan
</code></pre></article>
</section>
</div>
<nav>
<h2><a href="index.html">Home</a></h2><h3>Modules</h3><ul><li><a href="module-Signals.html">Signals</a></li></ul><h3>Classes</h3><ul><li><a href="module-Signals-DatabaseService.html">DatabaseService</a></li><li><a href="module-Signals-Message.html">Message</a></li><li><a href="module-Signals-Signal.html">Signal</a></li></ul><h3>Global</h3><ul><li><a href="global.html#createRawChannel">createRawChannel</a></li></ul>
</nav>
<br class="clear">
<footer>
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 4.0.2</a> on Sun Sep 24 2023 10:29:10 GMT+0200 (Mitteleuropäische Sommerzeit)
</footer>
<script> prettyPrint(); </script>
<script src="scripts/linenumber.js"> </script>
</body>
</html>