Skip to content
This repository was archived by the owner on Mar 27, 2021. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
70 commits
Select commit Hold shift + click to select a range
a6fab2c
Add functionality for reading serial data
AdamBusch Oct 29, 2018
2c68c1c
Fixed linting issues
AdamBusch Oct 29, 2018
3d133fe
Import full .gitignore file
AdamBusch Oct 29, 2018
47bd905
Add README.md
AdamBusch Oct 29, 2018
199502a
Merge branch 'feature_add_serial_reading' of https://github.com/Purdu…
AdamBusch Oct 29, 2018
3477156
Add inital data logging
AdamBusch Oct 30, 2018
be3ca48
Add final data formatting and IP address
AdamBusch Nov 29, 2018
7617704
Remove clientside code
AdamBusch Nov 29, 2018
d974150
Add router configuration files
AdamBusch Nov 29, 2018
024c6ce
Fix linting issues.
AdamBusch Jan 18, 2019
b151afa
Added a period
jacklecroy Jan 25, 2019
c63bca5
Merge branch 'master' into feature_add_data_logging
AdamBusch Jan 25, 2019
975e37d
Fix debug messages and double comment
AdamBusch Jan 25, 2019
c6974d2
Merge remote-tracking branch 'origin/master' into feature_add_data_lo…
AdamBusch Jan 26, 2019
3b57c4a
Add initial sensor dictionaly with CAN IDs
AdamBusch Jan 26, 2019
af48098
Add potential IDs and byte indicies.
AdamBusch Jan 26, 2019
ebb049d
Update message ID formatting
AdamBusch Jan 26, 2019
3d78566
Remove client HTML code
AdamBusch Jan 26, 2019
faf18ae
Update tire temp byte length
AdamBusch Jan 26, 2019
e8f2fc2
Adds a function to read sensor data from dictionary
jacklecroy Jan 26, 2019
649b1a9
Add print formatting for excel/google sheets
AdamBusch Jan 26, 2019
e3315f9
Adds function to save sensor data from a list
jacklecroy Jan 26, 2019
5780aaf
Merge branch 'feature_add_sensor_translation' of https://github.com/P…
jacklecroy Jan 26, 2019
ac54f87
Output correct start/stop bits for can IDs
AdamBusch Jan 26, 2019
eb5ea90
Update SensorDict.py to coding standards
jacklecroy Jan 26, 2019
9eaddd7
Updates SensorDict.py with line limit 80
jacklecroy Jan 26, 2019
d01d980
Merge branch 'feature_add_sensor_translation' of https://github.com/P…
AdamBusch Jan 26, 2019
52210b9
Change CAN message format for IMU
AdamBusch Jan 26, 2019
c7dda62
Fix linting issues
AdamBusch Jan 26, 2019
eb1dcb8
Add support for parsing multiple data points
AdamBusch Jan 26, 2019
d8e4385
Split sensors to front/back of car
AdamBusch Jan 28, 2019
3e354de
Merge branch 'feature_add_sensor_translation' of https://github.com/P…
AdamBusch Jan 30, 2019
74fb455
Fix linting issues
AdamBusch Jan 30, 2019
517571a
Fix typos mentioned in #7
AdamBusch Jan 30, 2019
2521349
Merge pull request #8 from PurdueElectricRacing/feature_add_sensor_tr…
Jan 30, 2019
bd67281
Add C-compatiable names
AdamBusch Feb 2, 2019
a1b0d07
Script to upate SensorDict from Google Sheets
jacklecroy Feb 4, 2019
f6f0868
Merge branch 'feature_add_data_logging' of https://github.com/PurdueE…
jacklecroy Feb 4, 2019
86d348f
update-SensorDict script adds comments
martinjaa18 Feb 5, 2019
33d6f71
Add file to generate C headers
jacklecroy Feb 9, 2019
ae876c2
Merge branch 'feature_add_data_logging' of https://github.com/PurdueE…
jacklecroy Feb 9, 2019
0b7fc9e
Format CANID names to work with header file gneration tool
AdamBusch Feb 9, 2019
c2eaae4
Fix formatting errors and duplicate message ids.
AdamBusch Feb 9, 2019
219a0f7
Fix linting errors...
AdamBusch Feb 10, 2019
99d63c9
Move CAN related files to new directory
AdamBusch Feb 12, 2019
6b1c7a4
Add documentation to generated header file
AdamBusch Feb 12, 2019
04137e0
Ignore nan rows from google sheets
AdamBusch Feb 12, 2019
ddbcfcf
Makes update script use iterrows
jacklecroy Feb 13, 2019
5cd766e
Makes header script use iterrows
jacklecroy Feb 14, 2019
958c620
Initial file structure
AdamBusch Feb 15, 2019
f6d0395
Initial dashboard testing with dummy data
AdamBusch Feb 15, 2019
eeaae43
Add initial dashboard framework for pyqt
AdamBusch Apr 5, 2019
404a32f
Add dynamic layouts
AdamBusch Apr 5, 2019
87b1d6b
Added generic data modules
AdamBusch Apr 5, 2019
16acc10
pyqt vis
AdamBusch Apr 14, 2019
f24024d
PYQT Initial dashboard
AdamBusch Apr 15, 2019
23ab4d7
Fixed gitignore
AdamBusch Apr 15, 2019
085bbe2
Add serial writing for variable baudrate
AdamBusch Apr 22, 2019
24afca6
Remove EXE file
AdamBusch Apr 22, 2019
2ec8bbb
Dashboard formatting
AdamBusch Jun 11, 2019
ecf020a
Removed experimental features for testing.
AdamBusch Aug 15, 2019
f53ccb7
Added websocket toggle for testing
AdamBusch Aug 15, 2019
c371299
Added toggle for testing pt. 2
AdamBusch Aug 15, 2019
a59294c
ADded final testing code
AdamBusch Sep 7, 2019
c52ab9e
Added ofline data logging
AdamBusch Sep 13, 2019
f398068
Merge branch 'feature_add_data_vis' into feature_add_data_logging
AdamBusch Sep 13, 2019
8454e87
Removed duplicate files
AdamBusch Sep 13, 2019
a668367
Fixed logs dropping out randomly
AdamBusch Oct 3, 2019
768d591
Screen script for starting up DAQ
AdamBusch Oct 12, 2019
4a0cdb9
Changed CAN_Logger to log files in csv format
LukeOxley Oct 17, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
*/__pycache__
__pycache__
.vscode/*
.vscode
*/.idea
.idea
*.pyc
<<<<<<< HEAD
/logs

=======
*/logs
logs
>>>>>>> feature_add_data_vis
6 changes: 0 additions & 6 deletions .vscode/settings.json

This file was deleted.

24 changes: 0 additions & 24 deletions GenerateHeaders.py

This file was deleted.

130 changes: 0 additions & 130 deletions Main_WT_Server_DAQ.py

This file was deleted.

43 changes: 0 additions & 43 deletions SavedGoogleDrive.csv

This file was deleted.

69 changes: 69 additions & 0 deletions WT_Server/CAN_Logger.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
import os.path
from datetime import datetime
import time
import sys
import csv

log_path = ''

# Max resolution (ms) for data frames to be logged
max_time_diff_ms = 10
start_time = int(round(time.time() * 1000))
last_time = start_time
multi_frame_message = []

def log_string(message):
global log_path
with open(log_path, 'a+') as logfile:
logfile.write(message)

#Same concept as SensorDict's save_data_to_csv(
def log_csv(input_list):
global log_path
with open(log_path, 'a+') as fid:
logfile = csv.DictWriter(fid,
fieldnames=["timestamp", "id", "data"],
extrasaction="ignore")
for dictionary in input_list:
logfile.writerow(dictionary)

def create_logfile():
print("[INFO] Creating logfile...")
global log_path

start_date_time = datetime.now().strftime("%Y_%m_%d_%H_%M_%S")
start_path = os.path.abspath(os.path.dirname(__file__))

log_path = os.path.join(start_path, 'logs',
start_date_time + '.csv')

#log_string(start_date_time)
log_csv([{"id": "id", "data": "data", "timestamp": "timestamp"}])

print("[INFO] Logfile created: {}.csv".format(start_date_time))


# Logs a set of CAN frames in a time interval to a log file
def log_CAN_data(can_id, message):

current_time = int(round(time.time() * 1000))

global start_time

# Wait for serial connection to stabilize, avoid garbage data
if current_time - start_time < 1500:
return

global last_time, multi_frame_message, log_path

delta_time = current_time - last_time
single_frame = {"id": str(can_id), "data": str(message), "timestamp": str(current_time-start_time)}

multi_frame_message.append(single_frame)

if(delta_time >= max_time_diff_ms):
log_csv(multi_frame_message)
last_time = current_time
print(str(multi_frame_message))
multi_frame_message.clear()

14 changes: 12 additions & 2 deletions DAQ_Simulation.py → WT_Server/DAQ_Simulation.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import WirelessTelemServer as server
import asyncio
import random
import time

# This file simulates the job of the DAQ code.
# A server is setup and broadcast on ip:port
Expand All @@ -9,6 +10,14 @@
ip = '127.0.0.1'
port = 5000

possible_data = [
{
'i': '501',
'm': '0F900EBF02A0029F',
'ts': None
},
]


possible_data = [
# {
Expand Down Expand Up @@ -47,12 +56,13 @@ async def send_data():
await asyncio.sleep(0.01)
index = int(random.random() * len(possible_data))
data = possible_data[index]
await server.send_data(data)
data['ts'] = int(time.time()*1000)
await server.send_data([data])


async def run_server(ip, port):
wait_task = asyncio.ensure_future(send_data())
server_task = asyncio.ensure_future(server.get_server('127.0.0.1', 5000))
server_task = asyncio.ensure_future(server.get_server(ip, port))

done, pending = await asyncio.wait(
[wait_task, server_task],
Expand Down
Loading