Merge pull request #76 from alanbjohnston/dev

Code cleanup and BPSK WOD testing
pull/77/head
alanbjohnston 5 years ago committed by GitHub
commit c5f11dda88
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -54,57 +54,57 @@ radiochat: chat/chat_main.o
radiopiglatin: libax5043.a
radiopiglatin: piglatin/piglatin_main.o
gcc -std=gnu99 $(DEBUG_BEHAVIOR) -o radiopiglatin -pedantic -Wall -Wextra -L./ piglatin/piglatin_main.o -lwiringPi -lax5043
gcc -std=gnu99 $(DEBUG_BEHAVIOR) -o radiopiglatin -Wall -Wextra -L./ piglatin/piglatin_main.o -lwiringPi -lax5043
testax5043tx: libax5043.a
testax5043tx: transmit/transmit_main.o
gcc -std=gnu99 $(DEBUG_BEHAVIOR) -o testax5043tx -pedantic -Wall -Wextra -L./ transmit/transmit_main.o -lwiringPi -lax5043
gcc -std=gnu99 $(DEBUG_BEHAVIOR) -o testax5043tx -Wall -Wextra -L./ transmit/transmit_main.o -lwiringPi -lax5043
testax5043rx: libax5043.a
testax5043rx: receive/receive_main.o
gcc -std=gnu99 $(DEBUG_BEHAVIOR) -o testax5043rx -pedantic -Wall -Wextra -L./ receive/receive_main.o -lwiringPi -lax5043
gcc -std=gnu99 $(DEBUG_BEHAVIOR) -o testax5043rx -Wall -Wextra -L./ receive/receive_main.o -lwiringPi -lax5043
testax5043init: libax5043.a
testax5043init: init/init_main.o
gcc -std=gnu99 $(DEBUG_BEHAVIOR) -o testax5043init -pedantic -Wall -Wextra -L./ init/init_main.o -lwiringPi -lax5043
gcc -std=gnu99 $(DEBUG_BEHAVIOR) -o testax5043init -Wall -Wextra -L./ init/init_main.o -lwiringPi -lax5043
testax50432freq: libax5043.a
testax50432freq: transmit2freq/transmit2freq_main.o
gcc -std=gnu99 $(DEBUG_BEHAVIOR) -o testax50432freq -pedantic -Wall -Wextra -L./ transmit2freq/transmit2freq_main.o -lwiringPi -lax5043
gcc -std=gnu99 $(DEBUG_BEHAVIOR) -o testax50432freq -Wall -Wextra -L./ transmit2freq/transmit2freq_main.o -lwiringPi -lax5043
testafsktx: libax5043.a
testafsktx: afsktx/ax25.o
testafsktx: afsktx/ax5043.o
testafsktx: afsktx/main.o
gcc -std=gnu99 $(DEBUG_BEHAVIOR) -o testafsktx -pedantic -Wall -Wextra -L./ afsktx/ax25.o afsktx/ax5043.o afsktx/main.o -lwiringPi -lax5043
gcc -std=gnu99 $(DEBUG_BEHAVIOR) -o testafsktx -Wall -Wextra -L./ afsktx/ax25.o afsktx/ax5043.o afsktx/main.o -lwiringPi -lax5043
radioafsk: libax5043.a
radioafsk: afsk/ax25.o
radioafsk: afsk/ax5043.o
radioafsk: afsk/main.o
gcc -std=gnu99 $(DEBUG_BEHAVIOR) -o radioafsk -pedantic -Wall -Wextra -L./ afsk/ax25.o afsk/ax5043.o afsk/main.o -lwiringPi -lax5043 -lm
gcc -std=gnu99 $(DEBUG_BEHAVIOR) -o radioafsk -Wall -Wextra -L./ afsk/ax25.o afsk/ax5043.o afsk/main.o -lwiringPi -lax5043 -lm
telem: afsk/telem.o
gcc -std=gnu99 $(DEBUG_BEHAVIOR) -o telem -pedantic -Wall -Wextra -L./ afsk/telem.o -lwiringPi
gcc -std=gnu99 $(DEBUG_BEHAVIOR) -o telem -Wall -Wextra -L./ afsk/telem.o -lwiringPi
ax5043/generated/configcommon.o: ax5043/generated/configcommon.c
ax5043/generated/configcommon.o: ax5043/generated/configrx.h
ax5043/generated/configcommon.o: ax5043/generated/configtx.h
ax5043/generated/configcommon.o: ax5043/axradio/axradioinit.h
ax5043/generated/configcommon.o: ax5043/axradio/axradioinit_p.h
cd ax5043/generated; gcc -std=gnu99 $(DEBUG_BEHAVIOR) -pedantic -Wall -Wextra -c configcommon.c
cd ax5043/generated; gcc -std=gnu99 $(DEBUG_BEHAVIOR) -Wall -Wextra -c configcommon.c
ax5043/generated/configrx.o: ax5043/generated/configrx.c
ax5043/generated/configrx.o: ax5043/generated/configrx.h
ax5043/generated/configrx.o: ax5043/axradio/axradioinit.h
ax5043/generated/configrx.o: ax5043/axradio/axradioinit_p.h
cd ax5043/generated; gcc -std=gnu99 $(DEBUG_BEHAVIOR) -pedantic -Wall -Wextra -c configrx.c
cd ax5043/generated; gcc -std=gnu99 $(DEBUG_BEHAVIOR) -Wall -Wextra -c configrx.c
ax5043/generated/configtx.o: ax5043/generated/configtx.c
ax5043/generated/configtx.o: ax5043/generated/configtx.h
ax5043/generated/configtx.o: ax5043/axradio/axradioinit.h
ax5043/generated/configtx.o: ax5043/axradio/axradioinit_p.h
cd ax5043/generated; gcc -std=gnu99 $(DEBUG_BEHAVIOR) -pedantic -Wall -Wextra -c configtx.c
cd ax5043/generated; gcc -std=gnu99 $(DEBUG_BEHAVIOR) -Wall -Wextra -c configtx.c
ax5043/generated/config.o: ax5043/generated/config.c
ax5043/generated/config.o: ax5043/generated/config.h
@ -113,12 +113,12 @@ ax5043/generated/config.o: ax5043/axradio/axradioinit_p.h
ax5043/generated/config.o: ax5043/spi/ax5043spi.h
ax5043/generated/config.o: ax5043/spi/ax5043spi_p.h
ax5043/generated/config.o: ax5043/crc/crc.h
cd ax5043/generated; gcc -std=gnu99 $(DEBUG_BEHAVIOR) -pedantic -Wall -Wextra -c config.c
cd ax5043/generated; gcc -std=gnu99 $(DEBUG_BEHAVIOR) -Wall -Wextra -c config.c
ax5043/spi/ax5043spi.o: ax5043/spi/ax5043spi.c
ax5043/spi/ax5043spi.o: ax5043/spi/ax5043spi.h
ax5043/spi/ax5043spi.o: ax5043/spi/ax5043spi_p.h
cd ax5043/spi; gcc -std=gnu99 $(DEBUG_BEHAVIOR) -pedantic -Wall -Wextra -c ax5043spi.c
cd ax5043/spi; gcc -std=gnu99 $(DEBUG_BEHAVIOR) -Wall -Wextra -c ax5043spi.c
ax5043/ax5043support/ax5043init.o: ax5043/ax5043support/ax5043init.c
ax5043/ax5043support/ax5043init.o: ax5043/ax5043support/ax5043init.h
@ -126,7 +126,7 @@ ax5043/ax5043support/ax5043init.o: ax5043/axradio/axradioinit.h
ax5043/ax5043support/ax5043init.o: ax5043/axradio/axradioinit_p.h
ax5043/ax5043support/ax5043init.o: ax5043/spi/ax5043spi.h
ax5043/ax5043support/ax5043init.o: ax5043/spi/ax5043spi_p.h
cd ax5043/ax5043support; gcc -std=gnu99 $(DEBUG_BEHAVIOR) -pedantic -Wall -Wextra -c ax5043init.c
cd ax5043/ax5043support; gcc -std=gnu99 $(DEBUG_BEHAVIOR) -Wall -Wextra -c ax5043init.c
ax5043/ax5043support/ax5043rx.o: ax5043/ax5043support/ax5043rx.c
ax5043/ax5043support/ax5043rx.o: ax5043/ax5043support/ax5043rx.h
@ -134,7 +134,7 @@ ax5043/ax5043support/ax5043rx.o: ax5043/axradio/axradioinit.h
ax5043/ax5043support/ax5043rx.o: ax5043/axradio/axradioinit_p.h
ax5043/ax5043support/ax5043rx.o: ax5043/spi/ax5043spi.h
ax5043/ax5043support/ax5043rx.o: ax5043/spi/ax5043spi_p.h
cd ax5043/ax5043support; gcc -std=gnu99 $(DEBUG_BEHAVIOR) -pedantic -Wall -Wextra -c ax5043rx.c
cd ax5043/ax5043support; gcc -std=gnu99 $(DEBUG_BEHAVIOR) -Wall -Wextra -c ax5043rx.c
ax5043/ax5043support/ax5043tx.o: ax5043/ax5043support/ax5043tx.c
ax5043/ax5043support/ax5043tx.o: ax5043/ax5043support/ax5043tx.h
@ -142,7 +142,7 @@ ax5043/ax5043support/ax5043tx.o: ax5043/axradio/axradioinit.h
ax5043/ax5043support/ax5043tx.o: ax5043/axradio/axradioinit_p.h
ax5043/ax5043support/ax5043tx.o: ax5043/spi/ax5043spi.h
ax5043/ax5043support/ax5043tx.o: ax5043/spi/ax5043spi_p.h
cd ax5043/ax5043support; gcc -std=gnu99 $(DEBUG_BEHAVIOR) -pedantic -Wall -Wextra -c ax5043tx.c
cd ax5043/ax5043support; gcc -std=gnu99 $(DEBUG_BEHAVIOR) -Wall -Wextra -c ax5043tx.c
ax5043/axradio/axradioinit.o: ax5043/axradio/axradioinit.c
ax5043/axradio/axradioinit.o: ax5043/axradio/axradioinit.h
@ -152,7 +152,7 @@ ax5043/axradio/axradioinit.o: ax5043/spi/ax5043spi.h
ax5043/axradio/axradioinit.o: ax5043/spi/ax5043spi_p.h
ax5043/axradio/axradioinit.o: ax5043/generated/config.h
ax5043/axradio/axradioinit.o: ax5043/crc/crc.h
cd ax5043/axradio; gcc -std=gnu99 $(DEBUG_BEHAVIOR) -pedantic -Wall -Wextra -c axradioinit.c
cd ax5043/axradio; gcc -std=gnu99 $(DEBUG_BEHAVIOR) -Wall -Wextra -c axradioinit.c
ax5043/axradio/axradiomode.o: ax5043/axradio/axradiomode.c
ax5043/axradio/axradiomode.o: ax5043/axradio/axradiomode.h
@ -162,7 +162,7 @@ ax5043/axradio/axradiomode.o: ax5043/axradio/axradioinit_p.h
ax5043/axradio/axradiomode.o: ax5043/spi/ax5043spi.h
ax5043/axradio/axradiomode.o: ax5043/spi/ax5043spi_p.h
ax5043/axradio/axradiomode.o: ax5043/generated/config.h
cd ax5043/axradio; gcc -std=gnu99 $(DEBUG_BEHAVIOR) -pedantic -Wall -Wextra -c axradiomode.c
cd ax5043/axradio; gcc -std=gnu99 $(DEBUG_BEHAVIOR) -Wall -Wextra -c axradiomode.c
ax5043/axradio/axradiorx.o: ax5043/axradio/axradiorx.c
ax5043/axradio/axradiorx.o: ax5043/axradio/axradiorx.h
@ -172,7 +172,7 @@ ax5043/axradio/axradiorx.o: ax5043/axradio/axradioinit.h
ax5043/axradio/axradiorx.o: ax5043/axradio/axradioinit_p.h
ax5043/axradio/axradiorx.o: ax5043/spi/ax5043spi.h
ax5043/axradio/axradiorx.o: ax5043/spi/ax5043spi_p.h
cd ax5043/axradio; gcc -std=gnu99 $(DEBUG_BEHAVIOR) -pedantic -Wall -Wextra -c axradiorx.c
cd ax5043/axradio; gcc -std=gnu99 $(DEBUG_BEHAVIOR) -Wall -Wextra -c axradiorx.c
ax5043/axradio/axradiotx.o: ax5043/axradio/axradiotx.c
ax5043/axradio/axradiotx.o: ax5043/axradio/axradiotx.h
@ -186,11 +186,11 @@ ax5043/axradio/axradiotx.o: ax5043/generated/config.h
ax5043/axradio/axradiotx.o: ax5043/axradio/axradiomode.h
ax5043/axradio/axradiotx.o: ax5043/axradio/axradiomode_p.h
ax5043/axradio/axradiotx.o: ax5043/crc/crc.h
cd ax5043/axradio; gcc -std=gnu99 $(DEBUG_BEHAVIOR) -pedantic -Wall -Wextra -c axradiotx.c
cd ax5043/axradio; gcc -std=gnu99 $(DEBUG_BEHAVIOR) -Wall -Wextra -c axradiotx.c
ax5043/crc/crc.o: ax5043/crc/crc.c
ax5043/crc/crc.o: ax5043/crc/crc.h
cd ax5043/crc; gcc -std=gnu99 $(DEBUG_BEHAVIOR) -pedantic -Wall -Wextra -c crc.c
cd ax5043/crc; gcc -std=gnu99 $(DEBUG_BEHAVIOR) -Wall -Wextra -c crc.c
chat/chat_main.o: chat/chat_main.c
chat/chat_main.o: ax5043/spi/ax5043spi.h
@ -204,13 +204,13 @@ chat/chat_main.o: ax5043/axradio/axradiorx_p.h
chat/chat_main.o: ax5043/axradio/axradiotx.h
chat/chat_main.o: ax5043/axradio/axradiotx_p.h
chat/chat_main.o: ax5043/generated/configtx.h
cd chat; gcc -std=gnu99 $(DEBUG_BEHAVIOR) -I../ax5043 -pedantic -Wconversion -Wall -Wextra -c chat_main.c; cd ..
cd chat; gcc -std=gnu99 $(DEBUG_BEHAVIOR) -I../ax5043 -c chat_main.c; cd ..
afsk/ax25.o: afsk/ax25.c
afsk/ax25.o: afsk/ax25.h
afsk/ax25.o: afsk/ax5043.h
afsk/ax25.o: afsk/status.h
cd afsk; gcc -std=gnu99 $(DEBUG_BEHAVIOR) -I ../ax5043 -pedantic -Wconversion -Wall -Wextra -c ax25.c; cd ..
cd afsk; gcc -std=gnu99 $(DEBUG_BEHAVIOR) -I ../ax5043 -c ax25.c; cd ..
afsk/ax5043.o: afsk/ax5043.c
afsk/ax5043.o: afsk/ax25.h
@ -219,17 +219,17 @@ afsk/ax5043.o: afsk/status.h
afsk/ax5043.o: afsk/utils.h
afsk/ax5043.o: afsk/main.c
afsk/ax5043.o: ax5043/spi/ax5043spi.h
cd afsk; gcc -std=gnu99 $(DEBUG_BEHAVIOR) -I ../ax5043 -pedantic -Wconversion -Wall -Wextra -c ax5043.c; cd ..
cd afsk; gcc -std=gnu99 $(DEBUG_BEHAVIOR) -I ../ax5043 -c ax5043.c; cd ..
afsk/main.o: afsk/main.c
afsk/main.o: afsk/status.h
afsk/main.o: afsk/ax5043.h
afsk/main.o: afsk/ax25.h
afsk/main.o: ax5043/spi/ax5043spi.h
cd afsk; gcc -std=gnu99 $(DEBUG_BEHAVIOR) -I ../ax5043 -pedantic -Wconversion -Wall -Wextra -c main.c; cd ..
cd afsk; gcc -std=gnu99 $(DEBUG_BEHAVIOR) -I ../ax5043 -c main.c; cd ..
afsk/telem.o: afsk/telem.c
cd afsk; gcc -std=gnu99 $(DEBUG_BEHAVIOR) -I ../ax5043 -pedantic -Wconversion -Wall -Wextra -c telem.c; cd ..
cd afsk; gcc -std=gnu99 $(DEBUG_BEHAVIOR) -I ../ax5043 -c telem.c; cd ..
cw/cw_main.o: cw/cw_main.c
cw/cw_main.o: ax5043/spi/ax5043spi.h
@ -243,7 +243,7 @@ cw/cw_main.o: ax5043/axradio/axradiorx_p.h
cw/cw_main.o: ax5043/axradio/axradiotx.h
cw/cw_main.o: ax5043/axradio/axradiotx_p.h
cw/cw_main.o: ax5043/generated/configtx.h
cd cw; gcc -std=gnu99 $(DEBUG_BEHAVIOR) -I../ax5043 -pedantic -Wconversion -Wall -Wextra -c cw_main.c; cd ..
cd cw; gcc -std=gnu99 $(DEBUG_BEHAVIOR) -I../ax5043 -c cw_main.c; cd ..
piglatin/piglatin_main.o: piglatin/piglatin_main.c
piglatin/piglatin_main.o: ax5043/spi/ax5043spi.h
@ -257,7 +257,7 @@ piglatin/piglatin_main.o: ax5043/axradio/axradiorx_p.h
piglatin/piglatin_main.o: ax5043/axradio/axradiotx.h
piglatin/piglatin_main.o: ax5043/axradio/axradiotx_p.h
piglatin/piglatin_main.o: ax5043/generated/configtx.h
cd piglatin; gcc -std=gnu99 $(DEBUG_BEHAVIOR) -I ../ax5043 -pedantic -Wconversion -Wall -Wextra -c piglatin_main.c; cd ..
cd piglatin; gcc -std=gnu99 $(DEBUG_BEHAVIOR) -I ../ax5043 -c piglatin_main.c; cd ..
receive/receive_main.o: receive/receive_main.c
receive/receive_main.o: ax5043/axradio/axradioinit.h
@ -269,7 +269,7 @@ receive/receive_main.o: ax5043/axradio/axradiomode_p.h
receive/receive_main.o: ax5043/axradio/axradiorx.h
receive/receive_main.o: ax5043/axradio/axradiorx_p.h
receive/receive_main.o: ax5043/generated/configrx.h
cd receive; gcc -std=gnu99 $(DEBUG_BEHAVIOR) -I ../ax5043 -pedantic -Wconversion -Wall -Wextra -c receive_main.c; cd ..
cd receive; gcc -std=gnu99 $(DEBUG_BEHAVIOR) -I ../ax5043 -c receive_main.c; cd ..
transmit/transmit_main.o: transmit/transmit_main.c
transmit/transmit_main.o: ax5043/axradio/axradioinit.h
@ -281,7 +281,7 @@ transmit/transmit_main.o: ax5043/axradio/axradiomode_p.h
transmit/transmit_main.o: ax5043/axradio/axradiotx.h
transmit/transmit_main.o: ax5043/axradio/axradiotx_p.h
transmit/transmit_main.o: ax5043/generated/configtx.h
cd transmit; gcc -std=gnu99 $(DEBUG_BEHAVIOR) -I ../ax5043 -pedantic -Wconversion -Wall -Wextra -c transmit_main.c; cd ..
cd transmit; gcc -std=gnu99 $(DEBUG_BEHAVIOR) -I ../ax5043 -c transmit_main.c; cd ..
transmit2freq/transmit2freq_main.o: transmit2freq/transmit2freq_main.c
transmit2freq/transmit2freq_main.o: ax5043/axradio/axradioinit.h
@ -293,20 +293,20 @@ transmit2freq/transmit2freq_main.o: ax5043/axradio/axradiomode_p.h
transmit2freq/transmit2freq_main.o: ax5043/axradio/axradiotx.h
transmit2freq/transmit2freq_main.o: ax5043/axradio/axradiotx_p.h
transmit2freq/transmit2freq_main.o: ax5043/generated/configtx.h
cd transmit2freq; gcc -std=gnu99 $(DEBUG_BEHAVIOR) -I ../ax5043 -pedantic -Wconversion -Wall -Wextra -c transmit2freq_main.c; cd ..
cd transmit2freq; gcc -std=gnu99 $(DEBUG_BEHAVIOR) -I ../ax5043 -c transmit2freq_main.c; cd ..
init/init_main.o: init/init_main.c
init/init_main.o: ax5043/axradio/axradioinit.h
init/init_main.o: ax5043/axradio/axradioinit_p.h
init/init_main.o: ax5043/spi/ax5043spi.h
init/init_main.o: ax5043/spi/ax5043spi_p.h
cd init; gcc -std=gnu99 $(DEBUG_BEHAVIOR) -I ../ax5043 -pedantic -Wconversion -Wall -Wextra -c init_main.c; cd ..
cd init; gcc -std=gnu99 $(DEBUG_BEHAVIOR) -I ../ax5043 -c init_main.c; cd ..
afsktx/ax25.o: afsktx/ax25.c
afsktx/ax25.o: afsktx/ax25.h
afsktx/ax25.o: afsktx/ax5043.h
afsktx/ax25.o: afsktx/status.h
cd afsktx; gcc -std=gnu99 $(DEBUG_BEHAVIOR) -I ../ax5043 -pedantic -Wconversion -Wall -Wextra -c ax25.c; cd ..
cd afsktx; gcc -std=gnu99 $(DEBUG_BEHAVIOR) -I ../ax5043 -c ax25.c; cd ..
afsktx/ax5043.o: afsktx/ax5043.c
afsktx/ax5043.o: afsktx/ax25.h
@ -314,11 +314,11 @@ afsktx/ax5043.o: afsktx/ax5043.h
afsktx/ax5043.o: afsktx/status.h
afsktx/ax5043.o: afsktx/utils.h
afsktx/ax5043.o: ax5043/spi/ax5043spi.h
cd afsktx; gcc -std=gnu99 $(DEBUG_BEHAVIOR) -I ../ax5043 -pedantic -Wconversion -Wall -Wextra -c ax5043.c; cd ..
cd afsktx; gcc -std=gnu99 $(DEBUG_BEHAVIOR) -I ../ax5043 -c ax5043.c; cd ..
afsktx/main.o: afsktx/main.c
afsktx/main.o: afsktx/status.h
afsktx/main.o: afsktx/ax5043.h
afsktx/main.o: afsktx/ax25.h
afsktx/main.o: ax5043/spi/ax5043spi.h
cd afsktx; gcc -std=gnu99 $(DEBUG_BEHAVIOR) -I ../ax5043 -pedantic -Wconversion -Wall -Wextra -c main.c; cd ..
cd afsktx; gcc -std=gnu99 $(DEBUG_BEHAVIOR) -I ../ax5043 -c main.c; cd ..

@ -86,8 +86,8 @@ ax25_conf_t hax25;
int twosToInt(int val, int len);
float rnd_float(double min, double max);
int get_tlm(void);
int get_tlm_fox();
void get_tlm();
void get_tlm_fox();
int encodeA(short int * b, int index, int val);
int encodeB(short int * b, int index, int val);
void config_x25();
@ -138,11 +138,11 @@ int sampleTime = 0, frames_sent = 0;
int cw_id = ON;
int vB4 = FALSE, vB5 = FALSE, vB3 = FALSE, ax5043 = FALSE, transmit = FALSE, onLed, onLedOn, onLedOff, txLed, txLedOn, txLedOff, payload = OFF;
float batteryThreshold = 3.0, batteryVoltage;
float latitude = 39.027702, longitude = -77.078064;
float latitude = 39.027702f, longitude = -77.078064f;
float lat_file, long_file;
float axis[3], angle[3], volts_max[3], amps_max[3], batt, speed, period, tempS, temp_max, temp_min;
int eclipse, i2c_bus0 = OFF, i2c_bus1 = OFF, i2c_bus3 = OFF, camera = OFF, sim_mode = FALSE, rxAntennaDeployed = 0, txAntennaDeployed = 0;
float axis[3], angle[3], volts_max[3], amps_max[3], batt, speed, period, tempS, temp_max, temp_min, eclipse;
int i2c_bus0 = OFF, i2c_bus1 = OFF, i2c_bus3 = OFF, camera = OFF, sim_mode = FALSE, rxAntennaDeployed = 0, txAntennaDeployed = 0;
double eclipse_time;
int test_i2c_bus(int bus);
@ -199,7 +199,7 @@ int main(int argc, char * argv[]) {
config_file = fopen("/home/pi/CubeSatSim/sim.cfg", "r");
}
char * cfg_buf[100];
// char * cfg_buf[100];
fscanf(config_file, "%s %d %f %f", call, & reset_count, & lat_file, & long_file);
fclose(config_file);
printf("Config file /home/pi/CubeSatSim/sim.cfg contains %s %d %f %f\n", call, reset_count, lat_file, long_file);
@ -356,11 +356,11 @@ int main(int argc, char * argv[]) {
if ((uart_fd = serialOpen("/dev/ttyAMA0", 9600)) >= 0) {
char c;
int charss = serialDataAvail(uart_fd);
int charss = (char) serialDataAvail(uart_fd);
if (charss != 0)
printf("Clearing buffer of %d chars \n", charss);
while ((charss--> 0))
c = serialGetchar(uart_fd); // clear buffer
c = (char) serialGetchar(uart_fd); // clear buffer
unsigned int waitTime;
int i;
@ -370,10 +370,10 @@ int main(int argc, char * argv[]) {
waitTime = millis() + 500;
while ((millis() < waitTime) && (payload != ON)) {
if (serialDataAvail(uart_fd)) {
printf("%c", c = serialGetchar(uart_fd));
printf("%c", c = (char) serialGetchar(uart_fd));
fflush(stdout);
if (c == 'O') {
printf("%c", c = serialGetchar(uart_fd));
printf("%c", c = (char) serialGetchar(uart_fd));
fflush(stdout);
if (c == 'K')
payload = ON;
@ -401,9 +401,9 @@ int main(int argc, char * argv[]) {
FILE * file4 = popen("vcgencmd get_camera", "r");
fgets(cmdbuffer1, 1000, file4);
char camera_present[] = "supported=1 detected=1";
printf("strstr: %s \n", strstr( & cmdbuffer1, camera_present));
camera = (strstr( & cmdbuffer1, camera_present) != NULL) ? ON : OFF;
printf("Camera result:%s camera: %d \n", & cmdbuffer1, camera);
// printf("strstr: %s \n", strstr( & cmdbuffer1, camera_present));
camera = (strstr( (const char *)& cmdbuffer1, camera_present) != NULL) ? ON : OFF;
// printf("Camera result:%s camera: %d \n", & cmdbuffer1, camera);
pclose(file4);
#ifdef DEBUG_LOGGING
@ -416,7 +416,7 @@ int main(int argc, char * argv[]) {
printf("Simulated telemetry mode!\n");
srand(time(0));
srand((unsigned int)time(0));
axis[0] = rnd_float(-0.2, 0.2);
if (axis[0] == 0)
@ -440,7 +440,7 @@ int main(int argc, char * argv[]) {
batt = rnd_float(3.8, 4.3);
speed = rnd_float(1.0, 2.5);
eclipse = (rnd_float(-1, +4) > 0) ? 1 : 0;
eclipse = (rnd_float(-1, +4) > 0) ? 1.0 : 0.0;
period = rnd_float(150, 300);
tempS = rnd_float(20, 55);
temp_max = rnd_float(50, 70);
@ -449,17 +449,17 @@ int main(int argc, char * argv[]) {
#ifdef DEBUG_LOGGING
for (int i = 0; i < 3; i++)
printf("axis: %f angle: %f v: %f i: %f \n", axis[i], angle[i], volts_max[i], amps_max[i]);
printf("batt: %f speed: %f eclipse_time: %f eclipse: %d period: %f temp: %f max: %f min: %f\n", batt, speed, eclipse_time, eclipse, period, tempS, temp_max, temp_min);
printf("batt: %f speed: %f eclipse_time: %f eclipse: %f period: %f temp: %f max: %f min: %f\n", batt, speed, eclipse_time, eclipse, period, tempS, temp_max, temp_min);
#endif
time_start = millis();
time_start = (long int) millis();
eclipse_time = millis() / 1000.0;
if (eclipse == 0)
eclipse_time = (long int)(millis() / 1000.0);
if (eclipse == 0.0)
eclipse_time -= period / 2; // if starting in eclipse, shorten interval
}
int ret;
//int ret;
//uint8_t data[1024];
tx_freq_hz -= tx_channel * 50000;
@ -527,8 +527,8 @@ int main(int argc, char * argv[]) {
samples = S_RATE / bitRate;
bufLen = (frameCnt * (syncBits + 10 * (headerLen + rsFrames * (rsFrameLen + parityLen))) * samples);
samplePeriod = ((float)((syncBits + 10 * (headerLen + rsFrames * (rsFrameLen + parityLen)))) / (float) bitRate) * 1000 - 500;
sleepTime = 0.1;
samplePeriod = (int) (((float)((syncBits + 10 * (headerLen + rsFrames * (rsFrameLen + parityLen)))) / (float) bitRate) * 1000 - 500);
sleepTime = 0.1f;
printf("\n FSK Mode, %d bits per frame, %d bits per second, %d ms sample period\n",
bufLen / (samples * frameCnt), bitRate, samplePeriod);
@ -550,7 +550,7 @@ int main(int argc, char * argv[]) {
// samplePeriod = 3000;
// sleepTime = 3.0;
samplePeriod = 2200; // reduce dut to python and sensor querying delays
sleepTime = 2.2;
sleepTime = 2.2f;
printf("\n BPSK Mode, bufLen: %d, %d bits per frame, %d bits per second, %d seconds per frame %d ms sample period\n",
bufLen, bufLen / (samples * frameCnt), bitRate, bufLen / (samples * frameCnt * bitRate), samplePeriod);
@ -580,7 +580,7 @@ int main(int argc, char * argv[]) {
printf("Tx LED On\n");
#endif
printf("Sleeping to allow BPSK transmission to finish.\n");
sleep(loop_count * 5);
sleep((unsigned int)(loop_count * 5));
printf("Done sleeping\n");
digitalWrite(txLed, txLedOff);
#ifdef DEBUG_LOGGING
@ -588,7 +588,7 @@ int main(int argc, char * argv[]) {
#endif
} else if (mode == FSK) {
printf("Sleeping to allow FSK transmission to finish.\n");
sleep(loop_count);
sleep((unsigned int)loop_count);
printf("Done sleeping\n");
}
@ -634,7 +634,7 @@ static int init_rf() {
return (1);
}
int get_tlm(void) {
void get_tlm(void) {
FILE * txResult;
@ -667,15 +667,15 @@ int get_tlm(void) {
for (count1 = 0; count1 < 8; count1++) {
if (token != NULL) {
voltage[count1] = atof(token);
voltage[count1] = (float) atof(token);
#ifdef DEBUG_LOGGING
// printf("voltage: %f ", voltage[count1]);
#endif
token = strtok(NULL, space);
if (token != NULL) {
current[count1] = atof(token);
current[count1] = (float) atof(token);
if ((current[count1] < 0) && (current[count1] > -0.5))
current[count1] *= (-1.0);
current[count1] *= (-1);
#ifdef DEBUG_LOGGING
// printf("current: %f\n", current[count1]);
#endif
@ -703,10 +703,10 @@ int get_tlm(void) {
if (sim_mode) {
// simulated telemetry
double time = (millis() - time_start) / 1000.0;
double time = ((long int) millis() - time_start) / 1000.0;
if ((time - eclipse_time) > period) {
eclipse = (eclipse == 1) ? 0 : 1;
eclipse = (eclipse == 1) ? 0.0 : 1.0;
eclipse_time = time;
printf("\n\nSwitching eclipse mode! \n\n");
}
@ -716,6 +716,7 @@ int get_tlm(void) {
double Yi = eclipse * amps_max[1] * sin((2.0 * 3.14 * time / (46.0 * speed)) + (3.14/2.0)) * fabs(sin((2.0 * 3.14 * time / (46.0 * speed)) + (3.14/2.0))) + rnd_float(-2, 2);
double Zi = eclipse * amps_max[2] * sin((2.0 * 3.14 * time / (46.0 * speed)) + 3.14 + angle[2]) * fabs(sin((2.0 * 3.14 * time / (46.0 * speed)) + 3.14 + angle[2])) + rnd_float(-2, 2);
*/
/*
double Xi = eclipse * amps_max[0] * sin(2.0 * 3.14 * time / (46.0 * speed)) + rnd_float(-2, 2);
double Yi = eclipse * amps_max[1] * sin((2.0 * 3.14 * time / (46.0 * speed)) + (3.14 / 2.0)) + rnd_float(-2, 2);
double Zi = eclipse * amps_max[2] * sin((2.0 * 3.14 * time / (46.0 * speed)) + 3.14 + angle[2]) + rnd_float(-2, 2);
@ -723,26 +724,34 @@ int get_tlm(void) {
double Xv = eclipse * volts_max[0] * sin(2.0 * 3.14 * time / (46.0 * speed)) + rnd_float(-0.2, 0.2);
double Yv = eclipse * volts_max[1] * sin((2.0 * 3.14 * time / (46.0 * speed)) + (3.14 / 2.0)) + rnd_float(-0.2, 0.2);
double Zv = 2.0 * eclipse * volts_max[2] * sin((2.0 * 3.14 * time / (46.0 * speed)) + 3.14 + angle[2]) + rnd_float(-0.2, 0.2);
*/
float Xi = eclipse * amps_max[0] * (float) sin(2.0 * 3.14 * time / (46.0 * speed)) + rnd_float(-2, 2);
float Yi = eclipse * amps_max[1] * (float) sin((2.0 * 3.14 * time / (46.0 * speed)) + (3.14 / 2.0)) + rnd_float(-2, 2);
float Zi = eclipse * amps_max[2] * (float) sin((2.0 * 3.14 * time / (46.0 * speed)) + 3.14 + angle[2]) + rnd_float(-2, 2);
float Xv = eclipse * volts_max[0] * (float) sin(2.0 * 3.14 * time / (46.0 * speed)) + rnd_float(-0.2, 0.2);
float Yv = eclipse * volts_max[1] * (float) sin((2.0 * 3.14 * time / (46.0 * speed)) + (3.14 / 2.0)) + rnd_float(-0.2, 0.2);
float Zv = 2.0 * eclipse * volts_max[2] * (float) sin((2.0 * 3.14 * time / (46.0 * speed)) + 3.14 + angle[2]) + rnd_float(-0.2, 0.2);
// printf("Yi: %f Zi: %f %f %f Zv: %f \n", Yi, Zi, amps_max[2], angle[2], Zv);
current[map[PLUS_X]] = (Xi >= 0) ? Xi : 0;
current[map[MINUS_X]] = (Xi >= 0) ? 0 : ((-1.0) * Xi);
current[map[MINUS_X]] = (Xi >= 0) ? 0 : ((-1.0f) * Xi);
current[map[PLUS_Y]] = (Yi >= 0) ? Yi : 0;
current[map[MINUS_Y]] = (Yi >= 0) ? 0 : ((-1.0) * Yi);
current[map[MINUS_Y]] = (Yi >= 0) ? 0 : ((-1.0f) * Yi);
current[map[PLUS_Z]] = (Zi >= 0) ? Zi : 0;
current[map[MINUS_Z]] = (Zi >= 0) ? 0 : ((-1.0) * Zi);
current[map[MINUS_Z]] = (Zi >= 0) ? 0 : ((-1.0f) * Zi);
voltage[map[PLUS_X]] = (Xv >= 1) ? Xv : rnd_float(0.9, 1.1);
voltage[map[MINUS_X]] = (Xv <= -1) ? ((-1.0) * Xv) : rnd_float(0.9, 1.1);
voltage[map[MINUS_X]] = (Xv <= -1) ? ((-1.0f) * Xv) : rnd_float(0.9, 1.1);
voltage[map[PLUS_Y]] = (Yv >= 1) ? Yv : rnd_float(0.9, 1.1);
voltage[map[MINUS_Y]] = (Yv <= -1) ? ((-1.0) * Yv) : rnd_float(0.9, 1.1);
voltage[map[MINUS_Y]] = (Yv <= -1) ? ((-1.0f) * Yv) : rnd_float(0.9, 1.1);
voltage[map[PLUS_Z]] = (Zv >= 1) ? Zv : rnd_float(0.9, 1.1);
voltage[map[MINUS_Z]] = (Zv <= -1) ? ((-1.0) * Zv) : rnd_float(0.9, 1.1);
voltage[map[MINUS_Z]] = (Zv <= -1) ? ((-1.0f) * Zv) : rnd_float(0.9, 1.1);
// printf("temp: %f Time: %f Eclipse: %d : %f %f | %f %f | %f %f\n",tempS, time, eclipse, voltage[map[PLUS_X]], voltage[map[MINUS_X]], voltage[map[PLUS_Y]], voltage[map[MINUS_Y]], current[map[PLUS_Z]], current[map[MINUS_Z]]);
tempS += (eclipse > 0) ? ((temp_max - tempS) / 50.0) : ((temp_min - tempS) / 50.0);
tempS += (eclipse > 0) ? ((temp_max - tempS) / 50.0) : ((temp_min - tempS) / 50.0f);
cpuTemp = tempS + rnd_float(-1.0, 1.0);
voltage[map[BUS]] = rnd_float(5.0, 5.005);
@ -751,7 +760,7 @@ int get_tlm(void) {
// float charging = current[map[PLUS_X]] + current[map[MINUS_X]] + current[map[PLUS_Y]] + current[map[MINUS_Y]] + current[map[PLUS_Z]] + current[map[MINUS_Z]];
float charging = eclipse * (fabs(amps_max[0] * 0.707) + fabs(amps_max[1] * 0.707) + rnd_float(-4.0, 4.0));
current[map[BAT]] = ((current[map[BUS]] * voltage[map[BUS]]) / (batt * 1.0)) - charging;
current[map[BAT]] = ((current[map[BUS]] * voltage[map[BUS]]) / batt) - charging;
// printf("charging: %f bat curr: %f bus curr: %f bat volt: %f bus volt: %f \n",charging, current[map[BAT]], current[map[BUS]], batt, voltage[map[BUS]]);
@ -864,11 +873,11 @@ int get_tlm(void) {
if (payload == ON) {
char c;
int charss = serialDataAvail(uart_fd);
int charss = (char) serialDataAvail(uart_fd);
if (charss != 0)
printf("Clearing buffer of %d chars \n", charss);
while ((charss--> 0))
c = serialGetchar(uart_fd); // clear buffer
c = (char) serialGetchar(uart_fd); // clear buffer
unsigned int waitTime;
int i = 0;
@ -878,9 +887,9 @@ int get_tlm(void) {
waitTime = millis() + 500;
int end = FALSE;
while ((millis() < waitTime) && !end) {
int chars = serialDataAvail(uart_fd);
int chars = (char) serialDataAvail(uart_fd);
while ((chars--> 0) && !end) {
c = serialGetchar(uart_fd);
c = (char) serialGetchar(uart_fd);
// printf ("%c", c);
// fflush(stdout);
if (c != '\n') {
@ -968,7 +977,7 @@ int get_tlm(void) {
return;
}
int get_tlm_fox() {
void get_tlm_fox() {
// Reading I2C voltage and current sensors
@ -984,7 +993,7 @@ int get_tlm_fox() {
// long int sync = SYNC_WORD;
long int sync = syncWord;
smaller = S_RATE / (2 * freq_Hz);
smaller = (int) (S_RATE / (2 * freq_Hz));
// short int b[DATA_LEN];
short int b[dataLen];
@ -1003,7 +1012,7 @@ int get_tlm_fox() {
short int rs_frame[rsFrames][223];
unsigned char parities[rsFrames][parityLen], inputByte;
int id, frm_type = 0x01, TxTemp = 0, IHUcpuTemp = 0, STEMBoardFailure = 1, NormalModeFailure = 0, groundCommandCount = 0;
int id, frm_type = 0x01, STEMBoardFailure = 1, NormalModeFailure = 0, groundCommandCount = 0;
int PayloadFailure1 = 0, PayloadFailure2 = 0;
int PSUVoltage = 0, PSUCurrent = 0, Resets = 0, Rssi = 2048;
int batt_a_v = 0, batt_b_v = 0, batt_c_v = 0, battCurr = 0;
@ -1012,16 +1021,16 @@ int get_tlm_fox() {
int head_offset = 0;
// int xAngularVelocity = (-0.69)*(-10)*(-10) + 45.3 * (-10) + 2078, yAngularVelocity = (-0.69)*(-6)*(-6) + 45.3 * (-6) + 2078, zAngularVelocity = (-0.69)*(6)*(6) + 45.3 * (6) + 2078; // XAxisAngularVelocity
// int xAngularVelocity = 2078, yAngularVelocity = 2078, zAngularVelocity = 2078; // XAxisAngularVelocity Y and Z set to 0
int xAngularVelocity = 2048, yAngularVelocity = 2048, zAngularVelocity = 2048; // XAxisAngularVelocity Y and Z set to 0
int RXTemperature = 0, temp = 0, spin = 0;;
float xAccel = 0.0, yAccel = 0.0, zAccel = 0.0;
float BME280pressure = 0.0, BME280altitude = 0.0, BME280humidity = 0.0, BME280temperature = 0.0;
float XSsensor1 = 0.0, XSsensor2 = 0.0, XSsensor3 = 0.0;
int sensor1 = 0, sensor2 = 2048, sensor3 = 2048;
// int xAngularVelocity = 2048, yAngularVelocity = 2048, zAngularVelocity = 2048; // XAxisAngularVelocity Y and Z set to 0
// int RXTemperature = 0, temp = 0, spin = 0;;
// float xAccel = 0.0, yAccel = 0.0, zAccel = 0.0;
// float BME280pressure = 0.0, BME280altitude = 0.0, BME280humidity = 0.0, BME280temperature = 0.0;
// float XSsensor1 = 0.0, XSsensor2 = 0.0, XSsensor3 = 0.0;
// int sensor1 = 0, sensor2 = 2048, sensor3 = 2048;
short int buffer_test[bufLen];
int buffSize;
buffSize = sizeof(buffer_test);
buffSize = (int) sizeof(buffer_test);
if (mode == FSK)
id = 7;
@ -1038,16 +1047,16 @@ int get_tlm_fox() {
printf("Tx LED On\n");
#endif
while ((millis() - sampleTime) < samplePeriod)
sleep(sleepTime);
while ((millis() - sampleTime) < (unsigned int)samplePeriod)
sleep((unsigned int)sleepTime);
digitalWrite(txLed, txLedOff);
#ifdef DEBUG_LOGGING
printf("Tx LED Off\n");
#endif
printf("Sample period: %d\n", millis() - sampleTime);
sampleTime = millis();
printf("Sample period: %d\n", millis() - (unsigned int)sampleTime);
sampleTime = (int) millis();
} else
printf("first time - no sleep\n");
@ -1071,15 +1080,15 @@ int get_tlm_fox() {
for (count1 = 0; count1 < 8; count1++) {
if (token != NULL) {
voltage[count1] = atof(token);
voltage[count1] = (float) atof(token);
#ifdef DEBUG_LOGGING
// printf("voltage: %f ", voltage[count1]);
#endif
token = strtok(NULL, space);
if (token != NULL) {
current[count1] = atof(token);
current[count1] = (float) atof(token);
if ((current[count1] < 0) && (current[count1] > -0.5))
current[count1] *= (-1.0);
current[count1] *= (-1.0f);
#ifdef DEBUG_LOGGING
// printf("current: %f\n", current[count1]);
#endif
@ -1107,7 +1116,7 @@ int get_tlm_fox() {
printf("CPU Temp Read: %6.1f\n", cpuTemp);
#endif
other[IHU_TEMP] = cpuTemp;
other[IHU_TEMP] = (double)cpuTemp;
// IHUcpuTemp = (int)((cpuTemp * 10.0) + 0.5);
}
@ -1119,11 +1128,11 @@ int get_tlm_fox() {
STEMBoardFailure = 0;
char c;
int charss = serialDataAvail(uart_fd);
int charss = (char) serialDataAvail(uart_fd);
if (charss != 0)
printf("Clearing buffer of %d chars \n", charss);
while ((charss--> 0))
c = serialGetchar(uart_fd); // clear buffer
c = (char) serialGetchar(uart_fd); // clear buffer
unsigned int waitTime;
int i = 0;
@ -1133,9 +1142,9 @@ int get_tlm_fox() {
int end = FALSE;
// int retry = FALSE;
while ((millis() < waitTime) && !end) {
int chars = serialDataAvail(uart_fd);
int chars = (char) serialDataAvail(uart_fd);
while ((chars--> 0) && !end) {
c = serialGetchar(uart_fd);
c = (char) serialGetchar(uart_fd);
// printf ("%c", c);
// fflush(stdout);
if (c != '\n') {
@ -1165,7 +1174,7 @@ int get_tlm_fox() {
token = strtok(sensor_payload, space);
for (count1 = 0; count1 < 17; count1++) {
if (token != NULL) {
sensor[count1] = atof(token);
sensor[count1] = (float) atof(token);
#ifdef DEBUG_LOGGING
printf("sensor: %f ", sensor[count1]);
#endif
@ -1181,7 +1190,7 @@ int get_tlm_fox() {
if (sim_mode) {
// simulated telemetry
double time = (millis() - time_start) / 1000.0;
double time = ((long int)millis() - time_start) / 1000.0;
if ((time - eclipse_time) > period) {
eclipse = (eclipse == 1) ? 0 : 1;
@ -1194,33 +1203,33 @@ int get_tlm_fox() {
double Yi = eclipse * amps_max[1] * sin((2.0 * 3.14 * time / (46.0 * speed)) + (3.14/2.0)) * fabs(sin((2.0 * 3.14 * time / (46.0 * speed)) + (3.14/2.0))) + rnd_float(-2, 2);
double Zi = eclipse * amps_max[2] * sin((2.0 * 3.14 * time / (46.0 * speed)) + 3.14 + angle[2]) * fabs(sin((2.0 * 3.14 * time / (46.0 * speed)) + 3.14 + angle[2])) + rnd_float(-2, 2);
*/
double Xi = eclipse * amps_max[0] * sin(2.0 * 3.14 * time / (46.0 * speed)) + rnd_float(-2, 2);
double Yi = eclipse * amps_max[1] * sin((2.0 * 3.14 * time / (46.0 * speed)) + (3.14 / 2.0)) + rnd_float(-2, 2);
double Zi = eclipse * amps_max[2] * sin((2.0 * 3.14 * time / (46.0 * speed)) + 3.14 + angle[2]) + rnd_float(-2, 2);
double Xi = eclipse * amps_max[0] * (float) sin(2.0 * 3.14 * time / (46.0 * speed)) + rnd_float(-2, 2);
double Yi = eclipse * amps_max[1] * (float) sin((2.0 * 3.14 * time / (46.0 * speed)) + (3.14 / 2.0)) + rnd_float(-2, 2);
double Zi = eclipse * amps_max[2] * (float) sin((2.0 * 3.14 * time / (46.0 * speed)) + 3.14 + angle[2]) + rnd_float(-2, 2);
double Xv = eclipse * volts_max[0] * sin(2.0 * 3.14 * time / (46.0 * speed)) + rnd_float(-0.2, 0.2);
double Yv = eclipse * volts_max[1] * sin((2.0 * 3.14 * time / (46.0 * speed)) + (3.14 / 2.0)) + rnd_float(-0.2, 0.2);
double Zv = 2.0 * eclipse * volts_max[2] * sin((2.0 * 3.14 * time / (46.0 * speed)) + 3.14 + angle[2]) + rnd_float(-0.2, 0.2);
double Xv = eclipse * volts_max[0] * (float) sin(2.0 * 3.14 * time / (46.0 * speed)) + rnd_float(-0.2, 0.2);
double Yv = eclipse * volts_max[1] * (float) sin((2.0 * 3.14 * time / (46.0 * speed)) + (3.14 / 2.0)) + rnd_float(-0.2, 0.2);
double Zv = 2.0 * eclipse * volts_max[2] * (float) sin((2.0 * 3.14 * time / (46.0 * speed)) + 3.14 + angle[2]) + rnd_float(-0.2, 0.2);
// printf("Yi: %f Zi: %f %f %f Zv: %f \n", Yi, Zi, amps_max[2], angle[2], Zv);
current[map[PLUS_X]] = (Xi >= 0) ? Xi : 0;
current[map[MINUS_X]] = (Xi >= 0) ? 0 : ((-1.0) * Xi);
current[map[MINUS_X]] = (Xi >= 0) ? 0 : ((-1.0f) * Xi);
current[map[PLUS_Y]] = (Yi >= 0) ? Yi : 0;
current[map[MINUS_Y]] = (Yi >= 0) ? 0 : ((-1.0) * Yi);
current[map[MINUS_Y]] = (Yi >= 0) ? 0 : ((-1.0f) * Yi);
current[map[PLUS_Z]] = (Zi >= 0) ? Zi : 0;
current[map[MINUS_Z]] = (Zi >= 0) ? 0 : ((-1.0) * Zi);
current[map[MINUS_Z]] = (Zi >= 0) ? 0 : ((-1.0f) * Zi);
voltage[map[PLUS_X]] = (Xv >= 1) ? Xv : rnd_float(0.9, 1.1);
voltage[map[MINUS_X]] = (Xv <= -1) ? ((-1.0) * Xv) : rnd_float(0.9, 1.1);
voltage[map[MINUS_X]] = (Xv <= -1) ? ((-1.0f) * Xv) : rnd_float(0.9, 1.1);
voltage[map[PLUS_Y]] = (Yv >= 1) ? Yv : rnd_float(0.9, 1.1);
voltage[map[MINUS_Y]] = (Yv <= -1) ? ((-1.0) * Yv) : rnd_float(0.9, 1.1);
voltage[map[MINUS_Y]] = (Yv <= -1) ? ((-1.0f) * Yv) : rnd_float(0.9, 1.1);
voltage[map[PLUS_Z]] = (Zv >= 1) ? Zv : rnd_float(0.9, 1.1);
voltage[map[MINUS_Z]] = (Zv <= -1) ? ((-1.0) * Zv) : rnd_float(0.9, 1.1);
voltage[map[MINUS_Z]] = (Zv <= -1) ? ((-1.0f) * Zv) : rnd_float(0.9, 1.1);
// printf("temp: %f Time: %f Eclipse: %d : %f %f | %f %f | %f %f\n",tempS, time, eclipse, voltage[map[PLUS_X]], voltage[map[MINUS_X]], voltage[map[PLUS_Y]], voltage[map[MINUS_Y]], current[map[PLUS_Z]], current[map[MINUS_Z]]);
tempS += (eclipse > 0) ? ((temp_max - tempS) / 50.0) : ((temp_min - tempS) / 50.0);
tempS += (eclipse > 0) ? ((temp_max - tempS) / 50.0f) : ((temp_min - tempS) / 50.0f);
tempS += +rnd_float(-1.0, 1.0);
// IHUcpuTemp = (int)((tempS + rnd_float(-1.0, 1.0)) * 10 + 0.5);
other[IHU_TEMP] = tempS;
@ -1231,7 +1240,7 @@ int get_tlm_fox() {
// float charging = current[map[PLUS_X]] + current[map[MINUS_X]] + current[map[PLUS_Y]] + current[map[MINUS_Y]] + current[map[PLUS_Z]] + current[map[MINUS_Z]];
float charging = eclipse * (fabs(amps_max[0] * 0.707) + fabs(amps_max[1] * 0.707) + rnd_float(-4.0, 4.0));
current[map[BAT]] = ((current[map[BUS]] * voltage[map[BUS]]) / (batt * 1.0)) - charging;
current[map[BAT]] = ((current[map[BUS]] * voltage[map[BUS]]) / batt) - charging;
// printf("charging: %f bat curr: %f bus curr: %f bat volt: %f bus volt: %f \n",charging, current[map[BAT]], current[map[BUS]], batt, voltage[map[BUS]]);
@ -1285,6 +1294,7 @@ int get_tlm_fox() {
printf("Other min %f max %f \n", other_min[count1], other_max[count1]);
}
if (mode == FSK) {
if (loop % 8 == 0) {
printf("Sending MIN frame \n");
frm_type = 0x03;
@ -1313,7 +1323,7 @@ int get_tlm_fox() {
sensor[count1] = sensor_max[count1];
}
}
}
memset(rs_frame, 0, sizeof(rs_frame));
memset(parities, 0, sizeof(parities));
@ -1323,20 +1333,20 @@ int get_tlm_fox() {
fclose(uptime_file);
printf("Reset Count: %d Uptime since Reset: %ld \n", reset_count, uptime);
h[0] = (h[0] & 0xf8) | (id & 0x07); // 3 bits
h[0] = (short int) ((h[0] & 0xf8) | (id & 0x07)); // 3 bits
// printf("h[0] %x\n", h[0]);
h[0] = (h[0] & 0x07) | ((reset_count & 0x1f) << 3);
h[0] = (short int) ((h[0] & 0x07) | ((reset_count & 0x1f) << 3));
// printf("h[0] %x\n", h[0]);
h[1] = (reset_count >> 5) & 0xff;
h[1] = (short int) ((reset_count >> 5) & 0xff);
// printf("h[1] %x\n", h[1]);
h[2] = (h[2] & 0xf8) | ((reset_count >> 13) & 0x07);
h[2] = (short int) ((h[2] & 0xf8) | ((reset_count >> 13) & 0x07));
// printf("h[2] %x\n", h[2]);
h[2] = (h[2] & 0x0e) | ((uptime & 0x1f) << 3);
h[2] = (short int) ((h[2] & 0x0e) | ((uptime & 0x1f) << 3));
// printf("h[2] %x\n", h[2]);
h[3] = (uptime >> 5) & 0xff;
h[4] = (uptime >> 13) & 0xff;
h[5] = (h[5] & 0xf0) | ((uptime >> 21) & 0x0f);
h[5] = (h[5] & 0x0f) | (frm_type << 4);
h[3] = (short int) ((uptime >> 5) & 0xff);
h[4] = (short int) ((uptime >> 13) & 0xff);
h[5] = (short int) ((h[5] & 0xf0) | ((uptime >> 21) & 0x0f));
h[5] = (short int) ((h[5] & 0x0f) | (frm_type << 4));
if (mode == BPSK)
h[6] = 99;
@ -1419,7 +1429,7 @@ int get_tlm_fox() {
encodeA(b, 30 + head_offset, PSUVoltage);
// encodeB(b, 31 + head_offset,(spin * 10) + 2048);
encodeB(b, 31 + head_offset, (other[SPIN] * 10) + 2048);
encodeB(b, 31 + head_offset, ((int)(other[SPIN] * 10)) + 2048);
// encodeA(b, 33 + head_offset,(int)(BME280pressure + 0.5)); // Pressure
// encodeB(b, 34 + head_offset,(int)(BME280altitude + 0.5)); // Altitude
@ -1465,6 +1475,11 @@ int get_tlm_fox() {
txAntennaDeployed = 1;
printf("TX Antenna Deployed!\n");
}
if (mode == BPSK) { // WOD field experiments
encodeA(b, 63 + head_offset, 0xff);
encodeB(b, 74 + head_offset, 0xff);
}
short int data10[headerLen + rsFrames * (rsFrameLen + parityLen)];
short int data8[headerLen + rsFrames * (rsFrameLen + parityLen)];
@ -1533,7 +1548,7 @@ int get_tlm_fox() {
int data;
int val;
int offset = 0;
//int offset = 0;
#ifdef DEBUG_LOGGING
// printf("\nAt start of buffer loop, syncBits %d samples %d ctr %d\n", syncBits, samples, ctr);
@ -1598,7 +1613,7 @@ int get_tlm_fox() {
#endif
int error = 0;
int count;
// int count;
// for (count = 0; count < dataLen; count++) {
// printf("%02X", b[count]);
// }
@ -1608,8 +1623,8 @@ int get_tlm_fox() {
if (!socket_open && transmit) {
printf("Opening socket!\n");
struct sockaddr_in address;
int valread;
// struct sockaddr_in address;
// int valread;
struct sockaddr_in serv_addr;
// char *hello = "Hello from client";
// char buffer[1024] = {0};
@ -1642,10 +1657,10 @@ int get_tlm_fox() {
if (!error && transmit) {
// digitalWrite (0, LOW);
printf("Sending %d buffer bytes over socket after %d ms!\n", ctr, millis() - start);
printf("Sending %d buffer bytes over socket after %d ms!\n", ctr, (long unsigned int)millis() - start);
start = millis();
int sock_ret = send(sock, buffer, ctr * 2 + 2, 0);
printf("Millis5: %d Result of socket send: %d \n", millis() - start, sock_ret);
int sock_ret = send(sock, buffer, (unsigned int)(ctr * 2 + 2), 0);
printf("Millis5: %d Result of socket send: %d \n", (unsigned int)millis() - start, sock_ret);
if (sock_ret < (ctr * 2 + 2)) {
printf("Not resending\n");
@ -1670,7 +1685,7 @@ int get_tlm_fox() {
else if (frames_sent > 0) //5)
firstTime = 0;
return 0;
return;
}
/*
* TelemEncoding.h
@ -1693,8 +1708,8 @@ int get_tlm_fox() {
//static int encodeB(short int *b, int index, int val);
//static int encodeA(short int *b, int index, int val);
static int NOT_FRAME = /* 0fa */ 0xfa & 0x3ff;
static int FRAME = /* 0fa */ ~0xfa & 0x3ff;
// static int NOT_FRAME = /* 0fa */ 0xfa & 0x3ff;
// static int FRAME = /* 0fa */ ~0xfa & 0x3ff;
/*
* TelemEncoding.c
@ -1865,16 +1880,16 @@ void write_wave(int i, short int *buffer)
if (mode == FSK)
{
if ((ctr - flip_ctr) < smaller)
buffer[ctr++] = 0.1 * phase * (ctr - flip_ctr) / smaller;
buffer[ctr++] = (short int)(0.1 * phase * (ctr - flip_ctr) / smaller);
else
buffer[ctr++] = 0.25 * amplitude * phase;
buffer[ctr++] = (short int)(0.25 * amplitude * phase);
}
else
{
if ((ctr - flip_ctr) < smaller)
buffer[ctr++] = (int)(amplitude * 0.4 * phase * sin((float)(2*M_PI*i*freq_Hz/S_RATE)));
buffer[ctr++] = (short int)(amplitude * 0.4 * phase * sin((float)(2*M_PI*i*freq_Hz/S_RATE)));
else
buffer[ctr++] = (int)(amplitude * phase * sin((float)(2*M_PI*i*freq_Hz/S_RATE)));
buffer[ctr++] = (short int)(amplitude * phase * sin((float)(2*M_PI*i*freq_Hz/S_RATE)));
}
// printf("%d %d \n", i, buffer[ctr - 1]);
@ -1883,13 +1898,13 @@ void write_wave(int i, short int *buffer)
int encodeA(short int *b, int index, int val) {
// printf("Encoding A\n");
b[index] = val & 0xff;
b[index + 1] = (b[index + 1] & 0xf0) | ((val >> 8) & 0x0f);
b[index + 1] = (short int) ((b[index + 1] & 0xf0) | ((val >> 8) & 0x0f));
return 0;
}
int encodeB(short int *b, int index, int val) {
// printf("Encoding B\n");
b[index] = (b[index] & 0x0f) | ((val << 4) & 0xf0);
b[index] = (short int) ((b[index] & 0x0f) | ((val << 4) & 0xf0));
b[index + 1] = (val >> 4 ) & 0xff;
return 0;
}

Loading…
Cancel
Save

Powered by TurnKey Linux.