Skip to content
Snippets Groups Projects
Commit 8e9effc2 authored by adam-abed-abud's avatar adam-abed-abud
Browse files

Arduino recorder interval time

parent 83b86cae
Branches
No related merge requests found
......@@ -27,6 +27,26 @@ def getList(dict):
# List of data variables in the data packet from the Arduino
data_format = getList(DataFormat().getDict())
def check_table(tableName):
conn = sqlite3.connect(sqlite_file)
c = conn.cursor()
#get the count of tables with the name
c.execute(''' SELECT count(name) FROM sqlite_master WHERE type='table' AND name='{tn}' '''.format(tn=tableName))
existence = False
#if the count is 1, then table exists
if c.fetchone()[0]==1 :
existence = True
print('Table exists.')
else :
print('Table does not exist.')
#commit the changes to db
conn.commit()
#close the connection
conn.close()
return existence
def database_setup():
'''
......@@ -59,7 +79,7 @@ def database_setup():
finally:
print('Table ' + TABLE_NAME + ' created successfully!')
def monitoring(source_address):
def monitoring(interval):
'''
Store arduino data in the sqlite3 table.
'''
......@@ -103,12 +123,11 @@ def monitoring(source_address):
conn.commit()
except sqlite3.Error as err:
raise Exception("sqlite3 error. Insert into database failed: {}".format(str(err)))
finally:
sys.stdout.flush()
time.sleep(0.2)
time.sleep(interval)
def progress(status, remaining, total):
print(f'Copied {total-remaining} of {total} pages...')
......@@ -135,7 +154,7 @@ def db_backup(backup_time):
def parse_args():
parser = argparse.ArgumentParser(description='Python script monitorign Arduino data')
parser.add_argument('--source', default='ttys0 or similar')
parser.add_argument('--interval', type=float, default=1)
parser.add_argument('--backup_time', type=int, default=600)
return parser.parse_args()
......@@ -143,4 +162,4 @@ if __name__ == "__main__":
ARGS = parse_args()
database_setup()
db_backup(ARGS.backup_time)
monitoring(ARGS.source)
monitoring(ARGS.interval)
No preview for this file type
No preview for this file type
<svg aria-hidden="true" focusable="false" data-prefix="fas" data-icon="play" class="svg-inline--fa fa-play fa-w-14" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512"><path fill="currentColor" d="M424.4 214.7L72.4 6.6C43.8-10.3 0 6.1 0 47.9V464c0 37.5 40.7 60.1 72.4 41.3l352-208c31.4-18.5 31.5-64.1 0-82.6z"></path></svg>
\ No newline at end of file
<svg aria-hidden="true" focusable="false" data-prefix="fas" data-icon="stop" class="svg-inline--fa fa-stop fa-w-14" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512"><path fill="currentColor" d="M400 32H48C21.5 32 0 53.5 0 80v352c0 26.5 21.5 48 48 48h352c26.5 0 48-21.5 48-48V80c0-26.5-21.5-48-48-48z"></path></svg>
\ No newline at end of file
......@@ -89,9 +89,11 @@
<form action="{{ url_for('send_cmd') }}" method="post">
<div class = "controls py-1 ml-auto mr-auto">
<input type="submit" name="start" value="START" onclick="cmdNotification(this.value)" class="sb-nav-button py-1 mb-1"></input>
<input type="submit" name="stop" value="STOP" onclick="cmdNotification(this.value)" class="sb-nav-button py-1 mb-1"></input>
<input type="submit" name="stop" value="STOP" onclick="cmdNotification(this.value)" class="sb-nav-button py-1 mb-1"></input>
<!-- <input type="submit" name="reset" value="RESET" onclick="cmdNotification(this.value)" class="sb-nav-button py-1 mb-1"></input> -->
</div>
</div>
</form>
</div>
</nav>
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment