Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
W
wifi_challenge
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
42loop
wifi_challenge
Commits
10c7d660
Commit
10c7d660
authored
5 years ago
by
42loop
Browse files
Options
Downloads
Patches
Plain Diff
Initial
parents
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
getmsg.sh
+23
-0
23 additions, 0 deletions
getmsg.sh
write_to_db.py
+52
-0
52 additions, 0 deletions
write_to_db.py
with
75 additions
and
0 deletions
getmsg.sh
0 → 100644
+
23
−
0
View file @
10c7d660
#!/bin/bash
#in rc.local:
# create backup of database
# init udp receiver
# /usr/bin/socat -u tcp-l:7777,fork system:/home/pi/getmsg.sh &
read
MESSAGE
#echo "$MESSAGE"
#' check message length ?'
ts
=
$((
$(
date
+%s%N
)
/
1000000
))
#call script to enter into sqlite table:
python /home/pi/write_to_db.py
$ts
This diff is collapsed.
Click to expand it.
write_to_db.py
0 → 100644
+
52
−
0
View file @
10c7d660
!
#/usr/bin/python3
import
sqlite3
as
lite
con
=
lite
.
connect
(
'
udp_pings.db
'
)
def
db_purge
():
global
con
with
con
:
cur
=
con
.
cursor
()
cur
.
execute
(
"
DELETE FROM udp_pings
"
)
def
db_insert
(
ts
):
global
con
with
con
:
cur
=
con
.
cursor
()
sql
=
"
INSERT INTO pings(ts) VALUES(
'"
+
str
(
ts
)
+
"'
)
"
cur
.
execute
(
sql
)
def
db_dump
():
global
con
with
con
:
cur
=
con
.
cursor
()
cur
.
execute
(
"
SELECT * FROM pings
"
)
rows
=
cur
.
fetchall
()
for
row
in
rows
:
print
(
row
)
def
db_create
():
global
con
with
con
:
cur
=
con
.
cursor
()
cur
.
execute
(
"
DROP TABLE IF EXISTS pings
"
)
cur
.
execute
(
"
CREATE TABLE pings(id INTEGER PRIMARY KEY,ts varchar(20) NOT NULL)
"
)
def
millis
():
return
int
(
round
(
time
.
time
()
*
1000
))
if
__name__
==
'
__main__
'
:
# db_create()
# db_purge()
# db_dump()
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment