Skip to content

Commit

Permalink
minor doc updated and cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
prasadtiru committed Apr 23, 2021
1 parent f91dc66 commit a0db0d7
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 22 deletions.
4 changes: 1 addition & 3 deletions unetsocket/c/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,9 @@ CC = gcc
CFLAGS += -std=c99 -Wall -Wextra -Werror -Wfloat-equal -Wconversion -Wparentheses -pedantic -Wunused-parameter -Wunused-variable -Wreturn-type -Wno-unused-function -Wredundant-decls -Wreturn-type -Wunused-value -Wswitch-default -Wuninitialized -Winit-self -O2
FJAGE_VER=7275142c2bc846d2f07400d7d628f213cb5b56ab
FJAGE_DIR=fjage-$(FJAGE_VER)

CONTRIB_VER = bd95ed77ef7c90edbba04dd67f8fb235262e08c8
BUILD = build
BUILD_API = $(BUILD)/api
CONTRIB_DIR = $(BUILD)/unet-contrib-$(CONTRIB_VER)
CONTRIB_DIR = $(BUILD)/temp

all: libs
rm -rf *.zip
Expand Down
6 changes: 3 additions & 3 deletions unetsocket/c/samples/bbrecord.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ int main(int argc, char *argv[]) {
if (argc > 3) port = (int)strtol(argv[3], NULL, 10);
}

float buf[siglen];
float buf[2*siglen];

#ifndef _WIN32
// Check valid ip address
Expand All @@ -68,7 +68,7 @@ int main(int argc, char *argv[]) {
printf("Starting a record\n");
rv = unetsocket_bbrecord(sock, buf, siglen);
if (rv == 0) {
for(int i = 0; i < siglen; i++) {
for(int i = 0; i < 2*siglen; i++) {
fprintf(fptr,"%f\n", buf[i]);
}
} else {
Expand All @@ -78,7 +78,7 @@ int main(int argc, char *argv[]) {
// Close the unet socket
unetsocket_close(sock);

printf("\nRecording Complete\n");
printf("\nRecording Complete (samples/bbrecordedsignal.txt saved with alternating real and imaginary values)\n");

fclose(fptr);
return 0;
Expand Down
2 changes: 1 addition & 1 deletion unetsocket/c/samples/pbrecord.c
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ int main(int argc, char *argv[]) {
// Close the unet socket
unetsocket_close(sock);

printf("\nRecording Complete\n");
printf("\nRecording Complete (samples/pbrecordedsignal.txt saved) \n");

fclose(fptr);
return 0;
Expand Down
35 changes: 20 additions & 15 deletions unetsocket/c/unet_ext.c
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ int unetsocket_npulses(unetsocket_t sock, float *signal, int nsamples, int rate,
fjage_aid_t bb;
int pulsedelay_cache = 0;
int npulses_cache = 0;
float signalduration = (float)((1000 / rate) * nsamples);
float signalduration = (float)((1000.0 / rate) * nsamples);
int pulsedelay = (int)round(((float)pri - signalduration));
if (pri < signalduration + 5)
{
Expand All @@ -174,7 +174,7 @@ int unetsocket_npulses(unetsocket_t sock, float *signal, int nsamples, int rate,
error("Unable to get/set pulse delay...");
return -1;
}
bb = fjage_agent_for_service(usock->gw, "org.arl.unet.Services.BASEBAND");
bb = fjage_agent_for_service(usock->gw, "org.arl.unet.Services.PHYSICAL");
msg = fjage_msg_create("org.arl.unet.bb.TxBasebandSignalReq", FJAGE_REQUEST);
fjage_msg_set_recipient(msg, bb);
fjage_msg_add_float(msg, "fc", 0);
Expand Down Expand Up @@ -429,7 +429,7 @@ int unetsocket_tx_signal(unetsocket_t sock, float *signal, int nsamples, float f
_unetsocket_t *usock = sock;
fjage_msg_t msg;
fjage_aid_t bb;
bb = fjage_agent_for_service(usock->gw, "org.arl.unet.Services.BASEBAND");
bb = fjage_agent_for_service(usock->gw, "org.arl.unet.Services.PHYSICAL");
msg = fjage_msg_create("org.arl.unet.bb.TxBasebandSignalReq", FJAGE_REQUEST);
fjage_msg_set_recipient(msg, bb);
if ((int)fc == 0) fjage_msg_add_float(msg, "fc", fc);
Expand All @@ -449,19 +449,24 @@ int unetsocket_bbrecord(unetsocket_t sock, float *buf, int nsamples) {
if (sock == NULL) return -1;
if (nsamples <= 0 || buf == NULL) return -1;
_unetsocket_t *usock = sock;
int bbscnt = 0;
float tempbuf[PBSBLK];
bbscnt = (int)ceil((float)nsamples / PBSBLK);
if (unetsocket_iset(usock, 0, "org.arl.unet.Services.PHYSICAL", "bbscnt", bbscnt) < 0) return -1;
for (int i = 0; i < bbscnt; i++)
{
fjage_msg_t rxsigntf = receive(usock, "org.arl.unet.bb.RxBasebandSignalNtf", NULL, 5 * TIMEOUT);
fjage_msg_get_float_array(rxsigntf, "signal", tempbuf, PBSBLK);
fjage_msg_destroy(rxsigntf);
unsigned long remaining = (unsigned long) (nsamples - (i * PBSBLK));
memcpy(buf + (i * PBSBLK), tempbuf, remaining > PBSBLK ? (sizeof(float)*PBSBLK) : (sizeof(float)*remaining));
fjage_msg_t msg;
fjage_aid_t bb;
msg = fjage_msg_create("org.arl.unet.bb.RecordBasebandSignalReq", FJAGE_REQUEST);
bb = fjage_agent_for_service(usock->gw, "org.arl.unet.Services.PHYSICAL");
fjage_msg_set_recipient(msg, bb);
fjage_msg_add_int(msg, "recLength", nsamples);
msg = request(usock, msg, 5 * TIMEOUT);
if (msg != NULL && fjage_msg_get_performative(msg) == FJAGE_AGREE) {
fjage_msg_destroy(msg);
msg = receive(usock, "org.arl.unet.bb.RxBasebandSignalNtf", NULL, 20 * TIMEOUT);
if (msg != NULL) {
fjage_msg_get_float_array(msg, "signal", buf, 2 * nsamples);
fjage_msg_destroy(msg);
return 0;
}
}
return 0;
fjage_msg_destroy(msg);
return -1;
}

int unetsocket_rs232_wakeup(char *devname, int baud, const char *settings)
Expand Down

0 comments on commit a0db0d7

Please sign in to comment.