Skip to content

Commit 52fff31

Browse files
1. Fixed bug with 'too many files'
2. Changed handling of deframer options 3. Fixed 'command_handler.py' script 4. Temporarily removed rotctl_stop()
1 parent e6377ee commit 52fff31

File tree

7 files changed

+100
-100
lines changed

7 files changed

+100
-100
lines changed

command_handler.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ def send_email_notification(auth_file, attachments=[]):
5353
msg["From"] = client_login
5454
msg["Subject"] = subject
5555

56-
body = "Hi there, sending this email from Python!"
56+
body = "Hi there, please find the results for another satellite!"
5757
msg.attach(MIMEText(body, "plain"))
5858

5959
for f in attachments or []:
@@ -142,10 +142,10 @@ def action_pre_doit(args):
142142
def action_post_doit(args):
143143
print('== post doit ==')
144144
today = date.today()
145-
files = glob.glob('*.dat')
145+
files = glob.glob('*GMT.dat')
146146
send_email_notification('/etc/gsc/email.cfg', files)
147-
os.system('mv -vf *.dat ' + RESULTS_PREFIX + str(today) + '/')
148-
os.system('mv -vf *.raw ' + RESULTS_PREFIX + str(today) + '/')
147+
os.system('mv -vf *GMT.dat ' + RESULTS_PREFIX + str(today) + '/')
148+
os.system('mv -vf *GMT.raw ' + RESULTS_PREFIX + str(today) + '/')
149149
return
150150

151151
actions = {

src/ev.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
#include <unistd.h>
2626
#include <fcntl.h>
2727
#include <strings.h>
28+
#include <errno.h>
2829
#include <json-c/json.h>
2930

3031
#include "ev.h"
@@ -71,6 +72,7 @@ void _ev_read_cb(struct ev_loop *loop, struct ev_io *watcher, int revents)
7172
ev_handler.buf_idx = 0;
7273
ev_handler.cont_length = 0;
7374
ev_io_stop(ev_handler.loop, watcher);
75+
close(watcher->fd);
7476
free(watcher);
7577
return;
7678
}
@@ -166,7 +168,7 @@ void _ev_accept_cb(struct ev_loop *loop, struct ev_io *watcher, int revents)
166168
{
167169
struct sockaddr_in client_addr;
168170
socklen_t client_len = sizeof(client_addr);
169-
struct ev_io *w_client = (struct ev_io*) malloc(sizeof(struct ev_io));
171+
struct ev_io *w_client = (struct ev_io *) malloc(sizeof(struct ev_io));
170172

171173
if (EV_ERROR & revents) {
172174
LOG_I("got invalid event");
@@ -175,7 +177,7 @@ void _ev_accept_cb(struct ev_loop *loop, struct ev_io *watcher, int revents)
175177

176178
ev_handler.client_sd = accept(watcher->fd, (struct sockaddr *)&client_addr, &client_len);
177179
if (ev_handler.client_sd < 0) {
178-
LOG_E("accept error");
180+
LOG_E("accept error, %s", strerror(errno));
179181
return;
180182
}
181183
/* fcntl(ev_handler.client_sd, F_SETFL, O_NONBLOCK); */

src/gnuradio.c

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -66,11 +66,11 @@ int sdr_prepare_config(cfg_t *cfg, satellite_t *sat, const char *filename)
6666
snprintf(cfg_line, sizeof(cfg_line), "[main]\n"
6767
"main_LPF_Cutoff_Freq=%d\n"
6868
"main_Network_Stream_Address=%s\n"
69-
"main_Network_Stream_Port=%s\n"
69+
"main_Network_Stream_Port=%d\n"
7070
"main_Result_File_Prefix=%s\n",
7171
sat->bandwidth,
72-
DEF_CONF_NETWORK_STREAM_ADDR,
73-
DEF_CONF_NETWORK_STREAM_PORT,
72+
sat->network_addr,
73+
sat->network_port,
7474
filename);
7575

7676
fwrite(cfg_line, strlen(cfg_line), 1, fd);
@@ -83,34 +83,35 @@ int sdr_prepare_config(cfg_t *cfg, satellite_t *sat, const char *filename)
8383

8484
fwrite(cfg_line, strlen(cfg_line), 1, fd);
8585

86+
snprintf(cfg_line, sizeof(cfg_line), "modulation_Short_Frames=%d\n"
87+
"modulation_G3RUH=%d\n"
88+
"modulation_CRC16=%d\n",
89+
sat->shortFrames,
90+
sat->g3ruh,
91+
sat->crc16);
92+
93+
fwrite(cfg_line, strlen(cfg_line), 1, fd);
94+
8695
switch (sat->modulation) {
8796
case MODULATION_BPSK:
8897
snprintf(cfg_line, sizeof(cfg_line), "modulation_BPSK_Manchester=%d\n"
89-
"modulation_BPSK_Differential=%d\n"
90-
"modulation_BPSK_Short_Preamb=%d\n"
91-
"modulation_BPSK_CRC16=%d\n",
98+
"modulation_BPSK_Differential=%d\n",
9299
sat->bpskManchester,
93-
sat->bpskDifferential,
94-
sat->bpskShort,
95-
sat->bpskCRC16);
100+
sat->bpskDifferential);
96101

97102
fwrite(cfg_line, strlen(cfg_line), 1, fd);
98103
break;
99104
case MODULATION_AFSK:
100105
snprintf(cfg_line, sizeof(cfg_line), "modulation_AFSK_Audio_Carrier_Freq=%d\n"
101-
"modulation_AFSK_Deviation=%d\n"
102-
"modulation_G3RUH=%d\n",
106+
"modulation_AFSK_Deviation=%d\n",
103107
sat->afskAFC,
104-
sat->afskDeviation,
105-
sat->afskG3RUH);
108+
sat->afskDeviation);
106109

107110
fwrite(cfg_line, strlen(cfg_line), 1, fd);
108111
break;
109112
case MODULATION_FSK:
110-
snprintf(cfg_line, sizeof(cfg_line), "modulation_FSK_Sub_Audio=%d\n"
111-
"modulation_G3RUH=%d\n",
112-
sat->fskSubAudio,
113-
sat->fskG3RUH);
113+
snprintf(cfg_line, sizeof(cfg_line), "modulation_FSK_Sub_Audio=%d\n",
114+
sat->fskSubAudio);
114115

115116
fwrite(cfg_line, strlen(cfg_line), 1, fd);
116117
break;

src/rest_api.c

Lines changed: 50 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -374,6 +374,23 @@ static int rest_api_set_observation(char *payload, char **reply_buf, const char
374374
goto out;
375375
}
376376

377+
sat->network_addr = strdup(json_get_string_by_key(jsatellitePart, "network_addr"));
378+
if (!sat->network_addr) {
379+
*error = "'/observation/satellite/network_addr' string is not specified!";
380+
ret = -1;
381+
goto out;
382+
}
383+
384+
LOG_V("Network stream address: [ %s ]", sat->network_addr);
385+
386+
if (!json_get_int_by_key(jsatellitePart, "network_port", &sat->network_port)) {
387+
*error = "'/observation/satellite/network_port' not specified";
388+
ret = -1;
389+
goto out;
390+
}
391+
392+
LOG_V("Network stream port: [ %d ]", sat->network_port);
393+
377394
if (!json_get_int_by_key(jsatellitePart, "baud_rate", &sat->baudRate)) {
378395
*error = "'/observation/satellite/baud_rate' not specified";
379396
ret = -1;
@@ -390,6 +407,39 @@ static int rest_api_set_observation(char *payload, char **reply_buf, const char
390407

391408
LOG_V("Bandwidth: [ %d ]", sat->bandwidth);
392409

410+
/** optional */
411+
json_object_object_get_ex(jsatellitePart, "short_frames", &valObj);
412+
413+
if (json_object_get_type(valObj) == json_type_boolean) {
414+
sat->shortFrames = json_object_get_boolean(valObj);
415+
} else {
416+
sat->shortFrames = false;
417+
}
418+
419+
LOG_V("Short Frames: [ %d ]", !!sat->shortFrames);
420+
421+
/** optional */
422+
json_object_object_get_ex(jsatellitePart, "crc16", &valObj);
423+
424+
if (json_object_get_type(valObj) == json_type_boolean) {
425+
sat->crc16 = json_object_get_boolean(valObj);
426+
} else {
427+
sat->crc16 = false;
428+
}
429+
430+
LOG_V("CRC16: [ %d ]", !!sat->crc16);
431+
432+
/** optional */
433+
json_object_object_get_ex(jsatellitePart, "g3ruh", &valObj);
434+
435+
if (json_object_get_type(valObj) == json_type_boolean) {
436+
sat->g3ruh = json_object_get_boolean(valObj);
437+
} else {
438+
sat->g3ruh = false;
439+
}
440+
441+
LOG_V("G3RUH: [ %d ]", !!sat->g3ruh);
442+
393443
if (streq(satModulation, "bpsk")) {
394444
sat->modulation = MODULATION_BPSK;
395445
if (!json_object_object_get_ex(jsatellitePart, "bpsk_manchester", &valObj)) {
@@ -424,38 +474,6 @@ static int rest_api_set_observation(char *payload, char **reply_buf, const char
424474

425475
LOG_V("BPSK Differential: [ %d ]", !!sat->bpskDifferential);
426476

427-
if (!json_object_object_get_ex(jsatellitePart, "bpsk_short_preamble", &valObj)) {
428-
*error = "'/observation/satellite/bpsk_short_preamble' object is missing";
429-
ret = -1;
430-
goto out;
431-
}
432-
433-
if (json_object_get_type(valObj) == json_type_boolean) {
434-
sat->bpskShort = json_object_get_boolean(valObj);
435-
} else {
436-
*error = "'/observation/satellite/bpsk_short_preamble' isn't boolean";
437-
ret = -1;
438-
goto out;
439-
}
440-
441-
LOG_V("BPSK Short Preamble: [ %d ]", !!sat->bpskShort);
442-
443-
if (!json_object_object_get_ex(jsatellitePart, "bpsk_crc16", &valObj)) {
444-
*error = "'/observation/satellite/bpsk_crc16' object is missing";
445-
ret = -1;
446-
goto out;
447-
}
448-
449-
if (json_object_get_type(valObj) == json_type_boolean) {
450-
sat->bpskCRC16 = json_object_get_boolean(valObj);
451-
} else {
452-
*error = "'/observation/satellite/bpsk_crc16' isn't boolean";
453-
ret = -1;
454-
goto out;
455-
}
456-
457-
LOG_V("BPSK CRC16: [ %d ]", !!sat->bpskCRC16);
458-
459477
} else if (streq(satModulation, "afsk")) {
460478
sat->modulation = MODULATION_AFSK;
461479
if (!json_get_int_by_key(jsatellitePart, "afsk_audio_freq_carrier", &sat->afskAFC)) {
@@ -474,22 +492,6 @@ static int rest_api_set_observation(char *payload, char **reply_buf, const char
474492

475493
LOG_V("AFSK Deviation: [ %d ]", sat->afskDeviation);
476494

477-
if (!json_object_object_get_ex(jsatellitePart, "afsk_g3ruh", &valObj)) {
478-
*error = "'/observation/satellite/afsk_g3ruh' object is missing";
479-
ret = -1;
480-
goto out;
481-
}
482-
483-
if (json_object_get_type(valObj) == json_type_boolean) {
484-
sat->afskG3RUH = json_object_get_boolean(valObj);
485-
} else {
486-
*error = "'/observation/satellite/afsk_g3ruh' isn't boolean";
487-
ret = -1;
488-
goto out;
489-
}
490-
491-
LOG_V("FSK G3RUH: [ %d ]", !!sat->afskG3RUH);
492-
493495
} else if (streq(satModulation, "fsk")) {
494496
sat->modulation = MODULATION_FSK;
495497

@@ -508,22 +510,6 @@ static int rest_api_set_observation(char *payload, char **reply_buf, const char
508510
}
509511

510512
LOG_V("FSK subaudio: [ %d ]", !!sat->fskSubAudio);
511-
512-
if (!json_object_object_get_ex(jsatellitePart, "fsk_g3ruh", &valObj)) {
513-
*error = "'/observation/satellite/fsk_g3ruh' object is missing";
514-
ret = -1;
515-
goto out;
516-
}
517-
518-
if (json_object_get_type(valObj) == json_type_boolean) {
519-
sat->fskG3RUH = json_object_get_boolean(valObj);
520-
} else {
521-
*error = "'/observation/satellite/fsk_g3ruh' isn't boolean";
522-
ret = -1;
523-
goto out;
524-
}
525-
526-
LOG_V("FSK G3RUH: [ %d ]", !!sat->fskG3RUH);
527513
}
528514
else {
529515
*error = "'/observation/satellite/modulation' only 'bpsk', 'fsk' and 'afsk' are supported";

src/rotctl.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,10 @@ int rotctl_stop(observation_t *obs)
105105

106106
write(obs->cfg->cli.azimuth_conn_fd, buf, strlen(buf));
107107
read(obs->cfg->cli.azimuth_conn_fd, rxbuf, sizeof(rxbuf));
108+
/* LOG_I("rxbuf1=%s", rxbuf); */
108109
write(obs->cfg->cli.elevation_conn_fd, buf, strlen(buf));
109110
read(obs->cfg->cli.elevation_conn_fd, rxbuf, sizeof(rxbuf));
111+
/* LOG_I("rxbuf2=%s", rxbuf); */
110112

111113
LOG_V("rotctl_stop() command done");
112114
return ret;

src/sat.c

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -339,6 +339,8 @@ static void *sat_scheduler(void *opt)
339339

340340
if (sat->next_aos > 0) {
341341
if ((current_time > (sat->next_aos - 300)) && sat->parked == false) {
342+
/* rotctl_stop(obs); */
343+
342344
if (obs->cfg->calibrate && stats->satellites_tracked % obs->cfg->calibrate == 0) {
343345
LOG_I("Performing the complete calibration");
344346
rotctl_calibrate(obs, true, true);
@@ -347,7 +349,6 @@ static void *sat_scheduler(void *opt)
347349

348350
LOG_I("Parking antenna for the reception of %s", sat->name);
349351
LOG_V("curr time = %ld, aos time = %ld", current_time, sat->next_aos);
350-
rotctl_stop(obs);
351352
if (!sat->zero_transition)
352353
rotctl_send_and_wait(obs, sat->aos_az, 0);
353354
else
@@ -405,6 +406,14 @@ static void *sat_scheduler(void *opt)
405406
LOG_E("Couldn't stop SDR");
406407
}
407408

409+
if (obs->active->frequency > LOW_VHF_BAND &&
410+
obs->active->frequency < HIGH_VHF_BAND) {
411+
stats->satellites_vhf++;
412+
} else if (obs->active->frequency > LOW_UHF_BAND &&
413+
obs->active->frequency < HIGH_UHF_BAND) {
414+
stats->satellites_uhf++;
415+
}
416+
408417
if ((post_doit(obs)) == -1) {
409418
LOG_E("Error on post-do-it");
410419
}
@@ -612,14 +621,6 @@ int sat_predict(satellite_t *sat)
612621
}
613622
}
614623

615-
if (sat->frequency > LOW_VHF_BAND &&
616-
sat->frequency < HIGH_VHF_BAND) {
617-
stats->satellites_vhf++;
618-
} else if (sat->frequency > LOW_UHF_BAND &&
619-
sat->frequency < HIGH_UHF_BAND) {
620-
stats->satellites_uhf++;
621-
}
622-
623624
return ret;
624625
}
625626

@@ -704,6 +705,7 @@ static int sat_clear_all(observation_t *obs)
704705
while (!LIST_EMPTY(&obs->satellites_list)) {
705706
sat = LIST_FIRST(&obs->satellites_list);
706707
predict_destroy_orbital_elements(sat->orbital_elements);
708+
free((void *) sat->network_addr);
707709
LIST_REMOVE(sat, entries);
708710
free(sat);
709711
}

src/sat.h

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,20 +50,27 @@ typedef struct satellite_t {
5050

5151
/** modulation */
5252
modulation_t modulation;
53+
const char *network_addr;
54+
int network_port;
5355
int baudRate;
5456

5557
/** bpsk */
5658
bool bpskManchester;
5759
bool bpskDifferential;
58-
bool bpskShort;
59-
bool bpskCRC16;
60+
6061
/** afsk */
6162
int afskDeviation;
62-
bool afskG3RUH;
6363
int afskAFC; /** audio frequency carrier */
64+
6465
/** fsk */
6566
bool fskSubAudio;
66-
bool fskG3RUH;
67+
68+
/** deframing */
69+
/** TODO: implement */
70+
int syncword_threshold;
71+
bool shortFrames;
72+
bool g3ruh;
73+
bool crc16;
6774

6875
double min_elevation;
6976
double max_elevation;

0 commit comments

Comments
 (0)