Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
EMM
meteorolog
Commits
995c2c8b
Commit
995c2c8b
authored
Jun 29, 2015
by
Nelso Jost
Browse files
NEW: sync RTC command
parent
5da41416
Changes
3
Hide whitespace changes
Inline
Side-by-side
logger/Makefile
View file @
995c2c8b
...
...
@@ -21,6 +21,8 @@ help:
@
echo
" supervisor daemon tool (requires root)"
@
echo
""
@
echo
" make tail-exec -- Follow the logger's execution.log"
@
echo
""
@
echo
" make sync-rtc -- Send the current system time to the board"
apt-install
:
sudo
apt-get
install
python python3-pip supervisor
...
...
@@ -54,3 +56,6 @@ undeploy:
tail-exec
:
tail
-F
logs/execution.log
sync-rtc
:
${VENV}
/bin/python
${PYVER}
run.py
--syncrtc
logger/app/main.py
View file @
995c2c8b
...
...
@@ -281,6 +281,40 @@ class Meteorologger:
logging
.
debug
(
"serial closed"
)
return
None
def
sync_rtc
(
self
,
port_index
=
None
):
if
isinstance
(
port_index
,
int
):
serial_port
=
self
.
SERIAL_PORTS
[
port_index
]
else
:
serial_port
=
self
.
SERIAL_PORTS
[
0
]
# if present, the board will be reseted
ser
=
serial
.
Serial
(
serial_port
,
self
.
CFG
[
'ARDUINO'
][
'BAUD_RATE'
],
timeout
=
self
.
SERIAL_READ_TIMEOUT
,
xonxoff
=
True
)
print
(
"Serial open <port='{}', baudrate={}>"
.
format
(
ser
.
port
,
ser
.
baudrate
))
time
.
sleep
(
self
.
BOARD_RESET_TIMEOUT
)
ser
.
flush
()
command_ser
=
'setrtc'
+
self
.
SERIAL_CSV_SEP
+
\
datetime
.
now
().
strftime
(
'%Y-%m-%d-%H-%M-%S'
.
replace
(
'-'
,
self
.
SERIAL_CSV_SEP
))
result
=
ser
.
write
(
bytes
(
command_ser
,
'utf8'
))
print
(
"sent: '{}' ({} bytes)"
.
format
(
command_ser
,
result
))
time
.
sleep
(
self
.
CFG
[
'ARDUINO'
][
'RESPONSE_DELAY'
])
result_line
=
ser
.
readline
()
print
(
"read: {} ({} bytes)"
.
format
(
result_line
,
len
(
result_line
)))
ser
.
close
()
def
setup_logging
(
self
):
if
self
.
verbose
:
# logging.basicConfig(
...
...
logger/run.py
View file @
995c2c8b
...
...
@@ -2,4 +2,7 @@ from app import Meteorologger
import
sys
if
__name__
==
'__main__'
:
Meteorologger
(
verbose
=
False
if
'-s'
in
sys
.
argv
else
True
).
run
()
if
'--syncrtc'
in
sys
.
argv
:
Meteorologger
().
sync_rtc
()
else
:
Meteorologger
(
verbose
=
False
if
'-s'
in
sys
.
argv
else
True
).
run
()
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment