Skip to content
This repository was archived by the owner on Feb 16, 2024. It is now read-only.

Commit 5ecf8aa

Browse files
committed
Merge branch 'release/1.1.0'
1 parent 61ebc0f commit 5ecf8aa

37 files changed

Lines changed: 2566 additions & 1543 deletions

.travis.yml

Lines changed: 29 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@ sudo: required
55
addons:
66
apt:
77
sources:
8-
- ubuntu-toolchain-r-test
8+
- ubuntu-toolchain-r-test
99
packages:
10-
- autoconf
11-
- automake
12-
- m4
13-
- gcc-4.9
14-
- g++-4.9
10+
- autoconf
11+
- automake
12+
- m4
13+
- gcc-4.9
14+
- g++-4.9
1515

1616
before_install:
1717
- git submodule update --init --recursive > /dev/null
@@ -20,8 +20,29 @@ before_install:
2020
install:
2121
- "bash -ex ./install-wiringpi.sh"
2222

23+
before_script:
24+
- "bash -ex ./prepare.sh"
25+
- export TZ=UTC
26+
2327
script:
24-
- "bash -ex ./build.sh"
28+
- make utesting && ./utesting
29+
- make clean && ./configure CPPFLAGS="-DDEBUG" && make utesting && ./utesting
30+
- make clean && ./configure CPPFLAGS="-DNO_SMS" && make utesting && ./utesting
31+
- make clean && ./configure CPPFLAGS="-DDEBUG -DNO_SMS" && make utesting && ./utesting
32+
- make clean && make
33+
- make clean && ./configure CPPFLAGS="-DNO_POWER_OFF" && make
34+
- make clean && ./configure CPPFLAGS="-DDEBUG" && make
35+
- make clean && ./configure CPPFLAGS="-DNO_POWER_OFF -DDEBUG" && make
36+
- make clean && ./configure CPPFLAGS="-DNO_SMS" && make
37+
- make clean && ./configure CPPFLAGS="-DDEBUG -DNO_SMS" && make
38+
- make clean && ./configure CPPFLAGS="-DSIM" && make
39+
- make clean && ./configure CPPFLAGS="-DDEBUG -DSIM" && make
40+
- make clean && ./configure CPPFLAGS="-DREAL_SIM" && make
41+
- make clean && ./configure CPPFLAGS="-DDEBUG -DREAL_SIM" && make
42+
- make clean && ./configure CPPFLAGS="-DNO_SMS -DREAL_SIM" && make
43+
- make clean && ./configure CPPFLAGS="-DDEBUG -DNO_SMS -DREAL_SIM" && make
44+
- make clean && ./configure CPPFLAGS="-DNO_SMS -D_SIM" && make
45+
- make clean && ./configure CPPFLAGS="-DDEBUG -DNO_SMS -D_SIM" && make
2546

2647
branches:
2748
only:
@@ -34,8 +55,7 @@ branches:
3455
notifications:
3556
email:
3657
recipients:
37-
- iban.eguia@opendeusto.es
38-
- jordan.aranda@me.com
58+
- razican@protonmail.ch
3959
- eneko.cruz@opendeusto.es
4060
on_success: change
4161
on_failure: always

Makefile.am

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
bin_PROGRAMS = openstratos
2-
openstratos_SOURCES = openstratos.cc utils.cc threads.cc camera/Camera.cc gps/GPS.cc serial/Serial.cc logger/Logger.cc gsm/GSM.cc
3-
openstratos_CPPFLAGS = -std=c++14
2+
openstratos_SOURCES = openstratos.cc logic/main_while.cc logic/shut_down.cc utils.cc threads.cc camera/Camera.cc gps/GPS.cc serial/Serial.cc logger/Logger.cc gsm/GSM.cc
3+
openstratos_CPPFLAGS = -Wall -Wextra -Werror -pedantic-errors -std=c++14
44

55
EXTRA_PROGRAMS = utesting
66
utesting_SOURCES = testing/testing.cc camera/Camera.cc gps/GPS.cc serial/Serial.cc logger/Logger.cc
7-
utesting_CPPFLAGS = -std=c++14 -Itesting/bandit -Wno-unused-result -DOS_TESTING
7+
utesting_CPPFLAGS = -Wall -Wextra -Werror -pedantic-errors -std=c++14 -Itesting/bandit -Wno-unused-parameter -DOS_TESTING

README

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
1-
# OpenStratos Server #
1+
# OpenStratos #
22

3-
[![Build Status](https://travis-ci.org/OpenStratos/server.svg?branch=develop)](https://travis-ci.org/OpenStratos/server)
3+
[![Build Status](https://travis-ci.org/OpenStratos/server.svg?branch=master)](https://travis-ci.org/OpenStratos/server)
44

5-
Server implemented in C++14. It will be in charge of the management of the balloon. It will
6-
communicate via SMS to the provided phone. It will initialize all needed components, track and log
7-
position and software messages, detect launch, burst and landing and send the landing position via
8-
SMS.
5+
Balloon control software implemented in C++14. It will be in charge of the management of the
6+
balloon and will communicate via SMS to the provided phone. It will initialize all needed
7+
components, track and log position and software messages, detect launch, burst and landing and send
8+
the landing position via SMS.
99

1010
## Requirements ##
1111

12-
The software needs a working instalation of WiringPi and a RaspiCam for the tests. It will perform
12+
The software needs a working installation of WiringPi and a RaspiCam for the tests. It will perform
1313
some basic tests if no Raspberry Pi is being used. It works with Adafruit Fona module, even though
1414
it should work with other GSM modules. It also uses the Adafruit Ultimate GPS module. The following
1515
software is needed to compile OpenStratos (apart from the WiringPi library):
@@ -23,23 +23,23 @@ software is needed to compile OpenStratos (apart from the WiringPi library):
2323
## Compiling ##
2424

2525
For compilation, a *build.sh* script is provided, that should be run as is. It will compile the
26-
tests of OpenStratos and run them. After that, the main program can be compiled using ```make```.
26+
tests of OpenStratos and run them. After that, the main program can be compiled using `make`.
2727
Optional configuration arguments can be passed. The first optional configuration argument is the
2828
*NO_SMS* flag. This prevents actual SMSs being sent, even if they are simulated. This way no charges
29-
will be applied. For using this argument the directory should be cleaned with ```make clean``` and
29+
will be applied. For using this argument the directory should be cleaned with `make clean` and
3030
then pass the *NO_SMS* flag to the configure script:
3131

3232
```
3333
./configure CPPFLAGS="-DNO_SMS"
3434
```
3535

36-
After that the usual ```make``` will compile the software. Note that the test do not send SMSs. The software itself comes with two built-in simulation modes:
36+
After that the usual `make` will compile the software. Note that the test do not send SMSs. The software itself comes with two built-in simulation modes:
3737

3838
### Normal Simulation ###
3939

4040
In this mode, a simple simulation is made, with a length of about 45 minutes. It will run through
4141
all the main stages of the program. For using this mode the directory should be cleaned with
42-
```make clean``` and then pass the *SIM* flag to the configure script:
42+
`make clean` and then pass the *SIM* flag to the configure script:
4343

4444
```
4545
./configure CPPFLAGS="-DSIM"
@@ -51,14 +51,14 @@ It can be combined with the *NO_SMS* flag:
5151
./configure CPPFLAGS="-DSIM -DNO_SMS"
5252
```
5353

54-
After that, the software can be compiled using ```make```.
54+
After that, the software can be compiled using `make`.
5555

5656
### Realistic Simulation ###
5757

5858
In this mode, a complete realistic simulation is made, that will last for about 5 hours. It will
5959
realistically simulate the times in a 35 km height balloon. It will be similar to the normal
6060
simulation, the only change will be in the timing. For using this mode the directory should be
61-
cleaned with ```make clean``` and then pass the *REAL_SIM* flag to the configure script:
61+
cleaned with `make clean` and then pass the *REAL_SIM* flag to the configure script:
6262

6363
```
6464
./configure CPPFLAGS="-DREAL_SIM"
@@ -70,15 +70,15 @@ It can be combined with the *NO_SMS* flag:
7070
./configure CPPFLAGS="-DREAL_SIM -DNO_SMS"
7171
```
7272

73-
After that, the software can be compiled using ```make```. The result of combining the two
74-
simulation flags is undetermined. They should not be combined.
73+
After that, the software can be compiled using `make`. The result of combining the two simulation
74+
flags will be an error when building the main program. For testing it will have no effect.
7575

7676
### Debug Mode ###
7777

7878
The software has a small debug mode, that prints from *stdio* some logs that occur before the log
7979
file is created. It also enables serial logging, that will log everything that happens in the
80-
serial. This has a moderate overhead and should not be used in production. GSM and GPS loggers log everythong they send and receive. This is only needed to debug if something goes wrong with the
81-
serial. For using this mode the directory should be cleaned with ```make clean``` and then pass the
80+
serial. This has a moderate overhead and should not be used in production. GSM and GPS loggers log everything they send and receive. This is only needed to debug if something goes wrong with the
81+
serial. For using this mode the directory should be cleaned with `make clean` and then pass the
8282
*DEBUG* flag to the configure script:
8383

8484
```
@@ -97,7 +97,7 @@ It can be combined with the *NO_SMS* flag or/and one of the simulation flags:
9797

9898
For some testing there is no need to reboot or shut down the system in failures. For this, the
9999
software provides the no power off mode, that will prevent the software from shutting the
100-
Raspberry Pi down. For using this mode the directory should be cleaned with ```make clean``` and
100+
Raspberry Pi down. For using this mode the directory should be cleaned with `make clean` and
101101
then pass the *NO_POWER_OFF* flag to the configure script:
102102

103103
```
@@ -110,6 +110,7 @@ It can be combined with the *NO_SMS* flag, the *DEBUG* flag or/and one of the si
110110
./configure CPPFLAGS="-DREAL_SIM -DNO_SMS -DDEBUG -DNO_POWER_OFF"
111111
./configure CPPFLAGS="-DSIM -DDEBUG -DNO_POWER_OFF"
112112
./configure CPPFLAGS="-DNO_SMS -DDEBUG -DNO_POWER_OFF"
113+
```
113114

114115
## License ##
115116

camera/Camera.cc

Lines changed: 73 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,13 @@ Camera::~Camera()
4141
{
4242
this->logger->log("Stopping video recording...");
4343
if ( ! this->stop())
44-
this->logger->log("Error soping video recording.");
44+
{
45+
this->logger->log("Error stoping video recording.");
46+
}
4547
else
48+
{
4649
this->logger->log("Video recording stopped.");
50+
}
4751
}
4852
this->logger->log("Shut down finished");
4953
delete this->logger;
@@ -59,7 +63,10 @@ void Camera::record_thread(int time)
5963

6064
bool Camera::record(int time)
6165
{
62-
if (time != 0) this->logger->log("Recording for "+to_string(time/1000)+" seconds...");
66+
if (time != 0)
67+
{
68+
this->logger->log("Recording for "+to_string(time/1000)+" seconds...");
69+
}
6370
if ( ! this->recording)
6471
{
6572
this->logger->log("Not already recording, creating command...");
@@ -91,11 +98,18 @@ bool Camera::record(int time)
9198
t.detach();
9299
}
93100

94-
if (result) this->logger->log("Video recording correctly started.");
95-
else this->logger->log("Error starting video recording.");
101+
if (result)
102+
{
103+
this->logger->log("Video recording correctly started.");
104+
}
105+
else
106+
{
107+
this->logger->log("Error starting video recording.");
108+
}
96109

97110
return result;
98111
}
112+
return false;
99113
}
100114

101115
bool Camera::record()
@@ -107,21 +121,25 @@ bool Camera::record()
107121
bool Camera::take_picture(const string& exif)
108122
{
109123
bool was_recording = this->recording;
110-
if (was_recording) this->logger->log("Recording video, stopping...");
111-
if (was_recording && ! this->stop()) return false;
112-
this->logger->log("Video recording stopped.");
124+
this->logger->log("Taking picture...");
125+
if (was_recording)
126+
{
127+
this->logger->log("The video is recording.");
128+
}
129+
if (was_recording && ! this->stop())
130+
{
131+
return false;
132+
}
113133

114134
string filename = "data/img/img-"+ to_string(get_file_count("data/img/")) +".jpg";
115135
#ifdef OS_TESTING
116136
filename = "data/img/test.jpg";
117137
#endif
118138

119-
string exif_command = exif != "" ? " -x "+ exif : "";
120-
121-
string command = "raspistill -n -o "+ filename +" " + (PHOTO_RAW ? "-r" : "") + " -w "+ to_string(PHOTO_WIDTH)
139+
string command = "raspistill -n -t 1 -o "+ filename +" " + (PHOTO_RAW ? "-r" : "") + " -w "+ to_string(PHOTO_WIDTH)
122140
+" -h "+ to_string(PHOTO_HEIGHT) +" -q "+ to_string(PHOTO_QUALITY)
123141
+" -co "+ to_string(PHOTO_CONTRAST) +" -br "+ to_string(PHOTO_BRIGHTNESS)
124-
+" -ex "+ PHOTO_EXPOSURE + exif_command;
142+
+" -ex "+ PHOTO_EXPOSURE + exif;
125143

126144
this->logger->log("Picture command: '"+command+"'");
127145

@@ -133,10 +151,19 @@ bool Camera::take_picture(const string& exif)
133151
int st = system(command.c_str());
134152
bool result = st == 0;
135153

136-
if (result) this->logger->log("Picture taken correctly.");
137-
else this->logger->log("Error taking picture.");
154+
if (result)
155+
{
156+
this->logger->log("Picture taken correctly.");
157+
}
158+
else
159+
{
160+
this->logger->log("Error taking picture.");
161+
}
138162

139-
if (was_recording) this->logger->log("Video recording was active before taking picture. Resuming...");
163+
if (was_recording)
164+
{
165+
this->logger->log("Video recording was active before taking picture. Resuming...");
166+
}
140167
if (was_recording && ! this->record())
141168
{
142169
this->logger->log("Error resuming video recording.");
@@ -159,20 +186,22 @@ bool Camera::stop()
159186
if (system("pkill raspivid") == 0)
160187
{
161188
this->logger->log("Video recording stopped correctly.");
189+
this_thread::sleep_for(50ms);
162190
this->recording = false;
163191
return true;
164192
}
165193
this->logger->log("Error stopping video recording.");
166194

167195
if ( ! this->is_really_recording())
168196
{
169-
this->logger->log("Warning: video was already stopped.");
197+
this->logger->log("Warning: video had already stopped.");
170198
this->recording = false;
171199
return true;
172200
}
173201
return false;
174202
#else
175203
this->logger->log("Test mode. Video recording stop simulated.");
204+
this_thread::sleep_for(50ms);
176205
this->recording = false;
177206
return true;
178207
#endif
@@ -190,17 +219,24 @@ int os::get_file_count(const string& path)
190219
struct dirent *ep;
191220
dp = opendir(path.c_str());
192221

193-
while (ep = readdir(dp)) i++;
194-
(void) closedir(dp);
222+
while ((ep = readdir(dp)) != NULL)
223+
{
224+
++i;
225+
}
226+
closedir(dp);
195227

196228
return i-2;
197229
}
198230

199231
const string os::generate_exif_data()
200232
{
201233
string exif;
202-
while (GPS::get_instance().get_PDOP() > 5)
203-
this_thread::sleep_for(1s);
234+
for (int i = 0;
235+
i < 10 && ( ! GPS::get_instance().is_fixed() || GPS::get_instance().get_PDOP() > MAX_DOP);
236+
++i)
237+
{
238+
this_thread::sleep_for(500ms);
239+
}
204240

205241
double gps_lat = GPS::get_instance().get_latitude();
206242
double gps_lon = GPS::get_instance().get_longitude();
@@ -209,14 +245,22 @@ const string os::generate_exif_data()
209245
float gps_pdop = GPS::get_instance().get_PDOP();
210246
euc_vec gps_velocity = GPS::get_instance().get_velocity();
211247

212-
exif += "GPSLatitudeRef="+to_string(gps_lat > 0 ? 'N' : 'S');
213-
exif += " GPSLatitude="+to_string(abs((int) gps_lat*1000000))+"/1000000,0/1,0/1";
214-
exif += " GPSLongitudeRef="+to_string(gps_lon > 0 ? 'E' : 'W');
215-
exif += " GPSLongitude="+to_string(abs((int) gps_lon*1000000))+"/1000000,0/1,0/1";
216-
exif += " GPSAltitudeRef=0 GPSAltitude="+to_string(gps_alt);
217-
exif += " GPSSatellites="+to_string(gps_sat);
218-
exif += " GPSDOP="+to_string(gps_pdop);
219-
exif += " GPSSpeedRef=K GPSSpeed="+to_string(gps_velocity.speed*3.6);
220-
exif += " GPSTrackRef=T GPSTrack="+to_string(gps_velocity.course);
221-
exif += " GPSDifferential=0";
248+
exif += " -x GPS.GPSLatitudeRef="+string(gps_lat > 0 ? "N" : "S");
249+
exif += " -x GPS.GPSLatitude="+to_string(
250+
abs((int) (gps_lat*1000000))
251+
)+"/1000000";
252+
exif += " -x GPS.GPSLongitudeRef="+string(gps_lat > 0 ? "E" : "W");
253+
exif += " -x GPS.GPSLongitude="+to_string(
254+
abs((int) (gps_lon*1000000))
255+
)+"/1000000";
256+
exif += " -x GPS.GPSAltitudeRef=0 -x GPS.GPSAltitude="+to_string((int) (gps_alt*100))+"/100";
257+
exif += " -x GPS.GPSSatellites="+to_string(gps_sat);
258+
exif += " -x GPS.GPSDOP="+to_string((int) (gps_pdop*1000))+"/1000";
259+
exif += " -x GPS.GPSSpeedRef=K -x GPS.GPSSpeed="+
260+
to_string((int) (gps_velocity.speed*3.6*1000))+"/1000";
261+
exif += " -x GPS.GPSTrackRef=T -x GPS.GPSTrack="+
262+
to_string((int) (gps_velocity.course*1000))+"/1000";
263+
exif += " -x GPS.GPSDifferential=0";
264+
265+
return exif;
222266
}

configure.ac

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# Process this file with autoconf to produce a configure script.
33

44
AC_PREREQ([2.68])
5-
AC_INIT(OpenStratos, 1.0, https://github.com/OpenStratos/server/issues)
5+
AC_INIT(OpenStratos, 1.1.0, https://github.com/OpenStratos/server/issues)
66
AC_CONFIG_SRCDIR([openstratos.cc])
77
AM_INIT_AUTOMAKE([subdir-objects])
88
AC_CONFIG_HEADERS([config.h])

0 commit comments

Comments
 (0)