-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #53 from org-arl/stp
Updated UnetSocket C APIs
- Loading branch information
Showing
20 changed files
with
193,543 additions
and
421 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
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 | ||
|
||
all: libs | ||
rm -rf *.zip | ||
rm -rf fjage-* | ||
|
||
libs: libfjage.a libunet.a | ||
rm -rf *.zip | ||
rm -rf fjage-* | ||
|
||
samples: txdata rxdata range setpowerlevel txsignal pbrecord bbrecord npulses wakeup rs232_wakeup gpio | ||
rm -rf *.zip | ||
rm -rf fjage-* | ||
|
||
libfjage.a: | ||
make -C libs/fjage/gateways/c/ | ||
cp libs/fjage/gateways/c/fjage.h . | ||
cp libs/fjage/gateways/c/libfjage.a . | ||
|
||
libunet.a: unet.o | ||
$(AR) rc $@ $^ | ||
|
||
unet_ext.o: unet.h fjage.h | ||
$(CC) $(CFLAGS) -c unet_ext.c -o unet_ext.o | ||
|
||
txdata.o: samples/txdata.c unet.h fjage.h | ||
$(CC) $(CFLAGS) -c samples/txdata.c -o samples/txdata.o | ||
|
||
txdata: txdata.o | ||
$(CC) -o samples/txdata samples/txdata.o libunet.a libfjage.a -lpthread -lm | ||
|
||
rxdata.o: samples/rxdata.c unet.h fjage.h | ||
$(CC) $(CFLAGS) -c samples/rxdata.c -o samples/rxdata.o | ||
|
||
rxdata: rxdata.o | ||
$(CC) -o samples/rxdata samples/rxdata.o libunet.a libfjage.a -lpthread -lm | ||
|
||
range.o: samples/range.c unet.h fjage.h unet_ext.o | ||
$(CC) $(CFLAGS) -c samples/range.c -o samples/range.o | ||
|
||
range: range.o unet_ext.o | ||
$(CC) -o samples/range unet_ext.o samples/range.o libunet.a libfjage.a -lpthread -lm | ||
|
||
setpowerlevel.o: samples/setpowerlevel.c unet.h fjage.h unet_ext.o | ||
$(CC) $(CFLAGS) -c samples/setpowerlevel.c -o samples/setpowerlevel.o | ||
|
||
setpowerlevel: setpowerlevel.o unet_ext.o | ||
$(CC) -o samples/setpowerlevel unet_ext.o samples/setpowerlevel.o libunet.a libfjage.a -lpthread -lm | ||
|
||
txsignal.o: samples/txsignal.c unet.h fjage.h unet_ext.o | ||
$(CC) $(CFLAGS) -c samples/txsignal.c -o samples/txsignal.o | ||
|
||
txsignal: txsignal.o | ||
$(CC) -o samples/txsignal unet_ext.o samples/txsignal.o libunet.a libfjage.a -lpthread -lm | ||
|
||
pbrecord.o: samples/pbrecord.c unet.h fjage.h unet_ext.o | ||
$(CC) $(CFLAGS) -c samples/pbrecord.c -o samples/pbrecord.o | ||
|
||
pbrecord: pbrecord.o unet_ext.o | ||
$(CC) -o samples/pbrecord unet_ext.o samples/pbrecord.o libunet.a libfjage.a -lpthread -lm | ||
|
||
bbrecord.o: samples/bbrecord.c unet.h fjage.h unet_ext.o | ||
$(CC) $(CFLAGS) -c samples/bbrecord.c -o samples/bbrecord.o | ||
|
||
bbrecord: bbrecord.o | ||
$(CC) -o samples/bbrecord unet_ext.o samples/bbrecord.o libunet.a libfjage.a -lpthread -lm | ||
|
||
npulses.o: samples/npulses.c unet.h fjage.h unet_ext.o | ||
$(CC) $(CFLAGS) -c samples/npulses.c -o samples/npulses.o | ||
|
||
npulses: npulses.o unet_ext.o | ||
$(CC) -o samples/npulses unet_ext.o samples/npulses.o libunet.a libfjage.a -lpthread -lm | ||
|
||
wakeup.o: samples/wakeup.c unet.h fjage.h unet_ext.o | ||
$(CC) $(CFLAGS) -c samples/wakeup.c -o samples/wakeup.o | ||
|
||
wakeup: wakeup.o unet_ext.o | ||
$(CC) -o samples/wakeup unet_ext.o samples/wakeup.o libunet.a libfjage.a -lpthread -lm | ||
|
||
rs232_wakeup.o: samples/rs232_wakeup.c unet.h fjage.h unet_ext.o | ||
$(CC) $(CFLAGS) -c samples/rs232_wakeup.c -o samples/rs232_wakeup.o | ||
|
||
rs232_wakeup: rs232_wakeup.o unet_ext.o | ||
$(CC) -o samples/rs232_wakeup unet_ext.o samples/rs232_wakeup.o libunet.a libfjage.a -lpthread -lm | ||
|
||
gpio.o: samples/gpio.c unet.h fjage.h unet_ext.o | ||
$(CC) $(CFLAGS) -c samples/gpio.c -o samples/gpio.o | ||
|
||
gpio: gpio.o unet_ext.o | ||
$(CC) -o samples/gpio unet_ext.o samples/gpio.o libunet.a libfjage.a -lpthread -lm | ||
|
||
test: test_unet unet_ext.o | ||
rm -rf *.zip | ||
rm -rf fjage-* | ||
|
||
test_unet.o: test/test_unet.c unet.h fjage.h unet_ext.o | ||
$(CC) $(CFLAGS) -c test/test_unet.c -o test/test_unet.o | ||
|
||
test_unet: test_unet.o | ||
$(CC) -o test/test_unet unet_ext.o test/test_unet.o libunet.a libfjage.a -lpthread -lm | ||
|
||
clean: | ||
rm -rf c-api libunet.a *.o samples/*.o test/*.o test/test_unet samples/wakeup samples/rs232_wakeup samples/txdata samples/rxdata samples/range samples/setpowerlevel samples/txsignal samples/pbrecord samples/bbrecordedsignal.txt samples/pbrecordedsignal.txt samples/bbrecord samples/npulses samples/gpio | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
1.0.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
/////////////////////////////////////////////////////////////////////////////// | ||
// | ||
// Record a baseband signal. | ||
// | ||
// In terminal window (an example): | ||
// | ||
// $ make samples | ||
// $ ./bbrecord <ip_address> <siglen> [port] | ||
// | ||
//////////////////////////////////////////////////////////////////////////////// | ||
|
||
#include <stdio.h> | ||
#include <stdlib.h> | ||
#include "../unet.h" | ||
#include "../unet_ext.h" | ||
#include <math.h> | ||
|
||
#ifndef _WIN32 | ||
#include <unistd.h> | ||
#include <netdb.h> | ||
#include <sys/time.h> | ||
#endif | ||
|
||
static int error(const char *msg) { | ||
printf("\n*** ERROR: %s\n\n", msg); | ||
return -1; | ||
} | ||
|
||
int main(int argc, char *argv[]) { | ||
FILE *fptr; | ||
fptr = (fopen("samples/bbrecordedsignal.txt", "w")); | ||
if(fptr == NULL) return -1; | ||
unetsocket_t sock; | ||
int port = 1100; | ||
int siglen = -1; | ||
int rv; | ||
if (argc <= 2) { | ||
error("Usage : bbrecord <ip_address> <siglen> [port] \n" | ||
"ip_address: IP address of the transmitter modem. \n" | ||
"siglen: number of baseband samples to record. \n" | ||
"port: port number of transmitter modem. \n" | ||
"A usage example: \n" | ||
"bbrecord 192.168.1.20 48000 1100\n"); | ||
return -1; | ||
} | ||
else if (argc >= 3) { | ||
siglen = (int)strtol(argv[2], NULL, 10); | ||
if (argc > 3) port = (int)strtol(argv[3], NULL, 10); | ||
} | ||
|
||
float buf[2*siglen]; | ||
|
||
#ifndef _WIN32 | ||
// Check valid ip address | ||
struct hostent *server = gethostbyname(argv[1]); | ||
if (server == NULL) { | ||
error("Enter a valid ip addreess\n"); | ||
return -1; | ||
} | ||
#endif | ||
// Open a unet socket connection to modem | ||
printf("Connecting to %s:%d\n",argv[1],port); | ||
|
||
sock = unetsocket_open(argv[1], port); | ||
if (sock == NULL) return error("Couldn't open unet socket"); | ||
|
||
// Record | ||
printf("Starting a record\n"); | ||
rv = unetsocket_ext_bbrecord(sock, buf, siglen); | ||
if (rv == 0) { | ||
for(int i = 0; i < 2*siglen; i++) { | ||
fprintf(fptr,"%f\n", buf[i]); | ||
} | ||
} else { | ||
error("Error recording signal"); | ||
} | ||
|
||
// Close the unet socket | ||
unetsocket_close(sock); | ||
|
||
printf("\nRecording Complete (samples/bbrecordedsignal.txt saved with alternating real and imaginary values)\n"); | ||
|
||
fclose(fptr); | ||
return 0; | ||
} |
Oops, something went wrong.