Skip to content

Commit 165f235

Browse files
DiveInoSimulator was updated to support the latest Node SerialPort version
1 parent e934400 commit 165f235

File tree

8 files changed

+32
-64
lines changed

8 files changed

+32
-64
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
/Tools/DiveInoSimulator/node_modules
2424
/Tools/DiveInoSimulator/.idea
2525
/Tools/DiveInoSimulator/.git
26+
/Tools/DiveInoSimulator/package-lock.json
2627
/PoC/DiveInoTouch/.ino.cpp
2728
/PoC/DiveInoTouch/sloeber.ino.cpp
2829
/PoC/DiveInoTouch/spec.d

PoC/DiveInoDroid/README.md

+1-15
Original file line numberDiff line numberDiff line change
@@ -1,15 +1 @@
1-
# DiveIno #
2-
3-
Android mobile application for the [DiveIno dive computer](http://www.diveino.hu/about/).
4-
5-
## Development
6-
7-
TODO
8-
9-
## Repository Owner
10-
11-
* [Kornel Schrenk](http://www.schrenk.hu/about/)
12-
13-
## License
14-
15-
This software is available under [MIT](../master/LICENSE) license.
1+
Android mobile application for the [DiveIno dive computer](http://www.diveino.hu/about/).

Tools/DiveInoConverter/README.md

-12
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
# DiveIno Converter #
2-
3-
![alt text](../master/src/main/resources/logo_small.png "DiveIno Converter logo")
4-
51
## Description
62

73
This software converts the dive profile log files from DiveIno dive computer format into UDDF or UDCF format.
@@ -37,11 +33,3 @@ Once you created the _DiveInoConverter.jar_ file, double click on it and the app
3733
* [UDCF - Universal Dive Computer Format](http://www.streit.cc/extern/udcf/udcf_doc_eng.html#toc2)
3834
* [UDDF - Universal Dive Data Format](http://www.uddf.org/)
3935
* [JavaFX deployment](http://code.makery.ch/library/javafx-8-tutorial/part7/)
40-
41-
## Repository Owner
42-
43-
* [Kornel Schrenk](http://www.schrenk.hu/about/)
44-
45-
## License
46-
47-
This software is available under [MIT](../master/LICENSE) license.

Tools/DiveInoSimulator/README.md

+1-9
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,3 @@
11
# DiveInoSimulator #
22

3-
This repository contains the source code of the software, which simulates dives on the [DiveIno dive computer](http://www.diveino.hu). More details can be found in the [Dry test](http://www.diveino.hu/2017/01/05/DryTest/) blog post.
4-
5-
## Repository Owner
6-
7-
* [Kornel Schrenk](http://www.schrenk.hu/about/)
8-
9-
## License
10-
11-
This software is available under [MIT](../master/LICENSE) license.
3+
This folder contains the source code of the software, which simulates dives on the [DiveIno dive computer](http://www.diveino.hu). More details can be found in the [Dry test](http://www.diveino.hu/2017/01/05/DryTest/) blog post.

Tools/DiveInoSimulator/config.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
2-
"port" : "COM7",
3-
"test" : "./data/TestLog4.json",
2+
"port" : "COM3",
3+
"test" : "./Tools/DiveInoSimulator/data/TestLog4.json",
44
"interval": 800,
55
"baudrate" : 115200,
66
"initialDelay" : 10

Tools/DiveInoSimulator/emulator.js

+12-11
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,18 @@
1-
var config = require("./config.json");
1+
const config = require("./config.json");
22

3-
var fs = require('fs');
3+
const fs = require('fs');
44

5-
var SerialPort = require("serialport");
6-
var sp = new SerialPort(config.port, {
7-
baudrate : config.baudrate,
8-
parser : SerialPort.parsers.readline("\n")
5+
const SerialPort = require("serialport");
6+
const Readline = require('@serialport/parser-readline');
7+
const port = new SerialPort(config.port, {
8+
baudRate : config.baudrate,
9+
parser : new Readline()
910
});
1011

1112
var startTimeStamp = Date.now();
1213
var testData;
1314

14-
sp.on("open", function() {
15+
port.on("open", function() {
1516
console.log("*EMULATOR*: " + config.port + " serial port was opened!");
1617
console.log("*EMULATOR*: " + config.test + " test data file will be used!");
1718

@@ -21,7 +22,7 @@ sp.on("open", function() {
2122
testData = JSON.parse(data);
2223
});
2324

24-
sp.on("data", function(data) {
25+
port.on("data", function(data) {
2526
if (data.startsWith("@START#")) {
2627
startTimeStamp = Date.now();
2728
console.log("*EMULATOR*: Dive started at: " + startTimeStamp);
@@ -38,9 +39,9 @@ sp.on("open", function() {
3839
}
3940
}
4041
console.log("*EMULATOR*: " + durationInSeconds + " sec, " + pressure + " mbar, " + temperature + " cel\n");
41-
sp.write(pressure + ", " + temperature + ",");
42+
port.write(pressure + ", " + temperature + ",");
4243
} else if (data.startsWith("@STOP#")) {
43-
sp.write("@EMULATOR OFF#", function(err) {
44+
port.write("@EMULATOR OFF#", function(err) {
4445
if (err) {
4546
return console.log("Error on write: ", err.message);
4647
}
@@ -52,7 +53,7 @@ sp.on("open", function() {
5253
});
5354

5455
setTimeout(function() {
55-
sp.write("@EMULATOR ON#", function(err) {
56+
port.write("@EMULATOR ON#", function(err) {
5657
if (err) {
5758
return console.log("Error on write: ", err.message);
5859
}

Tools/DiveInoSimulator/package.json

+3-4
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
{
22
"name": "diveinosimulator",
3-
"version": "1.0.1",
3+
"version": "1.0.2",
44
"description": "Provide a test harness for the open source DiveIno dive computer.",
55
"main": "emulator.js",
6-
"scripts": {
7-
},
6+
"scripts": {},
87
"dependencies": {
9-
"serialport": "~4.0.7"
8+
"serialport": "^9.0.1"
109
},
1110
"author": {
1211
"name": "Kornel Schrenk",

Tools/DiveInoSimulator/replay.js

+12-11
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,20 @@
1-
var config = require("./config.json");
1+
const config = require("./config.json");
22

3-
var fs = require('fs');
3+
const fs = require('fs');
44

5-
var SerialPort = require("serialport");
6-
var sp = new SerialPort(config.port, {
7-
baudrate : config.baudrate,
8-
parser : SerialPort.parsers.readline("\n")
5+
const SerialPort = require("serialport");
6+
const Readline = require('@serialport/parser-readline');
7+
const port = new SerialPort(config.port, {
8+
baudRate : config.baudrate,
9+
parser : new Readline()
910
});
1011

11-
sp.on("open", function () {
12+
port.on("open", function () {
1213
console.log("*REPLAY:* " + config.port + " serial port was opened!");
1314
console.log("*REPLAY:* " + config.test + " test data file will be used!");
1415

1516
//Log out to the console what the client sends back
16-
sp.on('data', function(data) {
17+
port.on('data', function(data) {
1718
console.log(data);
1819
});
1920

@@ -22,7 +23,7 @@ sp.on("open", function () {
2223

2324
//Turn on replay
2425
setTimeout(function() {
25-
sp.write("@REPLAY ON#", function(err) {
26+
port.write("@REPLAY ON#", function(err) {
2627
if (err) {
2728
return console.log("Error on write: ", err.message);
2829
}
@@ -32,7 +33,7 @@ sp.on("open", function () {
3233

3334
function sendMessage(duration, pressure, depth, temperature) {
3435
setTimeout(function () {
35-
sp.write(pressure + ", " + depth + ", " + duration + ", " + temperature + ",");
36+
port.write(pressure + ", " + depth + ", " + duration + ", " + temperature + ",");
3637
}, (config.initialDelay * 1000) + (duration * config.interval));
3738
}
3839

@@ -61,7 +62,7 @@ function handleFile(err, data) {
6162
//Turn off replay
6263
if (i == data.profile.length-1) {
6364
setTimeout(function() {
64-
sp.write("@REPLAY OFF#", function(err) {
65+
port.write("@REPLAY OFF#", function(err) {
6566
if (err) {
6667
return console.log("Error on write: ", err.message);
6768
}

0 commit comments

Comments
 (0)