Skip to content
Permalink
Browse files

refactor(capi): modified makefile to run samples and test separately …

…and improved the documentation in readme
  • Loading branch information...
prasadtiru committed Oct 8, 2019
1 parent 338fc55 commit 37e56bbae8d382de9355b867a151c18ee14934a5
@@ -1,8 +1,11 @@
CC = gcc
CGLAGS = $(CGLAGS) -std=c99 -Wall -Wextra -Werror -O2
FJAGE_VER=edc9ecffd444adaf789d7eb2ecc650d1d7044d84
FJAGE_DIR=fjage-$(FJAGE_VER)

all: libs wakeup rs232_wakeup txdata rxdata
all: libs

samples: libs wakeup rs232_wakeup txdata rxdata

libs: libfjage.a libunet.a

@@ -51,7 +54,7 @@ rxdata: libs rxdata.o
$(CC) -o samples/rxdata samples/rxdata.o libunet.a libfjage.a -lpthread -lm

test: libs test_unet
./test_unet ${IP} ${ADDR} ${DEVICE}
# ./test_unet ${IP} ${ADDR} ${DEVICE}

deepclean: clean
rm -rf "$(FJAGE_DIR)" "$(FJAGE_VER).zip" fjage.h libfjage.a kissfft kiss_fft.h
@@ -1,35 +1,58 @@
## Run Tests Utilizing Unet C API
# Unet C APIs

This folder contains the files `unet.h` and `unet.c`. The header file includes the definition and documentation of the C APIs and the source code is provided in the `unet.c` file. Examples of usage of these APIs can be found in `test.c`. `Makefile` is used to collate the necessary files and compile the source code and run tests.
## Build Unet C API library

This folder contains the files `unet.h` and `unet.c`. The header file includes the definition and documentation of the C APIs and the source code is provided in the `unet.c` file. `Makefile` is used to collate the necessary files and compile the source code and run tests.

To build Unet C APIs library, run

```bash
make
```

This will generate a library (`libunet.a`) which can be used to link.

## Build samples

To build the object files for the samples, run

```bash
make samples
```

## Test Unet C API library

To compile and run the tests, the following steps need to be performed:

- Two modems are needed to be setup in the water for communication.
1. Two modems are needed to be setup in the water for communication.

- Connect to one of the modem via ethernet or wifi.
2. Connect to one of the modem via ethernet or wifi.

- Open a terminal window and compile `test.c` using :
3. Open a terminal window and compile `test.c` using :

```bash
make test
```

- Run `test.c` as follows :
4. Run test as follows:

```bash
./test <IP> <PORT> <NODE_ID>
test/test_unet <IP> <NODE_ID>
```

where `<IP>` argument must be the IP address of the modem to connect to, `<PORT>` is the port number of the Unet service on that modem and `<NODE_ID>` is the node address of the other modem in the water for ranging tests.

Upon completion of the tests, the test results will be summarized.

- To delete the files and recompile from scratch, run `make clean`.




## Clean

To clean all the built files and the depencencies, run

```bash
make deepclean
```

To clean only the built files and not the dependencies, run

```bash
make clean
```
@@ -4,8 +4,7 @@
//
// In terminal window (an example):
//
// $ make
// $ make rs3232_wakeup
// $ make samples
// $ ./rs232_wakeup <devname>
//
////////////////////////////////////////////////////////////////////////////////
@@ -4,8 +4,7 @@
//
// In terminal window (an example):
//
// $ make
// $ make rxdata
// $ make samples
// $ ./rxdata 192.168.1.119
//
// Pass the actual IP address of the modem in use for receiving data.
@@ -4,8 +4,7 @@
//
// In terminal window (an example):
//
// $ make
// $ make txdata
// $ make samples
// $ ./txdata 192.168.1.119 2
//
// Pass the actual IP address of transmitter and node address of the receiver.
@@ -4,8 +4,7 @@
//
// In terminal window (an example):
//
// $ make
// $ make wakeup
// $ make samples
// $ ./wakeup 00:14:2D:2F:C0:9A
//
// Pass the actual MAC address of a sleeping modem to wake it up.
@@ -5,7 +5,6 @@
//
// In terminal window (an example):
//
// $ make
// $ make test_unet
// $ ./test_unet 192.168.1.74 9
//
@@ -17,7 +16,7 @@
#include <unistd.h>
#include <string.h>
#include <math.h>
#include "unet.h"
#include "../unet.h"

#define SIGLEN 2000
#define RECBUFSIZE 17000
@@ -121,10 +120,10 @@ int main(int argc, char* argv[]) {

sleep(3);

// Test modem sleep
x = modem_sleep(modem);
test_assert("Modem put to sleep", x == 0);
sleep(3);
// // Test modem sleep
// x = modem_sleep(modem);
// test_assert("Modem put to sleep", x == 0);
// sleep(3);

// Test acoustic wakeup transmission
x = modem_tx_wakeup(modem, id);
@@ -139,11 +138,11 @@ int main(int argc, char* argv[]) {

// Test recording
x = modem_record(modem, buf, 1000);
if (x == 0) {
for(int i = 0; i < 2000; i++) {
printf("%f\n", buf[i]);
}
}
// if (x == 0) {
// for(int i = 0; i < 2000; i++) {
// printf("%f\n", buf[i]);
// }
// }
test_assert("\nRecording", x == 0);

// Test setter and getter for integer valued modem parameter

0 comments on commit 37e56bb

Please sign in to comment.
You can’t perform that action at this time.