Skip to content

Commit 4e51be0

Browse files
committed
major overhaul to do serial reading and uploading in an asynchronous fashion. Moved concepts from gnssr4river to this repository
1 parent 79376d7 commit 4e51be0

10 files changed

+388
-127
lines changed

Diff for: .gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
__pycache__

Diff for: README.md

+65-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,70 @@
1-
# Raspberry_Gnssr
1+
# Using a low-cost Raspberry pi enabled Gnss reflectometer to log and upload NMEA messages
22

3+
[Instructions for building together the casing](doc/README.md)
34

5+
# Raspberry Information
6+
---
47

5-
[Instructions for building together the casing](doc/README.md)
8+
### Install the python module
9+
```
10+
pip install .
11+
```
12+
13+
### Copy and Change the yaml config file
14+
15+
The file ``nmeaconfig.yml`` is the file used for configuration. Copy the file to the user's home and open it with a text editor and change the value.
16+
17+
* ``file_base`` *ex: myfile*, the basename used for naming the output (date and increment will be appended to this e.g. providing `testname` will result in `testname_2022-01-01_00.gz`
18+
* ``data_dir`` *ex: /home/user*, the path where the data logs will be stored
19+
* ``device`` *ex: /dev/ttyAMA0*, the linux serial device path which produces the nmea output
20+
* ``baudrate`` *ex: 9600*, the baudrate of the serial port
21+
* ``serialsleep`` *ex: 20*, set the amount of microseconds to sleep between serial reads (this time will be made available to do other tasks such as uploading)
22+
* ``webdav``
23+
* ``url`` Webdav upload address
24+
* ``user``
25+
* ``password``
26+
27+
### How to setup a service file
28+
29+
If you want your raspberry to automatically launch the logger on boot, you need to create a service file (see the example file [nmealogger.service](nmealogger.service). This allows to simply plug your raspberry and directly execute a program without having to open a terminal. This is very useful for field survey where the raspberry boots and runs without interactive user input, or where a power failure will result in a reboot.
30+
31+
32+
Now to create the service, copy the modified [nmealogger.service file](nmealogger.service) into the right directory:
33+
```
34+
sudo cp nmealogger.service /etc/systemd/system/nmealogger.service
35+
```
36+
37+
Make sure to replace *User* with a user who can access the serial port and the *data_dir* provided in the [configuration file](nmeaconfig.yml)
38+
39+
```
40+
Before starting the service, execute the following line. It reloads to take the change into account
41+
```
42+
sudo systemctl daemon-reload
43+
```
44+
You can then start the service, if the service file is installed in the right directory (``/etc/systemd/system/``)
45+
```
46+
sudo systemctl start nmealogger.service
47+
```
48+
You can see if your service file is properly running by executing
49+
```
50+
sudo systemctl status nmealogger.service
51+
```
52+
You can also of course stop the service
53+
```
54+
sudo systemctl stop nmealogger.service
55+
```
56+
Your service file is now running on your raspberry until the board is shutdown. If you want to start it on boot *enable* it:
57+
58+
```
59+
sudo systemctl enable nmealogger.service
60+
```
61+
62+
63+
64+
65+
66+
## Authors
67+
68+
**Lubin Roineau, Roelof Rietbroek**
669
770

Diff for: ReadandWriteSerials.py

-66
This file was deleted.

Diff for: UploadingfileWebdav.py

-59
This file was deleted.

Diff for: nmeaconfig.yml

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Yaml file for raspberry gnssr-r configuration
2+
# Copy this file and replace values with your own
3+
---
4+
file_base: gnssr0
5+
data_dir: /tmp/gnssr_nmea/
6+
device: /dev/ttyAMA0
7+
baudrate: 9600
8+
serialsleep: 20 #microsecond sleep in between getting nmea messages from the serial port to get other stuff done
9+
#Possibly upload to a webdav folder
10+
webdav:
11+
url: "https://surfdrive.surf.nl/files/public.php/webdav"
12+
user: Changeme
13+
passw: Changemetoo
14+

Diff for: nmealogger.py

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#!/usr/bin/env python3
2+
"""
3+
Main nmealogging command line daemon
4+
Authors: Roelof Rietbroek
5+
Nov 2022
6+
"""
7+
8+
from raspberry_gnssr.gnssr import GNSSRconfig
9+
import asyncio
10+
import argparse
11+
import sys
12+
13+
def main(argv):
14+
usage="GNSSR nmea logging and upload daemon"
15+
parser = argparse.ArgumentParser(description=usage)
16+
17+
parser.add_argument('config',metavar="Configuration file",type=str,nargs="?",
18+
help="Specify configuration file to use (default ${HOME}/nmeaconfig.yml)")
19+
20+
parser.add_argument('-s','--simulate',action='store_true',
21+
help="Simulate some nmea messages on a fake serial port (allows testing on non gnss-enabled platforms)")
22+
parser.add_argument('-n','--noupload',action='store_true',
23+
help="Don't attempt to upload any logs")
24+
args=parser.parse_args(argv[1:])
25+
26+
gnssr=GNSSRconfig(args.config,args.simulate,args.noupload)
27+
try:
28+
asyncio.run(gnssr.startLoggingDaemon())
29+
except KeyboardInterrupt:
30+
gnssr.closeLog()
31+
32+
33+
if __name__ == "__main__":
34+
main(sys.argv)

Diff for: nmealogger.service

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
[Unit]
2+
Description=NMEA message logging service
3+
After=multi-user.target
4+
5+
[Service]
6+
Type=simple
7+
User=roelof
8+
Restart=on-abort
9+
ExecStart=nmealogger.py
10+
11+
[Install]
12+
WantedBy=multi-user.target
13+

Diff for: raspberry_gnssr/__init__.py

Whitespace-only changes.

0 commit comments

Comments
 (0)