forked from atbrask/CMS50Dplus
-
Notifications
You must be signed in to change notification settings - Fork 1
/
README
124 lines (87 loc) · 3.44 KB
/
README
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
Contec CMS50D+ Pulse Oximeter v7.0 Data Interface
=================================================
This python script contains a GUI and CLI to access realtime and storage data
from a Contec CMS50D+ pulse oximeter (Communication Protocol v7.0).
Features
--------
CLI
- Print realtime data
- Dump realtime/storage data (CSV)
GUI
- Interactive plots of realtime/storage data
- Save plots (Image)
- Save/Load data (CSV)
Requirements
------------
- python (>=3.8)
- python modules
- python-dateutil (>=2.8.1)
- pyserial (>=3.4)
- matplotlib (>=3.3.0)
Installation
------------
For virtualenv:
$git clone https://github.com/timegrid/CMS50Dplus7.git
$cd CMS50Dplus7
$python -m venv env
$source env/bin/activate
$pip install -r requirements.txt
Syntax
------
usage: cms50dplus7.py [-h] [-c] [-d {realtime,storage}] [-p PORT] [-f FILENAME]
[-s STARTTIME] [-t]
Contec CMS50D+ v7.0 Data Interface (c) 2020 Alexander Blum, (c) 2015 atbrask
optional arguments:
-h, --help show this help message and exit
-c, --cli Use CLI mode.
-p PORT, --port PORT Virtual serial port of the device.
-d {realtime,storage}, --datatype {realtime,storage}
Type of data.
-f FILENAME, --filename FILENAME
Output CSV file.
-s STARTTIME, --starttime STARTTIME
Start time for storage mode data [any parsable format].
-t, --testdata Use testdata, do not connect to the device.
The default port is /dev/ttyUSB0.
The default filename for the CLI storage dump is 'storage-<timestamp>.csv'.
The default starttime for the CLI storage dump is now().
The starttime may be any format parsable by dateutil.parser.
For CLI storage data you'll have to provide a starttime as the device doesn't
provide any historic timestamps at all.
Examples
--------
Start the GUI:
$./cms50dplus7.py
Start the GUI, connect to port initially:
$./cms50dplus7.py -p /dev/someport
Print realtime data on CLI:
$./cms50dplus7.py -c
Dump realtime data via CLI by providing a filename:
$./cms50dplus7.py -c -f 'realtime.csv'
Dump storage data via CLI, connect to port, set starttime:
$./cms50dplus7.py -c -p '/dev/someport' -d storage -s '01.01.1970 00:00:00'
Samplerate
----------
In storage mode we assume a sample rate of 1 Hz.
In realtime data mode the device will sample at 60 Hz.
In the GUI all datapoints are always preserved internally and during save/load,
although the plotting may use a different samplerate to decrease the CPU load.
While recording, only those datapoints within the range of the plot are plotted.
When stopped, the whole timespan is used eventually. If the CPU load feels still
too high, you might try to set:
- 'CMS50DplusGui.plot_samplerate' to around 1-10 Hz
- 'CMS50DplusGui.plot_refreshrate' to around 100-1000 ms.
Tests
-----
The unittests cover most of the device functions and parsers but not the GUI.
To run the unittests:
$./test.py
For manual testing without a device, provide the -t(estdata) flag
$./cms50dplus7.py -t
$./cms50dplus7.py -t -c
The code was written and tested with a Pulox PO-250 device.
Credit
------
This script is based on the CLI code by atbrask at https://github.com/atbrask/CMS50Dplus
for the Communication Protocol v5.0 and updated for v7.0 according to
https://github.com/InfantLab/Contec-Pulse-Oximeter-in-Matlab/blob/master/Communication%20protocol%20of%20pulse%20oximeter%20V7.0.pdf