Skip to content

Commit

Permalink
rade_rx() API change as per Mooneer's suggestion
Browse files Browse the repository at this point in the history
  • Loading branch information
drowe67 committed Nov 29, 2024
1 parent 1ca79a6 commit 5c02edf
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 14 deletions.
12 changes: 7 additions & 5 deletions src/radae_rx.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ int main(int argc, char *argv[])
int nin = rade_nin(r);
int n_eoo_bits = rade_n_eoo_bits(r);
FILE *feoo = fopen("eoo_rx.f32","wb"); assert(feoo != NULL);

int has_eoo_out;
float eoo_out[n_eoo_bits];

#ifdef _WIN32
// Note: freopen() returns NULL if filename is NULL, so
// we have to use setmode() to make it a binary stream instead.
Expand All @@ -38,13 +40,13 @@ int main(int argc, char *argv[])
#endif // _WIN32

while((size_t)nin == fread(rx_in, sizeof(RADE_COMP), nin, stdin)) {
int n_out = rade_rx(r,features_out,rx_in);
if (n_out == n_features_out) {
int n_out = rade_rx(r,features_out,&has_eoo_out,eoo_out,rx_in);
if (n_out) {
fwrite(features_out, sizeof(float), n_features_out, stdout);
fflush(stdout);
}
if (n_out == n_eoo_bits) {
fwrite(features_out, sizeof(float), n_eoo_bits, feoo);
if (has_eoo_out) {
fwrite(eoo_out, sizeof(float), n_eoo_bits, feoo);
}
nin = rade_nin(r);
}
Expand Down
14 changes: 8 additions & 6 deletions src/rade_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -457,7 +457,7 @@ int rade_tx_eoo(struct rade *r, RADE_COMP tx_eoo_out[]) {
return r->Neoo;
}

int rade_rx(struct rade *r, float features_out[], RADE_COMP rx_in[]) {
int rade_rx(struct rade *r, float features_out[], int *has_eoo_out, float eoo_out[], RADE_COMP rx_in[]) {
PyObject *pValue;
assert(r != NULL);
assert(features_out != NULL);
Expand Down Expand Up @@ -515,8 +515,11 @@ int rade_rx(struct rade *r, float features_out[], RADE_COMP rx_in[]) {
}
}

if (endofover)
memcpy(features_out, r->floats_out, sizeof(float)*(r->n_eoo_bits));
*has_eoo_out = 0;
if (endofover) {
memcpy(eoo_out, r->floats_out, sizeof(float)*(r->n_eoo_bits));
*has_eoo_out = 1;
}

// sample nin so we have an updated copy
r->nin = (int)call_getter(r->pInst_radae_rx, "get_nin");
Expand All @@ -526,9 +529,8 @@ int rade_rx(struct rade *r, float features_out[], RADE_COMP rx_in[]) {

if (valid_out)
return r->n_features_out;
if (endofover)
return r->n_eoo_bits;
return 0;
else
return 0;
}

int rade_sync(struct rade *r) {
Expand Down
6 changes: 3 additions & 3 deletions src/rade_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,9 @@ RADE_EXPORT int rade_nin(struct rade *r);

// returns non-zero if features_out[] contains valid output. The number
// returned is the number of samples written to features_out[]. If the
// number returned is equal to rade_n_eoo_bits(), features_out[]
// contains End of Over soft decision bits rather that vocoder features
RADE_EXPORT int rade_rx(struct rade *r, float features_out[], RADE_COMP rx_in[]);
// has_eoo_out is set, eoo_out[] contains End of Over soft decision bits
// from QPSK symbols in ..IQIQI... order
RADE_EXPORT int rade_rx(struct rade *r, float features_out[], int *has_eoo_out, float eoo_out[], RADE_COMP rx_in[]);

// returns non-zero if Rx is currently in sync
RADE_EXPORT int rade_sync(struct rade *r);
Expand Down

0 comments on commit 5c02edf

Please sign in to comment.