-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
66 lines (48 loc) · 1.33 KB
/
index.js
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
const express = require("express")
const path = require("path")
const app = express();
var exec = require("child_process").exec;
const http = require('http');
const server = http.createServer(app);
const { Server } = require("socket.io");
const io = new Server(server);
const dataValues = [
"rpm",
"vss",
"fli",
"temp"
]
const OBD = require("./lib/obd")
OBD.on("connection", () => {
console.log("connection")
dataValues.forEach(element => {
OBD.write(element)
});
})
OBD.on("data", (data) => {
io.emit(data.name, data.value)
console.log(data.name)
})
OBD.on("queueEmpty", function () {
dataValues.forEach(element => {
OBD.write(element)
});
})
OBD.connect("COM3");
pollingRate = 1000;
app.use("/deps", express.static("deps"))
app.use("/socket.io", express.static("node_modules/socket.io/client-dist/socket.io"))
io.on('connection', (socket) => {
console.log('a user connected');
socket.on('disconnect', () => {
console.log('user disconnected');
});
});
app.get("/*", (req, res) => {
res.sendFile(path.join(__dirname, "public/index.html"))
});
server.listen(8080, () => {
console.log("Server Listening on Port 8080")
exec('"C:\\Program Files\\BraveSoftware\\Brave-Browser\\Application\\brave.exe" --kiosk http://localhost:8080', function () {
})
})