-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdataStream.py
More file actions
48 lines (37 loc) · 1.08 KB
/
dataStream.py
File metadata and controls
48 lines (37 loc) · 1.08 KB
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
# -*- coding: utf-8 -*-
"""
Student Organisation for Aerospace Reasearch
University of Calgary
Canada
Developers:
Robbie Ridgeway
Nathan Meulenbroek
Description:
"""
# This is not a default module, make sure to install it!!!
import serial
import sys
class DataStream():
"""
Maintains data received from the downlink.
"""
ser = None
def __init__(self):
if sys.platform == 'win32':
isWindows=True
else:
isWindows=False
if isWindows: # This needs to be adjusted to the correct port name... []
# Import msvcrt
self.ser=serial.Serial('COM3',timeout=1)
if not isWindows:
# Import the linux version
self.ser=serial.Serial('/dev/ttyUSB0')
return None
def get_data(self):
currentLine = self.ser.readline().rstrip()
if len(currentLine) > 3 and currentLine[0] == '$' and currentLine[-1] == '*':
currentLine = currentLine[1:-1]
return currentLine
else:
return None