From 55660e29fb634f3589926a03f250e2f5ece8b5bb Mon Sep 17 00:00:00 2001 From: jmclemo6 Date: Mon, 8 Apr 2019 18:18:55 -0400 Subject: [PATCH 01/98] Refactor afsk/main.c to have better formatting and use ifdef guards instead of commenting out logging. --- Makefile | 78 ++++---- afsk/main.c | 527 +++++++++++++++++++++++++++------------------------- 2 files changed, 320 insertions(+), 285 deletions(-) diff --git a/Makefile b/Makefile index 6b5d00dc..ce9a4ed5 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,13 @@ +all: DEBUG_BEHAVIOR= all: libax5043.a all: radioafsk all: radiocw +debug: DEBUG_BEHAVIOR = -DDEBUG_LOGGING +debug: libax5043.a +debug: radioafsk +debug: radiocw + rebuild: clean rebuild: all @@ -44,47 +50,47 @@ libax5043.a: ax5043/spi/ax5043spi.o radiochat: libax5043.a radiochat: chat/chat_main.o - gcc -o radiochat -pthread -L./ chat/chat_main.o -lwiringPi -lax5043 + gcc -std=c99 $(DEBUG_BEHAVIOR) -o radiochat -pthread -L./ chat/chat_main.o -lwiringPi -lax5043 radiocw: libax5043.a radiocw: cw/cw_main.o radiocw: afsk/ax25.o radiocw: afsk/ax5043.o radiocw: afsk/send_afsk.o - gcc -o radiocw -L./ afsk/ax25.o afsk/ax5043.o afsk/send_afsk.o cw/cw_main.o -lwiringPi -lax5043 + gcc -std=c99 $(DEBUG_BEHAVIOR) -o radiocw -L./ afsk/ax25.o afsk/ax5043.o afsk/send_afsk.o cw/cw_main.o -lwiringPi -lax5043 radiopiglatin: libax5043.a radiopiglatin: piglatin/piglatin_main.o - gcc -o radiopiglatin -pedantic -Wall -Wextra -L./ piglatin/piglatin_main.o -lwiringPi -lax5043 + gcc -std=c99 $(DEBUG_BEHAVIOR) -o radiopiglatin -pedantic -Wall -Wextra -L./ piglatin/piglatin_main.o -lwiringPi -lax5043 testax5043tx: libax5043.a testax5043tx: transmit/transmit_main.o - gcc -o testax5043tx -pedantic -Wall -Wextra -L./ transmit/transmit_main.o -lwiringPi -lax5043 + gcc -std=c99 $(DEBUG_BEHAVIOR) -o testax5043tx -pedantic -Wall -Wextra -L./ transmit/transmit_main.o -lwiringPi -lax5043 testax5043rx: libax5043.a testax5043rx: receive/receive_main.o - gcc -o testax5043rx -pedantic -Wall -Wextra -L./ receive/receive_main.o -lwiringPi -lax5043 + gcc -std=c99 $(DEBUG_BEHAVIOR) -o testax5043rx -pedantic -Wall -Wextra -L./ receive/receive_main.o -lwiringPi -lax5043 testax5043init: libax5043.a testax5043init: init/init_main.o - gcc -o testax5043init -pedantic -Wall -Wextra -L./ init/init_main.o -lwiringPi -lax5043 + gcc -std=c99 $(DEBUG_BEHAVIOR) -o testax5043init -pedantic -Wall -Wextra -L./ init/init_main.o -lwiringPi -lax5043 testax50432freq: libax5043.a testax50432freq: transmit2freq/transmit2freq_main.o - gcc -o testax50432freq -pedantic -Wall -Wextra -L./ transmit2freq/transmit2freq_main.o -lwiringPi -lax5043 + gcc -std=c99 $(DEBUG_BEHAVIOR) -o testax50432freq -pedantic -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 -o testafsktx -pedantic -Wall -Wextra -L./ afsktx/ax25.o afsktx/ax5043.o afsktx/main.o -lwiringPi -lax5043 + gcc -std=c99 $(DEBUG_BEHAVIOR) -o testafsktx -pedantic -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 radioafsk: afsk/ina219.h - gcc -o radioafsk -pedantic -Wall -Wextra -L./ afsk/ax25.o afsk/ax5043.o afsk/main.o -lwiringPi -lax5043 + gcc -std=c99 $(DEBUG_BEHAVIOR) -o radioafsk -pedantic -Wall -Wextra -L./ afsk/ax25.o afsk/ax5043.o afsk/main.o -lwiringPi -lax5043 ax5043/generated/configcommon.o: ax5043/generated/configcommon.c @@ -92,19 +98,19 @@ 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 -pedantic -Wall -Wextra -c configcommon.c + cd ax5043/generated; gcc -std=c99 $(DEBUG_BEHAVIOR) -pedantic -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 -pedantic -Wall -Wextra -c configrx.c + cd ax5043/generated; gcc -std=c99 $(DEBUG_BEHAVIOR) -pedantic -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 -pedantic -Wall -Wextra -c configtx.c + cd ax5043/generated; gcc -std=c99 $(DEBUG_BEHAVIOR) -pedantic -Wall -Wextra -c configtx.c ax5043/generated/config.o: ax5043/generated/config.c ax5043/generated/config.o: ax5043/generated/config.h @@ -113,12 +119,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 -pedantic -Wall -Wextra -c config.c + cd ax5043/generated; gcc -std=c99 $(DEBUG_BEHAVIOR) -pedantic -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 -pedantic -Wall -Wextra -c ax5043spi.c + cd ax5043/spi; gcc -std=c99 $(DEBUG_BEHAVIOR) -pedantic -Wall -Wextra -c ax5043spi.c ax5043/ax5043support/ax5043init.o: ax5043/ax5043support/ax5043init.c ax5043/ax5043support/ax5043init.o: ax5043/ax5043support/ax5043init.h @@ -126,7 +132,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 -pedantic -Wall -Wextra -c ax5043init.c + cd ax5043/ax5043support; gcc -std=c99 $(DEBUG_BEHAVIOR) -pedantic -Wall -Wextra -c ax5043init.c ax5043/ax5043support/ax5043rx.o: ax5043/ax5043support/ax5043rx.c ax5043/ax5043support/ax5043rx.o: ax5043/ax5043support/ax5043rx.h @@ -134,7 +140,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 -pedantic -Wall -Wextra -c ax5043rx.c + cd ax5043/ax5043support; gcc -std=c99 $(DEBUG_BEHAVIOR) -pedantic -Wall -Wextra -c ax5043rx.c ax5043/ax5043support/ax5043tx.o: ax5043/ax5043support/ax5043tx.c ax5043/ax5043support/ax5043tx.o: ax5043/ax5043support/ax5043tx.h @@ -142,7 +148,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 -pedantic -Wall -Wextra -c ax5043tx.c + cd ax5043/ax5043support; gcc -std=c99 $(DEBUG_BEHAVIOR) -pedantic -Wall -Wextra -c ax5043tx.c ax5043/axradio/axradioinit.o: ax5043/axradio/axradioinit.c ax5043/axradio/axradioinit.o: ax5043/axradio/axradioinit.h @@ -152,7 +158,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 -pedantic -Wall -Wextra -c axradioinit.c + cd ax5043/axradio; gcc -std=c99 $(DEBUG_BEHAVIOR) -pedantic -Wall -Wextra -c axradioinit.c ax5043/axradio/axradiomode.o: ax5043/axradio/axradiomode.c ax5043/axradio/axradiomode.o: ax5043/axradio/axradiomode.h @@ -162,7 +168,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 -pedantic -Wall -Wextra -c axradiomode.c + cd ax5043/axradio; gcc -std=c99 $(DEBUG_BEHAVIOR) -pedantic -Wall -Wextra -c axradiomode.c ax5043/axradio/axradiorx.o: ax5043/axradio/axradiorx.c ax5043/axradio/axradiorx.o: ax5043/axradio/axradiorx.h @@ -172,7 +178,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 -pedantic -Wall -Wextra -c axradiorx.c + cd ax5043/axradio; gcc -std=c99 $(DEBUG_BEHAVIOR) -pedantic -Wall -Wextra -c axradiorx.c ax5043/axradio/axradiotx.o: ax5043/axradio/axradiotx.c ax5043/axradio/axradiotx.o: ax5043/axradio/axradiotx.h @@ -186,11 +192,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 -pedantic -Wall -Wextra -c axradiotx.c + cd ax5043/axradio; gcc -std=c99 $(DEBUG_BEHAVIOR) -pedantic -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 -pedantic -Wall -Wextra -c crc.c + cd ax5043/crc; gcc -std=c99 $(DEBUG_BEHAVIOR) -pedantic -Wall -Wextra -c crc.c chat/chat_main.o: chat/chat_main.c chat/chat_main.o: ax5043/spi/ax5043spi.h @@ -204,13 +210,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 -I../ax5043 -pedantic -Wconversion -Wall -Wextra -c chat_main.c; cd .. + cd chat; gcc -std=c99 $(DEBUG_BEHAVIOR) -I../ax5043 -pedantic -Wconversion -Wall -Wextra -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 -I ../ax5043 -pedantic -Wconversion -Wall -Wextra -c ax25.c; cd .. + cd afsk; gcc -std=c99 $(DEBUG_BEHAVIOR) -I ../ax5043 -pedantic -Wconversion -Wall -Wextra -c ax25.c; cd .. afsk/ax5043.o: afsk/ax5043.c afsk/ax5043.o: afsk/ax25.h @@ -219,21 +225,21 @@ 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 -I ../ax5043 -pedantic -Wconversion -Wall -Wextra -c ax5043.c; cd .. + cd afsk; gcc -std=c99 $(DEBUG_BEHAVIOR) -I ../ax5043 -pedantic -Wconversion -Wall -Wextra -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 -I ../ax5043 -pedantic -Wconversion -Wall -Wextra -c main.c; cd .. + cd afsk; gcc -std=c99 $(DEBUG_BEHAVIOR) -I ../ax5043 -pedantic -Wconversion -Wall -Wextra -c main.c; cd .. afsk/send_afsk.o: afsk/send_afsk.c afsk/send_afsk.o: afsk/send_afsk.h afsk/send_afsk.o: afsk/status.h afsk/send_afsk.o: afsk/ax5043.h afsk/send_afsk.o: afsk/ax25.h - cd afsk; gcc -I ../ax5043 -pedantic -Wconversion -Wall -Wextra -c send_afsk.c; cd .. + cd afsk; gcc -std=c99 $(DEBUG_BEHAVIOR) -I ../ax5043 -pedantic -Wconversion -Wall -Wextra -c send_afsk.c; cd .. cw/cw_main.o: cw/cw_main.c cw/cw_main.o: ax5043/spi/ax5043spi.h @@ -247,7 +253,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 -I../ax5043 -pedantic -Wconversion -Wall -Wextra -c cw_main.c; cd .. + cd cw; gcc -std=c99 $(DEBUG_BEHAVIOR) -I../ax5043 -pedantic -Wconversion -Wall -Wextra -c cw_main.c; cd .. piglatin/piglatin_main.o: piglatin/piglatin_main.c piglatin/piglatin_main.o: ax5043/spi/ax5043spi.h @@ -261,7 +267,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 -I ../ax5043 -pedantic -Wconversion -Wall -Wextra -c piglatin_main.c; cd .. + cd piglatin; gcc -std=c99 $(DEBUG_BEHAVIOR) -I ../ax5043 -pedantic -Wconversion -Wall -Wextra -c piglatin_main.c; cd .. receive/receive_main.o: receive/receive_main.c receive/receive_main.o: ax5043/axradio/axradioinit.h @@ -273,7 +279,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 -I ../ax5043 -pedantic -Wconversion -Wall -Wextra -c receive_main.c; cd .. + cd receive; gcc -std=c99 $(DEBUG_BEHAVIOR) -I ../ax5043 -pedantic -Wconversion -Wall -Wextra -c receive_main.c; cd .. transmit/transmit_main.o: transmit/transmit_main.c transmit/transmit_main.o: ax5043/axradio/axradioinit.h @@ -285,7 +291,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 -I ../ax5043 -pedantic -Wconversion -Wall -Wextra -c transmit_main.c; cd .. + cd transmit; gcc -std=c99 $(DEBUG_BEHAVIOR) -I ../ax5043 -pedantic -Wconversion -Wall -Wextra -c transmit_main.c; cd .. transmit2freq/transmit2freq_main.o: transmit2freq/transmit2freq_main.c transmit2freq/transmit2freq_main.o: ax5043/axradio/axradioinit.h @@ -297,20 +303,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 -I ../ax5043 -pedantic -Wconversion -Wall -Wextra -c transmit2freq_main.c; cd .. + cd transmit2freq; gcc -std=c99 $(DEBUG_BEHAVIOR) -I ../ax5043 -pedantic -Wconversion -Wall -Wextra -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 -I ../ax5043 -pedantic -Wconversion -Wall -Wextra -c init_main.c; cd .. + cd init; gcc -std=c99 $(DEBUG_BEHAVIOR) -I ../ax5043 -pedantic -Wconversion -Wall -Wextra -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 -I ../ax5043 -pedantic -Wconversion -Wall -Wextra -c ax25.c; cd .. + cd afsktx; gcc -std=c99 $(DEBUG_BEHAVIOR) -I ../ax5043 -pedantic -Wconversion -Wall -Wextra -c ax25.c; cd .. afsktx/ax5043.o: afsktx/ax5043.c afsktx/ax5043.o: afsktx/ax25.h @@ -318,11 +324,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 -I ../ax5043 -pedantic -Wconversion -Wall -Wextra -c ax5043.c; cd .. + cd afsktx; gcc -std=c99 $(DEBUG_BEHAVIOR) -I ../ax5043 -pedantic -Wconversion -Wall -Wextra -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 -I ../ax5043 -pedantic -Wconversion -Wall -Wextra -c main.c; cd .. + cd afsktx; gcc -std=c99 $(DEBUG_BEHAVIOR) -I ../ax5043 -pedantic -Wconversion -Wall -Wextra -c main.c; cd .. diff --git a/afsk/main.c b/afsk/main.c index ea4a98fd..4f25fed4 100644 --- a/afsk/main.c +++ b/afsk/main.c @@ -90,7 +90,6 @@ int z_fd; // I2C bos 0 address 0x44 int main(void) { - wiringPiSetup () ; pinMode (0, OUTPUT) ; int blink; @@ -99,179 +98,193 @@ int main(void) { digitalWrite (0, HIGH) ; delay (500) ; digitalWrite (0, LOW) ; delay (500) ; } - digitalWrite (0, HIGH) ; - - setSpiChannel(SPI_CHANNEL); - setSpiSpeed(SPI_SPEED); - initializeSpi(); - - int tlm[7][5]; - memset(tlm, 0, sizeof tlm); - - timestamp = time(NULL); - - int file_i2c; - //char *filenam1e = (char*)"/dev/i2c-3"; - if ((file_i2c = open("/dev/i2c-3", O_RDWR)) < 0) - { - fprintf(stderr,"ERROR: /dev/ic2-3 bus not present\n"); - tempSensor = -1; - } else - { - tempSensor = wiringPiI2CSetupInterface("/dev/i2c-3", 0x48); - } + digitalWrite (0, HIGH) ; + + setSpiChannel(SPI_CHANNEL); + setSpiSpeed(SPI_SPEED); + initializeSpi(); + + int tlm[7][5]; + memset(tlm, 0, sizeof tlm); + + timestamp = time(NULL); + + int file_i2c = open("/dev/i2c-3", O_RDWR); + //char *filenam1e = (char*)"/dev/i2c-3"; + if (file_i2c < 0) + { + fprintf(stderr,"ERROR: /dev/ic2-3 bus not present\n"); + tempSensor = -1; + } else + { + tempSensor = wiringPiI2CSetupInterface("/dev/i2c-3", 0x48); + } -// fprintf(stderr,"tempSensor: %d \n",tempSensor); - - int arduinoI2C; - if ((arduinoI2C = open("/dev/i2c-0", O_RDWR)) < 0) - { - fprintf(stderr,"ERROR: /dev/i2c-0 bus not present\n"); - } else { - arduinoI2C = wiringPiI2CSetupInterface("/dev/i2c-0", 0x4B); -// fprintf(stderr,"arduinoI2C: %d\n", arduinoI2C); - if (arduinoI2C > 0) { - if(wiringPiI2CReadReg16(arduinoI2C,0) < 0) { - arduinoI2C = -1; // Disable reading of Arduino payload information - fprintf(stderr,"Arduino payload not present\n"); - } - } else { - fprintf(stderr,"Arduino payload not present\n"); - } + #ifdef DEBUG_LOGGING + fprintf(stderr,"tempSensor: %d \n",tempSensor); + #endif + + int arduinoI2C = open("dev/i2c-0", O_RDWR); + if (arduinoI2C < 0) + { + fprintf(stderr,"ERROR: /dev/i2c-0 bus not present\n"); + } else { + arduinoI2C = wiringPiI2CSetupInterface("/dev/i2c-0", 0x4B); + + #ifdef DEBUG_LOGGING + fprintf(stderr,"arduinoI2C: %d\n", arduinoI2C); + #endif + + if (arduinoI2C > 0) { + if(wiringPiI2CReadReg16(arduinoI2C,0) < 0) { + arduinoI2C = -1; // Disable reading of Arduino payload information + fprintf(stderr,"Arduino payload not present\n"); + } + } else { + fprintf(stderr,"Arduino payload not present\n"); } + } // new INA219 current reading code - x_calValue = 8192; - x_powerMultiplier = 1; - x_currentDivider = 20; - config = INA219_CONFIG_BVOLTAGERANGE_16V | - INA219_CONFIG_GAIN_40MV | - INA219_CONFIG_BADCRES_12BIT | - INA219_CONFIG_SADCRES_12BIT_4S_2130US | - //INA219_CONFIG_SADCRES_12BIT_1S_532US | - INA219_CONFIG_MODE_SANDBVOLT_CONTINUOUS; - - if ((file_i2c = open("/dev/i2c-0", O_RDWR)) < 0) - { - fprintf(stderr,"ERROR: /dev/ic2-0 bus not present\n"); - x_fd = -1; // Disable reading -X, -Y, and -Z telemetry - y_fd = -1; - z_fd = -1; - } else - { - x_fd = wiringPiI2CSetupInterface("/dev/i2c-0", 0x40); -// fprintf(stderr,"Opening of -X fd %d\n", x_fd); - y_fd = wiringPiI2CSetupInterface("/dev/i2c-0", 0x41); -// printf("Opening of -Y fd %d\n", y_fd); - z_fd = wiringPiI2CSetupInterface("/dev/i2c-0", 0x44); -// printf("Opening of -Z fd %d\n", z_fd); - } - - int ret; - uint8_t data[1024]; + x_calValue = 8192; + x_powerMultiplier = 1; + x_currentDivider = 20; + config = INA219_CONFIG_BVOLTAGERANGE_16V | + INA219_CONFIG_GAIN_40MV | + INA219_CONFIG_BADCRES_12BIT | + INA219_CONFIG_SADCRES_12BIT_4S_2130US | + //INA219_CONFIG_SADCRES_12BIT_1S_532US | + INA219_CONFIG_MODE_SANDBVOLT_CONTINUOUS; + + if ((file_i2c = open("/dev/i2c-0", O_RDWR)) < 0) + { + fprintf(stderr,"ERROR: /dev/ic2-0 bus not present\n"); + x_fd = -1; // Disable reading -X, -Y, and -Z telemetry + y_fd = -1; + z_fd = -1; + } else + { + x_fd = wiringPiI2CSetupInterface("/dev/i2c-0", 0x40); + y_fd = wiringPiI2CSetupInterface("/dev/i2c-0", 0x41); + z_fd = wiringPiI2CSetupInterface("/dev/i2c-0", 0x44); + + #ifdef DEBUG_LOGGING + fprintf(stderr, "Opening of -X fd %d\n", x_fd); + fprintf(stderr, "Opening of -Y fd %d\n", y_fd); + fprintf(stderr, "Opening of -Z fd %d\n", z_fd); + #endif + } - tx_freq_hz -= tx_channel * 50000; + int ret; + uint8_t data[1024]; - init_rf(); + tx_freq_hz -= tx_channel * 50000; + + init_rf(); // ax25_init(&hax25, (uint8_t *) "CubeSatSim", '2', (uint8_t *) CALLSIGN, '2', - ax25_init(&hax25, (uint8_t *) "CQ", '1', (uint8_t *) CALLSIGN, '1', - AX25_PREAMBLE_LEN, - AX25_POSTAMBLE_LEN); - - - /* Infinite loop */ - for (;;) { - sleep(1); - - fprintf(stderr,"INFO: Getting TLM Data\n"); - - get_tlm(tlm); - - fprintf(stderr,"INFO: Preparing X.25 packet\n"); - - char str[1000]; - char tlm_str[1000]; - - char header_str[] = "\x03\xf0hi hi "; - strcpy(str, header_str); - - int channel; - for (channel = 1; channel < 7; channel++) { -// printf("%d %d %d %d \n", tlm[channel][1], tlm[channel][2], tlm[channel][3], tlm[channel][4]); - sprintf(tlm_str, "%d%d%d %d%d%d %d%d%d %d%d%d ", - channel, upper_digit(tlm[channel][1]), lower_digit(tlm[channel][1]), - channel, upper_digit(tlm[channel][2]), lower_digit(tlm[channel][2]), - channel, upper_digit(tlm[channel][3]), lower_digit(tlm[channel][3]), - channel, upper_digit(tlm[channel][4]), lower_digit(tlm[channel][4])); - printf("%s \n",tlm_str); - strcat(str, tlm_str); - } - - if (arduinoI2C > 0) { /* Read Arduino payload */ - for(int reg = 0; reg < 4; reg++) { - sprintf(tlm_str, " %04x",wiringPiI2CReadReg16(arduinoI2C,reg)); - printf("%s \n",tlm_str); - strcat(str,tlm_str); /* Append payload telemetry */ - usleep(100000); - } - } - - digitalWrite (0, LOW); - + ax25_init(&hax25, (uint8_t *) "CQ", '1', (uint8_t *) CALLSIGN, '1', + AX25_PREAMBLE_LEN, + AX25_POSTAMBLE_LEN); + + + /* Infinite loop */ + for (;;) { + sleep(1); + + fprintf(stderr,"INFO: Getting TLM Data\n"); + + get_tlm(tlm); + + fprintf(stderr,"INFO: Preparing X.25 packet\n"); + + char str[1000]; + char tlm_str[1000]; + + char header_str[] = "\x03\xf0hi hi "; + strcpy(str, header_str); + + int channel; + for (channel = 1; channel < 7; channel++) { + #ifdef DEBUG_LOGGING + printf("%d %d %d %d \n", tlm[channel][1], tlm[channel][2], tlm[channel][3], tlm[channel][4]); + #endif + + sprintf(tlm_str, "%d%d%d %d%d%d %d%d%d %d%d%d ", + channel, upper_digit(tlm[channel][1]), lower_digit(tlm[channel][1]), + channel, upper_digit(tlm[channel][2]), lower_digit(tlm[channel][2]), + channel, upper_digit(tlm[channel][3]), lower_digit(tlm[channel][3]), + channel, upper_digit(tlm[channel][4]), lower_digit(tlm[channel][4])); + printf("%s \n",tlm_str); + strcat(str, tlm_str); + } + + if (arduinoI2C > 0) { /* Read Arduino payload */ + for(int reg = 0; reg < 4; reg++) { + sprintf(tlm_str, " %04x",wiringPiI2CReadReg16(arduinoI2C,reg)); + printf("%s \n",tlm_str); + strcat(str,tlm_str); /* Append payload telemetry */ + usleep(100000); + } + } + + digitalWrite (0, LOW); + /* - char cmdbuffer[1000]; +char cmdbuffer[1000]; - if (charging) { - FILE* file1 = popen("/home/pi/mopower/mpcmd LED_STAT=1", "r"); - fgets(cmdbuffer, 999, file1); - pclose(file1); + if (charging) { + FILE* file1 = popen("/home/pi/mopower/mpcmd LED_STAT=1", "r"); + fgets(cmdbuffer, 999, file1); + pclose(file1); // printf("LED state: %s\n", cmdbuffer); - } + } */ - fprintf(stderr,"INFO: Transmitting X.25 packet\n"); - - memcpy(data, str, strnlen(str, 256)); - ret = ax25_tx_frame(&hax25, &hax5043, data, strnlen(str, 256)); - if (ret) { - fprintf(stderr, - "ERROR: Failed to transmit AX.25 frame with error code %d\n", - ret); - exit(EXIT_FAILURE); - } - ax5043_wait_for_transmit(); - digitalWrite (0, HIGH); - + + fprintf(stderr,"INFO: Transmitting X.25 packet\n"); + + memcpy(data, str, strnlen(str, 256)); + ret = ax25_tx_frame(&hax25, &hax5043, data, strnlen(str, 256)); + if (ret) { + fprintf(stderr, + "ERROR: Failed to transmit AX.25 frame with error code %d\n", + ret); + exit(EXIT_FAILURE); + } + + ax5043_wait_for_transmit(); + digitalWrite (0, HIGH); + /* - FILE* file2 = popen("/home/pi/mopower/mpcmd LED_STAT=0", "r"); - fgets(cmdbuffer, 999, file2); - pclose(file2); + FILE* file2 = popen("/home/pi/mopower/mpcmd LED_STAT=0", "r"); + fgets(cmdbuffer, 999, file2); + pclose(file2); // printf("LED state: %s\n", cmdbuffer); */ - if (ret) { - fprintf(stderr, - "ERROR: Failed to transmit entire AX.25 frame with error code %d\n", - ret); - exit(EXIT_FAILURE); - } + if (ret) { + fprintf(stderr, + "ERROR: Failed to transmit entire AX.25 frame with error code %d\n", + ret); + exit(EXIT_FAILURE); } + } - return 0; + return 0; } static void init_rf() { - int ret; - fprintf(stderr,"Initializing AX5043\n"); - - ret = ax5043_init(&hax5043, XTAL_FREQ_HZ, VCO_INTERNAL); - if (ret != PQWS_SUCCESS) { - fprintf(stderr, - "ERROR: Failed to initialize AX5043 with error code %d\n", ret); - exit(EXIT_FAILURE); - } + int ret; + fprintf(stderr,"Initializing AX5043\n"); + + ret = ax5043_init(&hax5043, XTAL_FREQ_HZ, VCO_INTERNAL); + if (ret != PQWS_SUCCESS) { + fprintf(stderr, + "ERROR: Failed to initialize AX5043 with error code %d\n", ret); + exit(EXIT_FAILURE); + } } // Returns lower digit of a number which must be less than 99 @@ -297,119 +310,135 @@ int upper_digit(int number) { fprintf(stderr,"ERROR: Not a digit in upper_digit!\n"); return digit; } + int get_tlm(int tlm[][5]) { - -// Reading I2C voltage and current sensors - - char cmdbuffer[1000]; - FILE* file = popen("sudo python /home/pi/CubeSatSim/python/readcurrent.py 2>&1", "r"); - fgets(cmdbuffer, 999, file); - pclose(file); - fprintf(stderr,"I2C Sensor data: %s\n", cmdbuffer); - - char ina219[16][20]; // voltage, currents, and power from the INA219 current sensors x4a, x40, x41, x44, and x45. - int i = 0; - char * data2 = strtok (cmdbuffer," "); - - while (data2 != NULL) { - strcpy(ina219[i], data2); - // printf ("ina219[%d]=%s\n",i,ina219[i]); - data2 = strtok (NULL, " "); - i++; - } - - // Reading MoPower telemetry info + // Reading I2C voltage and current sensors + char cmdbuffer[1000]; + FILE* file = popen("sudo python /home/pi/CubeSatSim/python/readcurrent.py 2>&1", "r"); + fgets(cmdbuffer, 999, file); + pclose(file); + fprintf(stderr,"I2C Sensor data: %s\n", cmdbuffer); + + char ina219[16][20]; // voltage, currents, and power from the INA219 current sensors x4a, x40, x41, x44, and x45. + int i = 0; + char * data2 = strtok (cmdbuffer," "); + + while (data2 != NULL) { + strcpy(ina219[i], data2); + #ifdef DEBUG_LOGGING + printf ("ina219[%d]=%s\n",i,ina219[i]); + #endif + data2 = strtok (NULL, " "); + i++; + } + +// Reading MoPower telemetry info /* - file = popen("/home/pi/mopower/mpcmd show data", "r"); + file = popen("/home/pi/mopower/mpcmd show data", "r"); - fgets(cmdbuffer, 999, file); + fgets(cmdbuffer, 999, file); - pclose(file); + pclose(file); // printf("MoPower data: %s\n", cmdbuffer); - char mopower[64][14]; + char mopower[64][14]; // char str[] ="- This, a sample string."; - char * pch; + char * pch; // printf ("Splitting string \"%s\" into tokens:\n",str); // pch = strtok (str," "); - i = 0; - pch = strtok (cmdbuffer," ,.-"); - while (pch != NULL) - { - strcpy(mopower[i], pch); + i = 0; + pch = strtok (cmdbuffer," ,.-"); + while (pch != NULL) + { + strcpy(mopower[i], pch); // printf ("mopwer[%d]=%s\n",i,mopower[i]); // pch); - pch = strtok (NULL, " "); - i++; - } - printf("Battery voltage = %s\n", mopower[16]); - if (strtof(mopower[17],NULL) > -0.5) { - charging = 1; - printf("Charging on\n"); - } - else { - charging = 0; - printf("Charging off\n"); + pch = strtok (NULL, " "); + i++; + } + printf("Battery voltage = %s\n", mopower[16]); + if (strtof(mopower[17],NULL) > -0.5) { +charging = 1; + printf("Charging on\n"); + } + else { +charging = 0; + printf("Charging off\n"); - } + } */ + // read i2c current sensors // - double current = 0, power = 0, y_current = 0, y_power = 0, z_current = 0, z_power = 0; - if (x_fd != -1) { - wiringPiI2CWriteReg16(x_fd, INA219_REG_CALIBRATION, x_calValue); - wiringPiI2CWriteReg16(x_fd, INA219_REG_CONFIG, config); - wiringPiI2CWriteReg16(x_fd, INA219_REG_CALIBRATION, x_calValue); - current = wiringPiI2CReadReg16(x_fd, INA219_REG_CURRENT) / x_currentDivider; - power = wiringPiI2CReadReg16(x_fd, INA219_REG_POWER) * x_powerMultiplier; - wiringPiI2CWriteReg16(y_fd, INA219_REG_CALIBRATION, x_calValue); - wiringPiI2CWriteReg16(y_fd, INA219_REG_CONFIG, config); - wiringPiI2CWriteReg16(y_fd, INA219_REG_CALIBRATION, x_calValue); - y_current = wiringPiI2CReadReg16(y_fd, INA219_REG_CURRENT) / x_currentDivider; - y_power = wiringPiI2CReadReg16(y_fd, INA219_REG_POWER) * x_powerMultiplier; - wiringPiI2CWriteReg16(z_fd, INA219_REG_CALIBRATION, x_calValue); - wiringPiI2CWriteReg16(z_fd, INA219_REG_CONFIG, config); - wiringPiI2CWriteReg16(z_fd, INA219_REG_CALIBRATION, x_calValue); - z_current = wiringPiI2CReadReg16(y_fd, INA219_REG_CURRENT) / x_currentDivider; - z_power = wiringPiI2CReadReg16(y_fd, INA219_REG_POWER) * x_powerMultiplier; - } - printf("-X 0x40 current %4.2f power %4.2f -Y 0x41 current %4.2f power %4.2f -Z 0x44 current %4.2f power %4.2f \n", - current, power, y_current, y_power, z_current, z_power); - -// printf("1B: ina219[%d]: %s val: %f \n", SENSOR_40 + CURRENT, ina219[SENSOR_40 + CURRENT], strtof(ina219[SENSOR_40 + CURRENT], NULL)); - - tlm[1][A] = (int)(strtof(ina219[SENSOR_4A + CURRENT], NULL) / 15 + 0.5) % 100; // Current of 5V supply to Pi - tlm[1][B] = (int) (99.5 - strtof(ina219[SENSOR_40 + CURRENT], NULL)/10) % 100; // +X current [4] - tlm[1][C] = (int) (99.5 - current/10) % 100; // X- current [10] - tlm[1][D] = (int) (99.5 - strtof(ina219[SENSOR_41 + CURRENT], NULL)/10) % 100; // +Y current [7] - - tlm[2][A] = (int) (99.5 - y_current/10) % 100; // -Y current [10] - tlm[2][B] = (int) (99.5 - strtof(ina219[SENSOR_44 + CURRENT], NULL)/10) % 100; // +Z current [10] // was 70/2m transponder power, AO-7 didn't have a Z panel - tlm[2][C] = (int) (99.5 - z_current/10) % 100; // -Z current (was timestamp) - + double current = 0, power = 0, y_current = 0, y_power = 0, z_current = 0, z_power = 0; + if (x_fd != -1) { + wiringPiI2CWriteReg16(x_fd, INA219_REG_CALIBRATION, x_calValue); + wiringPiI2CWriteReg16(x_fd, INA219_REG_CONFIG, config); + wiringPiI2CWriteReg16(x_fd, INA219_REG_CALIBRATION, x_calValue); + current = wiringPiI2CReadReg16(x_fd, INA219_REG_CURRENT) / x_currentDivider; + power = wiringPiI2CReadReg16(x_fd, INA219_REG_POWER) * x_powerMultiplier; + + wiringPiI2CWriteReg16(y_fd, INA219_REG_CALIBRATION, x_calValue); + wiringPiI2CWriteReg16(y_fd, INA219_REG_CONFIG, config); + wiringPiI2CWriteReg16(y_fd, INA219_REG_CALIBRATION, x_calValue); + y_current = wiringPiI2CReadReg16(y_fd, INA219_REG_CURRENT) / x_currentDivider; + y_power = wiringPiI2CReadReg16(y_fd, INA219_REG_POWER) * x_powerMultiplier; + + wiringPiI2CWriteReg16(z_fd, INA219_REG_CALIBRATION, x_calValue); + wiringPiI2CWriteReg16(z_fd, INA219_REG_CONFIG, config); + wiringPiI2CWriteReg16(z_fd, INA219_REG_CALIBRATION, x_calValue); + z_current = wiringPiI2CReadReg16(y_fd, INA219_REG_CURRENT) / x_currentDivider; + z_power = wiringPiI2CReadReg16(y_fd, INA219_REG_POWER) * x_powerMultiplier; + } + printf("-X 0x40 current %4.2f power %4.2f -Y 0x41 current %4.2f power %4.2f -Z 0x44 current %4.2f power %4.2f \n", + current, + power, + y_current, + y_power, + z_current, + z_power); + + #ifdef DEBUG_LOGGING + printf("1B: ina219[%d]: %s val: %f \n", SENSOR_40 + CURRENT, ina219[SENSOR_40 + CURRENT], strtof(ina219[SENSOR_40 + CURRENT], NULL)); + #endif + + tlm[1][A] = (int)(strtof(ina219[SENSOR_4A + CURRENT], NULL) / 15 + 0.5) % 100; // Current of 5V supply to Pi + tlm[1][B] = (int) (99.5 - strtof(ina219[SENSOR_40 + CURRENT], NULL)/10) % 100; // +X current [4] + tlm[1][C] = (int) (99.5 - current/10) % 100; // X- current [10] + tlm[1][D] = (int) (99.5 - strtof(ina219[SENSOR_41 + CURRENT], NULL)/10) % 100; // +Y current [7] + + tlm[2][A] = (int) (99.5 - y_current/10) % 100; // -Y current [10] + tlm[2][B] = (int) (99.5 - strtof(ina219[SENSOR_44 + CURRENT], NULL)/10) % 100; // +Z current [10] // was 70/2m transponder power, AO-7 didn't have a Z panel + tlm[2][C] = (int) (99.5 - z_current/10) % 100; // -Z current (was timestamp) + // tlm[2][C] = (int)((time(NULL) - timestamp) / 15) % 100; - tlm[2][D] = (int)(50.5 + strtof(ina219[SENSOR_45 + CURRENT], NULL)/10.0) % 100; // NiMH Battery current - - tlm[3][A] = abs((int)((strtof(ina219[SENSOR_45 + VOLTAGE], NULL) * 10) - 65.5) % 100); - tlm[3][B] = (int)(strtof(ina219[SENSOR_4A + VOLTAGE], NULL) * 10.0) % 100; // 5V supply to Pi - - if (tempSensor != -1) { - int tempValue = wiringPiI2CReadReg16(tempSensor, 0); -// printf("Read: %x\n", tempValue); - uint8_t upper = (uint8_t) (tempValue >> 8); - uint8_t lower = (uint8_t) (tempValue & 0xff); - float temp = (float)lower + ((float)upper / 0x100); - - tlm[4][A] = (int)((95.8 - temp)/1.48 + 0.5) % 100; - } - tlm[6][B] = 0 ; - tlm[6][D] = 49 + rand() % 3; + tlm[2][D] = (int)(50.5 + strtof(ina219[SENSOR_45 + CURRENT], NULL)/10.0) % 100; // NiMH Battery current + + tlm[3][A] = abs((int)((strtof(ina219[SENSOR_45 + VOLTAGE], NULL) * 10) - 65.5) % 100); + tlm[3][B] = (int)(strtof(ina219[SENSOR_4A + VOLTAGE], NULL) * 10.0) % 100; // 5V supply to Pi + + if (tempSensor != -1) { + int tempValue = wiringPiI2CReadReg16(tempSensor, 0); + #ifdef DEBUG_LOGGING + printf("Read: %x\n", tempValue); + #endif + + uint8_t upper = (uint8_t) (tempValue >> 8); + uint8_t lower = (uint8_t) (tempValue & 0xff); + float temp = (float)lower + ((float)upper / 0x100); + + tlm[4][A] = (int)((95.8 - temp)/1.48 + 0.5) % 100; + } + + tlm[6][B] = 0 ; + tlm[6][D] = 49 + rand() % 3; // Display tlm - int k, j; - for (k = 1; k < 7; k++) { - for (j = 1; j < 5; j++) { - printf(" %2d ", tlm[k][j]); - } + int k, j; + for (k = 1; k < 7; k++) { + for (j = 1; j < 5; j++) { + printf(" %2d ", tlm[k][j]); + } printf("\n"); - } - return 0; + } + + return 0; } From 3dbf81adf83784c0c071db948e803fc8b0f7bfbd Mon Sep 17 00:00:00 2001 From: jmclemo6 Date: Thu, 11 Apr 2019 13:20:30 -0400 Subject: [PATCH 02/98] Change open calls to access --- afsk/main.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/afsk/main.c b/afsk/main.c index 4f25fed4..ab41198a 100644 --- a/afsk/main.c +++ b/afsk/main.c @@ -109,7 +109,7 @@ int main(void) { timestamp = time(NULL); - int file_i2c = open("/dev/i2c-3", O_RDWR); + int file_i2c = access("/dev/i2c-3", W_OK | R_OK); //char *filenam1e = (char*)"/dev/i2c-3"; if (file_i2c < 0) { @@ -124,7 +124,7 @@ int main(void) { fprintf(stderr,"tempSensor: %d \n",tempSensor); #endif - int arduinoI2C = open("dev/i2c-0", O_RDWR); + int arduinoI2C = access("dev/i2c-0", W_OK | R_OK); if (arduinoI2C < 0) { fprintf(stderr,"ERROR: /dev/i2c-0 bus not present\n"); @@ -157,7 +157,8 @@ int main(void) { //INA219_CONFIG_SADCRES_12BIT_1S_532US | INA219_CONFIG_MODE_SANDBVOLT_CONTINUOUS; - if ((file_i2c = open("/dev/i2c-0", O_RDWR)) < 0) + file_i2c = access("/dev/i2c-0", W_OK | R_OK); + if (file_i2c < 0) { fprintf(stderr,"ERROR: /dev/ic2-0 bus not present\n"); x_fd = -1; // Disable reading -X, -Y, and -Z telemetry From 38fcb96a03e03c2d0fd4831294b6976b11b3b6cd Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Thu, 9 May 2019 17:50:27 -0400 Subject: [PATCH 03/98] fixed -Z telem bug --- afsk/main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/afsk/main.c b/afsk/main.c index ab41198a..7230ac2c 100644 --- a/afsk/main.c +++ b/afsk/main.c @@ -386,8 +386,8 @@ charging = 0; wiringPiI2CWriteReg16(z_fd, INA219_REG_CALIBRATION, x_calValue); wiringPiI2CWriteReg16(z_fd, INA219_REG_CONFIG, config); wiringPiI2CWriteReg16(z_fd, INA219_REG_CALIBRATION, x_calValue); - z_current = wiringPiI2CReadReg16(y_fd, INA219_REG_CURRENT) / x_currentDivider; - z_power = wiringPiI2CReadReg16(y_fd, INA219_REG_POWER) * x_powerMultiplier; + z_current = wiringPiI2CReadReg16(z_fd, INA219_REG_CURRENT) / x_currentDivider; + z_power = wiringPiI2CReadReg16(z_fd, INA219_REG_POWER) * x_powerMultiplier; } printf("-X 0x40 current %4.2f power %4.2f -Y 0x41 current %4.2f power %4.2f -Z 0x44 current %4.2f power %4.2f \n", current, From 2d8d802da52ffcef04f91d6c6d4b427aee233421 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sat, 6 Jul 2019 02:23:55 -0400 Subject: [PATCH 04/98] testing c code not working --- afsk/main.c | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/afsk/main.c b/afsk/main.c index 4f90184a..1c83776d 100644 --- a/afsk/main.c +++ b/afsk/main.c @@ -150,14 +150,14 @@ int main(void) { // new INA219 current reading code - x_calValue = 8192; - x_powerMultiplier = 1; - x_currentDivider = 20; - config = INA219_CONFIG_BVOLTAGERANGE_16V | - INA219_CONFIG_GAIN_40MV | + x_calValue = 4096; //8192; + x_powerMultiplier = 2; + x_currentDivider = 10; + config = INA219_CONFIG_BVOLTAGERANGE_32V | + INA219_CONFIG_GAIN_320MV | // 40MV | INA219_CONFIG_BADCRES_12BIT | - INA219_CONFIG_SADCRES_12BIT_4S_2130US | - //INA219_CONFIG_SADCRES_12BIT_1S_532US | + // INA219_CONFIG_SADCRES_12BIT_4S_2130US | + INA219_CONFIG_SADCRES_12BIT_1S_532US | INA219_CONFIG_MODE_SANDBVOLT_CONTINUOUS; if ((file_i2c = open("/dev/i2c-0", O_RDWR)) < 0) @@ -201,7 +201,7 @@ int main(void) { fprintf(stderr,"INFO: Getting TLM Data\n"); - //get_tlm(tlm); + get_tlm(tlm); fprintf(stderr,"INFO: Preparing X.25 packet\n"); @@ -358,6 +358,18 @@ int get_tlm(int tlm[][5]) { if (x_fd != -1) { wiringPiI2CWriteReg16(x_fd, INA219_REG_CALIBRATION, x_calValue); wiringPiI2CWriteReg16(x_fd, INA219_REG_CONFIG, config); + int blink; + for (blink = 1; blink < 20 ;blink++) { + delay(500); + int shuntVolts = wiringPiI2CReadReg16(x_fd, INA219_REG_SHUNTVOLTAGE); // * 0.01; + delay(500); + int busVolts = wiringPiI2CReadReg16(x_fd, INA219_REG_BUSVOLTAGE); // * 0.001; + busVolts = (int16_t)((busVolts >> 3) * 4); + double volts = busVolts * 0.001 + shuntVolts * 0.01; + + printf("********** -X 0x40 volts %4.2f busvoltage %d shutVoltage %d\n", volts, busVolts, shuntVolts); + delay(500); + } wiringPiI2CWriteReg16(x_fd, INA219_REG_CALIBRATION, x_calValue); current = wiringPiI2CReadReg16(x_fd, INA219_REG_CURRENT) / x_currentDivider; power = wiringPiI2CReadReg16(x_fd, INA219_REG_POWER) * x_powerMultiplier; From 45970c7b62f867d3d969e1409f076f65afe8bd5c Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sat, 6 Jul 2019 02:29:51 -0400 Subject: [PATCH 05/98] added Adafruit_INA219 --- Makefile | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 6ea66e39..1109edf5 100644 --- a/Makefile +++ b/Makefile @@ -84,8 +84,11 @@ radioafsk: afsk/ax25.o radioafsk: afsk/ax5043.o radioafsk: afsk/main.o radioafsk: afsk/ina219.h - gcc -o radioafsk -pedantic -Wall -Wextra -L./ afsk/ax25.o afsk/ax5043.o afsk/main.o -lwiringPi -lax5043 +radioafsk: Adafruit_INA219/Adafruit_INA219.o + gcc -o radioafsk -pedantic -Wall -Wextra -L./ afsk/ax25.o afsk/ax5043.o afsk/main.o Adafruit_INA219/Adafruit_INA219.o -lwiringPi -lax5043 +Adafruit_INA219/Adafruit_INA219.o: Adafruit_INA219/Adafruit_INA219.h + cd Adafruit_INA219; gcc -I -pedantic -Wconversion -Wall -Wextra -c Adafruit_INA219.c; cd .. ax5043/generated/configcommon.o: ax5043/generated/configcommon.c ax5043/generated/configcommon.o: ax5043/generated/configrx.h From 3be2f3b5baa9ba68f454d1a348faa686c3f5ac56 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sat, 6 Jul 2019 02:54:27 -0400 Subject: [PATCH 06/98] Update Makefile --- Makefile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Makefile b/Makefile index 1109edf5..209a58bc 100644 --- a/Makefile +++ b/Makefile @@ -85,8 +85,10 @@ radioafsk: afsk/ax5043.o radioafsk: afsk/main.o radioafsk: afsk/ina219.h radioafsk: Adafruit_INA219/Adafruit_INA219.o +radioafsk: Adafruit_INA219/Adafruit_INA219.h gcc -o radioafsk -pedantic -Wall -Wextra -L./ afsk/ax25.o afsk/ax5043.o afsk/main.o Adafruit_INA219/Adafruit_INA219.o -lwiringPi -lax5043 +Adafruit_INA219/Adafruit_INA219.o: Adafruit_INA219/Adafruit_INA219.c Adafruit_INA219/Adafruit_INA219.o: Adafruit_INA219/Adafruit_INA219.h cd Adafruit_INA219; gcc -I -pedantic -Wconversion -Wall -Wextra -c Adafruit_INA219.c; cd .. From 9e0e42617e7da10235f672e2be45d5d823b3d06b Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sat, 6 Jul 2019 03:19:36 -0400 Subject: [PATCH 07/98] added calls to Adafruit_INA219 libs --- afsk/main.c | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/afsk/main.c b/afsk/main.c index 1c83776d..3ca10c39 100644 --- a/afsk/main.c +++ b/afsk/main.c @@ -356,23 +356,34 @@ int get_tlm(int tlm[][5]) { // read i2c current sensors // double current = 0, power = 0, y_current = 0, y_power = 0, z_current = 0, z_power = 0; if (x_fd != -1) { - wiringPiI2CWriteReg16(x_fd, INA219_REG_CALIBRATION, x_calValue); - wiringPiI2CWriteReg16(x_fd, INA219_REG_CONFIG, config); +// wiringPiI2CWriteReg16(x_fd, INA219_REG_CALIBRATION, x_calValue); +// wiringPiI2CWriteReg16(x_fd, INA219_REG_CONFIG, config); + + setCalibration_16V_400mA(x_fd); + int blink; for (blink = 1; blink < 20 ;blink++) { - delay(500); +/* delay(500); int shuntVolts = wiringPiI2CReadReg16(x_fd, INA219_REG_SHUNTVOLTAGE); // * 0.01; delay(500); int busVolts = wiringPiI2CReadReg16(x_fd, INA219_REG_BUSVOLTAGE); // * 0.001; busVolts = (int16_t)((busVolts >> 3) * 4); double volts = busVolts * 0.001 + shuntVolts * 0.01; - + printf("********** -X 0x40 volts %4.2f busvoltage %d shutVoltage %d\n", volts, busVolts, shuntVolts); +*/ + float shuntVolts = getShuntVoltage_mV(x_fd); + float busVolts = getBusVoltage_V(x_fd); + current = getCurrent_mA(x_fd); + power = getPower_mW(x_fd); + + printf("********** -X 0x40 busVolts %4.2f shuntVolts %4.2f current %4.2f power %4.2f \n", busVolts, shuntVolts, current, power); + delay(500); } - wiringPiI2CWriteReg16(x_fd, INA219_REG_CALIBRATION, x_calValue); - current = wiringPiI2CReadReg16(x_fd, INA219_REG_CURRENT) / x_currentDivider; - power = wiringPiI2CReadReg16(x_fd, INA219_REG_POWER) * x_powerMultiplier; +// wiringPiI2CWriteReg16(x_fd, INA219_REG_CALIBRATION, x_calValue); +// current = wiringPiI2CReadReg16(x_fd, INA219_REG_CURRENT) / x_currentDivider; +// power = wiringPiI2CReadReg16(x_fd, INA219_REG_POWER) * x_powerMultiplier; wiringPiI2CWriteReg16(y_fd, INA219_REG_CALIBRATION, x_calValue); wiringPiI2CWriteReg16(y_fd, INA219_REG_CONFIG, config); wiringPiI2CWriteReg16(y_fd, INA219_REG_CALIBRATION, x_calValue); From 34481f4eb4c53dfcd30be86351123971d0e6060e Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sat, 6 Jul 2019 03:21:19 -0400 Subject: [PATCH 08/98] Update main.c --- afsk/main.c | 1 + 1 file changed, 1 insertion(+) diff --git a/afsk/main.c b/afsk/main.c index 3ca10c39..0cfcc657 100644 --- a/afsk/main.c +++ b/afsk/main.c @@ -35,6 +35,7 @@ #include #include #include "ina219.h" +#include "Adafruit_INA219/Adafruit_INA219.h" // Put your callsign here #define CALLSIGN "KU2Y" From 96d3b910a1f6bb13c064e483612d18bcd300444e Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sat, 6 Jul 2019 03:22:32 -0400 Subject: [PATCH 09/98] Update main.c --- afsk/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/afsk/main.c b/afsk/main.c index 0cfcc657..6761c312 100644 --- a/afsk/main.c +++ b/afsk/main.c @@ -35,7 +35,7 @@ #include #include #include "ina219.h" -#include "Adafruit_INA219/Adafruit_INA219.h" +#include "../Adafruit_INA219/Adafruit_INA219.h" // Put your callsign here #define CALLSIGN "KU2Y" From 341356bf33de8b0ed08a7bcfa0caeda852a8a016 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sat, 6 Jul 2019 03:24:40 -0400 Subject: [PATCH 10/98] Update main.c --- afsk/main.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/afsk/main.c b/afsk/main.c index 6761c312..c548f9db 100644 --- a/afsk/main.c +++ b/afsk/main.c @@ -35,7 +35,6 @@ #include #include #include "ina219.h" -#include "../Adafruit_INA219/Adafruit_INA219.h" // Put your callsign here #define CALLSIGN "KU2Y" @@ -70,6 +69,15 @@ int get_tlm(int tlm[][5]); long int timestamp; void config_x25(); void trans_x25(); +void setCalibration_32V_2A(int fd); +void setCalibration_32V_1A(int fd); +void setCalibration_16V_400mA(int fd); +float getBusVoltage_V(int fd); +float getShuntVoltage_mV(int fd); +float getCurrent_mA(int fd); +float getPower_mW(int fd); +void powerSave(int fd, int on); + //long int timestamp; int tempSensor; From d6e1eceb5c74e1314ca5468cf1c239c4c363371e Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sat, 6 Jul 2019 03:47:52 -0400 Subject: [PATCH 11/98] Update main.c --- afsk/main.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/afsk/main.c b/afsk/main.c index c548f9db..87634eb2 100644 --- a/afsk/main.c +++ b/afsk/main.c @@ -177,7 +177,9 @@ int main(void) { z_fd = -1; } else { - x_fd = wiringPiI2CSetupInterface("/dev/i2c-0", 0x40); +// x_fd = wiringPiI2CSetupInterface("/dev/i2c-0", 0x40); + x_fd = wiringPiI2CSetupInterface("/dev/i2c-1", 0x40); + fprintf("stderr,Opening of -X fd %d\n", x_fd); y_fd = wiringPiI2CSetupInterface("/dev/i2c-0", 0x41); printf("Opening of -Y fd %d\n", y_fd); From b893833d6cdc894fe7f2fa53135bda595584a978 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sat, 6 Jul 2019 15:33:48 -0400 Subject: [PATCH 12/98] Update main.c --- afsk/main.c | 62 ++++++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 52 insertions(+), 10 deletions(-) diff --git a/afsk/main.c b/afsk/main.c index 87634eb2..0b8ce484 100644 --- a/afsk/main.c +++ b/afsk/main.c @@ -61,6 +61,16 @@ #define POWER 2 #define VBATT 15 +#define PLUS_X 0 +#define PLUS_Y 1 +#define PLUS_Z 2 +#define BAT 3 +#define MINUS_X 4 +#define MINUS_Y 5 +#define MINUS_Z 6 +#define BUS 7 +#define OFF -1 + ax5043_conf_t hax5043; ax25_conf_t hax25; @@ -93,6 +103,7 @@ int x_currentDivider; int x_calValue; int y_fd; // I2C bus 0 address 0x41 int z_fd; // I2C bos 0 address 0x44 +int sensor[8]; // 7 current sensors in Solar Power PCB plus one in MoPower UPS V2 int main(void) { @@ -185,6 +196,36 @@ int main(void) { printf("Opening of -Y fd %d\n", y_fd); z_fd = wiringPiI2CSetupInterface("/dev/i2c-0", 0x44); printf("Opening of -Z fd %d\n", z_fd); + + if (open("/dev/i2c-1", O_RDWR)) > 0) // Test if I2C Bus 1 is present + { + sensor[PLUS_X] = wiringPiI2CSetupInterface("/dev/i2c-1", 0x40); + sensor[PLUS_Y] = wiringPiI2CSetupInterface("/dev/i2c-1", 0x41); + sensor[PLUS_Z] = wiringPiI2CSetupInterface("/dev/i2c-1", 0x44); + sensor[BAT] = wiringPiI2CSetupInterface("/dev/i2c-1", 0x45); + sensor[BUS] = wiringPiI2CSetupInterface("/dev/i2c-1", 0x4a); + } else + { + sensor[PLUS_X] = OFF; + sensor[PLUS_Y] = OFF; + sensor[PLUS_Z] = OFF; + sensor[BAT] = OFF; + sensor[BUS] = OFF; + } + if (open("/dev/i2c-0", O_RDWR)) > 0) // Test if I2C Bus 0 is present + { + sensor[MINUS_X] = wiringPiI2CSetupInterface("/dev/i2c-0", 0x40); + sensor[MINUS_Y] = wiringPiI2CSetupInterface("/dev/i2c-0", 0x41); + sensor[MINUS_Z] = wiringPiI2CSetupInterface("/dev/i2c-0", 0x44); + + } else + { + sensor[MINUS_X] = OFF; + sensor[MINUS_Y] = OFF; + sensor[MINUS_Z] = OFF; + } + + } int ret; @@ -365,15 +406,15 @@ int get_tlm(int tlm[][5]) { } */ // read i2c current sensors // - double current = 0, power = 0, y_current = 0, y_power = 0, z_current = 0, z_power = 0; + double current = 0, voltage = 0, power = 0, y_current = 0, y_voltage, y_power = 0, z_current = 0, z_voltage = 0, z_power = 0; if (x_fd != -1) { // wiringPiI2CWriteReg16(x_fd, INA219_REG_CALIBRATION, x_calValue); // wiringPiI2CWriteReg16(x_fd, INA219_REG_CONFIG, config); setCalibration_16V_400mA(x_fd); - int blink; - for (blink = 1; blink < 20 ;blink++) { +// int blink; +// for (blink = 1; blink < 20 ;blink++) { /* delay(500); int shuntVolts = wiringPiI2CReadReg16(x_fd, INA219_REG_SHUNTVOLTAGE); // * 0.01; delay(500); @@ -387,14 +428,14 @@ int get_tlm(int tlm[][5]) { float busVolts = getBusVoltage_V(x_fd); current = getCurrent_mA(x_fd); power = getPower_mW(x_fd); - - printf("********** -X 0x40 busVolts %4.2f shuntVolts %4.2f current %4.2f power %4.2f \n", busVolts, shuntVolts, current, power); + voltage = shuntVolts + busVolts; + printf("-X 0x40 busVolts %4.2f shuntVolts %4.2f current %4.2f power %4.2f \n", busVolts, shuntVolts, current, power); - delay(500); - } -// wiringPiI2CWriteReg16(x_fd, INA219_REG_CALIBRATION, x_calValue); -// current = wiringPiI2CReadReg16(x_fd, INA219_REG_CURRENT) / x_currentDivider; -// power = wiringPiI2CReadReg16(x_fd, INA219_REG_POWER) * x_powerMultiplier; +// delay(500); + // } +/* wiringPiI2CWriteReg16(x_fd, INA219_REG_CALIBRATION, x_calValue); + current = wiringPiI2CReadReg16(x_fd, INA219_REG_CURRENT) / x_currentDivider; + power = wiringPiI2CReadReg16(x_fd, INA219_REG_POWER) * x_powerMultiplier; wiringPiI2CWriteReg16(y_fd, INA219_REG_CALIBRATION, x_calValue); wiringPiI2CWriteReg16(y_fd, INA219_REG_CONFIG, config); wiringPiI2CWriteReg16(y_fd, INA219_REG_CALIBRATION, x_calValue); @@ -405,6 +446,7 @@ int get_tlm(int tlm[][5]) { wiringPiI2CWriteReg16(z_fd, INA219_REG_CALIBRATION, x_calValue); z_current = wiringPiI2CReadReg16(y_fd, INA219_REG_CURRENT) / x_currentDivider; z_power = wiringPiI2CReadReg16(y_fd, INA219_REG_POWER) * x_powerMultiplier; +*/ } printf("-X 0x40 current %4.2f power %4.2f -Y 0x41 current %4.2f power %4.2f -Z 0x44 current %4.2f power %4.2f \n", current, power, y_current, y_power, z_current, z_power); From e4cbde2f88b74b3f085e3ce1127a8cea3dbac125 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sat, 6 Jul 2019 15:41:58 -0400 Subject: [PATCH 13/98] Update main.c --- afsk/main.c | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/afsk/main.c b/afsk/main.c index 0b8ce484..3b4d4f3a 100644 --- a/afsk/main.c +++ b/afsk/main.c @@ -104,6 +104,7 @@ int x_calValue; int y_fd; // I2C bus 0 address 0x41 int z_fd; // I2C bos 0 address 0x44 int sensor[8]; // 7 current sensors in Solar Power PCB plus one in MoPower UPS V2 +float voltsBus[8], voltsShunt[8], current[8], power[8]; int main(void) { @@ -430,7 +431,30 @@ int get_tlm(int tlm[][5]) { power = getPower_mW(x_fd); voltage = shuntVolts + busVolts; printf("-X 0x40 busVolts %4.2f shuntVolts %4.2f current %4.2f power %4.2f \n", busVolts, shuntVolts, current, power); - + + int count; + for (count = 0; count < 8; count++) + { + if (sensor[count] != OFF) + { + voltsShunt[count] = getShuntVoltage_mV(sensor[count]); + voltsBus[count] = getBusVoltage_V(sensor[count]); + current[count] = getCurrent_mA(sensor[count]; + power[count] = getPower_mW(sensor[count]); + } + else + { + voltsShunt[count] = 0; + voltsBus[count] = 0; + current[count] = 0; + power[count] = 0; + } + } + + + + + // delay(500); // } /* wiringPiI2CWriteReg16(x_fd, INA219_REG_CALIBRATION, x_calValue); From 5d3131276eee0ac8049302243e2a3935785a648f Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sat, 6 Jul 2019 15:59:09 -0400 Subject: [PATCH 14/98] Update main.c --- afsk/main.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/afsk/main.c b/afsk/main.c index 3b4d4f3a..dabd2b3a 100644 --- a/afsk/main.c +++ b/afsk/main.c @@ -437,7 +437,8 @@ int get_tlm(int tlm[][5]) { { if (sensor[count] != OFF) { - voltsShunt[count] = getShuntVoltage_mV(sensor[count]); + setCalibration_16V_400mA(sensor[count]); + voltsShunt[count] = getShuntVoltage_mV(sensor[count])/1000; voltsBus[count] = getBusVoltage_V(sensor[count]); current[count] = getCurrent_mA(sensor[count]; power[count] = getPower_mW(sensor[count]); @@ -449,11 +450,10 @@ int get_tlm(int tlm[][5]) { current[count] = 0; power[count] = 0; } - } - - - - + printf(" sensor[%d] voltsBus %4.2f voltsShunt %4.2f current %4.2f power %4.2f \n", + count, busVolts[count], voltsShunt[count], current[count], power[count]); + } + // delay(500); // } @@ -470,11 +470,10 @@ int get_tlm(int tlm[][5]) { wiringPiI2CWriteReg16(z_fd, INA219_REG_CALIBRATION, x_calValue); z_current = wiringPiI2CReadReg16(y_fd, INA219_REG_CURRENT) / x_currentDivider; z_power = wiringPiI2CReadReg16(y_fd, INA219_REG_POWER) * x_powerMultiplier; -*/ } printf("-X 0x40 current %4.2f power %4.2f -Y 0x41 current %4.2f power %4.2f -Z 0x44 current %4.2f power %4.2f \n", current, power, y_current, y_power, z_current, z_power); - +*/ // printf("1B: ina219[%d]: %s val: %f \n", SENSOR_40 + CURRENT, ina219[SENSOR_40 + CURRENT], strtof(ina219[SENSOR_40 + CURRENT], NULL)); tlm[1][A] = (int)(strtof(ina219[SENSOR_4A + CURRENT], NULL) / 15 + 0.5) % 100; // Current of 5V supply to Pi From 61c3790ad3a7dc7239c63bbd277dc419c775e1aa Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sat, 6 Jul 2019 16:00:31 -0400 Subject: [PATCH 15/98] Update main.c --- afsk/main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/afsk/main.c b/afsk/main.c index dabd2b3a..133b68d8 100644 --- a/afsk/main.c +++ b/afsk/main.c @@ -198,7 +198,7 @@ int main(void) { z_fd = wiringPiI2CSetupInterface("/dev/i2c-0", 0x44); printf("Opening of -Z fd %d\n", z_fd); - if (open("/dev/i2c-1", O_RDWR)) > 0) // Test if I2C Bus 1 is present + if ((open("/dev/i2c-1", O_RDWR)) > 0) // Test if I2C Bus 1 is present { sensor[PLUS_X] = wiringPiI2CSetupInterface("/dev/i2c-1", 0x40); sensor[PLUS_Y] = wiringPiI2CSetupInterface("/dev/i2c-1", 0x41); @@ -213,7 +213,7 @@ int main(void) { sensor[BAT] = OFF; sensor[BUS] = OFF; } - if (open("/dev/i2c-0", O_RDWR)) > 0) // Test if I2C Bus 0 is present + if ((open("/dev/i2c-0", O_RDWR)) > 0) // Test if I2C Bus 0 is present { sensor[MINUS_X] = wiringPiI2CSetupInterface("/dev/i2c-0", 0x40); sensor[MINUS_Y] = wiringPiI2CSetupInterface("/dev/i2c-0", 0x41); From 0d51b4646568fb0889098018396c2f2c7f7cd947 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sat, 6 Jul 2019 16:02:11 -0400 Subject: [PATCH 16/98] Update main.c --- afsk/main.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/afsk/main.c b/afsk/main.c index 133b68d8..ffe98214 100644 --- a/afsk/main.c +++ b/afsk/main.c @@ -197,9 +197,11 @@ int main(void) { printf("Opening of -Y fd %d\n", y_fd); z_fd = wiringPiI2CSetupInterface("/dev/i2c-0", 0x44); printf("Opening of -Z fd %d\n", z_fd); - - if ((open("/dev/i2c-1", O_RDWR)) > 0) // Test if I2C Bus 1 is present + + int test; + if (((test = open("/dev/i2c-1", O_RDWR))) > 0) // Test if I2C Bus 1 is present { + close(test); sensor[PLUS_X] = wiringPiI2CSetupInterface("/dev/i2c-1", 0x40); sensor[PLUS_Y] = wiringPiI2CSetupInterface("/dev/i2c-1", 0x41); sensor[PLUS_Z] = wiringPiI2CSetupInterface("/dev/i2c-1", 0x44); @@ -213,8 +215,9 @@ int main(void) { sensor[BAT] = OFF; sensor[BUS] = OFF; } - if ((open("/dev/i2c-0", O_RDWR)) > 0) // Test if I2C Bus 0 is present + if (((test = open("/dev/i2c-0", O_RDWR))) > 0) // Test if I2C Bus 0 is present { + close(test); sensor[MINUS_X] = wiringPiI2CSetupInterface("/dev/i2c-0", 0x40); sensor[MINUS_Y] = wiringPiI2CSetupInterface("/dev/i2c-0", 0x41); sensor[MINUS_Z] = wiringPiI2CSetupInterface("/dev/i2c-0", 0x44); From 0c6805f1cdeb2e949316fa917c65b25029818e5f Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sat, 6 Jul 2019 16:04:38 -0400 Subject: [PATCH 17/98] Update main.c --- afsk/main.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/afsk/main.c b/afsk/main.c index ffe98214..609b9452 100644 --- a/afsk/main.c +++ b/afsk/main.c @@ -57,7 +57,7 @@ #define SENSOR_45 9 #define SENSOR_4A 12 #define VOLTAGE 0 -#define CURRENT 1 +#define CURRENTV 1 #define POWER 2 #define VBATT 15 @@ -479,17 +479,17 @@ int get_tlm(int tlm[][5]) { */ // printf("1B: ina219[%d]: %s val: %f \n", SENSOR_40 + CURRENT, ina219[SENSOR_40 + CURRENT], strtof(ina219[SENSOR_40 + CURRENT], NULL)); - tlm[1][A] = (int)(strtof(ina219[SENSOR_4A + CURRENT], NULL) / 15 + 0.5) % 100; // Current of 5V supply to Pi - tlm[1][B] = (int) (99.5 - strtof(ina219[SENSOR_40 + CURRENT], NULL)/10) % 100; // +X current [4] + tlm[1][A] = (int)(strtof(ina219[SENSOR_4A + CURRENTV], NULL) / 15 + 0.5) % 100; // Current of 5V supply to Pi + tlm[1][B] = (int) (99.5 - strtof(ina219[SENSOR_40 + CURRENTV], NULL)/10) % 100; // +X current [4] tlm[1][C] = (int) (99.5 - current/10) % 100; // X- current [10] - tlm[1][D] = (int) (99.5 - strtof(ina219[SENSOR_41 + CURRENT], NULL)/10) % 100; // +Y current [7] + tlm[1][D] = (int) (99.5 - strtof(ina219[SENSOR_41 + CURRENTV], NULL)/10) % 100; // +Y current [7] tlm[2][A] = (int) (99.5 - y_current/10) % 100; // -Y current [10] - tlm[2][B] = (int) (99.5 - strtof(ina219[SENSOR_44 + CURRENT], NULL)/10) % 100; // +Z current [10] // was 70/2m transponder power, AO-7 didn't have a Z panel + tlm[2][B] = (int) (99.5 - strtof(ina219[SENSOR_44 + CURRENTV], NULL)/10) % 100; // +Z current [10] // was 70/2m transponder power, AO-7 didn't have a Z panel tlm[2][C] = (int) (99.5 - z_current/10) % 100; // -Z current (was timestamp) // tlm[2][C] = (int)((time(NULL) - timestamp) / 15) % 100; - tlm[2][D] = (int)(50.5 + strtof(ina219[SENSOR_45 + CURRENT], NULL)/10.0) % 100; // NiMH Battery current + tlm[2][D] = (int)(50.5 + strtof(ina219[SENSOR_45 + CURRENTV], NULL)/10.0) % 100; // NiMH Battery current tlm[3][A] = abs((int)((strtof(ina219[SENSOR_45 + VOLTAGE], NULL) * 10) - 65.5) % 100); tlm[3][B] = (int)(strtof(ina219[SENSOR_4A + VOLTAGE], NULL) * 10.0) % 100; // 5V supply to Pi From b1f6e12f535baa3a468bb8e7fab5a0f6b241bf5f Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sat, 6 Jul 2019 16:08:41 -0400 Subject: [PATCH 18/98] Update main.c --- afsk/main.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/afsk/main.c b/afsk/main.c index 609b9452..ccd5a1d2 100644 --- a/afsk/main.c +++ b/afsk/main.c @@ -104,7 +104,10 @@ int x_calValue; int y_fd; // I2C bus 0 address 0x41 int z_fd; // I2C bos 0 address 0x44 int sensor[8]; // 7 current sensors in Solar Power PCB plus one in MoPower UPS V2 -float voltsBus[8], voltsShunt[8], current[8], power[8]; +float voltsBus[8]; +float voltsShunt[8]; +float current[8]; +float power[8]; int main(void) { @@ -410,7 +413,7 @@ int get_tlm(int tlm[][5]) { } */ // read i2c current sensors // - double current = 0, voltage = 0, power = 0, y_current = 0, y_voltage, y_power = 0, z_current = 0, z_voltage = 0, z_power = 0; + double x_current = 0, voltage = 0, power = 0, y_current = 0, y_voltage, y_power = 0, z_current = 0, z_voltage = 0, z_power = 0; if (x_fd != -1) { // wiringPiI2CWriteReg16(x_fd, INA219_REG_CALIBRATION, x_calValue); // wiringPiI2CWriteReg16(x_fd, INA219_REG_CONFIG, config); @@ -430,10 +433,10 @@ int get_tlm(int tlm[][5]) { */ float shuntVolts = getShuntVoltage_mV(x_fd); float busVolts = getBusVoltage_V(x_fd); - current = getCurrent_mA(x_fd); + x_current = getCurrent_mA(x_fd); power = getPower_mW(x_fd); voltage = shuntVolts + busVolts; - printf("-X 0x40 busVolts %4.2f shuntVolts %4.2f current %4.2f power %4.2f \n", busVolts, shuntVolts, current, power); + printf("-X 0x40 busVolts %4.2f shuntVolts %4.2f current %4.2f power %4.2f \n", busVolts, shuntVolts, x_current, power); int count; for (count = 0; count < 8; count++) @@ -461,7 +464,7 @@ int get_tlm(int tlm[][5]) { // delay(500); // } /* wiringPiI2CWriteReg16(x_fd, INA219_REG_CALIBRATION, x_calValue); - current = wiringPiI2CReadReg16(x_fd, INA219_REG_CURRENT) / x_currentDivider; + x_current = wiringPiI2CReadReg16(x_fd, INA219_REG_CURRENT) / x_currentDivider; power = wiringPiI2CReadReg16(x_fd, INA219_REG_POWER) * x_powerMultiplier; wiringPiI2CWriteReg16(y_fd, INA219_REG_CALIBRATION, x_calValue); wiringPiI2CWriteReg16(y_fd, INA219_REG_CONFIG, config); @@ -475,13 +478,13 @@ int get_tlm(int tlm[][5]) { z_power = wiringPiI2CReadReg16(y_fd, INA219_REG_POWER) * x_powerMultiplier; } printf("-X 0x40 current %4.2f power %4.2f -Y 0x41 current %4.2f power %4.2f -Z 0x44 current %4.2f power %4.2f \n", - current, power, y_current, y_power, z_current, z_power); + x_current, power, y_current, y_power, z_current, z_power); */ // printf("1B: ina219[%d]: %s val: %f \n", SENSOR_40 + CURRENT, ina219[SENSOR_40 + CURRENT], strtof(ina219[SENSOR_40 + CURRENT], NULL)); tlm[1][A] = (int)(strtof(ina219[SENSOR_4A + CURRENTV], NULL) / 15 + 0.5) % 100; // Current of 5V supply to Pi tlm[1][B] = (int) (99.5 - strtof(ina219[SENSOR_40 + CURRENTV], NULL)/10) % 100; // +X current [4] - tlm[1][C] = (int) (99.5 - current/10) % 100; // X- current [10] + tlm[1][C] = (int) (99.5 - x_current/10) % 100; // X- current [10] tlm[1][D] = (int) (99.5 - strtof(ina219[SENSOR_41 + CURRENTV], NULL)/10) % 100; // +Y current [7] tlm[2][A] = (int) (99.5 - y_current/10) % 100; // -Y current [10] From 89f794331e1dd3d200a29831578e09ccaeff42bb Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sat, 6 Jul 2019 16:09:38 -0400 Subject: [PATCH 19/98] Update main.c --- afsk/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/afsk/main.c b/afsk/main.c index ccd5a1d2..ef43cf37 100644 --- a/afsk/main.c +++ b/afsk/main.c @@ -446,7 +446,7 @@ int get_tlm(int tlm[][5]) { setCalibration_16V_400mA(sensor[count]); voltsShunt[count] = getShuntVoltage_mV(sensor[count])/1000; voltsBus[count] = getBusVoltage_V(sensor[count]); - current[count] = getCurrent_mA(sensor[count]; + current[count] = getCurrent_mA(sensor[count]); power[count] = getPower_mW(sensor[count]); } else From 0a36cc2f07b605299d151bb84c0ee861564b04de Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sat, 6 Jul 2019 16:10:42 -0400 Subject: [PATCH 20/98] Update main.c --- afsk/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/afsk/main.c b/afsk/main.c index ef43cf37..16f7d492 100644 --- a/afsk/main.c +++ b/afsk/main.c @@ -457,7 +457,7 @@ int get_tlm(int tlm[][5]) { power[count] = 0; } printf(" sensor[%d] voltsBus %4.2f voltsShunt %4.2f current %4.2f power %4.2f \n", - count, busVolts[count], voltsShunt[count], current[count], power[count]); + count, voltsBus[count], voltsShunt[count], current[count], power[count]); } From b24d1fcf8315446c8a31e8f407a0bb329699e290 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sat, 6 Jul 2019 16:12:14 -0400 Subject: [PATCH 21/98] Update main.c --- afsk/main.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/afsk/main.c b/afsk/main.c index 16f7d492..b03740ac 100644 --- a/afsk/main.c +++ b/afsk/main.c @@ -413,7 +413,7 @@ int get_tlm(int tlm[][5]) { } */ // read i2c current sensors // - double x_current = 0, voltage = 0, power = 0, y_current = 0, y_voltage, y_power = 0, z_current = 0, z_voltage = 0, z_power = 0; + double x_current = 0, voltage = 0, x_power = 0, y_current = 0, y_voltage, y_power = 0, z_current = 0, z_voltage = 0, z_power = 0; if (x_fd != -1) { // wiringPiI2CWriteReg16(x_fd, INA219_REG_CALIBRATION, x_calValue); // wiringPiI2CWriteReg16(x_fd, INA219_REG_CONFIG, config); @@ -465,7 +465,7 @@ int get_tlm(int tlm[][5]) { // } /* wiringPiI2CWriteReg16(x_fd, INA219_REG_CALIBRATION, x_calValue); x_current = wiringPiI2CReadReg16(x_fd, INA219_REG_CURRENT) / x_currentDivider; - power = wiringPiI2CReadReg16(x_fd, INA219_REG_POWER) * x_powerMultiplier; + x_power = wiringPiI2CReadReg16(x_fd, INA219_REG_POWER) * x_powerMultiplier; wiringPiI2CWriteReg16(y_fd, INA219_REG_CALIBRATION, x_calValue); wiringPiI2CWriteReg16(y_fd, INA219_REG_CONFIG, config); wiringPiI2CWriteReg16(y_fd, INA219_REG_CALIBRATION, x_calValue); @@ -478,7 +478,7 @@ int get_tlm(int tlm[][5]) { z_power = wiringPiI2CReadReg16(y_fd, INA219_REG_POWER) * x_powerMultiplier; } printf("-X 0x40 current %4.2f power %4.2f -Y 0x41 current %4.2f power %4.2f -Z 0x44 current %4.2f power %4.2f \n", - x_current, power, y_current, y_power, z_current, z_power); + x_current, x_power, y_current, y_power, z_current, z_power); */ // printf("1B: ina219[%d]: %s val: %f \n", SENSOR_40 + CURRENT, ina219[SENSOR_40 + CURRENT], strtof(ina219[SENSOR_40 + CURRENT], NULL)); From ed6452ed25413be526862eaf1bbda94c23e64426 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sat, 6 Jul 2019 16:14:40 -0400 Subject: [PATCH 22/98] Update main.c --- afsk/main.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/afsk/main.c b/afsk/main.c index b03740ac..e8b8e269 100644 --- a/afsk/main.c +++ b/afsk/main.c @@ -437,7 +437,8 @@ int get_tlm(int tlm[][5]) { power = getPower_mW(x_fd); voltage = shuntVolts + busVolts; printf("-X 0x40 busVolts %4.2f shuntVolts %4.2f current %4.2f power %4.2f \n", busVolts, shuntVolts, x_current, power); - + + } int count; for (count = 0; count < 8; count++) { From f6a088812697fb92e6031df780ae66c13b6cb44c Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sat, 6 Jul 2019 16:15:59 -0400 Subject: [PATCH 23/98] Update main.c --- afsk/main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/afsk/main.c b/afsk/main.c index e8b8e269..0ad6ab1b 100644 --- a/afsk/main.c +++ b/afsk/main.c @@ -434,9 +434,9 @@ int get_tlm(int tlm[][5]) { float shuntVolts = getShuntVoltage_mV(x_fd); float busVolts = getBusVoltage_V(x_fd); x_current = getCurrent_mA(x_fd); - power = getPower_mW(x_fd); + x_power = getPower_mW(x_fd); voltage = shuntVolts + busVolts; - printf("-X 0x40 busVolts %4.2f shuntVolts %4.2f current %4.2f power %4.2f \n", busVolts, shuntVolts, x_current, power); + printf("-X 0x40 busVolts %4.2f shuntVolts %4.2f current %4.2f power %4.2f \n", busVolts, shuntVolts, x_current, x_power); } int count; From f720278ce41e67ea28765d1f18c0401864b9c591 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sat, 6 Jul 2019 16:51:06 -0400 Subject: [PATCH 24/98] Update main.c --- afsk/main.c | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/afsk/main.c b/afsk/main.c index 0ad6ab1b..b60f8db7 100644 --- a/afsk/main.c +++ b/afsk/main.c @@ -440,7 +440,7 @@ int get_tlm(int tlm[][5]) { } int count; - for (count = 0; count < 8; count++) + for (count = 0; count < 7; count++) { if (sensor[count] != OFF) { @@ -460,7 +460,27 @@ int get_tlm(int tlm[][5]) { printf(" sensor[%d] voltsBus %4.2f voltsShunt %4.2f current %4.2f power %4.2f \n", count, voltsBus[count], voltsShunt[count], current[count], power[count]); } + if (sensor[count] != OFF) // count = 7 MoPower V2 INA219 + { + setCalibration_16V_400mA(sensor[count]); + voltsShunt[count] = getShuntVoltage_mV(sensor[count])/1000; + voltsBus[count] = getBusVoltage_V(sensor[count]); + current[count] = getCurrent_mA(sensor[count]) * 4; + power[count] = getPower_mW(sensor[count]) *2; + } + else + { + voltsShunt[count] = 0; + voltsBus[count] = 0; + current[count] = 0; + power[count] = 0; + } + printf(" sensor[%d] voltsBus %4.2f voltsShunt %4.2f current %4.2f power %4.2f \n", + count, voltsBus[count], voltsShunt[count], current[count], power[count]); + + + // delay(500); // } From 16cd6764596b98e819de178ea8f82448c0ca3aa3 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sun, 7 Jul 2019 01:18:07 -0400 Subject: [PATCH 25/98] Update main.c --- afsk/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/afsk/main.c b/afsk/main.c index b60f8db7..8514ac94 100644 --- a/afsk/main.c +++ b/afsk/main.c @@ -195,7 +195,7 @@ int main(void) { // x_fd = wiringPiI2CSetupInterface("/dev/i2c-0", 0x40); x_fd = wiringPiI2CSetupInterface("/dev/i2c-1", 0x40); - fprintf("stderr,Opening of -X fd %d\n", x_fd); + fprintf(stderr,"Opening of -X fd %d\n", x_fd); y_fd = wiringPiI2CSetupInterface("/dev/i2c-0", 0x41); printf("Opening of -Y fd %d\n", y_fd); z_fd = wiringPiI2CSetupInterface("/dev/i2c-0", 0x44); From cd14848514703bbfe5161b73bba1f04d42df0167 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sun, 7 Jul 2019 01:57:24 -0400 Subject: [PATCH 26/98] Update main.c --- afsk/main.c | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/afsk/main.c b/afsk/main.c index 8514ac94..7cad8c9b 100644 --- a/afsk/main.c +++ b/afsk/main.c @@ -82,6 +82,7 @@ void trans_x25(); void setCalibration_32V_2A(int fd); void setCalibration_32V_1A(int fd); void setCalibration_16V_400mA(int fd); +void setCalibration_16V_2A(int fd); float getBusVoltage_V(int fd); float getShuntVoltage_mV(int fd); float getCurrent_mA(int fd); @@ -460,23 +461,23 @@ int get_tlm(int tlm[][5]) { printf(" sensor[%d] voltsBus %4.2f voltsShunt %4.2f current %4.2f power %4.2f \n", count, voltsBus[count], voltsShunt[count], current[count], power[count]); } - if (sensor[count] != OFF) // count = 7 MoPower V2 INA219 + if (sensor[BUS] != OFF) // For MoPower V2 INA219 { - setCalibration_16V_400mA(sensor[count]); - voltsShunt[count] = getShuntVoltage_mV(sensor[count])/1000; - voltsBus[count] = getBusVoltage_V(sensor[count]); - current[count] = getCurrent_mA(sensor[count]) * 4; - power[count] = getPower_mW(sensor[count]) *2; + setCalibration_16V_2A(sensor[BUS]); + voltsShunt[BUS] = getShuntVoltage_mV(sensor[BUS])/1000; + voltsBus[BUS] = getBusVoltage_V(sensor[BUS]); + current[BUS] = getCurrent_mA(sensor[BUS]) * 4; + power[BUS] = getPower_mW(sensor[BUS]) *2; } else { - voltsShunt[count] = 0; - voltsBus[count] = 0; - current[count] = 0; - power[count] = 0; + voltsShunt[BUS] = 0; + voltsBus[BUS] = 0; + current[BUS] = 0; + power[BUS] = 0; } printf(" sensor[%d] voltsBus %4.2f voltsShunt %4.2f current %4.2f power %4.2f \n", - count, voltsBus[count], voltsShunt[count], current[count], power[count]); + count, voltsBus[BUS], voltsShunt[BUS], current[BUS], power[BUS]); From fbf6fa8c0c2c13e56c78a5c9683954b277751b8f Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sun, 7 Jul 2019 02:01:34 -0400 Subject: [PATCH 27/98] Update main.c --- afsk/main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/afsk/main.c b/afsk/main.c index 7cad8c9b..79122286 100644 --- a/afsk/main.c +++ b/afsk/main.c @@ -466,8 +466,8 @@ int get_tlm(int tlm[][5]) { setCalibration_16V_2A(sensor[BUS]); voltsShunt[BUS] = getShuntVoltage_mV(sensor[BUS])/1000; voltsBus[BUS] = getBusVoltage_V(sensor[BUS]); - current[BUS] = getCurrent_mA(sensor[BUS]) * 4; - power[BUS] = getPower_mW(sensor[BUS]) *2; + current[BUS] = getCurrent_mA(sensor[BUS]); // * 4; + power[BUS] = getPower_mW(sensor[BUS]); // *2; } else { From ced44d2f974c1492761cc7a376ada135f7d926a9 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Wed, 17 Jul 2019 08:33:05 +0000 Subject: [PATCH 28/98] groundstation scripts and configuration files --- groundstation/config_webrx_107.py | 216 ++++++++++++++++++++++++++++++ groundstation/config_webrx_145.py | 216 ++++++++++++++++++++++++++++++ groundstation/config_webrx_440.py | 216 ++++++++++++++++++++++++++++++ groundstation/config_webrx_fm.py | 216 ++++++++++++++++++++++++++++++ groundstation/cubesatsim-lite.sh | 8 ++ groundstation/decode-lite.sh | 10 ++ groundstation/default.conf | 37 +++++ groundstation/gqrx.sh | 16 +++ groundstation/kill_all.sh | 19 +++ groundstation/rtl-tcp-alt.sh | 14 ++ groundstation/rtl-tcp.sh | 14 ++ groundstation/sdr-2m.sh | 15 +++ groundstation/sdr-70cm.sh | 15 +++ groundstation/sdr-fm.sh | 15 +++ 14 files changed, 1027 insertions(+) create mode 100644 groundstation/config_webrx_107.py create mode 100644 groundstation/config_webrx_145.py create mode 100644 groundstation/config_webrx_440.py create mode 100644 groundstation/config_webrx_fm.py create mode 100755 groundstation/cubesatsim-lite.sh create mode 100755 groundstation/decode-lite.sh create mode 100644 groundstation/default.conf create mode 100755 groundstation/gqrx.sh create mode 100755 groundstation/kill_all.sh create mode 100755 groundstation/rtl-tcp-alt.sh create mode 100755 groundstation/rtl-tcp.sh create mode 100755 groundstation/sdr-2m.sh create mode 100755 groundstation/sdr-70cm.sh create mode 100755 groundstation/sdr-fm.sh diff --git a/groundstation/config_webrx_107.py b/groundstation/config_webrx_107.py new file mode 100644 index 00000000..71633d8d --- /dev/null +++ b/groundstation/config_webrx_107.py @@ -0,0 +1,216 @@ +# -*- coding: utf-8 -*- + +""" +config_webrx: configuration options for OpenWebRX + + This file is part of OpenWebRX, + an open-source SDR receiver software with a web UI. + Copyright (c) 2013-2015 by Andras Retzler + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as + published by the Free Software Foundation, either version 3 of the + License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . + + ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + + In addition, as a special exception, the copyright holders + state that config_rtl.py and config_webrx.py are not part of the + Corresponding Source defined in GNU AGPL version 3 section 1. + + (It means that you do not have to redistribute config_rtl.py and + config_webrx.py if you make any changes to these two configuration files, + and use them for running your web service with OpenWebRX.) +""" + +# NOTE: you can find additional information about configuring OpenWebRX in the Wiki: +# https://github.com/simonyiszk/openwebrx/wiki + +# ==== Server settings ==== +web_port=8073 +server_hostname="localhost" # If this contains an incorrect value, the web UI may freeze on load (it can't open websocket) +max_clients=20 + +# ==== Web GUI configuration ==== +receiver_name="ARISS Ground Station" +receiver_location="" +receiver_qra="" +receiver_asl=0 +receiver_ant="monopole" +receiver_device="RTL-SDR" +receiver_admin="ku2y@amsat.org" +receiver_gps=(39.0302,-77.0747) +photo_height=350 +photo_title="Panorama of Budapest from Schönherz Zoltán Dormitory" +photo_desc=""" +You can add your own background photo and receiver information.
+Receiver is operated by: %[RX_ADMIN]
+Device: %[RX_DEVICE]
+Antenna: %[RX_ANT]
+Website: http://localhost +""" + +# ==== sdr.hu listing ==== +# If you want your ham receiver to be listed publicly on sdr.hu, then take the following steps: +# 1. Register at: http://sdr.hu/register +# 2. You will get an unique key by email. Copy it and paste here: +sdrhu_key = "" +# 3. Set this setting to True to enable listing: +sdrhu_public_listing = False + +# ==== DSP/RX settings ==== +fft_fps=9 +fft_size=4096 #Should be power of 2 +fft_voverlap_factor=0.3 #If fft_voverlap_factor is above 0, multiple FFTs will be used for creating a line on the diagram. + +#samp_rate = 250000 +samp_rate = 2400000 +center_freq = 107000000 +rf_gain = 20 #in dB. For an RTL-SDR, rf_gain=0 will set the tuner to auto gain mode, else it will be in manual gain mode. +ppm = 0 + +audio_compression="adpcm" #valid values: "adpcm", "none" +fft_compression="adpcm" #valid values: "adpcm", "none" + +digimodes_enable=False # True #Decoding digimodes come with higher CPU usage. +digimodes_fft_size=1024 + +start_rtl_thread=True + +""" +Note: if you experience audio underruns while CPU usage is 100%, you can: +- decrease `samp_rate`, +- set `fft_voverlap_factor` to 0, +- decrease `fft_fps` and `fft_size`, +- limit the number of users by decreasing `max_clients`. +""" + +# ==== I/Q sources ==== +# (Uncomment the appropriate by removing # characters at the beginning of the corresponding lines.) + +################################################################################################# +# Is my SDR hardware supported? # +# Check here: https://github.com/simonyiszk/openwebrx/wiki#guides-for-receiver-hardware-support # +################################################################################################# + +# You can use other SDR hardware as well, by giving your own command that outputs the I/Q samples... Some examples of configuration are available here (default is RTL-SDR): + +# >> RTL-SDR via rtl_sdr +start_rtl_command="rtl_sdr -s {samp_rate} -f {center_freq} -p {ppm} -g {rf_gain} -".format(rf_gain=rf_gain, center_freq=center_freq, samp_rate=samp_rate, ppm=ppm) +format_conversion="csdr convert_u8_f" + +#lna_gain=8 +#rf_amp=1 +#start_rtl_command="hackrf_transfer -s {samp_rate} -f {center_freq} -g {rf_gain} -l{lna_gain} -a{rf_amp} -r-".format(rf_gain=rf_gain, center_freq=center_freq, samp_rate=samp_rate, ppm=ppm, rf_amp=rf_amp, lna_gain=lna_gain) +#format_conversion="csdr convert_s8_f" +""" +To use a HackRF, compile the HackRF host tools from its "stdout" branch: + git clone https://github.com/mossmann/hackrf/ + cd hackrf + git fetch + git checkout origin/stdout + cd host + mkdir build + cd build + cmake .. -DINSTALL_UDEV_RULES=ON + make + sudo make install +""" + +# >> Sound card SDR (needs ALSA) +# I did not have the chance to properly test it. +#samp_rate = 96000 +#start_rtl_command="arecord -f S16_LE -r {samp_rate} -c2 -".format(samp_rate=samp_rate) +#format_conversion="csdr convert_s16_f | csdr gain_ff 30" + +# >> /dev/urandom test signal source +# samp_rate = 2400000 +# start_rtl_command="cat /dev/urandom | (pv -qL `python -c 'print int({samp_rate} * 2.2)'` 2>&1)".format(rf_gain=rf_gain, center_freq=center_freq, samp_rate=samp_rate) +# format_conversion="csdr convert_u8_f" + +# >> Pre-recorded raw I/Q file as signal source +# You will have to correctly specify: samp_rate, center_freq, format_conversion in order to correctly play an I/Q file. +#start_rtl_command="(while true; do cat my_iq_file.raw; done) | csdr flowcontrol {sr} 20 ".format(sr=samp_rate*2*1.05) +#format_conversion="csdr convert_u8_f" + +#>> The rx_sdr command works with a variety of SDR harware: RTL-SDR, HackRF, SDRplay, UHD, Airspy, Red Pitaya, audio devices, etc. +# It will auto-detect your SDR hardware if the following tools are installed: +# * the vendor provided driver and library, +# * the vendor-specific SoapySDR wrapper library, +# * and SoapySDR itself. +# Check out this article on the OpenWebRX Wiki: https://github.com/simonyiszk/openwebrx/wiki/Using-rx_tools-with-OpenWebRX/ +#start_rtl_command="rx_sdr -F CF32 -s {samp_rate} -f {center_freq} -p {ppm} -g {rf_gain} -".format(rf_gain=rf_gain, center_freq=center_freq, samp_rate=samp_rate, ppm=ppm) +#format_conversion="" + +# >> gr-osmosdr signal source using GNU Radio (follow this guide: https://github.com/simonyiszk/openwebrx/wiki/Using-GrOsmoSDR-as-signal-source) +#start_rtl_command="cat /tmp/osmocom_fifo" +#format_conversion="" + +# ==== Misc settings ==== + +shown_center_freq = center_freq #you can change this if you use an upconverter + +client_audio_buffer_size = 5 +#increasing client_audio_buffer_size will: +# - also increase the latency +# - decrease the chance of audio underruns + +start_freq = center_freq +start_mod = "nfm" #nfm, am, lsb, usb, cw + +iq_server_port = 4951 #TCP port for ncat to listen on. It will send I/Q data over its connections, for internal use in OpenWebRX. It is only accessible from the localhost by default. + +#access_log = "~/openwebrx_access.log" + +# ==== Color themes ==== + +#A guide is available to help you set these values: https://github.com/simonyiszk/openwebrx/wiki/Calibrating-waterfall-display-levels + +### default theme by teejez: +waterfall_colors = "[0x000000ff,0x0000ffff,0x00ffffff,0x00ff00ff,0xffff00ff,0xff0000ff,0xff00ffff,0xffffffff]" +waterfall_min_level = -88 #in dB +waterfall_max_level = -20 +waterfall_auto_level_margin = (5, 40) +### old theme by HA7ILM: +#waterfall_colors = "[0x000000ff,0x2e6893ff, 0x69a5d0ff, 0x214b69ff, 0x9dc4e0ff, 0xfff775ff, 0xff8a8aff, 0xb20000ff]" +#waterfall_min_level = -115 #in dB +#waterfall_max_level = 0 +#waterfall_auto_level_margin = (20, 30) +##For the old colors, you might also want to set [fft_voverlap_factor] to 0. + +#Note: When the auto waterfall level button is clicked, the following happens: +# [waterfall_min_level] = [current_min_power_level] - [waterfall_auto_level_margin[0]] +# [waterfall_max_level] = [current_max_power_level] + [waterfall_auto_level_margin[1]] +# +# ___|____________________________________|____________________________________|____________________________________|___> signal power +# \_waterfall_auto_level_margin[0]_/ |__ current_min_power_level | \_waterfall_auto_level_margin[1]_/ +# current_max_power_level __| + +# 3D view settings +mathbox_waterfall_frequency_resolution = 128 #bins +mathbox_waterfall_history_length = 10 #seconds +mathbox_waterfall_colors = "[0x000000ff,0x2e6893ff, 0x69a5d0ff, 0x214b69ff, 0x9dc4e0ff, 0xfff775ff, 0xff8a8aff, 0xb20000ff]" + +# === Experimental settings === +#Warning! The settings below are very experimental. +csdr_dynamic_bufsize = False # This allows you to change the buffering mode of csdr. +csdr_print_bufsizes = False # This prints the buffer sizes used for csdr processes. +csdr_through = False # Setting this True will print out how much data is going into the DSP chains. + +nmux_memory = 50 #in megabytes. This sets the approximate size of the circular buffer used by nmux. + +#Look up external IP address automatically from icanhazip.com, and use it as [server_hostname] +""" +print "[openwebrx-config] Detecting external IP address..." +import urllib2 +server_hostname=urllib2.urlopen("http://icanhazip.com").read()[:-1] +print "[openwebrx-config] External IP address detected:", server_hostname +""" diff --git a/groundstation/config_webrx_145.py b/groundstation/config_webrx_145.py new file mode 100644 index 00000000..803adff9 --- /dev/null +++ b/groundstation/config_webrx_145.py @@ -0,0 +1,216 @@ +# -*- coding: utf-8 -*- + +""" +config_webrx: configuration options for OpenWebRX + + This file is part of OpenWebRX, + an open-source SDR receiver software with a web UI. + Copyright (c) 2013-2015 by Andras Retzler + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as + published by the Free Software Foundation, either version 3 of the + License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . + + ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + + In addition, as a special exception, the copyright holders + state that config_rtl.py and config_webrx.py are not part of the + Corresponding Source defined in GNU AGPL version 3 section 1. + + (It means that you do not have to redistribute config_rtl.py and + config_webrx.py if you make any changes to these two configuration files, + and use them for running your web service with OpenWebRX.) +""" + +# NOTE: you can find additional information about configuring OpenWebRX in the Wiki: +# https://github.com/simonyiszk/openwebrx/wiki + +# ==== Server settings ==== +web_port=8073 +server_hostname="localhost" # If this contains an incorrect value, the web UI may freeze on load (it can't open websocket) +max_clients=20 + +# ==== Web GUI configuration ==== +receiver_name="ARISS Ground Station" +receiver_location="" +receiver_qra="" +receiver_asl=0 +receiver_ant="monopole" +receiver_device="RTL-SDR" +receiver_admin="ku2y@amsat.org" +receiver_gps=(39.0302,-77.0747) +photo_height=350 +photo_title="Panorama of Budapest from Schönherz Zoltán Dormitory" +photo_desc=""" +You can add your own background photo and receiver information.
+Receiver is operated by: %[RX_ADMIN]
+Device: %[RX_DEVICE]
+Antenna: %[RX_ANT]
+Website: http://localhost +""" + +# ==== sdr.hu listing ==== +# If you want your ham receiver to be listed publicly on sdr.hu, then take the following steps: +# 1. Register at: http://sdr.hu/register +# 2. You will get an unique key by email. Copy it and paste here: +sdrhu_key = "" +# 3. Set this setting to True to enable listing: +sdrhu_public_listing = False + +# ==== DSP/RX settings ==== +fft_fps=9 +fft_size=4096 #Should be power of 2 +fft_voverlap_factor=0.3 #If fft_voverlap_factor is above 0, multiple FFTs will be used for creating a line on the diagram. + +#samp_rate = 250000 +samp_rate = 2400000 +center_freq = 145800000 +rf_gain = 20 #in dB. For an RTL-SDR, rf_gain=0 will set the tuner to auto gain mode, else it will be in manual gain mode. +ppm = 0 + +audio_compression="adpcm" #valid values: "adpcm", "none" +fft_compression="adpcm" #valid values: "adpcm", "none" + +digimodes_enable=False # True #Decoding digimodes come with higher CPU usage. +digimodes_fft_size=1024 + +start_rtl_thread=True + +""" +Note: if you experience audio underruns while CPU usage is 100%, you can: +- decrease `samp_rate`, +- set `fft_voverlap_factor` to 0, +- decrease `fft_fps` and `fft_size`, +- limit the number of users by decreasing `max_clients`. +""" + +# ==== I/Q sources ==== +# (Uncomment the appropriate by removing # characters at the beginning of the corresponding lines.) + +################################################################################################# +# Is my SDR hardware supported? # +# Check here: https://github.com/simonyiszk/openwebrx/wiki#guides-for-receiver-hardware-support # +################################################################################################# + +# You can use other SDR hardware as well, by giving your own command that outputs the I/Q samples... Some examples of configuration are available here (default is RTL-SDR): + +# >> RTL-SDR via rtl_sdr +start_rtl_command="rtl_sdr -s {samp_rate} -f {center_freq} -p {ppm} -g {rf_gain} -".format(rf_gain=rf_gain, center_freq=center_freq, samp_rate=samp_rate, ppm=ppm) +format_conversion="csdr convert_u8_f" + +#lna_gain=8 +#rf_amp=1 +#start_rtl_command="hackrf_transfer -s {samp_rate} -f {center_freq} -g {rf_gain} -l{lna_gain} -a{rf_amp} -r-".format(rf_gain=rf_gain, center_freq=center_freq, samp_rate=samp_rate, ppm=ppm, rf_amp=rf_amp, lna_gain=lna_gain) +#format_conversion="csdr convert_s8_f" +""" +To use a HackRF, compile the HackRF host tools from its "stdout" branch: + git clone https://github.com/mossmann/hackrf/ + cd hackrf + git fetch + git checkout origin/stdout + cd host + mkdir build + cd build + cmake .. -DINSTALL_UDEV_RULES=ON + make + sudo make install +""" + +# >> Sound card SDR (needs ALSA) +# I did not have the chance to properly test it. +#samp_rate = 96000 +#start_rtl_command="arecord -f S16_LE -r {samp_rate} -c2 -".format(samp_rate=samp_rate) +#format_conversion="csdr convert_s16_f | csdr gain_ff 30" + +# >> /dev/urandom test signal source +# samp_rate = 2400000 +# start_rtl_command="cat /dev/urandom | (pv -qL `python -c 'print int({samp_rate} * 2.2)'` 2>&1)".format(rf_gain=rf_gain, center_freq=center_freq, samp_rate=samp_rate) +# format_conversion="csdr convert_u8_f" + +# >> Pre-recorded raw I/Q file as signal source +# You will have to correctly specify: samp_rate, center_freq, format_conversion in order to correctly play an I/Q file. +#start_rtl_command="(while true; do cat my_iq_file.raw; done) | csdr flowcontrol {sr} 20 ".format(sr=samp_rate*2*1.05) +#format_conversion="csdr convert_u8_f" + +#>> The rx_sdr command works with a variety of SDR harware: RTL-SDR, HackRF, SDRplay, UHD, Airspy, Red Pitaya, audio devices, etc. +# It will auto-detect your SDR hardware if the following tools are installed: +# * the vendor provided driver and library, +# * the vendor-specific SoapySDR wrapper library, +# * and SoapySDR itself. +# Check out this article on the OpenWebRX Wiki: https://github.com/simonyiszk/openwebrx/wiki/Using-rx_tools-with-OpenWebRX/ +#start_rtl_command="rx_sdr -F CF32 -s {samp_rate} -f {center_freq} -p {ppm} -g {rf_gain} -".format(rf_gain=rf_gain, center_freq=center_freq, samp_rate=samp_rate, ppm=ppm) +#format_conversion="" + +# >> gr-osmosdr signal source using GNU Radio (follow this guide: https://github.com/simonyiszk/openwebrx/wiki/Using-GrOsmoSDR-as-signal-source) +#start_rtl_command="cat /tmp/osmocom_fifo" +#format_conversion="" + +# ==== Misc settings ==== + +shown_center_freq = center_freq #you can change this if you use an upconverter + +client_audio_buffer_size = 5 +#increasing client_audio_buffer_size will: +# - also increase the latency +# - decrease the chance of audio underruns + +start_freq = center_freq +start_mod = "nfm" #nfm, am, lsb, usb, cw + +iq_server_port = 4951 #TCP port for ncat to listen on. It will send I/Q data over its connections, for internal use in OpenWebRX. It is only accessible from the localhost by default. + +#access_log = "~/openwebrx_access.log" + +# ==== Color themes ==== + +#A guide is available to help you set these values: https://github.com/simonyiszk/openwebrx/wiki/Calibrating-waterfall-display-levels + +### default theme by teejez: +waterfall_colors = "[0x000000ff,0x0000ffff,0x00ffffff,0x00ff00ff,0xffff00ff,0xff0000ff,0xff00ffff,0xffffffff]" +waterfall_min_level = -88 #in dB +waterfall_max_level = -20 +waterfall_auto_level_margin = (5, 40) +### old theme by HA7ILM: +#waterfall_colors = "[0x000000ff,0x2e6893ff, 0x69a5d0ff, 0x214b69ff, 0x9dc4e0ff, 0xfff775ff, 0xff8a8aff, 0xb20000ff]" +#waterfall_min_level = -115 #in dB +#waterfall_max_level = 0 +#waterfall_auto_level_margin = (20, 30) +##For the old colors, you might also want to set [fft_voverlap_factor] to 0. + +#Note: When the auto waterfall level button is clicked, the following happens: +# [waterfall_min_level] = [current_min_power_level] - [waterfall_auto_level_margin[0]] +# [waterfall_max_level] = [current_max_power_level] + [waterfall_auto_level_margin[1]] +# +# ___|____________________________________|____________________________________|____________________________________|___> signal power +# \_waterfall_auto_level_margin[0]_/ |__ current_min_power_level | \_waterfall_auto_level_margin[1]_/ +# current_max_power_level __| + +# 3D view settings +mathbox_waterfall_frequency_resolution = 128 #bins +mathbox_waterfall_history_length = 10 #seconds +mathbox_waterfall_colors = "[0x000000ff,0x2e6893ff, 0x69a5d0ff, 0x214b69ff, 0x9dc4e0ff, 0xfff775ff, 0xff8a8aff, 0xb20000ff]" + +# === Experimental settings === +#Warning! The settings below are very experimental. +csdr_dynamic_bufsize = False # This allows you to change the buffering mode of csdr. +csdr_print_bufsizes = False # This prints the buffer sizes used for csdr processes. +csdr_through = False # Setting this True will print out how much data is going into the DSP chains. + +nmux_memory = 50 #in megabytes. This sets the approximate size of the circular buffer used by nmux. + +#Look up external IP address automatically from icanhazip.com, and use it as [server_hostname] +""" +print "[openwebrx-config] Detecting external IP address..." +import urllib2 +server_hostname=urllib2.urlopen("http://icanhazip.com").read()[:-1] +print "[openwebrx-config] External IP address detected:", server_hostname +""" diff --git a/groundstation/config_webrx_440.py b/groundstation/config_webrx_440.py new file mode 100644 index 00000000..ae31ac35 --- /dev/null +++ b/groundstation/config_webrx_440.py @@ -0,0 +1,216 @@ +# -*- coding: utf-8 -*- + +""" +config_webrx: configuration options for OpenWebRX + + This file is part of OpenWebRX, + an open-source SDR receiver software with a web UI. + Copyright (c) 2013-2015 by Andras Retzler + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as + published by the Free Software Foundation, either version 3 of the + License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . + + ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + + In addition, as a special exception, the copyright holders + state that config_rtl.py and config_webrx.py are not part of the + Corresponding Source defined in GNU AGPL version 3 section 1. + + (It means that you do not have to redistribute config_rtl.py and + config_webrx.py if you make any changes to these two configuration files, + and use them for running your web service with OpenWebRX.) +""" + +# NOTE: you can find additional information about configuring OpenWebRX in the Wiki: +# https://github.com/simonyiszk/openwebrx/wiki + +# ==== Server settings ==== +web_port=8073 +server_hostname="localhost" # If this contains an incorrect value, the web UI may freeze on load (it can't open websocket) +max_clients=20 + +# ==== Web GUI configuration ==== +receiver_name="ARISS Ground Station" +receiver_location="" +receiver_qra="" +receiver_asl=0 +receiver_ant="monopole" +receiver_device="RTL-SDR" +receiver_admin="ku2y@amsat.org" +receiver_gps=(39.0302,-77.0747) +photo_height=350 +photo_title="Panorama of Budapest from Schönherz Zoltán Dormitory" +photo_desc=""" +You can add your own background photo and receiver information.
+Receiver is operated by: %[RX_ADMIN]
+Device: %[RX_DEVICE]
+Antenna: %[RX_ANT]
+Website: http://localhost +""" + +# ==== sdr.hu listing ==== +# If you want your ham receiver to be listed publicly on sdr.hu, then take the following steps: +# 1. Register at: http://sdr.hu/register +# 2. You will get an unique key by email. Copy it and paste here: +sdrhu_key = "" +# 3. Set this setting to True to enable listing: +sdrhu_public_listing = False + +# ==== DSP/RX settings ==== +fft_fps=9 +fft_size=4096 #Should be power of 2 +fft_voverlap_factor=0.3 #If fft_voverlap_factor is above 0, multiple FFTs will be used for creating a line on the diagram. + +samp_rate = 250000 +# samp_rate = 2400000 +center_freq = 440450000 +rf_gain = 5 #in dB. For an RTL-SDR, rf_gain=0 will set the tuner to auto gain mode, else it will be in manual gain mode. +ppm = 0 + +audio_compression="adpcm" #valid values: "adpcm", "none" +fft_compression="adpcm" #valid values: "adpcm", "none" + +digimodes_enable=False # True #Decoding digimodes come with higher CPU usage. +digimodes_fft_size=1024 + +start_rtl_thread=True + +""" +Note: if you experience audio underruns while CPU usage is 100%, you can: +- decrease `samp_rate`, +- set `fft_voverlap_factor` to 0, +- decrease `fft_fps` and `fft_size`, +- limit the number of users by decreasing `max_clients`. +""" + +# ==== I/Q sources ==== +# (Uncomment the appropriate by removing # characters at the beginning of the corresponding lines.) + +################################################################################################# +# Is my SDR hardware supported? # +# Check here: https://github.com/simonyiszk/openwebrx/wiki#guides-for-receiver-hardware-support # +################################################################################################# + +# You can use other SDR hardware as well, by giving your own command that outputs the I/Q samples... Some examples of configuration are available here (default is RTL-SDR): + +# >> RTL-SDR via rtl_sdr +start_rtl_command="rtl_sdr -s {samp_rate} -f {center_freq} -p {ppm} -g {rf_gain} -".format(rf_gain=rf_gain, center_freq=center_freq, samp_rate=samp_rate, ppm=ppm) +format_conversion="csdr convert_u8_f" + +#lna_gain=8 +#rf_amp=1 +#start_rtl_command="hackrf_transfer -s {samp_rate} -f {center_freq} -g {rf_gain} -l{lna_gain} -a{rf_amp} -r-".format(rf_gain=rf_gain, center_freq=center_freq, samp_rate=samp_rate, ppm=ppm, rf_amp=rf_amp, lna_gain=lna_gain) +#format_conversion="csdr convert_s8_f" +""" +To use a HackRF, compile the HackRF host tools from its "stdout" branch: + git clone https://github.com/mossmann/hackrf/ + cd hackrf + git fetch + git checkout origin/stdout + cd host + mkdir build + cd build + cmake .. -DINSTALL_UDEV_RULES=ON + make + sudo make install +""" + +# >> Sound card SDR (needs ALSA) +# I did not have the chance to properly test it. +#samp_rate = 96000 +#start_rtl_command="arecord -f S16_LE -r {samp_rate} -c2 -".format(samp_rate=samp_rate) +#format_conversion="csdr convert_s16_f | csdr gain_ff 30" + +# >> /dev/urandom test signal source +# samp_rate = 2400000 +# start_rtl_command="cat /dev/urandom | (pv -qL `python -c 'print int({samp_rate} * 2.2)'` 2>&1)".format(rf_gain=rf_gain, center_freq=center_freq, samp_rate=samp_rate) +# format_conversion="csdr convert_u8_f" + +# >> Pre-recorded raw I/Q file as signal source +# You will have to correctly specify: samp_rate, center_freq, format_conversion in order to correctly play an I/Q file. +#start_rtl_command="(while true; do cat my_iq_file.raw; done) | csdr flowcontrol {sr} 20 ".format(sr=samp_rate*2*1.05) +#format_conversion="csdr convert_u8_f" + +#>> The rx_sdr command works with a variety of SDR harware: RTL-SDR, HackRF, SDRplay, UHD, Airspy, Red Pitaya, audio devices, etc. +# It will auto-detect your SDR hardware if the following tools are installed: +# * the vendor provided driver and library, +# * the vendor-specific SoapySDR wrapper library, +# * and SoapySDR itself. +# Check out this article on the OpenWebRX Wiki: https://github.com/simonyiszk/openwebrx/wiki/Using-rx_tools-with-OpenWebRX/ +#start_rtl_command="rx_sdr -F CF32 -s {samp_rate} -f {center_freq} -p {ppm} -g {rf_gain} -".format(rf_gain=rf_gain, center_freq=center_freq, samp_rate=samp_rate, ppm=ppm) +#format_conversion="" + +# >> gr-osmosdr signal source using GNU Radio (follow this guide: https://github.com/simonyiszk/openwebrx/wiki/Using-GrOsmoSDR-as-signal-source) +#start_rtl_command="cat /tmp/osmocom_fifo" +#format_conversion="" + +# ==== Misc settings ==== + +shown_center_freq = center_freq #you can change this if you use an upconverter + +client_audio_buffer_size = 5 +#increasing client_audio_buffer_size will: +# - also increase the latency +# - decrease the chance of audio underruns + +start_freq = center_freq +start_mod = "nfm" #nfm, am, lsb, usb, cw + +iq_server_port = 4951 #TCP port for ncat to listen on. It will send I/Q data over its connections, for internal use in OpenWebRX. It is only accessible from the localhost by default. + +#access_log = "~/openwebrx_access.log" + +# ==== Color themes ==== + +#A guide is available to help you set these values: https://github.com/simonyiszk/openwebrx/wiki/Calibrating-waterfall-display-levels + +### default theme by teejez: +waterfall_colors = "[0x000000ff,0x0000ffff,0x00ffffff,0x00ff00ff,0xffff00ff,0xff0000ff,0xff00ffff,0xffffffff]" +waterfall_min_level = -88 #in dB +waterfall_max_level = -20 +waterfall_auto_level_margin = (5, 40) +### old theme by HA7ILM: +#waterfall_colors = "[0x000000ff,0x2e6893ff, 0x69a5d0ff, 0x214b69ff, 0x9dc4e0ff, 0xfff775ff, 0xff8a8aff, 0xb20000ff]" +#waterfall_min_level = -115 #in dB +#waterfall_max_level = 0 +#waterfall_auto_level_margin = (20, 30) +##For the old colors, you might also want to set [fft_voverlap_factor] to 0. + +#Note: When the auto waterfall level button is clicked, the following happens: +# [waterfall_min_level] = [current_min_power_level] - [waterfall_auto_level_margin[0]] +# [waterfall_max_level] = [current_max_power_level] + [waterfall_auto_level_margin[1]] +# +# ___|____________________________________|____________________________________|____________________________________|___> signal power +# \_waterfall_auto_level_margin[0]_/ |__ current_min_power_level | \_waterfall_auto_level_margin[1]_/ +# current_max_power_level __| + +# 3D view settings +mathbox_waterfall_frequency_resolution = 128 #bins +mathbox_waterfall_history_length = 10 #seconds +mathbox_waterfall_colors = "[0x000000ff,0x2e6893ff, 0x69a5d0ff, 0x214b69ff, 0x9dc4e0ff, 0xfff775ff, 0xff8a8aff, 0xb20000ff]" + +# === Experimental settings === +#Warning! The settings below are very experimental. +csdr_dynamic_bufsize = False # This allows you to change the buffering mode of csdr. +csdr_print_bufsizes = False # This prints the buffer sizes used for csdr processes. +csdr_through = False # Setting this True will print out how much data is going into the DSP chains. + +nmux_memory = 50 #in megabytes. This sets the approximate size of the circular buffer used by nmux. + +#Look up external IP address automatically from icanhazip.com, and use it as [server_hostname] +""" +print "[openwebrx-config] Detecting external IP address..." +import urllib2 +server_hostname=urllib2.urlopen("http://icanhazip.com").read()[:-1] +print "[openwebrx-config] External IP address detected:", server_hostname +""" diff --git a/groundstation/config_webrx_fm.py b/groundstation/config_webrx_fm.py new file mode 100644 index 00000000..116bf9e7 --- /dev/null +++ b/groundstation/config_webrx_fm.py @@ -0,0 +1,216 @@ +# -*- coding: utf-8 -*- + +""" +config_webrx: configuration options for OpenWebRX + + This file is part of OpenWebRX, + an open-source SDR receiver software with a web UI. + Copyright (c) 2013-2015 by Andras Retzler + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as + published by the Free Software Foundation, either version 3 of the + License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . + + ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + + In addition, as a special exception, the copyright holders + state that config_rtl.py and config_webrx.py are not part of the + Corresponding Source defined in GNU AGPL version 3 section 1. + + (It means that you do not have to redistribute config_rtl.py and + config_webrx.py if you make any changes to these two configuration files, + and use them for running your web service with OpenWebRX.) +""" + +# NOTE: you can find additional information about configuring OpenWebRX in the Wiki: +# https://github.com/simonyiszk/openwebrx/wiki + +# ==== Server settings ==== +web_port=8073 +server_hostname="localhost" # If this contains an incorrect value, the web UI may freeze on load (it can't open websocket) +max_clients=20 + +# ==== Web GUI configuration ==== +receiver_name="AMSATCubeSat Simulator Ground Station" +receiver_location="" +receiver_qra="" +receiver_asl=0 +receiver_ant="monopole" +receiver_device="RTL-SDR" +receiver_admin="ku2y@amsat.org" +receiver_gps=(39.0302,-77.0747) +photo_height=350 +photo_title="Panorama of Budapest from Schönherz Zoltán Dormitory" +photo_desc=""" +You can add your own background photo and receiver information.
+Receiver is operated by: %[RX_ADMIN]
+Device: %[RX_DEVICE]
+Antenna: %[RX_ANT]
+Website: http://localhost +""" + +# ==== sdr.hu listing ==== +# If you want your ham receiver to be listed publicly on sdr.hu, then take the following steps: +# 1. Register at: http://sdr.hu/register +# 2. You will get an unique key by email. Copy it and paste here: +sdrhu_key = "" +# 3. Set this setting to True to enable listing: +sdrhu_public_listing = False + +# ==== DSP/RX settings ==== +fft_fps=9 +fft_size=4096 #Should be power of 2 +fft_voverlap_factor=0.3 #If fft_voverlap_factor is above 0, multiple FFTs will be used for creating a line on the diagram. + +samp_rate = 250000 +# samp_rate = 2400000 +center_freq = 128000000 +rf_gain = 5 #in dB. For an RTL-SDR, rf_gain=0 will set the tuner to auto gain mode, else it will be in manual gain mode. +ppm = 0 + +audio_compression="adpcm" #valid values: "adpcm", "none" +fft_compression="adpcm" #valid values: "adpcm", "none" + +digimodes_enable=False # True #Decoding digimodes come with higher CPU usage. +digimodes_fft_size=1024 + +start_rtl_thread=True + +""" +Note: if you experience audio underruns while CPU usage is 100%, you can: +- decrease `samp_rate`, +- set `fft_voverlap_factor` to 0, +- decrease `fft_fps` and `fft_size`, +- limit the number of users by decreasing `max_clients`. +""" + +# ==== I/Q sources ==== +# (Uncomment the appropriate by removing # characters at the beginning of the corresponding lines.) + +################################################################################################# +# Is my SDR hardware supported? # +# Check here: https://github.com/simonyiszk/openwebrx/wiki#guides-for-receiver-hardware-support # +################################################################################################# + +# You can use other SDR hardware as well, by giving your own command that outputs the I/Q samples... Some examples of configuration are available here (default is RTL-SDR): + +# >> RTL-SDR via rtl_sdr +start_rtl_command="rtl_sdr -s {samp_rate} -f {center_freq} -p {ppm} -g {rf_gain} -".format(rf_gain=rf_gain, center_freq=center_freq, samp_rate=samp_rate, ppm=ppm) +format_conversion="csdr convert_u8_f" + +#lna_gain=8 +#rf_amp=1 +#start_rtl_command="hackrf_transfer -s {samp_rate} -f {center_freq} -g {rf_gain} -l{lna_gain} -a{rf_amp} -r-".format(rf_gain=rf_gain, center_freq=center_freq, samp_rate=samp_rate, ppm=ppm, rf_amp=rf_amp, lna_gain=lna_gain) +#format_conversion="csdr convert_s8_f" +""" +To use a HackRF, compile the HackRF host tools from its "stdout" branch: + git clone https://github.com/mossmann/hackrf/ + cd hackrf + git fetch + git checkout origin/stdout + cd host + mkdir build + cd build + cmake .. -DINSTALL_UDEV_RULES=ON + make + sudo make install +""" + +# >> Sound card SDR (needs ALSA) +# I did not have the chance to properly test it. +#samp_rate = 96000 +#start_rtl_command="arecord -f S16_LE -r {samp_rate} -c2 -".format(samp_rate=samp_rate) +#format_conversion="csdr convert_s16_f | csdr gain_ff 30" + +# >> /dev/urandom test signal source +# samp_rate = 2400000 +# start_rtl_command="cat /dev/urandom | (pv -qL `python -c 'print int({samp_rate} * 2.2)'` 2>&1)".format(rf_gain=rf_gain, center_freq=center_freq, samp_rate=samp_rate) +# format_conversion="csdr convert_u8_f" + +# >> Pre-recorded raw I/Q file as signal source +# You will have to correctly specify: samp_rate, center_freq, format_conversion in order to correctly play an I/Q file. +#start_rtl_command="(while true; do cat my_iq_file.raw; done) | csdr flowcontrol {sr} 20 ".format(sr=samp_rate*2*1.05) +#format_conversion="csdr convert_u8_f" + +#>> The rx_sdr command works with a variety of SDR harware: RTL-SDR, HackRF, SDRplay, UHD, Airspy, Red Pitaya, audio devices, etc. +# It will auto-detect your SDR hardware if the following tools are installed: +# * the vendor provided driver and library, +# * the vendor-specific SoapySDR wrapper library, +# * and SoapySDR itself. +# Check out this article on the OpenWebRX Wiki: https://github.com/simonyiszk/openwebrx/wiki/Using-rx_tools-with-OpenWebRX/ +#start_rtl_command="rx_sdr -F CF32 -s {samp_rate} -f {center_freq} -p {ppm} -g {rf_gain} -".format(rf_gain=rf_gain, center_freq=center_freq, samp_rate=samp_rate, ppm=ppm) +#format_conversion="" + +# >> gr-osmosdr signal source using GNU Radio (follow this guide: https://github.com/simonyiszk/openwebrx/wiki/Using-GrOsmoSDR-as-signal-source) +#start_rtl_command="cat /tmp/osmocom_fifo" +#format_conversion="" + +# ==== Misc settings ==== + +shown_center_freq = center_freq #you can change this if you use an upconverter + +client_audio_buffer_size = 5 +#increasing client_audio_buffer_size will: +# - also increase the latency +# - decrease the chance of audio underruns + +start_freq = center_freq +start_mod = "nfm" #nfm, am, lsb, usb, cw + +iq_server_port = 4951 #TCP port for ncat to listen on. It will send I/Q data over its connections, for internal use in OpenWebRX. It is only accessible from the localhost by default. + +#access_log = "~/openwebrx_access.log" + +# ==== Color themes ==== + +#A guide is available to help you set these values: https://github.com/simonyiszk/openwebrx/wiki/Calibrating-waterfall-display-levels + +### default theme by teejez: +waterfall_colors = "[0x000000ff,0x0000ffff,0x00ffffff,0x00ff00ff,0xffff00ff,0xff0000ff,0xff00ffff,0xffffffff]" +waterfall_min_level = -88 #in dB +waterfall_max_level = -20 +waterfall_auto_level_margin = (5, 40) +### old theme by HA7ILM: +#waterfall_colors = "[0x000000ff,0x2e6893ff, 0x69a5d0ff, 0x214b69ff, 0x9dc4e0ff, 0xfff775ff, 0xff8a8aff, 0xb20000ff]" +#waterfall_min_level = -115 #in dB +#waterfall_max_level = 0 +#waterfall_auto_level_margin = (20, 30) +##For the old colors, you might also want to set [fft_voverlap_factor] to 0. + +#Note: When the auto waterfall level button is clicked, the following happens: +# [waterfall_min_level] = [current_min_power_level] - [waterfall_auto_level_margin[0]] +# [waterfall_max_level] = [current_max_power_level] + [waterfall_auto_level_margin[1]] +# +# ___|____________________________________|____________________________________|____________________________________|___> signal power +# \_waterfall_auto_level_margin[0]_/ |__ current_min_power_level | \_waterfall_auto_level_margin[1]_/ +# current_max_power_level __| + +# 3D view settings +mathbox_waterfall_frequency_resolution = 128 #bins +mathbox_waterfall_history_length = 10 #seconds +mathbox_waterfall_colors = "[0x000000ff,0x2e6893ff, 0x69a5d0ff, 0x214b69ff, 0x9dc4e0ff, 0xfff775ff, 0xff8a8aff, 0xb20000ff]" + +# === Experimental settings === +#Warning! The settings below are very experimental. +csdr_dynamic_bufsize = False # This allows you to change the buffering mode of csdr. +csdr_print_bufsizes = False # This prints the buffer sizes used for csdr processes. +csdr_through = False # Setting this True will print out how much data is going into the DSP chains. + +nmux_memory = 50 #in megabytes. This sets the approximate size of the circular buffer used by nmux. + +#Look up external IP address automatically from icanhazip.com, and use it as [server_hostname] +""" +print "[openwebrx-config] Detecting external IP address..." +import urllib2 +server_hostname=urllib2.urlopen("http://icanhazip.com").read()[:-1] +print "[openwebrx-config] External IP address detected:", server_hostname +""" diff --git a/groundstation/cubesatsim-lite.sh b/groundstation/cubesatsim-lite.sh new file mode 100755 index 00000000..5a048954 --- /dev/null +++ b/groundstation/cubesatsim-lite.sh @@ -0,0 +1,8 @@ +#!/bin/bash +# script to run CubeSat Simulator Lite +# +# on SDR application, listen at 107.9 + +echo -e "\nScript to run CubeSat Simulator Lite \n" + +sudo /home/pi/CubeSatSim/PiFmRds/src/pi_fm_rds -audio /home/pi/CubeSatSim/wav/afsk2.wav -freq 107.9 diff --git a/groundstation/decode-lite.sh b/groundstation/decode-lite.sh new file mode 100755 index 00000000..4db99571 --- /dev/null +++ b/groundstation/decode-lite.sh @@ -0,0 +1,10 @@ +#!/bin/bash +# script to auto decode CubeSat Simulator telemetry + +# kill openwebrx if it is running +ps -ef | grep rtl | grep -v grep | awk '{print $2}' | sudo xargs kill + +echo -e "Script to auto decode CubeSat Simulator telemetry\n" + +sudo rtl_fm -f 107.906M -M wbfm -s 70000 -g 48 - | multimon-ng -a AFSK1200 -A -t raw - + diff --git a/groundstation/default.conf b/groundstation/default.conf new file mode 100644 index 00000000..ae81605e --- /dev/null +++ b/groundstation/default.conf @@ -0,0 +1,37 @@ +[General] +configversion=2 +crashed=false + +[audio] +gain=224 +udp_host=localhost + +[fft] +fft_size=4096 +split=40 + +[gui] +geometry=@ByteArray(\x1\xd9\xd0\xcb\0\x2\0\0\0\0\0#\0\0\0\x32\0\0\x3\r\0\0\x3\b\0\0\0%\0\0\0P\0\0\x3\r\0\0\x3\b\0\0\0\0\0\0\0\0\x3 ) +state=@ByteArray(\0\0\0\xff\0\0\0\0\xfd\0\0\0\x2\0\0\0\x1\0\0\x1&\0\0\x2\\\xfc\x2\0\0\0\x2\xfc\0\0\0\x43\0\0\x2\\\0\0\x1\x8e\0\b\0!\xfa\0\0\0\x2\x2\0\0\0\x3\xfb\0\0\0\x18\0\x44\0o\0\x63\0k\0I\0n\0p\0u\0t\0\x43\0t\0l\x1\0\0\0\0\xff\xff\xff\xff\0\0\x1\x35\0\xff\xff\xff\xfb\0\0\0\x12\0\x44\0o\0\x63\0k\0R\0x\0O\0p\0t\x1\0\0\0\0\xff\xff\xff\xff\0\0\x1l\0\a\xff\xff\xfb\0\0\0\xe\0\x44\0o\0\x63\0k\0\x46\0\x66\0t\x1\0\0\0\0\xff\xff\xff\xff\0\0\0\xc8\0\a\xff\xff\xfc\0\0\x1\xd7\0\0\0\xc8\0\0\0\0\0\xff\xff\xff\xfa\xff\xff\xff\xff\x2\0\0\0\x2\xfb\0\0\0\x12\0\x44\0o\0\x63\0k\0\x41\0u\0\x64\0i\0o\0\0\0\0\0\xff\xff\xff\xff\0\0\0\xc8\0\xff\xff\xff\xfb\0\0\0\xe\0\x44\0o\0\x63\0k\0R\0\x44\0S\0\0\0\0\0\xff\xff\xff\xff\0\0\0h\0\xff\xff\xff\0\0\0\x3\0\0\x1\xbd\0\0\0\xeb\xfc\x1\0\0\0\x1\xfb\0\0\0\x1a\0\x44\0o\0\x63\0k\0\x42\0o\0o\0k\0m\0\x61\0r\0k\0s\x1\0\0\0\0\0\0\x1\xbd\0\0\x1\x42\0\xff\xff\xff\0\0\x1\xbd\0\0\x1k\0\0\0\x1\0\0\0\x2\0\0\0\b\0\0\0\x2\xfc\0\0\0\x1\0\0\0\x2\0\0\0\x1\0\0\0\x16\0m\0\x61\0i\0n\0T\0o\0o\0l\0\x42\0\x61\0r\x1\0\0\0\0\xff\xff\xff\xff\0\0\0\0\0\0\0\0) + +[input] +bandwidth=2400000 +device="rtl=0" +frequency=98506000 +gains=@Variant(\0\0\0\b\0\0\0\x1\0\0\0\x6\0L\0N\0\x41\0\0\0\x2\0\0\x1\xf0) +sample_rate=512000 + +[output] +device="bcm2835 ALSA: - (hw:0,0)" + +[receiver] +agc_decay=100 +agc_off=true +demod=5 +filter_high_cut=80000 +filter_low_cut=-80000 +offset=-402000 +sql_level=-42.5 + +[remote_control] +allowed_hosts=::ffff:127.0.0.1 diff --git a/groundstation/gqrx.sh b/groundstation/gqrx.sh new file mode 100755 index 00000000..7e995d2e --- /dev/null +++ b/groundstation/gqrx.sh @@ -0,0 +1,16 @@ +#!/bin/bash +# script to auto decode CubeSat Simulator telemetry + +# kill rtl if running +ps -ef | grep rtl | grep -v grep | awk '{print $2}' | sudo xargs kill + +# kill openwebrx process if running +ps -ef | grep openwebrx | grep -v grep | awk '{print $2}' | sudo xargs kill + +# kill csdr process if running +ps -ef | grep csdr | grep -v grep | awk '{print $2}' | sudo xargs kill + +echo -e "Script to run Gqrx\n" + +/home/pi/gqrx-sdr-2.11.5-linux-rpi3/gqrx + diff --git a/groundstation/kill_all.sh b/groundstation/kill_all.sh new file mode 100755 index 00000000..2d9970ec --- /dev/null +++ b/groundstation/kill_all.sh @@ -0,0 +1,19 @@ +#!/bin/bash +# script to kill all SDR or RTL processes +# + +echo -e "\nKilling all SDR or RTL processes \n" + +# kill rtl if running +ps -ef | grep rtl_ | grep -v grep | awk '{print $2}' | sudo xargs kill > /dev/null 2>&1 + +# kill openwebrx process if running +ps -ef | grep openwebrx | grep -v grep | awk '{print $2}' | sudo xargs kill > /dev/null 2>&1 + +# kill csdr process if running +ps -ef | grep csdr | grep -v grep | awk '{print $2}' | sudo xargs kill > /dev/null 2>&1 + +# kill gqrx process if running +ps -ef | grep gqrx-sdr-2.11.5-linux-rpi3/gqrx | grep -v grep | awk '{print $2}' | sudo xargs kill > /dev/null 2>&1 + + diff --git a/groundstation/rtl-tcp-alt.sh b/groundstation/rtl-tcp-alt.sh new file mode 100755 index 00000000..53cb0d6a --- /dev/null +++ b/groundstation/rtl-tcp-alt.sh @@ -0,0 +1,14 @@ +#!/bin/bash +# script to run RTL-TCP Server +# +# On SDR client, use 10.3.141.1:1234 to connect + +echo -e "\nScript to run RTL-TCP Server for ARISS Ground Station\n" + +echo -e "IP Address to use in web browsers is: " + +hostname -I|cut -f1 -d ' ' + +./kill_all.sh + +sudo /bin/sh -c '/usr/local/bin/rtl_tcp -a $(hostname -I|cut -f2 -d " ")' diff --git a/groundstation/rtl-tcp.sh b/groundstation/rtl-tcp.sh new file mode 100755 index 00000000..9559643c --- /dev/null +++ b/groundstation/rtl-tcp.sh @@ -0,0 +1,14 @@ +#!/bin/bash +# script to run RTL-TCP Server +# +# On SDR client, use 10.3.141.1:1234 to connect + +echo -e "\nScript to run RTL-TCP Server for ARISS Ground Station\n" + +echo -e "IP Address to use in web browsers is: " + +hostname -I|cut -f1 -d ' ' + +./kill_all.sh + +sudo /bin/sh -c '/usr/local/bin/rtl_tcp -a $(hostname -I|cut -f1 -d " ")' diff --git a/groundstation/sdr-2m.sh b/groundstation/sdr-2m.sh new file mode 100755 index 00000000..c4e3f963 --- /dev/null +++ b/groundstation/sdr-2m.sh @@ -0,0 +1,15 @@ +#!/bin/bash +# script to run OpenWebRX SDR + +echo -e "\nScript to run SDR for ARISS Ground Station\n" + +echo -e "IP Address to use in web browsers is: " + +hostname -I|cut -f1 -d ' ' + + +./kill_all.sh + +cd ~/openwebrx + +sudo python openwebrx.py config_webrx_145 diff --git a/groundstation/sdr-70cm.sh b/groundstation/sdr-70cm.sh new file mode 100755 index 00000000..f23c82b3 --- /dev/null +++ b/groundstation/sdr-70cm.sh @@ -0,0 +1,15 @@ +#!/bin/bash +# script to run OpenWebRX SDR + +echo -e "\nScript to run SDR for ARISS Ground Station\n" + +echo -e "IP Address to use in web browsers is: " + +hostname -I|cut -f1 -d ' ' + + +./kill_all.sh + +cd ~/openwebrx + +sudo python openwebrx.py config_webrx_440 diff --git a/groundstation/sdr-fm.sh b/groundstation/sdr-fm.sh new file mode 100755 index 00000000..6da6c725 --- /dev/null +++ b/groundstation/sdr-fm.sh @@ -0,0 +1,15 @@ +#!/bin/bash +# script to run OpenWebRX SDR + +echo -e "\nScript to run SDR for ARISS Ground Station\n" + +echo -e "IP Address to use in web browsers is: " + +hostname -I|cut -f1 -d ' ' + + +./kill_all.sh + +cd ~/openwebrx + +sudo python openwebrx.py config_webrx_107 From 4286a09f0f62e0879abdc7c310c994f5d93a6bd8 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Thu, 18 Jul 2019 12:45:15 +0000 Subject: [PATCH 29/98] updates to scripts and config files --- groundstation/aprs.sh | 0 groundstation/config_webrx.py | 4 ++-- groundstation/config_webrx_107.py | 4 ++-- groundstation/config_webrx_145.py | 4 ++-- groundstation/config_webrx_440.py | 4 ++-- groundstation/config_webrx_fm.py | 4 ++-- groundstation/cubesatsim-lite-alt.sh | 8 ++++++++ groundstation/decode.sh | 0 groundstation/ipaddress.sh | 0 groundstation/satnogs_readme.txt | 19 +++++++++++++++++++ groundstation/sdr.sh | 0 11 files changed, 37 insertions(+), 10 deletions(-) mode change 100644 => 100755 groundstation/aprs.sh create mode 100755 groundstation/cubesatsim-lite-alt.sh mode change 100644 => 100755 groundstation/decode.sh mode change 100644 => 100755 groundstation/ipaddress.sh create mode 100644 groundstation/satnogs_readme.txt mode change 100644 => 100755 groundstation/sdr.sh diff --git a/groundstation/aprs.sh b/groundstation/aprs.sh old mode 100644 new mode 100755 diff --git a/groundstation/config_webrx.py b/groundstation/config_webrx.py index a45298bd..1a549578 100644 --- a/groundstation/config_webrx.py +++ b/groundstation/config_webrx.py @@ -40,7 +40,7 @@ server_hostname="localhost" # If this contains an incorrect value, the web UI ma max_clients=20 # ==== Web GUI configuration ==== -receiver_name="AMSATCubeSat Simulator Ground Station" +receiver_name="AMSAT CubeSat Simulator Ground Station" receiver_location="" receiver_qra="" receiver_asl=0 @@ -74,7 +74,7 @@ fft_voverlap_factor=0.3 #If fft_voverlap_factor is above 0, multiple FFTs will b samp_rate = 250000 # samp_rate = 2400000 center_freq = 440450000 -rf_gain = 5 #in dB. For an RTL-SDR, rf_gain=0 will set the tuner to auto gain mode, else it will be in manual gain mode. +rf_gain = 37 #in dB. For an RTL-SDR, rf_gain=0 will set the tuner to auto gain mode, else it will be in manual gain mode. ppm = 0 audio_compression="adpcm" #valid values: "adpcm", "none" diff --git a/groundstation/config_webrx_107.py b/groundstation/config_webrx_107.py index 71633d8d..568e3a9b 100644 --- a/groundstation/config_webrx_107.py +++ b/groundstation/config_webrx_107.py @@ -49,7 +49,7 @@ receiver_device="RTL-SDR" receiver_admin="ku2y@amsat.org" receiver_gps=(39.0302,-77.0747) photo_height=350 -photo_title="Panorama of Budapest from Schönherz Zoltán Dormitory" +photo_title="ARISS - Amateur Radio on the International Space Station" photo_desc=""" You can add your own background photo and receiver information.
Receiver is operated by: %[RX_ADMIN]
@@ -74,7 +74,7 @@ fft_voverlap_factor=0.3 #If fft_voverlap_factor is above 0, multiple FFTs will b #samp_rate = 250000 samp_rate = 2400000 center_freq = 107000000 -rf_gain = 20 #in dB. For an RTL-SDR, rf_gain=0 will set the tuner to auto gain mode, else it will be in manual gain mode. +rf_gain = 37 #in dB. For an RTL-SDR, rf_gain=0 will set the tuner to auto gain mode, else it will be in manual gain mode. ppm = 0 audio_compression="adpcm" #valid values: "adpcm", "none" diff --git a/groundstation/config_webrx_145.py b/groundstation/config_webrx_145.py index 803adff9..549f93f7 100644 --- a/groundstation/config_webrx_145.py +++ b/groundstation/config_webrx_145.py @@ -49,7 +49,7 @@ receiver_device="RTL-SDR" receiver_admin="ku2y@amsat.org" receiver_gps=(39.0302,-77.0747) photo_height=350 -photo_title="Panorama of Budapest from Schönherz Zoltán Dormitory" +photo_title="ARISS - Amateur Radio on the International Space Station" photo_desc=""" You can add your own background photo and receiver information.
Receiver is operated by: %[RX_ADMIN]
@@ -74,7 +74,7 @@ fft_voverlap_factor=0.3 #If fft_voverlap_factor is above 0, multiple FFTs will b #samp_rate = 250000 samp_rate = 2400000 center_freq = 145800000 -rf_gain = 20 #in dB. For an RTL-SDR, rf_gain=0 will set the tuner to auto gain mode, else it will be in manual gain mode. +rf_gain = 37 #in dB. For an RTL-SDR, rf_gain=0 will set the tuner to auto gain mode, else it will be in manual gain mode. ppm = 0 audio_compression="adpcm" #valid values: "adpcm", "none" diff --git a/groundstation/config_webrx_440.py b/groundstation/config_webrx_440.py index ae31ac35..d0725a9b 100644 --- a/groundstation/config_webrx_440.py +++ b/groundstation/config_webrx_440.py @@ -49,7 +49,7 @@ receiver_device="RTL-SDR" receiver_admin="ku2y@amsat.org" receiver_gps=(39.0302,-77.0747) photo_height=350 -photo_title="Panorama of Budapest from Schönherz Zoltán Dormitory" +photo_title="ARISS - Amateur Radio on the International Space Station" photo_desc=""" You can add your own background photo and receiver information.
Receiver is operated by: %[RX_ADMIN]
@@ -74,7 +74,7 @@ fft_voverlap_factor=0.3 #If fft_voverlap_factor is above 0, multiple FFTs will b samp_rate = 250000 # samp_rate = 2400000 center_freq = 440450000 -rf_gain = 5 #in dB. For an RTL-SDR, rf_gain=0 will set the tuner to auto gain mode, else it will be in manual gain mode. +rf_gain = 37 #in dB. For an RTL-SDR, rf_gain=0 will set the tuner to auto gain mode, else it will be in manual gain mode. ppm = 0 audio_compression="adpcm" #valid values: "adpcm", "none" diff --git a/groundstation/config_webrx_fm.py b/groundstation/config_webrx_fm.py index 116bf9e7..fbe61561 100644 --- a/groundstation/config_webrx_fm.py +++ b/groundstation/config_webrx_fm.py @@ -49,7 +49,7 @@ receiver_device="RTL-SDR" receiver_admin="ku2y@amsat.org" receiver_gps=(39.0302,-77.0747) photo_height=350 -photo_title="Panorama of Budapest from Schönherz Zoltán Dormitory" +photo_title="ARISS - Amateur Radio on the International Space Station" photo_desc=""" You can add your own background photo and receiver information.
Receiver is operated by: %[RX_ADMIN]
@@ -74,7 +74,7 @@ fft_voverlap_factor=0.3 #If fft_voverlap_factor is above 0, multiple FFTs will b samp_rate = 250000 # samp_rate = 2400000 center_freq = 128000000 -rf_gain = 5 #in dB. For an RTL-SDR, rf_gain=0 will set the tuner to auto gain mode, else it will be in manual gain mode. +rf_gain = 37 #in dB. For an RTL-SDR, rf_gain=0 will set the tuner to auto gain mode, else it will be in manual gain mode. ppm = 0 audio_compression="adpcm" #valid values: "adpcm", "none" diff --git a/groundstation/cubesatsim-lite-alt.sh b/groundstation/cubesatsim-lite-alt.sh new file mode 100755 index 00000000..9ad01561 --- /dev/null +++ b/groundstation/cubesatsim-lite-alt.sh @@ -0,0 +1,8 @@ +#!/bin/bash +# script to run CubeSat Simulator Lite +# +# on SDR application, listen at 107.9 + +echo -e "\nScript to run CubeSat Simulator Lite \n" + +sudo /home/pi/CubeSatSim/PiFmRds/src/pi_fm_rds -audio /home/pi/CubeSatSim/wav/afsk2.wav -freq 107.5 diff --git a/groundstation/decode.sh b/groundstation/decode.sh old mode 100644 new mode 100755 diff --git a/groundstation/ipaddress.sh b/groundstation/ipaddress.sh old mode 100644 new mode 100755 diff --git a/groundstation/satnogs_readme.txt b/groundstation/satnogs_readme.txt new file mode 100644 index 00000000..21f0ef05 --- /dev/null +++ b/groundstation/satnogs_readme.txt @@ -0,0 +1,19 @@ +This image has the SatNOGS client pre installed. It allows you to join the Satellite Network Operators Group network: + +https://network.satnogs.org + +To join, all you have to do is follow the instructions starting at SatNOGS Client Setup + +https://wiki.satnogs.org/SatNOGS_Client_Ansible#SatNOGS_Client_Setup + +You will need to Sign Up and create an account: + +https://network.satnogs.org/login/auth0 + +Maybe include "ARISS" in your SatNOGS station name? For example: Joe's ARISS GS + +Once you have an account and have logged in, click on the upper right corner and select Dashboard. Click on the API Key button to copy and paste your API Key which you will need to configure using sudo satnogs-setup Basic Configuration SATNOGS_API_TOKEN + +Good luck and feel free to message me ku2y on SatNOGS! + + diff --git a/groundstation/sdr.sh b/groundstation/sdr.sh old mode 100644 new mode 100755 From 23f7067e6b8a25e1093903934b7a3f72e4531525 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Thu, 18 Jul 2019 13:15:00 +0000 Subject: [PATCH 30/98] auto loading chromium --- groundstation/default.conf | 18 +++++++----------- groundstation/sdr-2m.sh | 2 ++ groundstation/sdr-70cm.sh | 4 ++++ groundstation/sdr-fm.sh | 5 ++++- 4 files changed, 17 insertions(+), 12 deletions(-) diff --git a/groundstation/default.conf b/groundstation/default.conf index ae81605e..7f3e052c 100644 --- a/groundstation/default.conf +++ b/groundstation/default.conf @@ -11,26 +11,22 @@ fft_size=4096 split=40 [gui] -geometry=@ByteArray(\x1\xd9\xd0\xcb\0\x2\0\0\0\0\0#\0\0\0\x32\0\0\x3\r\0\0\x3\b\0\0\0%\0\0\0P\0\0\x3\r\0\0\x3\b\0\0\0\0\0\0\0\0\x3 ) -state=@ByteArray(\0\0\0\xff\0\0\0\0\xfd\0\0\0\x2\0\0\0\x1\0\0\x1&\0\0\x2\\\xfc\x2\0\0\0\x2\xfc\0\0\0\x43\0\0\x2\\\0\0\x1\x8e\0\b\0!\xfa\0\0\0\x2\x2\0\0\0\x3\xfb\0\0\0\x18\0\x44\0o\0\x63\0k\0I\0n\0p\0u\0t\0\x43\0t\0l\x1\0\0\0\0\xff\xff\xff\xff\0\0\x1\x35\0\xff\xff\xff\xfb\0\0\0\x12\0\x44\0o\0\x63\0k\0R\0x\0O\0p\0t\x1\0\0\0\0\xff\xff\xff\xff\0\0\x1l\0\a\xff\xff\xfb\0\0\0\xe\0\x44\0o\0\x63\0k\0\x46\0\x66\0t\x1\0\0\0\0\xff\xff\xff\xff\0\0\0\xc8\0\a\xff\xff\xfc\0\0\x1\xd7\0\0\0\xc8\0\0\0\0\0\xff\xff\xff\xfa\xff\xff\xff\xff\x2\0\0\0\x2\xfb\0\0\0\x12\0\x44\0o\0\x63\0k\0\x41\0u\0\x64\0i\0o\0\0\0\0\0\xff\xff\xff\xff\0\0\0\xc8\0\xff\xff\xff\xfb\0\0\0\xe\0\x44\0o\0\x63\0k\0R\0\x44\0S\0\0\0\0\0\xff\xff\xff\xff\0\0\0h\0\xff\xff\xff\0\0\0\x3\0\0\x1\xbd\0\0\0\xeb\xfc\x1\0\0\0\x1\xfb\0\0\0\x1a\0\x44\0o\0\x63\0k\0\x42\0o\0o\0k\0m\0\x61\0r\0k\0s\x1\0\0\0\0\0\0\x1\xbd\0\0\x1\x42\0\xff\xff\xff\0\0\x1\xbd\0\0\x1k\0\0\0\x1\0\0\0\x2\0\0\0\b\0\0\0\x2\xfc\0\0\0\x1\0\0\0\x2\0\0\0\x1\0\0\0\x16\0m\0\x61\0i\0n\0T\0o\0o\0l\0\x42\0\x61\0r\x1\0\0\0\0\xff\xff\xff\xff\0\0\0\0\0\0\0\0) +geometry=@ByteArray(\x1\xd9\xd0\xcb\0\x2\0\0\0\0\0\0\0\0\0$\0\0\x3\xff\0\0\x2\xff\0\0\0\0\0\0\0\x42\0\0\x2\xe8\0\0\x2\xed\0\0\0\0\x2\0\0\0\x4\0) +state=@ByteArray(\0\0\0\xff\0\0\0\0\xfd\0\0\0\x2\0\0\0\x1\0\0\x1&\0\0\x2\x65\xfc\x2\0\0\0\x2\xfc\0\0\0\x41\0\0\x1\x90\0\0\x1\x83\0\b\0 \xfa\0\0\0\x1\x2\0\0\0\x3\xfb\0\0\0\x18\0\x44\0o\0\x63\0k\0I\0n\0p\0u\0t\0\x43\0t\0l\x1\0\0\0\0\xff\xff\xff\xff\0\0\x1.\0\xff\xff\xff\xfb\0\0\0\x12\0\x44\0o\0\x63\0k\0R\0x\0O\0p\0t\x1\0\0\0\0\xff\xff\xff\xff\0\0\x1\x62\0\a\xff\xff\xfb\0\0\0\xe\0\x44\0o\0\x63\0k\0\x46\0\x66\0t\x1\0\0\0\0\xff\xff\xff\xff\0\0\0\xc8\0\a\xff\xff\xfc\0\0\x1\xd7\0\0\0\xcf\0\0\0\xc8\0\xff\xff\xff\xfa\0\0\0\0\x2\0\0\0\x2\xfb\0\0\0\x12\0\x44\0o\0\x63\0k\0\x41\0u\0\x64\0i\0o\x1\0\0\0\0\xff\xff\xff\xff\0\0\0\xc8\0\xff\xff\xff\xfb\0\0\0\xe\0\x44\0o\0\x63\0k\0R\0\x44\0S\0\0\0\0\0\xff\xff\xff\xff\0\0\0h\0\xff\xff\xff\0\0\0\x3\0\0\x2\xd4\0\0\0\xe9\xfc\x1\0\0\0\x1\xfb\0\0\0\x1a\0\x44\0o\0\x63\0k\0\x42\0o\0o\0k\0m\0\x61\0r\0k\0s\x1\0\0\0\0\0\0\x2\xd4\0\0\x1\x42\0\xff\xff\xff\0\0\x2\xd4\0\0\x1v\0\0\0\x1\0\0\0\x2\0\0\0\b\0\0\0\x2\xfc\0\0\0\x1\0\0\0\x2\0\0\0\x1\0\0\0\x16\0m\0\x61\0i\0n\0T\0o\0o\0l\0\x42\0\x61\0r\x1\0\0\0\0\xff\xff\xff\xff\0\0\0\0\0\0\0\0) [input] -bandwidth=2400000 device="rtl=0" -frequency=98506000 +frequency=145800000 gains=@Variant(\0\0\0\b\0\0\0\x1\0\0\0\x6\0L\0N\0\x41\0\0\0\x2\0\0\x1\xf0) sample_rate=512000 -[output] -device="bcm2835 ALSA: - (hw:0,0)" - [receiver] agc_decay=100 agc_off=true -demod=5 -filter_high_cut=80000 -filter_low_cut=-80000 -offset=-402000 +demod=3 +filter_high_cut=5000 +filter_low_cut=-5000 +offset=-202000 sql_level=-42.5 [remote_control] diff --git a/groundstation/sdr-2m.sh b/groundstation/sdr-2m.sh index c4e3f963..429cb736 100755 --- a/groundstation/sdr-2m.sh +++ b/groundstation/sdr-2m.sh @@ -12,4 +12,6 @@ hostname -I|cut -f1 -d ' ' cd ~/openwebrx +chromium-browser http://localhost:8073 & + sudo python openwebrx.py config_webrx_145 diff --git a/groundstation/sdr-70cm.sh b/groundstation/sdr-70cm.sh index f23c82b3..e0895206 100755 --- a/groundstation/sdr-70cm.sh +++ b/groundstation/sdr-70cm.sh @@ -8,8 +8,12 @@ echo -e "IP Address to use in web browsers is: " hostname -I|cut -f1 -d ' ' +./kill_all.sh + ./kill_all.sh cd ~/openwebrx +chromium-browser http://localhost:8073 & + sudo python openwebrx.py config_webrx_440 diff --git a/groundstation/sdr-fm.sh b/groundstation/sdr-fm.sh index 6da6c725..188db296 100755 --- a/groundstation/sdr-fm.sh +++ b/groundstation/sdr-fm.sh @@ -12,4 +12,7 @@ hostname -I|cut -f1 -d ' ' cd ~/openwebrx -sudo python openwebrx.py config_webrx_107 +chromium-browser http://localhost:8073 & + +sudo python openwebrx.py config_webrx_107 + From 55c7eba409e49675f410cfcf38af51fc52448597 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sat, 20 Jul 2019 02:05:00 -0400 Subject: [PATCH 31/98] changed -std=c99 to gnu99 to fix warnings --- Makefile | 72 ++++++++++++++++++++++++++++---------------------------- 1 file changed, 36 insertions(+), 36 deletions(-) diff --git a/Makefile b/Makefile index ce9a4ed5..7e9dd00c 100644 --- a/Makefile +++ b/Makefile @@ -50,47 +50,47 @@ libax5043.a: ax5043/spi/ax5043spi.o radiochat: libax5043.a radiochat: chat/chat_main.o - gcc -std=c99 $(DEBUG_BEHAVIOR) -o radiochat -pthread -L./ chat/chat_main.o -lwiringPi -lax5043 + gcc -std=gnu99 $(DEBUG_BEHAVIOR) -o radiochat -pthread -L./ chat/chat_main.o -lwiringPi -lax5043 radiocw: libax5043.a radiocw: cw/cw_main.o radiocw: afsk/ax25.o radiocw: afsk/ax5043.o radiocw: afsk/send_afsk.o - gcc -std=c99 $(DEBUG_BEHAVIOR) -o radiocw -L./ afsk/ax25.o afsk/ax5043.o afsk/send_afsk.o cw/cw_main.o -lwiringPi -lax5043 + gcc -std=gnu99 $(DEBUG_BEHAVIOR) -o radiocw -L./ afsk/ax25.o afsk/ax5043.o afsk/send_afsk.o cw/cw_main.o -lwiringPi -lax5043 radiopiglatin: libax5043.a radiopiglatin: piglatin/piglatin_main.o - gcc -std=c99 $(DEBUG_BEHAVIOR) -o radiopiglatin -pedantic -Wall -Wextra -L./ piglatin/piglatin_main.o -lwiringPi -lax5043 + gcc -std=gnu99 $(DEBUG_BEHAVIOR) -o radiopiglatin -pedantic -Wall -Wextra -L./ piglatin/piglatin_main.o -lwiringPi -lax5043 testax5043tx: libax5043.a testax5043tx: transmit/transmit_main.o - gcc -std=c99 $(DEBUG_BEHAVIOR) -o testax5043tx -pedantic -Wall -Wextra -L./ transmit/transmit_main.o -lwiringPi -lax5043 + gcc -std=gnu99 $(DEBUG_BEHAVIOR) -o testax5043tx -pedantic -Wall -Wextra -L./ transmit/transmit_main.o -lwiringPi -lax5043 testax5043rx: libax5043.a testax5043rx: receive/receive_main.o - gcc -std=c99 $(DEBUG_BEHAVIOR) -o testax5043rx -pedantic -Wall -Wextra -L./ receive/receive_main.o -lwiringPi -lax5043 + gcc -std=gnu99 $(DEBUG_BEHAVIOR) -o testax5043rx -pedantic -Wall -Wextra -L./ receive/receive_main.o -lwiringPi -lax5043 testax5043init: libax5043.a testax5043init: init/init_main.o - gcc -std=c99 $(DEBUG_BEHAVIOR) -o testax5043init -pedantic -Wall -Wextra -L./ init/init_main.o -lwiringPi -lax5043 + gcc -std=gnu99 $(DEBUG_BEHAVIOR) -o testax5043init -pedantic -Wall -Wextra -L./ init/init_main.o -lwiringPi -lax5043 testax50432freq: libax5043.a testax50432freq: transmit2freq/transmit2freq_main.o - gcc -std=c99 $(DEBUG_BEHAVIOR) -o testax50432freq -pedantic -Wall -Wextra -L./ transmit2freq/transmit2freq_main.o -lwiringPi -lax5043 + gcc -std=gnu99 $(DEBUG_BEHAVIOR) -o testax50432freq -pedantic -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=c99 $(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 -pedantic -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 radioafsk: afsk/ina219.h - gcc -std=c99 $(DEBUG_BEHAVIOR) -o radioafsk -pedantic -Wall -Wextra -L./ afsk/ax25.o afsk/ax5043.o afsk/main.o -lwiringPi -lax5043 + gcc -std=gnu99 $(DEBUG_BEHAVIOR) -o radioafsk -pedantic -Wall -Wextra -L./ afsk/ax25.o afsk/ax5043.o afsk/main.o -lwiringPi -lax5043 ax5043/generated/configcommon.o: ax5043/generated/configcommon.c @@ -98,19 +98,19 @@ 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=c99 $(DEBUG_BEHAVIOR) -pedantic -Wall -Wextra -c configcommon.c + cd ax5043/generated; gcc -std=gnu99 $(DEBUG_BEHAVIOR) -pedantic -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=c99 $(DEBUG_BEHAVIOR) -pedantic -Wall -Wextra -c configrx.c + cd ax5043/generated; gcc -std=gnu99 $(DEBUG_BEHAVIOR) -pedantic -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=c99 $(DEBUG_BEHAVIOR) -pedantic -Wall -Wextra -c configtx.c + cd ax5043/generated; gcc -std=gnu99 $(DEBUG_BEHAVIOR) -pedantic -Wall -Wextra -c configtx.c ax5043/generated/config.o: ax5043/generated/config.c ax5043/generated/config.o: ax5043/generated/config.h @@ -119,12 +119,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=c99 $(DEBUG_BEHAVIOR) -pedantic -Wall -Wextra -c config.c + cd ax5043/generated; gcc -std=gnu99 $(DEBUG_BEHAVIOR) -pedantic -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=c99 $(DEBUG_BEHAVIOR) -pedantic -Wall -Wextra -c ax5043spi.c + cd ax5043/spi; gcc -std=gnu99 $(DEBUG_BEHAVIOR) -pedantic -Wall -Wextra -c ax5043spi.c ax5043/ax5043support/ax5043init.o: ax5043/ax5043support/ax5043init.c ax5043/ax5043support/ax5043init.o: ax5043/ax5043support/ax5043init.h @@ -132,7 +132,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=c99 $(DEBUG_BEHAVIOR) -pedantic -Wall -Wextra -c ax5043init.c + cd ax5043/ax5043support; gcc -std=gnu99 $(DEBUG_BEHAVIOR) -pedantic -Wall -Wextra -c ax5043init.c ax5043/ax5043support/ax5043rx.o: ax5043/ax5043support/ax5043rx.c ax5043/ax5043support/ax5043rx.o: ax5043/ax5043support/ax5043rx.h @@ -140,7 +140,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=c99 $(DEBUG_BEHAVIOR) -pedantic -Wall -Wextra -c ax5043rx.c + cd ax5043/ax5043support; gcc -std=gnu99 $(DEBUG_BEHAVIOR) -pedantic -Wall -Wextra -c ax5043rx.c ax5043/ax5043support/ax5043tx.o: ax5043/ax5043support/ax5043tx.c ax5043/ax5043support/ax5043tx.o: ax5043/ax5043support/ax5043tx.h @@ -148,7 +148,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=c99 $(DEBUG_BEHAVIOR) -pedantic -Wall -Wextra -c ax5043tx.c + cd ax5043/ax5043support; gcc -std=gnu99 $(DEBUG_BEHAVIOR) -pedantic -Wall -Wextra -c ax5043tx.c ax5043/axradio/axradioinit.o: ax5043/axradio/axradioinit.c ax5043/axradio/axradioinit.o: ax5043/axradio/axradioinit.h @@ -158,7 +158,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=c99 $(DEBUG_BEHAVIOR) -pedantic -Wall -Wextra -c axradioinit.c + cd ax5043/axradio; gcc -std=gnu99 $(DEBUG_BEHAVIOR) -pedantic -Wall -Wextra -c axradioinit.c ax5043/axradio/axradiomode.o: ax5043/axradio/axradiomode.c ax5043/axradio/axradiomode.o: ax5043/axradio/axradiomode.h @@ -168,7 +168,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=c99 $(DEBUG_BEHAVIOR) -pedantic -Wall -Wextra -c axradiomode.c + cd ax5043/axradio; gcc -std=gnu99 $(DEBUG_BEHAVIOR) -pedantic -Wall -Wextra -c axradiomode.c ax5043/axradio/axradiorx.o: ax5043/axradio/axradiorx.c ax5043/axradio/axradiorx.o: ax5043/axradio/axradiorx.h @@ -178,7 +178,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=c99 $(DEBUG_BEHAVIOR) -pedantic -Wall -Wextra -c axradiorx.c + cd ax5043/axradio; gcc -std=gnu99 $(DEBUG_BEHAVIOR) -pedantic -Wall -Wextra -c axradiorx.c ax5043/axradio/axradiotx.o: ax5043/axradio/axradiotx.c ax5043/axradio/axradiotx.o: ax5043/axradio/axradiotx.h @@ -192,11 +192,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=c99 $(DEBUG_BEHAVIOR) -pedantic -Wall -Wextra -c axradiotx.c + cd ax5043/axradio; gcc -std=gnu99 $(DEBUG_BEHAVIOR) -pedantic -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=c99 $(DEBUG_BEHAVIOR) -pedantic -Wall -Wextra -c crc.c + cd ax5043/crc; gcc -std=gnu99 $(DEBUG_BEHAVIOR) -pedantic -Wall -Wextra -c crc.c chat/chat_main.o: chat/chat_main.c chat/chat_main.o: ax5043/spi/ax5043spi.h @@ -210,13 +210,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=c99 $(DEBUG_BEHAVIOR) -I../ax5043 -pedantic -Wconversion -Wall -Wextra -c chat_main.c; cd .. + cd chat; gcc -std=gnu99 $(DEBUG_BEHAVIOR) -I../ax5043 -pedantic -Wconversion -Wall -Wextra -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=c99 $(DEBUG_BEHAVIOR) -I ../ax5043 -pedantic -Wconversion -Wall -Wextra -c ax25.c; cd .. + cd afsk; gcc -std=gnu99 $(DEBUG_BEHAVIOR) -I ../ax5043 -pedantic -Wconversion -Wall -Wextra -c ax25.c; cd .. afsk/ax5043.o: afsk/ax5043.c afsk/ax5043.o: afsk/ax25.h @@ -225,21 +225,21 @@ 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=c99 $(DEBUG_BEHAVIOR) -I ../ax5043 -pedantic -Wconversion -Wall -Wextra -c ax5043.c; cd .. + cd afsk; gcc -std=gnu99 $(DEBUG_BEHAVIOR) -I ../ax5043 -pedantic -Wconversion -Wall -Wextra -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=c99 $(DEBUG_BEHAVIOR) -I ../ax5043 -pedantic -Wconversion -Wall -Wextra -c main.c; cd .. + cd afsk; gcc -std=gnu99 $(DEBUG_BEHAVIOR) -I ../ax5043 -pedantic -Wconversion -Wall -Wextra -c main.c; cd .. afsk/send_afsk.o: afsk/send_afsk.c afsk/send_afsk.o: afsk/send_afsk.h afsk/send_afsk.o: afsk/status.h afsk/send_afsk.o: afsk/ax5043.h afsk/send_afsk.o: afsk/ax25.h - cd afsk; gcc -std=c99 $(DEBUG_BEHAVIOR) -I ../ax5043 -pedantic -Wconversion -Wall -Wextra -c send_afsk.c; cd .. + cd afsk; gcc -std=gnu99 $(DEBUG_BEHAVIOR) -I ../ax5043 -pedantic -Wconversion -Wall -Wextra -c send_afsk.c; cd .. cw/cw_main.o: cw/cw_main.c cw/cw_main.o: ax5043/spi/ax5043spi.h @@ -253,7 +253,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=c99 $(DEBUG_BEHAVIOR) -I../ax5043 -pedantic -Wconversion -Wall -Wextra -c cw_main.c; cd .. + cd cw; gcc -std=gnu99 $(DEBUG_BEHAVIOR) -I../ax5043 -pedantic -Wconversion -Wall -Wextra -c cw_main.c; cd .. piglatin/piglatin_main.o: piglatin/piglatin_main.c piglatin/piglatin_main.o: ax5043/spi/ax5043spi.h @@ -267,7 +267,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=c99 $(DEBUG_BEHAVIOR) -I ../ax5043 -pedantic -Wconversion -Wall -Wextra -c piglatin_main.c; cd .. + cd piglatin; gcc -std=gnu99 $(DEBUG_BEHAVIOR) -I ../ax5043 -pedantic -Wconversion -Wall -Wextra -c piglatin_main.c; cd .. receive/receive_main.o: receive/receive_main.c receive/receive_main.o: ax5043/axradio/axradioinit.h @@ -279,7 +279,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=c99 $(DEBUG_BEHAVIOR) -I ../ax5043 -pedantic -Wconversion -Wall -Wextra -c receive_main.c; cd .. + cd receive; gcc -std=gnu99 $(DEBUG_BEHAVIOR) -I ../ax5043 -pedantic -Wconversion -Wall -Wextra -c receive_main.c; cd .. transmit/transmit_main.o: transmit/transmit_main.c transmit/transmit_main.o: ax5043/axradio/axradioinit.h @@ -291,7 +291,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=c99 $(DEBUG_BEHAVIOR) -I ../ax5043 -pedantic -Wconversion -Wall -Wextra -c transmit_main.c; cd .. + cd transmit; gcc -std=gnu99 $(DEBUG_BEHAVIOR) -I ../ax5043 -pedantic -Wconversion -Wall -Wextra -c transmit_main.c; cd .. transmit2freq/transmit2freq_main.o: transmit2freq/transmit2freq_main.c transmit2freq/transmit2freq_main.o: ax5043/axradio/axradioinit.h @@ -303,20 +303,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=c99 $(DEBUG_BEHAVIOR) -I ../ax5043 -pedantic -Wconversion -Wall -Wextra -c transmit2freq_main.c; cd .. + cd transmit2freq; gcc -std=gnu99 $(DEBUG_BEHAVIOR) -I ../ax5043 -pedantic -Wconversion -Wall -Wextra -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=c99 $(DEBUG_BEHAVIOR) -I ../ax5043 -pedantic -Wconversion -Wall -Wextra -c init_main.c; cd .. + cd init; gcc -std=gnu99 $(DEBUG_BEHAVIOR) -I ../ax5043 -pedantic -Wconversion -Wall -Wextra -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=c99 $(DEBUG_BEHAVIOR) -I ../ax5043 -pedantic -Wconversion -Wall -Wextra -c ax25.c; cd .. + cd afsktx; gcc -std=gnu99 $(DEBUG_BEHAVIOR) -I ../ax5043 -pedantic -Wconversion -Wall -Wextra -c ax25.c; cd .. afsktx/ax5043.o: afsktx/ax5043.c afsktx/ax5043.o: afsktx/ax25.h @@ -324,11 +324,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=c99 $(DEBUG_BEHAVIOR) -I ../ax5043 -pedantic -Wconversion -Wall -Wextra -c ax5043.c; cd .. + cd afsktx; gcc -std=gnu99 $(DEBUG_BEHAVIOR) -I ../ax5043 -pedantic -Wconversion -Wall -Wextra -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=c99 $(DEBUG_BEHAVIOR) -I ../ax5043 -pedantic -Wconversion -Wall -Wextra -c main.c; cd .. + cd afsktx; gcc -std=gnu99 $(DEBUG_BEHAVIOR) -I ../ax5043 -pedantic -Wconversion -Wall -Wextra -c main.c; cd .. From c8db1e4f6232df00f89c51c333d92ad54475f712 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sat, 20 Jul 2019 02:54:00 -0400 Subject: [PATCH 32/98] Added #ifdef DEBUG_LOGGING around all non-error printfs --- afsk/main.c | 87 +++++++++++++++++------------------------------------ 1 file changed, 28 insertions(+), 59 deletions(-) diff --git a/afsk/main.c b/afsk/main.c index d8845d32..fa2615c6 100644 --- a/afsk/main.c +++ b/afsk/main.c @@ -19,10 +19,7 @@ * along with this program. If not, see . */ -//#include //Needed for I2C port #include //Needed for I2C port -//#include //Needed for I2C port - #include #include #include @@ -36,7 +33,6 @@ #include #include "ina219.h" - #define CALLSIGN "" // Put your callsign here! #define VBATT 15 #define ADC5 17 @@ -192,14 +188,18 @@ int main(void) { /* Infinite loop */ for (;;) { - sleep(1); - - fprintf(stderr,"INFO: Getting TLM Data\n"); + sleep(1); // Delay 1 second + #ifdef DEBUG_LOGGING + fprintf(stderr,"INFO: Getting TLM Data\n"); + #endif + get_tlm(tlm); - fprintf(stderr,"INFO: Preparing X.25 packet\n"); - + #ifdef DEBUG_LOGGING + fprintf(stderr,"INFO: Preparing X.25 packet\n"); + #endif + char str[1000]; char tlm_str[1000]; @@ -224,8 +224,10 @@ int main(void) { if (arduinoI2C > 0) { /* Read Arduino payload */ for(int reg = 0; reg < 4; reg++) { sprintf(tlm_str, " %04x",wiringPiI2CReadReg16(arduinoI2C,reg)); - printf("%s \n",tlm_str); - strcat(str,tlm_str); /* Append payload telemetry */ + #ifdef DEBUG_LOGGING + printf("%s \n",tlm_str); + #endif + strcat(str,tlm_str); /* Append payload telemetry */ usleep(100000); } } @@ -243,9 +245,9 @@ char cmdbuffer[1000]; // printf("LED state: %s\n", cmdbuffer); } */ - - fprintf(stderr,"INFO: Transmitting X.25 packet\n"); - + #ifdef DEBUG_LOGGING + fprintf(stderr,"INFO: Transmitting X.25 packet\n"); + #endif memcpy(data, str, strnlen(str, 256)); ret = ax25_tx_frame(&hax25, &hax5043, data, strnlen(str, 256)); if (ret) { @@ -278,8 +280,9 @@ char cmdbuffer[1000]; static void init_rf() { int ret; - fprintf(stderr,"Initializing AX5043\n"); - + #ifdef DEBUG_LOGGING + fprintf(stderr,"Initializing AX5043\n"); + #endif ret = ax5043_init(&hax5043, XTAL_FREQ_HZ, VCO_INTERNAL); if (ret != PQWS_SUCCESS) { fprintf(stderr, @@ -318,8 +321,10 @@ int get_tlm(int tlm[][5]) { FILE* file = popen("sudo python /home/pi/CubeSatSim/python/readcurrent.py 2>&1", "r"); fgets(cmdbuffer, 999, file); pclose(file); - fprintf(stderr,"I2C Sensor data: %s\n", cmdbuffer); - + #ifdef DEBUG_LOGGING + fprintf(stderr,"I2C Sensor data: %s\n", cmdbuffer); + #endif + char ina219[16][20]; // voltage, currents, and power from the INA219 current sensors x4a, x40, x41, x44, and x45. int i = 0; char * data2 = strtok (cmdbuffer," "); @@ -331,42 +336,7 @@ int get_tlm(int tlm[][5]) { #endif data2 = strtok (NULL, " "); i++; - } - -// Reading MoPower telemetry info -/* - file = popen("/home/pi/mopower/mpcmd show data", "r"); - - fgets(cmdbuffer, 999, file); - - pclose(file); -// printf("MoPower data: %s\n", cmdbuffer); - - char mopower[64][14]; -// char str[] ="- This, a sample string."; - char * pch; -// printf ("Splitting string \"%s\" into tokens:\n",str); -// pch = strtok (str," "); - i = 0; - pch = strtok (cmdbuffer," ,.-"); - while (pch != NULL) - { - strcpy(mopower[i], pch); -// printf ("mopwer[%d]=%s\n",i,mopower[i]); // pch); - pch = strtok (NULL, " "); - i++; - } - printf("Battery voltage = %s\n", mopower[16]); - if (strtof(mopower[17],NULL) > -0.5) { -charging = 1; - printf("Charging on\n"); - } - else { -charging = 0; - printf("Charging off\n"); - - } -*/ + } // read i2c current sensors // double current = 0, power = 0, y_current = 0, y_power = 0, z_current = 0, z_power = 0; @@ -388,16 +358,15 @@ charging = 0; wiringPiI2CWriteReg16(z_fd, INA219_REG_CALIBRATION, x_calValue); z_current = wiringPiI2CReadReg16(z_fd, INA219_REG_CURRENT) / x_currentDivider; z_power = wiringPiI2CReadReg16(z_fd, INA219_REG_POWER) * x_powerMultiplier; - } - printf("-X 0x40 current %4.2f power %4.2f -Y 0x41 current %4.2f power %4.2f -Z 0x44 current %4.2f power %4.2f \n", + } + #ifdef DEBUG_LOGGING + printf("-X 0x40 current %4.2f power %4.2f -Y 0x41 current %4.2f power %4.2f -Z 0x44 current %4.2f power %4.2f \n", current, power, y_current, y_power, z_current, z_power); - - #ifdef DEBUG_LOGGING printf("1B: ina219[%d]: %s val: %f \n", SENSOR_40 + CURRENT, ina219[SENSOR_40 + CURRENT], strtof(ina219[SENSOR_40 + CURRENT], NULL)); #endif @@ -419,7 +388,7 @@ charging = 0; if (tempSensor != -1) { int tempValue = wiringPiI2CReadReg16(tempSensor, 0); #ifdef DEBUG_LOGGING - printf("Read: %x\n", tempValue); + printf("Temp Sensor Read: %x\n", tempValue); #endif uint8_t upper = (uint8_t) (tempValue >> 8); From 568bab80e1f7598577e7b2a92297024aea16161a Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sat, 20 Jul 2019 02:56:09 -0400 Subject: [PATCH 33/98] Fixed missing / in /dev/i2c-0 --- afsk/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/afsk/main.c b/afsk/main.c index fa2615c6..c10ee7e4 100644 --- a/afsk/main.c +++ b/afsk/main.c @@ -120,7 +120,7 @@ int main(void) { fprintf(stderr,"tempSensor: %d \n",tempSensor); #endif - int arduinoI2C = access("dev/i2c-0", W_OK | R_OK); + int arduinoI2C = access("/dev/i2c-0", W_OK | R_OK); if (arduinoI2C < 0) { fprintf(stderr,"ERROR: /dev/i2c-0 bus not present\n"); From aa2148083c7d692ed83687eb6c6e91db906a291c Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sat, 20 Jul 2019 03:01:13 -0400 Subject: [PATCH 34/98] added #ifdef DEBUG_LOGGING around INFO printf messages --- afsk/ax5043.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/afsk/ax5043.c b/afsk/ax5043.c index 8ed001f5..f8c3b2e9 100644 --- a/afsk/ax5043.c +++ b/afsk/ax5043.c @@ -1071,7 +1071,9 @@ int ax5043_wait_for_transmit() { /* tx is done */ __tx_frame_end(__ax5043_conf); transmittedPostamble = 0; - printf("INFO: TX done\n"); + #ifdef DEBUG_LOGGING + printf("INFO: TX done\n"); + #endif return PQWS_SUCCESS; } @@ -1130,7 +1132,9 @@ int ax5043_wait_for_transmit() { if (radiostate == 0) { /* tx is done */ __tx_active = 0; - printf("INFO: TX done\n"); + #ifdef DEBUG_LOGGING + printf("INFO: TX done\n"); + #endif } } } From 20178e9d7c2a68adc9eb5e4b3e22d2b5fdf88bf7 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sat, 20 Jul 2019 03:15:03 -0400 Subject: [PATCH 35/98] added printf of packet --- afsk/ax25.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/afsk/ax25.c b/afsk/ax25.c index 15b127c2..6c3b089e 100644 --- a/afsk/ax25.c +++ b/afsk/ax25.c @@ -88,6 +88,18 @@ int ax25_tx_frame(ax25_conf_t *hax25, ax5043_conf_t *hax, memcpy(__tx_buffer, hax25->addr_field, hax25->addr_field_len); memcpy(__tx_buffer + hax25->addr_field_len, payload, len); + + + int jj; + for(jj = 0; jj < 118; jj++) { + /* sprintf(hex_octet, "%02x",__tx_buffer[jj]); + strcat(hex_data, hex_octet); */ + printf("%c",__tx_buffer[jj]); + } + printf("\n"); + + + return ax5043_tx_frame(hax, __tx_buffer, len + hax25->addr_field_len, hax25->preamble_len, hax25->postable_len, 1000); From 65b6fac1c333f77ff1451d074a774328819e4e1c Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sat, 20 Jul 2019 03:15:55 -0400 Subject: [PATCH 36/98] added stdio.h --- afsk/ax25.c | 1 + 1 file changed, 1 insertion(+) diff --git a/afsk/ax25.c b/afsk/ax25.c index 6c3b089e..807b65bd 100644 --- a/afsk/ax25.c +++ b/afsk/ax25.c @@ -18,6 +18,7 @@ * along with this program. If not, see . */ +#include #include "ax25.h" #include #include "ax5043.h" From 78499e72d93454c8141b5dd7e78a1d9b2a61a2c8 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sat, 20 Jul 2019 03:26:53 -0400 Subject: [PATCH 37/98] removed last printf --- afsk/main.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/afsk/main.c b/afsk/main.c index c10ee7e4..ddecd43d 100644 --- a/afsk/main.c +++ b/afsk/main.c @@ -217,7 +217,9 @@ int main(void) { channel, upper_digit(tlm[channel][2]), lower_digit(tlm[channel][2]), channel, upper_digit(tlm[channel][3]), lower_digit(tlm[channel][3]), channel, upper_digit(tlm[channel][4]), lower_digit(tlm[channel][4])); - printf("%s \n",tlm_str); + #ifdef DEBUG_LOGGING + printf("%s \n",tlm_str); + #endif strcat(str, tlm_str); } From 78b440aed75bc64367ad4dc5ed12fcd2b7d1a323 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sat, 20 Jul 2019 03:32:31 -0400 Subject: [PATCH 38/98] added src>dst: to printf --- afsk/ax25.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/afsk/ax25.c b/afsk/ax25.c index 807b65bd..3742a64a 100644 --- a/afsk/ax25.c +++ b/afsk/ax25.c @@ -78,6 +78,9 @@ int ax25_init(ax25_conf_t *conf, const uint8_t *dest_addr, uint8_t dest_ssid, *out++ = (uint8_t) ((0x0F & src_ssid) << 1) | 0x61; //*out++ = ((0b1111 & src_ssid) << 1) | 0b01100001; conf->addr_field_len = AX25_MIN_ADDR_LEN; + + printf(%s>%s:", src_addr, dst_addr); + return PQWS_SUCCESS; } @@ -90,7 +93,6 @@ int ax25_tx_frame(ax25_conf_t *hax25, ax5043_conf_t *hax, memcpy(__tx_buffer, hax25->addr_field, hax25->addr_field_len); memcpy(__tx_buffer + hax25->addr_field_len, payload, len); - int jj; for(jj = 0; jj < 118; jj++) { /* sprintf(hex_octet, "%02x",__tx_buffer[jj]); From 601217a87e7d240edd87bf2c5530a0ceee584f4a Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sat, 20 Jul 2019 03:34:49 -0400 Subject: [PATCH 39/98] Update ax25.c --- afsk/ax25.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/afsk/ax25.c b/afsk/ax25.c index 3742a64a..9fad58b7 100644 --- a/afsk/ax25.c +++ b/afsk/ax25.c @@ -79,7 +79,7 @@ int ax25_init(ax25_conf_t *conf, const uint8_t *dest_addr, uint8_t dest_ssid, //*out++ = ((0b1111 & src_ssid) << 1) | 0b01100001; conf->addr_field_len = AX25_MIN_ADDR_LEN; - printf(%s>%s:", src_addr, dst_addr); + printf("%s>%s:", src_addr, dst_addr); return PQWS_SUCCESS; } From 249b114227632f618b62843d859f6f1a20136bdf Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sat, 20 Jul 2019 03:35:31 -0400 Subject: [PATCH 40/98] fixed printf of source, dest callsign --- afsk/ax25.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/afsk/ax25.c b/afsk/ax25.c index 9fad58b7..52021c7f 100644 --- a/afsk/ax25.c +++ b/afsk/ax25.c @@ -79,7 +79,7 @@ int ax25_init(ax25_conf_t *conf, const uint8_t *dest_addr, uint8_t dest_ssid, //*out++ = ((0b1111 & src_ssid) << 1) | 0b01100001; conf->addr_field_len = AX25_MIN_ADDR_LEN; - printf("%s>%s:", src_addr, dst_addr); + printf("%s>%s:", src_addr, dest_addr); return PQWS_SUCCESS; } From 3480dfd5019f0775411947afe91c8f2a3ca886aa Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sat, 20 Jul 2019 03:41:40 -0400 Subject: [PATCH 41/98] added callsign and telem printf --- afsk/main.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/afsk/main.c b/afsk/main.c index ddecd43d..0dc7eb62 100644 --- a/afsk/main.c +++ b/afsk/main.c @@ -184,7 +184,8 @@ int main(void) { ax25_init(&hax25, (uint8_t *) "CQ", '1', (uint8_t *) CALLSIGN, '1', AX25_PREAMBLE_LEN, AX25_POSTAMBLE_LEN); - + + printf("%s-1>CQ-1:", CALLSIGN); /* Infinite loop */ for (;;) { @@ -233,7 +234,9 @@ int main(void) { usleep(100000); } } - + + print("%s\n", str[3]); + digitalWrite (0, LOW); /* From 671a3594326c0a869585598d6615b0db8454497a Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sat, 20 Jul 2019 03:42:28 -0400 Subject: [PATCH 42/98] Update main.c --- afsk/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/afsk/main.c b/afsk/main.c index 0dc7eb62..aa9d3caf 100644 --- a/afsk/main.c +++ b/afsk/main.c @@ -235,7 +235,7 @@ int main(void) { } } - print("%s\n", str[3]); + printf("%s\n", str[3]); digitalWrite (0, LOW); From 3e18c22cd17a06d2fd5941692eb8e91d1edd037e Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sat, 20 Jul 2019 03:47:57 -0400 Subject: [PATCH 43/98] Update main.c --- afsk/main.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/afsk/main.c b/afsk/main.c index aa9d3caf..ba96ee90 100644 --- a/afsk/main.c +++ b/afsk/main.c @@ -206,7 +206,8 @@ int main(void) { char header_str[] = "\x03\xf0hi hi "; strcpy(str, header_str); - + printf("hi hi "); + int channel; for (channel = 1; channel < 7; channel++) { #ifdef DEBUG_LOGGING @@ -218,10 +219,8 @@ int main(void) { channel, upper_digit(tlm[channel][2]), lower_digit(tlm[channel][2]), channel, upper_digit(tlm[channel][3]), lower_digit(tlm[channel][3]), channel, upper_digit(tlm[channel][4]), lower_digit(tlm[channel][4])); - #ifdef DEBUG_LOGGING - printf("%s \n",tlm_str); - #endif - strcat(str, tlm_str); + printf("%s",tlm_str); + strcat(str, tlm_str); } if (arduinoI2C > 0) { /* Read Arduino payload */ @@ -230,12 +229,12 @@ int main(void) { #ifdef DEBUG_LOGGING printf("%s \n",tlm_str); #endif - strcat(str,tlm_str); /* Append payload telemetry */ + strcat(str,tlm_str); /* Append payload telemetry */ + printf("%s",tlm_str); usleep(100000); } } - - printf("%s\n", str[3]); + printf("\n"); digitalWrite (0, LOW); From 57d0a56cb771b75d643653b0fb9e47db5b62c2b9 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sat, 20 Jul 2019 03:50:18 -0400 Subject: [PATCH 44/98] reverted changes --- afsk/ax25.c | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/afsk/ax25.c b/afsk/ax25.c index 52021c7f..15b127c2 100644 --- a/afsk/ax25.c +++ b/afsk/ax25.c @@ -18,7 +18,6 @@ * along with this program. If not, see . */ -#include #include "ax25.h" #include #include "ax5043.h" @@ -78,9 +77,6 @@ int ax25_init(ax25_conf_t *conf, const uint8_t *dest_addr, uint8_t dest_ssid, *out++ = (uint8_t) ((0x0F & src_ssid) << 1) | 0x61; //*out++ = ((0b1111 & src_ssid) << 1) | 0b01100001; conf->addr_field_len = AX25_MIN_ADDR_LEN; - - printf("%s>%s:", src_addr, dest_addr); - return PQWS_SUCCESS; } @@ -92,17 +88,6 @@ int ax25_tx_frame(ax25_conf_t *hax25, ax5043_conf_t *hax, memcpy(__tx_buffer, hax25->addr_field, hax25->addr_field_len); memcpy(__tx_buffer + hax25->addr_field_len, payload, len); - - int jj; - for(jj = 0; jj < 118; jj++) { - /* sprintf(hex_octet, "%02x",__tx_buffer[jj]); - strcat(hex_data, hex_octet); */ - printf("%c",__tx_buffer[jj]); - } - printf("\n"); - - - return ax5043_tx_frame(hax, __tx_buffer, len + hax25->addr_field_len, hax25->preamble_len, hax25->postable_len, 1000); From f7fdbc20cb8a97a07a178a96b504d9e4028aaaef Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sat, 20 Jul 2019 03:52:55 -0400 Subject: [PATCH 45/98] fixed source and dest callsign printf issue --- afsk/main.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/afsk/main.c b/afsk/main.c index ba96ee90..f708bbc3 100644 --- a/afsk/main.c +++ b/afsk/main.c @@ -183,9 +183,7 @@ int main(void) { // ax25_init(&hax25, (uint8_t *) "CubeSatSim", '2', (uint8_t *) CALLSIGN, '2', ax25_init(&hax25, (uint8_t *) "CQ", '1', (uint8_t *) CALLSIGN, '1', AX25_PREAMBLE_LEN, - AX25_POSTAMBLE_LEN); - - printf("%s-1>CQ-1:", CALLSIGN); + AX25_POSTAMBLE_LEN); /* Infinite loop */ for (;;) { @@ -206,7 +204,7 @@ int main(void) { char header_str[] = "\x03\xf0hi hi "; strcpy(str, header_str); - printf("hi hi "); + printf("%s-1>CQ-1:hi hi ", CALLSIGN); int channel; for (channel = 1; channel < 7; channel++) { From f308d5d4ebc325681910d895b94e009dedb8b6a0 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sat, 20 Jul 2019 04:50:45 -0400 Subject: [PATCH 46/98] added command line Callsign --- afsk/main.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/afsk/main.c b/afsk/main.c index f708bbc3..896a1129 100644 --- a/afsk/main.c +++ b/afsk/main.c @@ -83,9 +83,14 @@ int x_currentDivider; int x_calValue; int y_fd; // I2C bus 0 address 0x41 int z_fd; // I2C bos 0 address 0x44 +char src_addr[] = ""; +char dest_addr[] = "CQ"; - -int main(void) { +int main(int argc, *argv[]) { + + if (argc > 1) { + strcpy(src_addr, argv[1]); + }` wiringPiSetup () ; pinMode (0, OUTPUT) ; int blink; @@ -181,7 +186,9 @@ int main(void) { init_rf(); // ax25_init(&hax25, (uint8_t *) "CubeSatSim", '2', (uint8_t *) CALLSIGN, '2', - ax25_init(&hax25, (uint8_t *) "CQ", '1', (uint8_t *) CALLSIGN, '1', +// ax25_init(&hax25, (uint8_t *) "CQ", '1', (uint8_t *) CALLSIGN, '1', + + ax25_init(&hax25, (uint8_t *) dest_addr, '1', (uint8_t *) src_addr, '1', AX25_PREAMBLE_LEN, AX25_POSTAMBLE_LEN); @@ -204,7 +211,9 @@ int main(void) { char header_str[] = "\x03\xf0hi hi "; strcpy(str, header_str); - printf("%s-1>CQ-1:hi hi ", CALLSIGN); + // printf("%s-1>CQ-1:hi hi ", CALLSIGN); + printf("%s-1>%s-1:hi hi ", src_addr, dest_addr); + int channel; for (channel = 1; channel < 7; channel++) { From 1141fe958de3d67012f9e29d021565726d2e97bd Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sat, 20 Jul 2019 04:51:58 -0400 Subject: [PATCH 47/98] Update main.c --- afsk/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/afsk/main.c b/afsk/main.c index 896a1129..c4f08966 100644 --- a/afsk/main.c +++ b/afsk/main.c @@ -86,7 +86,7 @@ int z_fd; // I2C bos 0 address 0x44 char src_addr[] = ""; char dest_addr[] = "CQ"; -int main(int argc, *argv[]) { +int main(int argc, char *argv[]) { if (argc > 1) { strcpy(src_addr, argv[1]); From e06842a698379de00abc85f36693b0b6755620ad Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sat, 20 Jul 2019 04:52:30 -0400 Subject: [PATCH 48/98] Update main.c --- afsk/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/afsk/main.c b/afsk/main.c index c4f08966..4878cb7c 100644 --- a/afsk/main.c +++ b/afsk/main.c @@ -90,7 +90,7 @@ int main(int argc, char *argv[]) { if (argc > 1) { strcpy(src_addr, argv[1]); - }` + } wiringPiSetup () ; pinMode (0, OUTPUT) ; int blink; From b645db5d5d4e01c19b1be17117130f2b8bf33abc Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sat, 20 Jul 2019 05:03:20 -0400 Subject: [PATCH 49/98] Update main.c --- afsk/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/afsk/main.c b/afsk/main.c index 4878cb7c..a241d07c 100644 --- a/afsk/main.c +++ b/afsk/main.c @@ -212,7 +212,7 @@ int main(int argc, char *argv[]) { char header_str[] = "\x03\xf0hi hi "; strcpy(str, header_str); // printf("%s-1>CQ-1:hi hi ", CALLSIGN); - printf("%s-1>%s-1:hi hi ", src_addr, dest_addr); + printf("%s>%s:hi hi ", src_addr, dest_addr); int channel; From 2bbd6a31167d0880b360e45b5bdbd53d07b4f475 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sat, 20 Jul 2019 05:05:19 -0400 Subject: [PATCH 50/98] Update main.c --- afsk/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/afsk/main.c b/afsk/main.c index a241d07c..12af710c 100644 --- a/afsk/main.c +++ b/afsk/main.c @@ -212,7 +212,7 @@ int main(int argc, char *argv[]) { char header_str[] = "\x03\xf0hi hi "; strcpy(str, header_str); // printf("%s-1>CQ-1:hi hi ", CALLSIGN); - printf("%s>%s:hi hi ", src_addr, dest_addr); + printf("%s %s hi hi ", src_addr, dest_addr); int channel; From a88e52af5a45eb93fcb8b6b5c2cc814896810c7d Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sat, 20 Jul 2019 05:12:38 -0400 Subject: [PATCH 51/98] callsign added via command line argv[1] --- afsk/main.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/afsk/main.c b/afsk/main.c index 12af710c..39ecbdb4 100644 --- a/afsk/main.c +++ b/afsk/main.c @@ -83,8 +83,8 @@ int x_currentDivider; int x_calValue; int y_fd; // I2C bus 0 address 0x41 int z_fd; // I2C bos 0 address 0x44 -char src_addr[] = ""; -char dest_addr[] = "CQ"; +char src_addr[5] = ""; +char dest_addr[5] = "CQ"; int main(int argc, char *argv[]) { @@ -212,7 +212,7 @@ int main(int argc, char *argv[]) { char header_str[] = "\x03\xf0hi hi "; strcpy(str, header_str); // printf("%s-1>CQ-1:hi hi ", CALLSIGN); - printf("%s %s hi hi ", src_addr, dest_addr); + printf("%s-1>%s-1:hi hi ", (uint8_t *)src_addr, (uint8_t *)dest_addr); int channel; From 83cec356712c7a7485ee736c51433f3f5fee02da Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sat, 20 Jul 2019 05:43:21 -0400 Subject: [PATCH 52/98] frequency set to 434.9 MHz --- afsk/main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/afsk/main.c b/afsk/main.c index 39ecbdb4..f626f01e 100644 --- a/afsk/main.c +++ b/afsk/main.c @@ -57,7 +57,7 @@ #define POWER 2 #define VBATT 15 -uint32_t tx_freq_hz = 440310000; +uint32_t tx_freq_hz = 434900000 + FREQUENCY_OFFSET; uint32_t tx_channel = 0; ax5043_conf_t hax5043; @@ -181,7 +181,7 @@ int main(int argc, char *argv[]) { int ret; uint8_t data[1024]; - tx_freq_hz -= tx_channel * 50000; + tx_freq_hz -= tx_channel * 50000 + 85000; // subtracting rx offset of 90kHz init_rf(); From bd5b35c7849b30d38760c13486f91a9d7c891ea1 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sun, 21 Jul 2019 10:42:26 -0400 Subject: [PATCH 53/98] renamed config to x_config --- afsk/main.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/afsk/main.c b/afsk/main.c index 2760c35b..f5a52c42 100644 --- a/afsk/main.c +++ b/afsk/main.c @@ -93,7 +93,7 @@ int upper_digit(int number); int lower_digit(int number); int charging = 0; -uint16_t config = (0x2000 | 0x1800 | 0x0180 | 0x0018 | 0x0007 ); +uint16_t x_config = (0x2000 | 0x1800 | 0x0180 | 0x0018 | 0x0007 ); int x_fd; // I2C bus 0 address 0x40 int x_powerMultiplier; @@ -151,7 +151,7 @@ int main(int argc, char *argv[]) { x_calValue = 4096; //8192; x_powerMultiplier = 2; x_currentDivider = 10; - config = INA219_CONFIG_BVOLTAGERANGE_32V | + x_config = INA219_CONFIG_BVOLTAGERANGE_32V | INA219_CONFIG_GAIN_320MV | // 40MV | INA219_CONFIG_BADCRES_12BIT | // INA219_CONFIG_SADCRES_12BIT_4S_2130US | @@ -213,7 +213,7 @@ int main(int argc, char *argv[]) { x_calValue = 8192; x_powerMultiplier = 1; x_currentDivider = 20; - config = INA219_CONFIG_BVOLTAGERANGE_16V | + x_config = INA219_CONFIG_BVOLTAGERANGE_16V | INA219_CONFIG_GAIN_40MV | INA219_CONFIG_BADCRES_12BIT | INA219_CONFIG_SADCRES_12BIT_4S_2130US | @@ -415,7 +415,7 @@ int get_tlm(int tlm[][5]) { double x_current = 0, voltage = 0, x_power = 0, y_current = 0, y_voltage, y_power = 0, z_current = 0, z_voltage = 0, z_power = 0; if (x_fd != -1) { // wiringPiI2CWriteReg16(x_fd, INA219_REG_CALIBRATION, x_calValue); -// wiringPiI2CWriteReg16(x_fd, INA219_REG_CONFIG, config); +// wiringPiI2CWriteReg16(x_fd, INA219_REG_CONFIG, x_config); setCalibration_16V_400mA(x_fd); @@ -491,12 +491,12 @@ int get_tlm(int tlm[][5]) { x_current = wiringPiI2CReadReg16(x_fd, INA219_REG_CURRENT) / x_currentDivider; x_power = wiringPiI2CReadReg16(x_fd, INA219_REG_POWER) * x_powerMultiplier; wiringPiI2CWriteReg16(y_fd, INA219_REG_CALIBRATION, x_calValue); - wiringPiI2CWriteReg16(y_fd, INA219_REG_CONFIG, config); + wiringPiI2CWriteReg16(y_fd, INA219_REG_CONFIG, x_config); wiringPiI2CWriteReg16(y_fd, INA219_REG_CALIBRATION, x_calValue); y_current = wiringPiI2CReadReg16(y_fd, INA219_REG_CURRENT) / x_currentDivider; y_power = wiringPiI2CReadReg16(y_fd, INA219_REG_POWER) * x_powerMultiplier; wiringPiI2CWriteReg16(z_fd, INA219_REG_CALIBRATION, x_calValue); - wiringPiI2CWriteReg16(z_fd, INA219_REG_CONFIG, config); + wiringPiI2CWriteReg16(z_fd, INA219_REG_CONFIG, x_config); wiringPiI2CWriteReg16(z_fd, INA219_REG_CALIBRATION, x_calValue); z_current = wiringPiI2CReadReg16(y_fd, INA219_REG_CURRENT) / x_currentDivider; z_power = wiringPiI2CReadReg16(y_fd, INA219_REG_POWER) * x_powerMultiplier; From ff183d7378a5a95ab99e11c5f89b145a52229205 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sun, 21 Jul 2019 10:43:43 -0400 Subject: [PATCH 54/98] Update main.c --- afsk/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/afsk/main.c b/afsk/main.c index f5a52c42..8c0363c0 100644 --- a/afsk/main.c +++ b/afsk/main.c @@ -213,7 +213,7 @@ int main(int argc, char *argv[]) { x_calValue = 8192; x_powerMultiplier = 1; x_currentDivider = 20; - x_config = INA219_CONFIG_BVOLTAGERANGE_16V | + config = INA219_CONFIG_BVOLTAGERANGE_16V | INA219_CONFIG_GAIN_40MV | INA219_CONFIG_BADCRES_12BIT | INA219_CONFIG_SADCRES_12BIT_4S_2130US | From 4f031fa8132cd2832adb0469ecc2d7f15c115ea7 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sun, 21 Jul 2019 10:45:37 -0400 Subject: [PATCH 55/98] commented out extra curly bracket --- afsk/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/afsk/main.c b/afsk/main.c index 8c0363c0..6ae03fdb 100644 --- a/afsk/main.c +++ b/afsk/main.c @@ -205,7 +205,7 @@ int main(int argc, char *argv[]) { sensor[MINUS_Y] = OFF; sensor[MINUS_Z] = OFF; } - } +// } Extra close bracket?? } // new INA219 current reading code From 9b31ba1370a1c32c82e3a8f060fc2bc2c549342a Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sun, 21 Jul 2019 10:48:42 -0400 Subject: [PATCH 56/98] commented out arduinoI2C --- afsk/main.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/afsk/main.c b/afsk/main.c index 6ae03fdb..c47fa0d3 100644 --- a/afsk/main.c +++ b/afsk/main.c @@ -213,7 +213,7 @@ int main(int argc, char *argv[]) { x_calValue = 8192; x_powerMultiplier = 1; x_currentDivider = 20; - config = INA219_CONFIG_BVOLTAGERANGE_16V | + x_config = INA219_CONFIG_BVOLTAGERANGE_16V | INA219_CONFIG_GAIN_40MV | INA219_CONFIG_BADCRES_12BIT | INA219_CONFIG_SADCRES_12BIT_4S_2130US | @@ -291,8 +291,8 @@ int main(int argc, char *argv[]) { printf("%s",tlm_str); strcat(str, tlm_str); } - - if (arduinoI2C > 0) { /* Read Arduino payload */ +/* + if (arduinoI2C > 0) { // Read Arduino payload for(int reg = 0; reg < 4; reg++) { sprintf(tlm_str, " %04x",wiringPiI2CReadReg16(arduinoI2C,reg)); #ifdef DEBUG_LOGGING @@ -303,6 +303,7 @@ int main(int argc, char *argv[]) { usleep(100000); } } +*/ printf("\n"); digitalWrite (0, LOW); From ea059afeb64668907fda2eb3f455537d54ef439c Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sun, 21 Jul 2019 10:49:36 -0400 Subject: [PATCH 57/98] Update main.c --- afsk/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/afsk/main.c b/afsk/main.c index c47fa0d3..626ad2f7 100644 --- a/afsk/main.c +++ b/afsk/main.c @@ -298,7 +298,7 @@ int main(int argc, char *argv[]) { #ifdef DEBUG_LOGGING printf("%s \n",tlm_str); #endif - strcat(str,tlm_str); /* Append payload telemetry */ + strcat(str,tlm_str); // Append payload telemetry printf("%s",tlm_str); usleep(100000); } From c979313e9fd17c0469b4e65c97c6f20be91d7765 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sun, 21 Jul 2019 11:10:28 -0400 Subject: [PATCH 58/98] Compiling now, no -x, -y, or -z current; removed CALLSIGN --- afsk/main.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/afsk/main.c b/afsk/main.c index 626ad2f7..d6d0b0d8 100644 --- a/afsk/main.c +++ b/afsk/main.c @@ -33,7 +33,6 @@ #include #include "ina219.h" -#define CALLSIGN "" // Put your callsign here! #define VBATT 15 #define ADC5 17 #define ADC6 18 @@ -247,9 +246,6 @@ int main(int argc, char *argv[]) { init_rf(); -// ax25_init(&hax25, (uint8_t *) "CubeSatSim", '2', (uint8_t *) CALLSIGN, '2', -// ax25_init(&hax25, (uint8_t *) "CQ", '1', (uint8_t *) CALLSIGN, '1', - ax25_init(&hax25, (uint8_t *) dest_addr, '1', (uint8_t *) src_addr, '1', AX25_PREAMBLE_LEN, AX25_POSTAMBLE_LEN); From f7aa30efee5944eb16f188c54702d6654025c3a4 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sun, 21 Jul 2019 11:18:07 -0400 Subject: [PATCH 59/98] fixed x_fd, cleanup of rest --- afsk/main.c | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/afsk/main.c b/afsk/main.c index d6d0b0d8..b2d9fabf 100644 --- a/afsk/main.c +++ b/afsk/main.c @@ -165,9 +165,7 @@ int main(int argc, char *argv[]) { z_fd = -1; } else { -// x_fd = wiringPiI2CSetupInterface("/dev/i2c-0", 0x40); - x_fd = wiringPiI2CSetupInterface("/dev/i2c-1", 0x40); - + x_fd = wiringPiI2CSetupInterface("/dev/i2c-0", 0x40); fprintf(stderr,"Opening of -X fd %d\n", x_fd); y_fd = wiringPiI2CSetupInterface("/dev/i2c-0", 0x41); printf("Opening of -Y fd %d\n", y_fd); @@ -185,6 +183,7 @@ int main(int argc, char *argv[]) { sensor[BUS] = wiringPiI2CSetupInterface("/dev/i2c-1", 0x4a); } else { + printf("ERROR: /dev/i2c-1 not present \n"); sensor[PLUS_X] = OFF; sensor[PLUS_Y] = OFF; sensor[PLUS_Z] = OFF; @@ -200,6 +199,7 @@ int main(int argc, char *argv[]) { } else { + printf("ERROR: /dev/i2c-0 not present \n"); sensor[MINUS_X] = OFF; sensor[MINUS_Y] = OFF; sensor[MINUS_Z] = OFF; @@ -208,7 +208,7 @@ int main(int argc, char *argv[]) { } // new INA219 current reading code - +/* x_calValue = 8192; x_powerMultiplier = 1; x_currentDivider = 20; @@ -238,11 +238,11 @@ int main(int argc, char *argv[]) { fprintf(stderr, "Opening of -Z fd %d\n", z_fd); #endif } - +*/ int ret; uint8_t data[1024]; - tx_freq_hz -= tx_channel * 50000 + 85000; // subtracting rx offset of 90kHz + tx_freq_hz -= tx_channel * 50000; init_rf(); @@ -275,10 +275,6 @@ int main(int argc, char *argv[]) { int channel; for (channel = 1; channel < 7; channel++) { - #ifdef DEBUG_LOGGING - printf("%d %d %d %d \n", tlm[channel][1], tlm[channel][2], tlm[channel][3], tlm[channel][4]); - #endif - sprintf(tlm_str, "%d%d%d %d%d%d %d%d%d %d%d%d ", channel, upper_digit(tlm[channel][1]), lower_digit(tlm[channel][1]), channel, upper_digit(tlm[channel][2]), lower_digit(tlm[channel][2]), From 1fd7a2f0dea27b56f87750a52554e018dd7d4017 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sun, 21 Jul 2019 11:27:44 -0400 Subject: [PATCH 60/98] Update main.c --- afsk/main.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/afsk/main.c b/afsk/main.c index b2d9fabf..5fac9e6b 100644 --- a/afsk/main.c +++ b/afsk/main.c @@ -412,9 +412,9 @@ int get_tlm(int tlm[][5]) { setCalibration_16V_400mA(x_fd); -// int blink; -// for (blink = 1; blink < 20 ;blink++) { -/* delay(500); + int blink; + for (blink = 1; blink < 20 ;blink++) { + delay(500); int shuntVolts = wiringPiI2CReadReg16(x_fd, INA219_REG_SHUNTVOLTAGE); // * 0.01; delay(500); int busVolts = wiringPiI2CReadReg16(x_fd, INA219_REG_BUSVOLTAGE); // * 0.001; @@ -422,21 +422,24 @@ int get_tlm(int tlm[][5]) { double volts = busVolts * 0.001 + shuntVolts * 0.01; printf("********** -X 0x40 volts %4.2f busvoltage %d shutVoltage %d\n", volts, busVolts, shuntVolts); -*/ +/* float shuntVolts = getShuntVoltage_mV(x_fd); float busVolts = getBusVoltage_V(x_fd); x_current = getCurrent_mA(x_fd); x_power = getPower_mW(x_fd); voltage = shuntVolts + busVolts; +*/ #ifdef DEBUG_LOGGING - printf("-X 0x40 busVolts %4.2f shuntVolts %4.2f current %4.2f power %4.2f \n", busVolts, shuntVolts, x_current, x_power); - #endif - } + printf("-X 0x40 busVolts %4.2f shuntVolts %4.2f current %4.2f power %4.2f \n\n", busVolts, shuntVolts, x_current, x_power); + #endif + } + } int count; for (count = 0; count < 7; count++) { if (sensor[count] != OFF) { + printf("Reading of sensnsor[%d]\n", count); setCalibration_16V_400mA(sensor[count]); voltsShunt[count] = getShuntVoltage_mV(sensor[count])/1000; voltsBus[count] = getBusVoltage_V(sensor[count]); @@ -457,6 +460,7 @@ int get_tlm(int tlm[][5]) { } if (sensor[BUS] != OFF) // For MoPower V2 INA219 { + printf("Reading of sensnsor[%d] \n", BUS); setCalibration_16V_2A(sensor[BUS]); voltsShunt[BUS] = getShuntVoltage_mV(sensor[BUS])/1000; voltsBus[BUS] = getBusVoltage_V(sensor[BUS]); From 28353dd3deee66d0dde30750a598fcfe9ee9b4ee Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sun, 21 Jul 2019 11:33:38 -0400 Subject: [PATCH 61/98] switched x_fd to wireReadRegister --- afsk/main.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/afsk/main.c b/afsk/main.c index 5fac9e6b..e41d3535 100644 --- a/afsk/main.c +++ b/afsk/main.c @@ -407,17 +407,18 @@ int get_tlm(int tlm[][5]) { // read i2c current sensors // double x_current = 0, voltage = 0, x_power = 0, y_current = 0, y_voltage, y_power = 0, z_current = 0, z_voltage = 0, z_power = 0; if (x_fd != -1) { -// wiringPiI2CWriteReg16(x_fd, INA219_REG_CALIBRATION, x_calValue); -// wiringPiI2CWriteReg16(x_fd, INA219_REG_CONFIG, x_config); + wireWriteRegister(x_fd, INA219_REG_CALIBRATION, x_calValue); + wireWriteRegister(x_fd, INA219_REG_CONFIG, x_config); setCalibration_16V_400mA(x_fd); int blink; - for (blink = 1; blink < 20 ;blink++) { + for (blink = 1; blink < 4 ;blink++) { delay(500); - int shuntVolts = wiringPiI2CReadReg16(x_fd, INA219_REG_SHUNTVOLTAGE); // * 0.01; + int shuntVolts = wireReadRegister(x_fd, INA219_REG_SHUNTVOLTAGE); // * 0.01; + delay(500); - int busVolts = wiringPiI2CReadReg16(x_fd, INA219_REG_BUSVOLTAGE); // * 0.001; + int busVolts = wireReadRegister(x_fd, INA219_REG_BUSVOLTAGE); // * 0.001; busVolts = (int16_t)((busVolts >> 3) * 4); double volts = busVolts * 0.001 + shuntVolts * 0.01; From 397ba72eaf0bcf61723f7f3f84ff0b3cb0888163 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sun, 21 Jul 2019 11:39:47 -0400 Subject: [PATCH 62/98] cleanup of x_fd printfs --- afsk/main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/afsk/main.c b/afsk/main.c index e41d3535..44494e6f 100644 --- a/afsk/main.c +++ b/afsk/main.c @@ -422,7 +422,7 @@ int get_tlm(int tlm[][5]) { busVolts = (int16_t)((busVolts >> 3) * 4); double volts = busVolts * 0.001 + shuntVolts * 0.01; - printf("********** -X 0x40 volts %4.2f busvoltage %d shutVoltage %d\n", volts, busVolts, shuntVolts); +// printf("********** -X 0x40 volts %4.2f busvoltage %d shutVoltage %d\n", volts, busVolts, shuntVolts); /* float shuntVolts = getShuntVoltage_mV(x_fd); float busVolts = getBusVoltage_V(x_fd); @@ -431,7 +431,7 @@ int get_tlm(int tlm[][5]) { voltage = shuntVolts + busVolts; */ #ifdef DEBUG_LOGGING - printf("-X 0x40 busVolts %4.2f shuntVolts %4.2f current %4.2f power %4.2f \n\n", busVolts, shuntVolts, x_current, x_power); + printf("-X 0x40 volts %4.2f busVolts %4.2f shuntVolts %4.2f current %4.2f power %4.2f \n\n", volts, busVolts, shuntVolts, x_current, x_power); #endif } } From 6c495cd29c6be3010c379e8f8f9a811a718e093c Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sun, 21 Jul 2019 12:19:16 -0400 Subject: [PATCH 63/98] added #include "Adafruit_INA219/Adafruit_INA219.h" --- afsk/main.c | 1 + 1 file changed, 1 insertion(+) diff --git a/afsk/main.c b/afsk/main.c index 44494e6f..597d0c29 100644 --- a/afsk/main.c +++ b/afsk/main.c @@ -32,6 +32,7 @@ #include #include #include "ina219.h" +#include "Adafruit_INA219/Adafruit_INA219.h" #define VBATT 15 #define ADC5 17 From 4a9c9f97c79f40b3e054ef74bc1b8b976576edb6 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sun, 21 Jul 2019 12:21:14 -0400 Subject: [PATCH 64/98] fixed location of Adafruit_INA219.h --- afsk/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/afsk/main.c b/afsk/main.c index 597d0c29..d3eceb2d 100644 --- a/afsk/main.c +++ b/afsk/main.c @@ -32,7 +32,7 @@ #include #include #include "ina219.h" -#include "Adafruit_INA219/Adafruit_INA219.h" +#include "../Adafruit_INA219/Adafruit_INA219.h" #define VBATT 15 #define ADC5 17 From 9fc67b8e39b4a69cc03e882b132d78618f2a09dc Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sun, 21 Jul 2019 12:25:06 -0400 Subject: [PATCH 65/98] removed ina219.h since replaced by Adafruit --- afsk/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/afsk/main.c b/afsk/main.c index d3eceb2d..f290745d 100644 --- a/afsk/main.c +++ b/afsk/main.c @@ -31,7 +31,7 @@ #include #include #include -#include "ina219.h" +//#include "ina219.h" #include "../Adafruit_INA219/Adafruit_INA219.h" #define VBATT 15 From 9877a9caf154b765e88dbb14140567149931c3dd Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sun, 21 Jul 2019 12:30:49 -0400 Subject: [PATCH 66/98] replaced INA219_CONFIG_GAIN_8_320MV --- afsk/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/afsk/main.c b/afsk/main.c index f290745d..459f89d0 100644 --- a/afsk/main.c +++ b/afsk/main.c @@ -152,7 +152,7 @@ int main(int argc, char *argv[]) { x_powerMultiplier = 2; x_currentDivider = 10; x_config = INA219_CONFIG_BVOLTAGERANGE_32V | - INA219_CONFIG_GAIN_320MV | // 40MV | + INA219_CONFIG_GAIN_8_320MV | // 40MV | INA219_CONFIG_BADCRES_12BIT | // INA219_CONFIG_SADCRES_12BIT_4S_2130US | INA219_CONFIG_SADCRES_12BIT_1S_532US | From 58419e72a4311d088f0f54a95c00b7c50911b08d Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sun, 21 Jul 2019 13:08:12 -0400 Subject: [PATCH 67/98] Update main.c --- afsk/main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/afsk/main.c b/afsk/main.c index 459f89d0..25b55b7f 100644 --- a/afsk/main.c +++ b/afsk/main.c @@ -98,7 +98,7 @@ uint16_t x_config = (0x2000 | 0x1800 | 0x0180 | 0x0018 | 0x0007 ); int x_fd; // I2C bus 0 address 0x40 int x_powerMultiplier; int x_currentDivider; -int x_calValue; +uint16_t x_calValue; int y_fd; // I2C bus 0 address 0x41 int z_fd; // I2C bos 0 address 0x44 int sensor[8]; // 7 current sensors in Solar Power PCB plus one in MoPower UPS V2 @@ -432,7 +432,7 @@ int get_tlm(int tlm[][5]) { voltage = shuntVolts + busVolts; */ #ifdef DEBUG_LOGGING - printf("-X 0x40 volts %4.2f busVolts %4.2f shuntVolts %4.2f current %4.2f power %4.2f \n\n", volts, busVolts, shuntVolts, x_current, x_power); + printf("-X 0x40 volts %4.2f busVolts %d shuntVolts %d current %4.2f power %4.2f \n\n", volts, busVolts, shuntVolts); #endif } } From 8d5ecd3633c0c5f19df53dd45c294e8f56684ea1 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sun, 21 Jul 2019 13:13:42 -0400 Subject: [PATCH 68/98] fixed debug loging warning --- afsk/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/afsk/main.c b/afsk/main.c index 25b55b7f..d5b1d2f2 100644 --- a/afsk/main.c +++ b/afsk/main.c @@ -432,7 +432,7 @@ int get_tlm(int tlm[][5]) { voltage = shuntVolts + busVolts; */ #ifdef DEBUG_LOGGING - printf("-X 0x40 volts %4.2f busVolts %d shuntVolts %d current %4.2f power %4.2f \n\n", volts, busVolts, shuntVolts); + printf("-X 0x40 volts %4.2f busVolts %d shuntVolts %d \n\n", volts, busVolts, shuntVolts); #endif } } From 58eadd263ee5069474dc08f2af73d6ba92d60bdb Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sun, 21 Jul 2019 13:48:04 -0400 Subject: [PATCH 69/98] changed printf for sensor data --- afsk/main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/afsk/main.c b/afsk/main.c index d5b1d2f2..7a385d1a 100644 --- a/afsk/main.c +++ b/afsk/main.c @@ -441,7 +441,7 @@ int get_tlm(int tlm[][5]) { { if (sensor[count] != OFF) { - printf("Reading of sensnsor[%d]\n", count); + printf("Read sensnsor[%d] ", count); setCalibration_16V_400mA(sensor[count]); voltsShunt[count] = getShuntVoltage_mV(sensor[count])/1000; voltsBus[count] = getBusVoltage_V(sensor[count]); @@ -456,7 +456,7 @@ int get_tlm(int tlm[][5]) { power[count] = 0; } #ifdef DEBUG_LOGGING - printf(" sensor[%d] voltsBus %4.2f voltsShunt %4.2f current %4.2f power %4.2f \n", + printf("voltsBus %4.2f voltsShunt %4.2f current %4.2f power %4.2f \n", count, voltsBus[count], voltsShunt[count], current[count], power[count]); #endif } From ab7e10a6d637cf3bee6bae0093b52f19bcf6816a Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Mon, 22 Jul 2019 03:20:59 -0400 Subject: [PATCH 70/98] putting back master code for x_fd, y_fd, and z_fd --- afsk/main.c | 51 ++++++++++++++++++++++----------------------------- 1 file changed, 22 insertions(+), 29 deletions(-) diff --git a/afsk/main.c b/afsk/main.c index 7a385d1a..262dff0a 100644 --- a/afsk/main.c +++ b/afsk/main.c @@ -406,36 +406,29 @@ int get_tlm(int tlm[][5]) { } // read i2c current sensors // - double x_current = 0, voltage = 0, x_power = 0, y_current = 0, y_voltage, y_power = 0, z_current = 0, z_voltage = 0, z_power = 0; +// code added back from master + double x_current = 0, power = 0, y_current = 0, y_power = 0, z_current = 0, z_power = 0; if (x_fd != -1) { - wireWriteRegister(x_fd, INA219_REG_CALIBRATION, x_calValue); - wireWriteRegister(x_fd, INA219_REG_CONFIG, x_config); - - setCalibration_16V_400mA(x_fd); - - int blink; - for (blink = 1; blink < 4 ;blink++) { - delay(500); - int shuntVolts = wireReadRegister(x_fd, INA219_REG_SHUNTVOLTAGE); // * 0.01; - - delay(500); - int busVolts = wireReadRegister(x_fd, INA219_REG_BUSVOLTAGE); // * 0.001; - busVolts = (int16_t)((busVolts >> 3) * 4); - double volts = busVolts * 0.001 + shuntVolts * 0.01; - -// printf("********** -X 0x40 volts %4.2f busvoltage %d shutVoltage %d\n", volts, busVolts, shuntVolts); -/* - float shuntVolts = getShuntVoltage_mV(x_fd); - float busVolts = getBusVoltage_V(x_fd); - x_current = getCurrent_mA(x_fd); - x_power = getPower_mW(x_fd); - voltage = shuntVolts + busVolts; -*/ - #ifdef DEBUG_LOGGING - printf("-X 0x40 volts %4.2f busVolts %d shuntVolts %d \n\n", volts, busVolts, shuntVolts); - #endif - } - } + wiringPiI2CWriteReg16(x_fd, INA219_REG_CALIBRATION, x_calValue_x); + wiringPiI2CWriteReg16(x_fd, INA219_REG_CONFIG, config); + wiringPiI2CWriteReg16(x_fd, INA219_REG_CALIBRATION, x_calValue_x); + x_current = wiringPiI2CReadReg16(x_fd, INA219_REG_CURRENT) / x_currentDivider; + power = wiringPiI2CReadReg16(x_fd, INA219_REG_POWER) * x_powerMultiplier; + wiringPiI2CWriteReg16(y_fd, INA219_REG_CALIBRATION, x_calValue_x); + wiringPiI2CWriteReg16(y_fd, INA219_REG_CONFIG, config); + wiringPiI2CWriteReg16(y_fd, INA219_REG_CALIBRATION, x_calValue_x); + y_current = wiringPiI2CReadReg16(y_fd, INA219_REG_CURRENT) / x_currentDivider; + y_power = wiringPiI2CReadReg16(y_fd, INA219_REG_POWER) * x_powerMultiplier; + wiringPiI2CWriteReg16(z_fd, INA219_REG_CALIBRATION, x_calValue_x); + wiringPiI2CWriteReg16(z_fd, INA219_REG_CONFIG, config); + wiringPiI2CWriteReg16(z_fd, INA219_REG_CALIBRATION, x_calValue_x); + z_current = wiringPiI2CReadReg16(z_fd, INA219_REG_CURRENT) / x_currentDivider; + z_power = wiringPiI2CReadReg16(z_fd, INA219_REG_POWER) * x_powerMultiplier; + } + printf("-X 0x40 current %4.2f power %4.2f -Y 0x41 current %4.2f power %4.2f -Z 0x44 current %4.2f power %4.2f \n", + x_current, power, y_current, y_power, z_current, z_power); +// end of master code + int count; for (count = 0; count < 7; count++) { From 6b73a5a8eeea4913cf92f3bc2af4bc21e4fd8c4a Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Mon, 22 Jul 2019 03:30:20 -0400 Subject: [PATCH 71/98] x_calValue cleanup with code from master --- afsk/main.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/afsk/main.c b/afsk/main.c index 262dff0a..ee6e846b 100644 --- a/afsk/main.c +++ b/afsk/main.c @@ -98,7 +98,7 @@ uint16_t x_config = (0x2000 | 0x1800 | 0x0180 | 0x0018 | 0x0007 ); int x_fd; // I2C bus 0 address 0x40 int x_powerMultiplier; int x_currentDivider; -uint16_t x_calValue; +int x_calValue_x; int y_fd; // I2C bus 0 address 0x41 int z_fd; // I2C bos 0 address 0x44 int sensor[8]; // 7 current sensors in Solar Power PCB plus one in MoPower UPS V2 @@ -148,11 +148,11 @@ int main(int argc, char *argv[]) { fprintf(stderr,"tempSensor: %d \n",tempSensor); #endif - x_calValue = 4096; //8192; - x_powerMultiplier = 2; - x_currentDivider = 10; + x_calValue_x = 8192; + x_powerMultiplier = 1; + x_currentDivider = 20; x_config = INA219_CONFIG_BVOLTAGERANGE_32V | - INA219_CONFIG_GAIN_8_320MV | // 40MV | + INA219_CONFIG_GAIN_1_40MV | INA219_CONFIG_BADCRES_12BIT | // INA219_CONFIG_SADCRES_12BIT_4S_2130US | INA219_CONFIG_SADCRES_12BIT_1S_532US | From e87ea997f0011d13f2862299a12e413e795e33d9 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Mon, 22 Jul 2019 03:33:49 -0400 Subject: [PATCH 72/98] fixed config and x_power from master --- afsk/main.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/afsk/main.c b/afsk/main.c index ee6e846b..674857db 100644 --- a/afsk/main.c +++ b/afsk/main.c @@ -407,26 +407,26 @@ int get_tlm(int tlm[][5]) { // read i2c current sensors // // code added back from master - double x_current = 0, power = 0, y_current = 0, y_power = 0, z_current = 0, z_power = 0; + double x_current = 0, x_power = 0, y_current = 0, y_power = 0, z_current = 0, z_power = 0; if (x_fd != -1) { wiringPiI2CWriteReg16(x_fd, INA219_REG_CALIBRATION, x_calValue_x); - wiringPiI2CWriteReg16(x_fd, INA219_REG_CONFIG, config); + wiringPiI2CWriteReg16(x_fd, INA219_REG_CONFIG, x_config); wiringPiI2CWriteReg16(x_fd, INA219_REG_CALIBRATION, x_calValue_x); x_current = wiringPiI2CReadReg16(x_fd, INA219_REG_CURRENT) / x_currentDivider; - power = wiringPiI2CReadReg16(x_fd, INA219_REG_POWER) * x_powerMultiplier; + x_power = wiringPiI2CReadReg16(x_fd, INA219_REG_POWER) * x_powerMultiplier; wiringPiI2CWriteReg16(y_fd, INA219_REG_CALIBRATION, x_calValue_x); - wiringPiI2CWriteReg16(y_fd, INA219_REG_CONFIG, config); + wiringPiI2CWriteReg16(y_fd, INA219_REG_CONFIG, x_config); wiringPiI2CWriteReg16(y_fd, INA219_REG_CALIBRATION, x_calValue_x); y_current = wiringPiI2CReadReg16(y_fd, INA219_REG_CURRENT) / x_currentDivider; y_power = wiringPiI2CReadReg16(y_fd, INA219_REG_POWER) * x_powerMultiplier; wiringPiI2CWriteReg16(z_fd, INA219_REG_CALIBRATION, x_calValue_x); - wiringPiI2CWriteReg16(z_fd, INA219_REG_CONFIG, config); + wiringPiI2CWriteReg16(z_fd, INA219_REG_CONFIG, x_config); wiringPiI2CWriteReg16(z_fd, INA219_REG_CALIBRATION, x_calValue_x); z_current = wiringPiI2CReadReg16(z_fd, INA219_REG_CURRENT) / x_currentDivider; z_power = wiringPiI2CReadReg16(z_fd, INA219_REG_POWER) * x_powerMultiplier; } printf("-X 0x40 current %4.2f power %4.2f -Y 0x41 current %4.2f power %4.2f -Z 0x44 current %4.2f power %4.2f \n", - x_current, power, y_current, y_power, z_current, z_power); + x_current, x_power, y_current, y_power, z_current, z_power); // end of master code int count; From 4babd587122188118f112f1e0f877615593ce7de Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Mon, 22 Jul 2019 03:35:28 -0400 Subject: [PATCH 73/98] fixed printf --- afsk/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/afsk/main.c b/afsk/main.c index 674857db..613d099b 100644 --- a/afsk/main.c +++ b/afsk/main.c @@ -450,7 +450,7 @@ int get_tlm(int tlm[][5]) { } #ifdef DEBUG_LOGGING printf("voltsBus %4.2f voltsShunt %4.2f current %4.2f power %4.2f \n", - count, voltsBus[count], voltsShunt[count], current[count], power[count]); + voltsBus[count], voltsShunt[count], current[count], power[count]); #endif } if (sensor[BUS] != OFF) // For MoPower V2 INA219 From 235fd7d6dd244d6df3ffa9ea799b5c3226f6a706 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Mon, 22 Jul 2019 03:37:01 -0400 Subject: [PATCH 74/98] removed debug ina219[] printf --- afsk/main.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/afsk/main.c b/afsk/main.c index 613d099b..fa350e56 100644 --- a/afsk/main.c +++ b/afsk/main.c @@ -398,9 +398,9 @@ int get_tlm(int tlm[][5]) { while (data2 != NULL) { strcpy(ina219[i], data2); - #ifdef DEBUG_LOGGING - printf ("ina219[%d]=%s\n",i,ina219[i]); - #endif +// #ifdef DEBUG_LOGGING +// printf ("ina219[%d]=%s\n",i,ina219[i]); +// #endif data2 = strtok (NULL, " "); i++; } From 1addf19abc7706c567a94439458cb75c285afaed Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Mon, 22 Jul 2019 03:58:36 -0400 Subject: [PATCH 75/98] changed to all I2C telemetry --- afsk/main.c | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/afsk/main.c b/afsk/main.c index fa350e56..ba3c8d3b 100644 --- a/afsk/main.c +++ b/afsk/main.c @@ -498,20 +498,27 @@ int get_tlm(int tlm[][5]) { */ // printf("1B: ina219[%d]: %s val: %f \n", SENSOR_40 + CURRENT, ina219[SENSOR_40 + CURRENT], strtof(ina219[SENSOR_40 + CURRENT], NULL)); - tlm[1][A] = (int)(strtof(ina219[SENSOR_4A + CURRENTV], NULL) / 15 + 0.5) % 100; // Current of 5V supply to Pi - tlm[1][B] = (int) (99.5 - strtof(ina219[SENSOR_40 + CURRENTV], NULL)/10) % 100; // +X current [4] +// tlm[1][A] = (int)(strtof(ina219[SENSOR_4A + CURRENTV], NULL) / 15 + 0.5) % 100; // Current of 5V supply to Pi + tlm[1][A] = (int)(voltsBus[BUS] / 15 + 0.5) % 100; // Current of 5V supply to Pi +// tlm[1][B] = (int) (99.5 - strtof(ina219[SENSOR_40 + CURRENTV], NULL)/10) % 100; // +X current [4] + tlm[1][B] = (int) (99.5 - current[PLUS_X]/10) % 100; // +X current [4] tlm[1][C] = (int) (99.5 - x_current/10) % 100; // X- current [10] - tlm[1][D] = (int) (99.5 - strtof(ina219[SENSOR_41 + CURRENTV], NULL)/10) % 100; // +Y current [7] +// tlm[1][D] = (int) (99.5 - strtof(ina219[SENSOR_41 + CURRENTV], NULL)/10) % 100; // +Y current [7] + tlm[1][D] = (int) (99.5 - current[PLUS_Y]/10) % 100; // +Y current [7] tlm[2][A] = (int) (99.5 - y_current/10) % 100; // -Y current [10] - tlm[2][B] = (int) (99.5 - strtof(ina219[SENSOR_44 + CURRENTV], NULL)/10) % 100; // +Z current [10] // was 70/2m transponder power, AO-7 didn't have a Z panel +// tlm[2][B] = (int) (99.5 - strtof(ina219[SENSOR_44 + CURRENTV], NULL)/10) % 100; // +Z current [10] // was 70/2m transponder power, AO-7 didn't have a Z panel + tlm[2][B] = (int) (99.5 - current[PLUS_Z]/10) % 100; // +Z current [10] // was 70/2m transponder power, AO-7 didn't have a Z panel tlm[2][C] = (int) (99.5 - z_current/10) % 100; // -Z current (was timestamp) // tlm[2][C] = (int)((time(NULL) - timestamp) / 15) % 100; - tlm[2][D] = (int)(50.5 + strtof(ina219[SENSOR_45 + CURRENTV], NULL)/10.0) % 100; // NiMH Battery current +// tlm[2][D] = (int)(50.5 + strtof(ina219[SENSOR_45 + CURRENTV], NULL)/10.0) % 100; // NiMH Battery current + tlm[2][D] = (int)(50.5 + current[BAT]/10.0) % 100; // NiMH Battery current - tlm[3][A] = abs((int)((strtof(ina219[SENSOR_45 + VOLTAGE], NULL) * 10) - 65.5) % 100); - tlm[3][B] = (int)(strtof(ina219[SENSOR_4A + VOLTAGE], NULL) * 10.0) % 100; // 5V supply to Pi +// tlm[3][A] = abs((int)((strtof(ina219[SENSOR_45 + VOLTAGE], NULL) * 10) - 65.5) % 100); + tlm[3][A] = abs((int)((voltsBus[BAT] * 10) - 65.5) % 100); +// tlm[3][B] = (int)(strtof(ina219[SENSOR_4A + VOLTAGE], NULL) * 10.0) % 100; // 5V supply to Pi + tlm[3][B] = (int)(voltsBus[BUS] * 10.0) % 100; // 5V supply to Pi if (tempSensor != -1) { int tempValue = wiringPiI2CReadReg16(tempSensor, 0); From dc17fd64ed47309870a6c62ecc27b665e6d16a2a Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Mon, 22 Jul 2019 07:51:23 -0400 Subject: [PATCH 76/98] Added debug flag to Adafruit_INA219 --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index b8eb6573..a545bd17 100644 --- a/Makefile +++ b/Makefile @@ -97,7 +97,7 @@ radioafsk: Adafruit_INA219/Adafruit_INA219.h Adafruit_INA219/Adafruit_INA219.o: Adafruit_INA219/Adafruit_INA219.c Adafruit_INA219/Adafruit_INA219.o: Adafruit_INA219/Adafruit_INA219.h - cd Adafruit_INA219; gcc -I -pedantic -Wconversion -Wall -Wextra -c Adafruit_INA219.c; cd .. + cd Adafruit_INA219; gcc $(DEBUG_BEHAVIOR) -I -pedantic -Wconversion -Wall -Wextra -c Adafruit_INA219.c; cd .. ax5043/generated/configcommon.o: ax5043/generated/configcommon.c ax5043/generated/configcommon.o: ax5043/generated/configrx.h From 17d99e839ba19f5a0f87a69ce9079bb964e77a83 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Mon, 22 Jul 2019 08:14:25 -0400 Subject: [PATCH 77/98] added x_voltage, y_voltage, and z_voltage readings --- afsk/main.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/afsk/main.c b/afsk/main.c index ba3c8d3b..85bfdaff 100644 --- a/afsk/main.c +++ b/afsk/main.c @@ -407,26 +407,30 @@ int get_tlm(int tlm[][5]) { // read i2c current sensors // // code added back from master - double x_current = 0, x_power = 0, y_current = 0, y_power = 0, z_current = 0, z_power = 0; + double x_current = 0, x_voltage = 0, x_power = 0, y_current = 0, y_voltage = 0, y_power = 0, + z_current = 0, z_voltage = 0, z_power = 0; if (x_fd != -1) { wiringPiI2CWriteReg16(x_fd, INA219_REG_CALIBRATION, x_calValue_x); wiringPiI2CWriteReg16(x_fd, INA219_REG_CONFIG, x_config); wiringPiI2CWriteReg16(x_fd, INA219_REG_CALIBRATION, x_calValue_x); x_current = wiringPiI2CReadReg16(x_fd, INA219_REG_CURRENT) / x_currentDivider; + x_voltage = wiringPiI2CReadReg16(x_fd, INA219_REG_BUSVOLTAGE) / 1000; x_power = wiringPiI2CReadReg16(x_fd, INA219_REG_POWER) * x_powerMultiplier; wiringPiI2CWriteReg16(y_fd, INA219_REG_CALIBRATION, x_calValue_x); wiringPiI2CWriteReg16(y_fd, INA219_REG_CONFIG, x_config); wiringPiI2CWriteReg16(y_fd, INA219_REG_CALIBRATION, x_calValue_x); y_current = wiringPiI2CReadReg16(y_fd, INA219_REG_CURRENT) / x_currentDivider; + y_voltage = wiringPiI2CReadReg16(y_fd, INA219_REG_BUSVOLTAGE) / 1000; y_power = wiringPiI2CReadReg16(y_fd, INA219_REG_POWER) * x_powerMultiplier; wiringPiI2CWriteReg16(z_fd, INA219_REG_CALIBRATION, x_calValue_x); wiringPiI2CWriteReg16(z_fd, INA219_REG_CONFIG, x_config); wiringPiI2CWriteReg16(z_fd, INA219_REG_CALIBRATION, x_calValue_x); z_current = wiringPiI2CReadReg16(z_fd, INA219_REG_CURRENT) / x_currentDivider; + z_voltage = wiringPiI2CReadReg16(z_fd, INA219_REG_BUSVOLTAGE) / 1000; z_power = wiringPiI2CReadReg16(z_fd, INA219_REG_POWER) * x_powerMultiplier; - } - printf("-X 0x40 current %4.2f power %4.2f -Y 0x41 current %4.2f power %4.2f -Z 0x44 current %4.2f power %4.2f \n", - x_current, x_power, y_current, y_power, z_current, z_power); + } + printf("-X %4.2f V %4.2f mA power %4.2f mW -Y %4.2f V %4.2f mA %4.2f mW -Z %4.2f V %4.2f mA %4.2f mW \n", + x_voltage, x_current, x_power, y_voltage, y_current, y_power, z_voltage, z_current, z_power); // end of master code int count; From e46e82f18aac80ee03bf418ffb8f02855c5aba2d Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Mon, 22 Jul 2019 08:19:44 -0400 Subject: [PATCH 78/98] cleanup of V, mA, and mW printfs --- afsk/main.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/afsk/main.c b/afsk/main.c index 85bfdaff..7963a2c5 100644 --- a/afsk/main.c +++ b/afsk/main.c @@ -429,7 +429,7 @@ int get_tlm(int tlm[][5]) { z_voltage = wiringPiI2CReadReg16(z_fd, INA219_REG_BUSVOLTAGE) / 1000; z_power = wiringPiI2CReadReg16(z_fd, INA219_REG_POWER) * x_powerMultiplier; } - printf("-X %4.2f V %4.2f mA power %4.2f mW -Y %4.2f V %4.2f mA %4.2f mW -Z %4.2f V %4.2f mA %4.2f mW \n", + printf("-X %4.2f V %4.2fmA %4.2fmW -Y %4.2fV %4.2fmA %4.2fmW -Z %4.2fV %4.2fmA %4.2fmW \n", x_voltage, x_current, x_power, y_voltage, y_current, y_power, z_voltage, z_current, z_power); // end of master code @@ -453,7 +453,7 @@ int get_tlm(int tlm[][5]) { power[count] = 0; } #ifdef DEBUG_LOGGING - printf("voltsBus %4.2f voltsShunt %4.2f current %4.2f power %4.2f \n", + printf("%4.2fV %4.2fV %4.2fmA %4.2fmW \n", voltsBus[count], voltsShunt[count], current[count], power[count]); #endif } @@ -474,8 +474,8 @@ int get_tlm(int tlm[][5]) { power[BUS] = 0; } #ifdef DEBUG_LOGGING - printf(" sensor[%d] voltsBus %4.2f voltsShunt %4.2f current %4.2f power %4.2f \n", - count, voltsBus[BUS], voltsShunt[BUS], current[BUS], power[BUS]); + printf("%4.2fV %4.2fmA %4.2fmW \n", + voltsBus[BUS], voltsShunt[BUS], current[BUS], power[BUS]); #endif From b9b8d7e826ae7372dce68fc9006469dd5addf889 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Mon, 22 Jul 2019 08:20:54 -0400 Subject: [PATCH 79/98] fixed V printf --- afsk/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/afsk/main.c b/afsk/main.c index 7963a2c5..9188ab5a 100644 --- a/afsk/main.c +++ b/afsk/main.c @@ -474,7 +474,7 @@ int get_tlm(int tlm[][5]) { power[BUS] = 0; } #ifdef DEBUG_LOGGING - printf("%4.2fV %4.2fmA %4.2fmW \n", + printf("%4.2fV %4.2fV %4.2fmA %4.2fmW \n", voltsBus[BUS], voltsShunt[BUS], current[BUS], power[BUS]); #endif From eddd071771a444771ce653f1f368b1ba6adeec1a Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Mon, 22 Jul 2019 08:25:18 -0400 Subject: [PATCH 80/98] changed temp printf --- afsk/main.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/afsk/main.c b/afsk/main.c index 9188ab5a..67d523a0 100644 --- a/afsk/main.c +++ b/afsk/main.c @@ -526,14 +526,15 @@ int get_tlm(int tlm[][5]) { if (tempSensor != -1) { int tempValue = wiringPiI2CReadReg16(tempSensor, 0); - #ifdef DEBUG_LOGGING - printf("Temp Sensor Read: %x\n", tempValue); - #endif uint8_t upper = (uint8_t) (tempValue >> 8); uint8_t lower = (uint8_t) (tempValue & 0xff); float temp = (float)lower + ((float)upper / 0x100); - + + #ifdef DEBUG_LOGGING + printf("Temp Sensor Read: %6.1f\n", temp); + #endif + tlm[4][A] = (int)((95.8 - temp)/1.48 + 0.5) % 100; } From 09bc98a60a66e391fd1873efbcc91c67ed12c996 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Mon, 22 Jul 2019 08:27:18 -0400 Subject: [PATCH 81/98] got rid of "sensnsor" --- afsk/main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/afsk/main.c b/afsk/main.c index 67d523a0..50fdbbda 100644 --- a/afsk/main.c +++ b/afsk/main.c @@ -438,7 +438,7 @@ int get_tlm(int tlm[][5]) { { if (sensor[count] != OFF) { - printf("Read sensnsor[%d] ", count); + printf("Read sensor[%d] ", count); setCalibration_16V_400mA(sensor[count]); voltsShunt[count] = getShuntVoltage_mV(sensor[count])/1000; voltsBus[count] = getBusVoltage_V(sensor[count]); @@ -459,7 +459,7 @@ int get_tlm(int tlm[][5]) { } if (sensor[BUS] != OFF) // For MoPower V2 INA219 { - printf("Reading of sensnsor[%d] \n", BUS); + printf("Reading of sensor[%d] ", BUS); setCalibration_16V_2A(sensor[BUS]); voltsShunt[BUS] = getShuntVoltage_mV(sensor[BUS])/1000; voltsBus[BUS] = getBusVoltage_V(sensor[BUS]); From 03261b9cfe4f2dfd15c5aca87ff4d0b1a872d7da Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Mon, 22 Jul 2019 08:30:15 -0400 Subject: [PATCH 82/98] added missing #ifdef DEBUG_LOGGING around printfs --- afsk/main.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/afsk/main.c b/afsk/main.c index 50fdbbda..d9ad66a9 100644 --- a/afsk/main.c +++ b/afsk/main.c @@ -428,9 +428,12 @@ int get_tlm(int tlm[][5]) { z_current = wiringPiI2CReadReg16(z_fd, INA219_REG_CURRENT) / x_currentDivider; z_voltage = wiringPiI2CReadReg16(z_fd, INA219_REG_BUSVOLTAGE) / 1000; z_power = wiringPiI2CReadReg16(z_fd, INA219_REG_POWER) * x_powerMultiplier; - } - printf("-X %4.2f V %4.2fmA %4.2fmW -Y %4.2fV %4.2fmA %4.2fmW -Z %4.2fV %4.2fmA %4.2fmW \n", + } + #ifdef DEBUG_LOGGING + printf("-X %4.2f V %4.2fmA %4.2fmW -Y %4.2fV %4.2fmA %4.2fmW -Z %4.2fV %4.2fmA %4.2fmW \n", x_voltage, x_current, x_power, y_voltage, y_current, y_power, z_voltage, z_current, z_power); + #endif + // end of master code int count; @@ -438,7 +441,9 @@ int get_tlm(int tlm[][5]) { { if (sensor[count] != OFF) { - printf("Read sensor[%d] ", count); + #ifdef DEBUG_LOGGING + printf("Read sensor[%d] ", count); + #endif setCalibration_16V_400mA(sensor[count]); voltsShunt[count] = getShuntVoltage_mV(sensor[count])/1000; voltsBus[count] = getBusVoltage_V(sensor[count]); @@ -459,7 +464,9 @@ int get_tlm(int tlm[][5]) { } if (sensor[BUS] != OFF) // For MoPower V2 INA219 { - printf("Reading of sensor[%d] ", BUS); + #ifdef DEBUG_LOGGING + printf("Read sensor[%d] ", BUS); + #endif setCalibration_16V_2A(sensor[BUS]); voltsShunt[BUS] = getShuntVoltage_mV(sensor[BUS])/1000; voltsBus[BUS] = getBusVoltage_V(sensor[BUS]); From 52a9087bf04a2ab7bca390acd6b14774dbfa6151 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Mon, 22 Jul 2019 08:35:53 -0400 Subject: [PATCH 83/98] reconfigures power and voltage to eliminate no debug compiler warnings --- afsk/main.c | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/afsk/main.c b/afsk/main.c index d9ad66a9..9210c968 100644 --- a/afsk/main.c +++ b/afsk/main.c @@ -407,28 +407,36 @@ int get_tlm(int tlm[][5]) { // read i2c current sensors // // code added back from master - double x_current = 0, x_voltage = 0, x_power = 0, y_current = 0, y_voltage = 0, y_power = 0, - z_current = 0, z_voltage = 0, z_power = 0; + double x_current, y_current, z_current; if (x_fd != -1) { wiringPiI2CWriteReg16(x_fd, INA219_REG_CALIBRATION, x_calValue_x); wiringPiI2CWriteReg16(x_fd, INA219_REG_CONFIG, x_config); wiringPiI2CWriteReg16(x_fd, INA219_REG_CALIBRATION, x_calValue_x); x_current = wiringPiI2CReadReg16(x_fd, INA219_REG_CURRENT) / x_currentDivider; - x_voltage = wiringPiI2CReadReg16(x_fd, INA219_REG_BUSVOLTAGE) / 1000; - x_power = wiringPiI2CReadReg16(x_fd, INA219_REG_POWER) * x_powerMultiplier; + #ifdef DEBUG_LOGGING + double x_voltage, x_power; + x_voltage = wiringPiI2CReadReg16(x_fd, INA219_REG_BUSVOLTAGE) / 1000; + x_power = wiringPiI2CReadReg16(x_fd, INA219_REG_POWER) * x_powerMultiplier; + #endif wiringPiI2CWriteReg16(y_fd, INA219_REG_CALIBRATION, x_calValue_x); wiringPiI2CWriteReg16(y_fd, INA219_REG_CONFIG, x_config); wiringPiI2CWriteReg16(y_fd, INA219_REG_CALIBRATION, x_calValue_x); y_current = wiringPiI2CReadReg16(y_fd, INA219_REG_CURRENT) / x_currentDivider; - y_voltage = wiringPiI2CReadReg16(y_fd, INA219_REG_BUSVOLTAGE) / 1000; - y_power = wiringPiI2CReadReg16(y_fd, INA219_REG_POWER) * x_powerMultiplier; + #ifdef DEBUG_LOGGING + double y_voltage, y_power; + y_voltage = wiringPiI2CReadReg16(y_fd, INA219_REG_BUSVOLTAGE) / 1000; + y_power = wiringPiI2CReadReg16(y_fd, INA219_REG_POWER) * x_powerMultiplier; + #endif wiringPiI2CWriteReg16(z_fd, INA219_REG_CALIBRATION, x_calValue_x); wiringPiI2CWriteReg16(z_fd, INA219_REG_CONFIG, x_config); wiringPiI2CWriteReg16(z_fd, INA219_REG_CALIBRATION, x_calValue_x); z_current = wiringPiI2CReadReg16(z_fd, INA219_REG_CURRENT) / x_currentDivider; - z_voltage = wiringPiI2CReadReg16(z_fd, INA219_REG_BUSVOLTAGE) / 1000; - z_power = wiringPiI2CReadReg16(z_fd, INA219_REG_POWER) * x_powerMultiplier; - } + #ifdef DEBUG_LOGGING + double z_voltage, z_power; + z_voltage = wiringPiI2CReadReg16(z_fd, INA219_REG_BUSVOLTAGE) / 1000; + z_power = wiringPiI2CReadReg16(z_fd, INA219_REG_POWER) * x_powerMultiplier; + #endif + } #ifdef DEBUG_LOGGING printf("-X %4.2f V %4.2fmA %4.2fmW -Y %4.2fV %4.2fmA %4.2fmW -Z %4.2fV %4.2fmA %4.2fmW \n", x_voltage, x_current, x_power, y_voltage, y_current, y_power, z_voltage, z_current, z_power); From accfbe77475940ba4c41a3e947a41248a442a14e Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Mon, 22 Jul 2019 08:40:48 -0400 Subject: [PATCH 84/98] fixed #DEBUG LOGGING of x_fd, y_fd, and z_fd --- afsk/main.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/afsk/main.c b/afsk/main.c index 9210c968..2b37ccb5 100644 --- a/afsk/main.c +++ b/afsk/main.c @@ -167,11 +167,11 @@ int main(int argc, char *argv[]) { } else { x_fd = wiringPiI2CSetupInterface("/dev/i2c-0", 0x40); - fprintf(stderr,"Opening of -X fd %d\n", x_fd); y_fd = wiringPiI2CSetupInterface("/dev/i2c-0", 0x41); - printf("Opening of -Y fd %d\n", y_fd); - z_fd = wiringPiI2CSetupInterface("/dev/i2c-0", 0x44); - printf("Opening of -Z fd %d\n", z_fd); + z_fd = wiringPiI2CSetupInterface("/dev/i2c-0", 0x44); + #ifdef DEBUG_LOGGING + fprintf(stderr, "Opening of -X %d, -Y %d, -Z %d\n", x_fd, y_fd, z_fd); + #endif int test; if (((test = open("/dev/i2c-1", O_RDWR))) > 0) // Test if I2C Bus 1 is present From 0427a73b1ebe53f4f19db545c7e6b287be0a7b59 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Mon, 22 Jul 2019 08:43:58 -0400 Subject: [PATCH 85/98] commented out unneeded #defines --- afsk/main.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/afsk/main.c b/afsk/main.c index 2b37ccb5..d64cb0e9 100644 --- a/afsk/main.c +++ b/afsk/main.c @@ -33,7 +33,7 @@ #include //#include "ina219.h" #include "../Adafruit_INA219/Adafruit_INA219.h" - +/* #define VBATT 15 #define ADC5 17 #define ADC6 18 @@ -42,11 +42,12 @@ #define TIME 8 #define UCTEMP 30 #define UPTIME_SEC 8 +*/ #define A 1 #define B 2 #define C 3 #define D 4 - +/* #define SENSOR_40 0 #define SENSOR_41 3 #define SENSOR_44 6 @@ -55,6 +56,7 @@ #define VOLTAGE 0 #define CURRENTV 1 #define POWER 2 +*/ #define VBATT 15 #define PLUS_X 0 #define PLUS_Y 1 From eb6cff57d8de67b146f90c9b124ae10c8d9f0d0a Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Mon, 22 Jul 2019 08:46:41 -0400 Subject: [PATCH 86/98] fixed x_voltage, x_power definitions --- afsk/main.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/afsk/main.c b/afsk/main.c index d64cb0e9..c67755fb 100644 --- a/afsk/main.c +++ b/afsk/main.c @@ -410,13 +410,15 @@ int get_tlm(int tlm[][5]) { // read i2c current sensors // // code added back from master double x_current, y_current, z_current; + #ifdef DEBUG_LOGGING + double x_voltage, x_power, y_voltage, y_power, z_voltage, z_power; + #endif if (x_fd != -1) { wiringPiI2CWriteReg16(x_fd, INA219_REG_CALIBRATION, x_calValue_x); wiringPiI2CWriteReg16(x_fd, INA219_REG_CONFIG, x_config); wiringPiI2CWriteReg16(x_fd, INA219_REG_CALIBRATION, x_calValue_x); x_current = wiringPiI2CReadReg16(x_fd, INA219_REG_CURRENT) / x_currentDivider; - #ifdef DEBUG_LOGGING - double x_voltage, x_power; + #ifdef DEBUG_LOGGING x_voltage = wiringPiI2CReadReg16(x_fd, INA219_REG_BUSVOLTAGE) / 1000; x_power = wiringPiI2CReadReg16(x_fd, INA219_REG_POWER) * x_powerMultiplier; #endif @@ -425,7 +427,6 @@ int get_tlm(int tlm[][5]) { wiringPiI2CWriteReg16(y_fd, INA219_REG_CALIBRATION, x_calValue_x); y_current = wiringPiI2CReadReg16(y_fd, INA219_REG_CURRENT) / x_currentDivider; #ifdef DEBUG_LOGGING - double y_voltage, y_power; y_voltage = wiringPiI2CReadReg16(y_fd, INA219_REG_BUSVOLTAGE) / 1000; y_power = wiringPiI2CReadReg16(y_fd, INA219_REG_POWER) * x_powerMultiplier; #endif @@ -434,7 +435,6 @@ int get_tlm(int tlm[][5]) { wiringPiI2CWriteReg16(z_fd, INA219_REG_CALIBRATION, x_calValue_x); z_current = wiringPiI2CReadReg16(z_fd, INA219_REG_CURRENT) / x_currentDivider; #ifdef DEBUG_LOGGING - double z_voltage, z_power; z_voltage = wiringPiI2CReadReg16(z_fd, INA219_REG_BUSVOLTAGE) / 1000; z_power = wiringPiI2CReadReg16(z_fd, INA219_REG_POWER) * x_powerMultiplier; #endif From 57112c38b17934772bbdc64af3d446da441ffe57 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Mon, 22 Jul 2019 08:48:11 -0400 Subject: [PATCH 87/98] Changed -1 to OFF --- afsk/main.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/afsk/main.c b/afsk/main.c index c67755fb..58e4697a 100644 --- a/afsk/main.c +++ b/afsk/main.c @@ -67,6 +67,7 @@ #define MINUS_Z 6 #define BUS 7 #define OFF -1 + uint32_t tx_freq_hz = 434900000 + FREQUENCY_OFFSET; uint32_t tx_channel = 0; @@ -140,7 +141,7 @@ int main(int argc, char *argv[]) { if (file_i2c < 0) { fprintf(stderr,"ERROR: /dev/ic2-3 bus not present\n"); - tempSensor = -1; + tempSensor = OFF; } else { tempSensor = wiringPiI2CSetupInterface("/dev/i2c-3", 0x48); @@ -163,9 +164,9 @@ int main(int argc, char *argv[]) { if ((file_i2c = open("/dev/i2c-0", O_RDWR)) < 0) { fprintf(stderr,"ERROR: /dev/ic2-0 bus not present\n"); - x_fd = -1; - y_fd = -1; - z_fd = -1; + x_fd = OFF; + y_fd = OFF; + z_fd = OFF; } else { x_fd = wiringPiI2CSetupInterface("/dev/i2c-0", 0x40); @@ -413,7 +414,7 @@ int get_tlm(int tlm[][5]) { #ifdef DEBUG_LOGGING double x_voltage, x_power, y_voltage, y_power, z_voltage, z_power; #endif - if (x_fd != -1) { + if (x_fd != OFF) { wiringPiI2CWriteReg16(x_fd, INA219_REG_CALIBRATION, x_calValue_x); wiringPiI2CWriteReg16(x_fd, INA219_REG_CONFIG, x_config); wiringPiI2CWriteReg16(x_fd, INA219_REG_CALIBRATION, x_calValue_x); @@ -541,7 +542,7 @@ int get_tlm(int tlm[][5]) { // tlm[3][B] = (int)(strtof(ina219[SENSOR_4A + VOLTAGE], NULL) * 10.0) % 100; // 5V supply to Pi tlm[3][B] = (int)(voltsBus[BUS] * 10.0) % 100; // 5V supply to Pi - if (tempSensor != -1) { + if (tempSensor != OFF) { int tempValue = wiringPiI2CReadReg16(tempSensor, 0); uint8_t upper = (uint8_t) (tempValue >> 8); From 29522b3220706c1221954115c77f772857d23112 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Mon, 22 Jul 2019 08:51:09 -0400 Subject: [PATCH 88/98] changed to %+4.2f for sign alignment --- afsk/main.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/afsk/main.c b/afsk/main.c index 58e4697a..bac73628 100644 --- a/afsk/main.c +++ b/afsk/main.c @@ -441,7 +441,7 @@ int get_tlm(int tlm[][5]) { #endif } #ifdef DEBUG_LOGGING - printf("-X %4.2f V %4.2fmA %4.2fmW -Y %4.2fV %4.2fmA %4.2fmW -Z %4.2fV %4.2fmA %4.2fmW \n", + printf("-X %+4.2f V %+4.2fmA %+4.2fmW -Y %+4.2fV %+4.2fmA %+4.2fmW -Z %+4.2fV %+4.2fmA %+4.2fmW \n", x_voltage, x_current, x_power, y_voltage, y_current, y_power, z_voltage, z_current, z_power); #endif @@ -469,7 +469,7 @@ int get_tlm(int tlm[][5]) { power[count] = 0; } #ifdef DEBUG_LOGGING - printf("%4.2fV %4.2fV %4.2fmA %4.2fmW \n", + printf("%+4.2fV %+4.2fV %+4.2fmA %+4.2fmW \n", voltsBus[count], voltsShunt[count], current[count], power[count]); #endif } @@ -492,7 +492,7 @@ int get_tlm(int tlm[][5]) { power[BUS] = 0; } #ifdef DEBUG_LOGGING - printf("%4.2fV %4.2fV %4.2fmA %4.2fmW \n", + printf("%+4.2fV %+4.2fV %+4.2fmA %+4.2fmW \n", voltsBus[BUS], voltsShunt[BUS], current[BUS], power[BUS]); #endif From ee45b621755ed36addbd815ae6f14503f7c7baf3 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Mon, 22 Jul 2019 10:39:58 -0400 Subject: [PATCH 89/98] switched master code from 1 to 0 to test --- afsk/main.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/afsk/main.c b/afsk/main.c index bac73628..ebc84d0f 100644 --- a/afsk/main.c +++ b/afsk/main.c @@ -161,7 +161,7 @@ int main(int argc, char *argv[]) { INA219_CONFIG_SADCRES_12BIT_1S_532US | INA219_CONFIG_MODE_SANDBVOLT_CONTINUOUS; - if ((file_i2c = open("/dev/i2c-0", O_RDWR)) < 0) + if ((file_i2c = open("/dev/i2c-0", O_RDWR)) < 0) { fprintf(stderr,"ERROR: /dev/ic2-0 bus not present\n"); x_fd = OFF; @@ -169,9 +169,9 @@ int main(int argc, char *argv[]) { z_fd = OFF; } else { - x_fd = wiringPiI2CSetupInterface("/dev/i2c-0", 0x40); - y_fd = wiringPiI2CSetupInterface("/dev/i2c-0", 0x41); - z_fd = wiringPiI2CSetupInterface("/dev/i2c-0", 0x44); + x_fd = wiringPiI2CSetupInterface("/dev/i2c-1", 0x40); // switched to 1 from 0 + y_fd = wiringPiI2CSetupInterface("/dev/i2c-1", 0x41); // switched to 1 from 0 + z_fd = wiringPiI2CSetupInterface("/dev/i2c-1", 0x44); // switched to 1 from 0 #ifdef DEBUG_LOGGING fprintf(stderr, "Opening of -X %d, -Y %d, -Z %d\n", x_fd, y_fd, z_fd); #endif @@ -180,7 +180,7 @@ int main(int argc, char *argv[]) { if (((test = open("/dev/i2c-1", O_RDWR))) > 0) // Test if I2C Bus 1 is present { close(test); - sensor[PLUS_X] = wiringPiI2CSetupInterface("/dev/i2c-1", 0x40); + sensor[PLUS_X] = wiringPiI2CSetupInterface("/dev/i2c-1", 0x40); sensor[PLUS_Y] = wiringPiI2CSetupInterface("/dev/i2c-1", 0x41); sensor[PLUS_Z] = wiringPiI2CSetupInterface("/dev/i2c-1", 0x44); sensor[BAT] = wiringPiI2CSetupInterface("/dev/i2c-1", 0x45); From de2c89411d016bb25f215dc50538eb5756622583 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Mon, 22 Jul 2019 10:52:34 -0400 Subject: [PATCH 90/98] turning off master code i2c-1 read as a test --- afsk/main.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/afsk/main.c b/afsk/main.c index ebc84d0f..d24085ca 100644 --- a/afsk/main.c +++ b/afsk/main.c @@ -161,7 +161,7 @@ int main(int argc, char *argv[]) { INA219_CONFIG_SADCRES_12BIT_1S_532US | INA219_CONFIG_MODE_SANDBVOLT_CONTINUOUS; - if ((file_i2c = open("/dev/i2c-0", O_RDWR)) < 0) + if (1) // ((file_i2c = open("/dev/i2c-0", O_RDWR)) < 0) // turning off { fprintf(stderr,"ERROR: /dev/ic2-0 bus not present\n"); x_fd = OFF; @@ -175,7 +175,7 @@ int main(int argc, char *argv[]) { #ifdef DEBUG_LOGGING fprintf(stderr, "Opening of -X %d, -Y %d, -Z %d\n", x_fd, y_fd, z_fd); #endif - + } // moved here int test; if (((test = open("/dev/i2c-1", O_RDWR))) > 0) // Test if I2C Bus 1 is present { @@ -209,7 +209,7 @@ int main(int argc, char *argv[]) { sensor[MINUS_Z] = OFF; } // } Extra close bracket?? - } +// } // move up! // new INA219 current reading code /* From 6d2b7ae7983e758890995ddf3dbb9f497f079105 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Mon, 22 Jul 2019 11:21:13 -0400 Subject: [PATCH 91/98] reverted bus switch, testing new busVolts calculation --- afsk/main.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/afsk/main.c b/afsk/main.c index d24085ca..5234616f 100644 --- a/afsk/main.c +++ b/afsk/main.c @@ -161,7 +161,7 @@ int main(int argc, char *argv[]) { INA219_CONFIG_SADCRES_12BIT_1S_532US | INA219_CONFIG_MODE_SANDBVOLT_CONTINUOUS; - if (1) // ((file_i2c = open("/dev/i2c-0", O_RDWR)) < 0) // turning off + if ((file_i2c = open("/dev/i2c-0", O_RDWR)) < 0) { fprintf(stderr,"ERROR: /dev/ic2-0 bus not present\n"); x_fd = OFF; @@ -169,9 +169,9 @@ int main(int argc, char *argv[]) { z_fd = OFF; } else { - x_fd = wiringPiI2CSetupInterface("/dev/i2c-1", 0x40); // switched to 1 from 0 - y_fd = wiringPiI2CSetupInterface("/dev/i2c-1", 0x41); // switched to 1 from 0 - z_fd = wiringPiI2CSetupInterface("/dev/i2c-1", 0x44); // switched to 1 from 0 + x_fd = wiringPiI2CSetupInterface("/dev/i2c-0", 0x40); + y_fd = wiringPiI2CSetupInterface("/dev/i2c-0", 0x41); + z_fd = wiringPiI2CSetupInterface("/dev/i2c-0", 0x44); #ifdef DEBUG_LOGGING fprintf(stderr, "Opening of -X %d, -Y %d, -Z %d\n", x_fd, y_fd, z_fd); #endif @@ -413,6 +413,7 @@ int get_tlm(int tlm[][5]) { double x_current, y_current, z_current; #ifdef DEBUG_LOGGING double x_voltage, x_power, y_voltage, y_power, z_voltage, z_power; + uint16_t value; #endif if (x_fd != OFF) { wiringPiI2CWriteReg16(x_fd, INA219_REG_CALIBRATION, x_calValue_x); @@ -420,7 +421,9 @@ int get_tlm(int tlm[][5]) { wiringPiI2CWriteReg16(x_fd, INA219_REG_CALIBRATION, x_calValue_x); x_current = wiringPiI2CReadReg16(x_fd, INA219_REG_CURRENT) / x_currentDivider; #ifdef DEBUG_LOGGING - x_voltage = wiringPiI2CReadReg16(x_fd, INA219_REG_BUSVOLTAGE) / 1000; +// x_voltage = wiringPiI2CReadReg16(x_fd, INA219_REG_BUSVOLTAGE) / 1000; + value = wiringPiI2CReadReg16(x_fd, INA219_REG_BUSVOLTAGE); + x_voltage = ((double)(value >> 3) * 4) / 1000; x_power = wiringPiI2CReadReg16(x_fd, INA219_REG_POWER) * x_powerMultiplier; #endif wiringPiI2CWriteReg16(y_fd, INA219_REG_CALIBRATION, x_calValue_x); From b10a98064af7e043566a4851dad8288d943c14d5 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Mon, 22 Jul 2019 11:28:22 -0400 Subject: [PATCH 92/98] fixed value type --- afsk/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/afsk/main.c b/afsk/main.c index 5234616f..93515782 100644 --- a/afsk/main.c +++ b/afsk/main.c @@ -413,7 +413,7 @@ int get_tlm(int tlm[][5]) { double x_current, y_current, z_current; #ifdef DEBUG_LOGGING double x_voltage, x_power, y_voltage, y_power, z_voltage, z_power; - uint16_t value; + int value; #endif if (x_fd != OFF) { wiringPiI2CWriteReg16(x_fd, INA219_REG_CALIBRATION, x_calValue_x); From 3998bc3165be699ea1bae3811b7ca226a9c02080 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Mon, 22 Jul 2019 11:50:24 -0400 Subject: [PATCH 93/98] -X, -Y, and -Z voltage working! --- afsk/main.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/afsk/main.c b/afsk/main.c index 93515782..22adfd16 100644 --- a/afsk/main.c +++ b/afsk/main.c @@ -413,7 +413,7 @@ int get_tlm(int tlm[][5]) { double x_current, y_current, z_current; #ifdef DEBUG_LOGGING double x_voltage, x_power, y_voltage, y_power, z_voltage, z_power; - int value; + uint16_t value; #endif if (x_fd != OFF) { wiringPiI2CWriteReg16(x_fd, INA219_REG_CALIBRATION, x_calValue_x); @@ -422,7 +422,7 @@ int get_tlm(int tlm[][5]) { x_current = wiringPiI2CReadReg16(x_fd, INA219_REG_CURRENT) / x_currentDivider; #ifdef DEBUG_LOGGING // x_voltage = wiringPiI2CReadReg16(x_fd, INA219_REG_BUSVOLTAGE) / 1000; - value = wiringPiI2CReadReg16(x_fd, INA219_REG_BUSVOLTAGE); + value = (uint16_t)wireReadRegister(x_fd, INA219_REG_BUSVOLTAGE); x_voltage = ((double)(value >> 3) * 4) / 1000; x_power = wiringPiI2CReadReg16(x_fd, INA219_REG_POWER) * x_powerMultiplier; #endif @@ -431,7 +431,9 @@ int get_tlm(int tlm[][5]) { wiringPiI2CWriteReg16(y_fd, INA219_REG_CALIBRATION, x_calValue_x); y_current = wiringPiI2CReadReg16(y_fd, INA219_REG_CURRENT) / x_currentDivider; #ifdef DEBUG_LOGGING - y_voltage = wiringPiI2CReadReg16(y_fd, INA219_REG_BUSVOLTAGE) / 1000; +// y_voltage = wiringPiI2CReadReg16(y_fd, INA219_REG_BUSVOLTAGE) / 1000; + value = (uint16_t)wireReadRegister(y_fd, INA219_REG_BUSVOLTAGE); + y_voltage = ((double)(value >> 3) * 4) / 1000; y_power = wiringPiI2CReadReg16(y_fd, INA219_REG_POWER) * x_powerMultiplier; #endif wiringPiI2CWriteReg16(z_fd, INA219_REG_CALIBRATION, x_calValue_x); @@ -439,7 +441,9 @@ int get_tlm(int tlm[][5]) { wiringPiI2CWriteReg16(z_fd, INA219_REG_CALIBRATION, x_calValue_x); z_current = wiringPiI2CReadReg16(z_fd, INA219_REG_CURRENT) / x_currentDivider; #ifdef DEBUG_LOGGING - z_voltage = wiringPiI2CReadReg16(z_fd, INA219_REG_BUSVOLTAGE) / 1000; +// z_voltage = wiringPiI2CReadReg16(z_fd, INA219_REG_BUSVOLTAGE) / 1000; + value = (uint16_t)wireReadRegister(z_fd, INA219_REG_BUSVOLTAGE); + z_voltage = ((double)(value >> 3) * 4) / 1000; z_power = wiringPiI2CReadReg16(z_fd, INA219_REG_POWER) * x_powerMultiplier; #endif } From 1171effa927ac3645363b6c7148f3f6f46268ebc Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Mon, 22 Jul 2019 13:36:09 -0400 Subject: [PATCH 94/98] disable old code to test new code --- afsk/main.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/afsk/main.c b/afsk/main.c index 22adfd16..4ee3bb9c 100644 --- a/afsk/main.c +++ b/afsk/main.c @@ -415,6 +415,7 @@ int get_tlm(int tlm[][5]) { double x_voltage, x_power, y_voltage, y_power, z_voltage, z_power; uint16_t value; #endif +/* Disable old code if (x_fd != OFF) { wiringPiI2CWriteReg16(x_fd, INA219_REG_CALIBRATION, x_calValue_x); wiringPiI2CWriteReg16(x_fd, INA219_REG_CONFIG, x_config); @@ -451,7 +452,7 @@ int get_tlm(int tlm[][5]) { printf("-X %+4.2f V %+4.2fmA %+4.2fmW -Y %+4.2fV %+4.2fmA %+4.2fmW -Z %+4.2fV %+4.2fmA %+4.2fmW \n", x_voltage, x_current, x_power, y_voltage, y_current, y_power, z_voltage, z_current, z_power); #endif - +*/ // end of master code int count; From f2260ebc63c2f3470f325ac82a1abd041f556c75 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Mon, 22 Jul 2019 14:17:58 -0400 Subject: [PATCH 95/98] commented out last of x_fd, y_fd, and z_fd --- afsk/main.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/afsk/main.c b/afsk/main.c index 4ee3bb9c..7e20c097 100644 --- a/afsk/main.c +++ b/afsk/main.c @@ -150,7 +150,8 @@ int main(int argc, char *argv[]) { #ifdef DEBUG_LOGGING fprintf(stderr,"tempSensor: %d \n",tempSensor); #endif - + +/* start of old master code x_calValue_x = 8192; x_powerMultiplier = 1; x_currentDivider = 20; @@ -176,6 +177,7 @@ int main(int argc, char *argv[]) { fprintf(stderr, "Opening of -X %d, -Y %d, -Z %d\n", x_fd, y_fd, z_fd); #endif } // moved here +end of old code */ int test; if (((test = open("/dev/i2c-1", O_RDWR))) > 0) // Test if I2C Bus 1 is present { From e6fd3b3dca206bf61b84e563cb1f2384eef43d04 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Mon, 22 Jul 2019 14:26:16 -0400 Subject: [PATCH 96/98] changed order of current and bus reading to match old code --- afsk/main.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/afsk/main.c b/afsk/main.c index 7e20c097..7ec2d60f 100644 --- a/afsk/main.c +++ b/afsk/main.c @@ -466,9 +466,9 @@ int get_tlm(int tlm[][5]) { printf("Read sensor[%d] ", count); #endif setCalibration_16V_400mA(sensor[count]); - voltsShunt[count] = getShuntVoltage_mV(sensor[count])/1000; - voltsBus[count] = getBusVoltage_V(sensor[count]); current[count] = getCurrent_mA(sensor[count]); + voltsBus[count] = getBusVoltage_V(sensor[count]); + voltsShunt[count] = getShuntVoltage_mV(sensor[count])/1000; power[count] = getPower_mW(sensor[count]); } else @@ -489,9 +489,9 @@ int get_tlm(int tlm[][5]) { printf("Read sensor[%d] ", BUS); #endif setCalibration_16V_2A(sensor[BUS]); - voltsShunt[BUS] = getShuntVoltage_mV(sensor[BUS])/1000; - voltsBus[BUS] = getBusVoltage_V(sensor[BUS]); current[BUS] = getCurrent_mA(sensor[BUS]); // * 4; + voltsBus[BUS] = getBusVoltage_V(sensor[BUS]); + voltsShunt[BUS] = getShuntVoltage_mV(sensor[BUS])/1000; power[BUS] = getPower_mW(sensor[BUS]); // *2; } else From 8db31fc5c3860fc8064ab363da2611cdf029a37a Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Mon, 22 Jul 2019 14:32:23 -0400 Subject: [PATCH 97/98] commented out readcurrenty.py call --- afsk/main.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/afsk/main.c b/afsk/main.c index 7ec2d60f..3ca2df41 100644 --- a/afsk/main.c +++ b/afsk/main.c @@ -388,7 +388,8 @@ int upper_digit(int number) { } int get_tlm(int tlm[][5]) { - // Reading I2C voltage and current sensors + // Reading I2C voltage and current sensors +/* char cmdbuffer[1000]; FILE* file = popen("sudo python /home/pi/CubeSatSim/python/readcurrent.py 2>&1", "r"); fgets(cmdbuffer, 999, file); @@ -409,7 +410,8 @@ int get_tlm(int tlm[][5]) { data2 = strtok (NULL, " "); i++; } - +*/ + // read i2c current sensors // // code added back from master double x_current, y_current, z_current; From 61240b40ec7c42ef7fbe89cd1227f1fba0c2f738 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Tue, 23 Jul 2019 01:04:45 -0400 Subject: [PATCH 98/98] changed to all sensor[] tlm --- afsk/main.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/afsk/main.c b/afsk/main.c index 3ca2df41..4880bb61 100644 --- a/afsk/main.c +++ b/afsk/main.c @@ -536,14 +536,17 @@ int get_tlm(int tlm[][5]) { tlm[1][A] = (int)(voltsBus[BUS] / 15 + 0.5) % 100; // Current of 5V supply to Pi // tlm[1][B] = (int) (99.5 - strtof(ina219[SENSOR_40 + CURRENTV], NULL)/10) % 100; // +X current [4] tlm[1][B] = (int) (99.5 - current[PLUS_X]/10) % 100; // +X current [4] - tlm[1][C] = (int) (99.5 - x_current/10) % 100; // X- current [10] +// tlm[1][C] = (int) (99.5 - x_current/10) % 100; // X- current [10] + tlm[1][C] = (int) (99.5 - current[MINUS_X]/10) % 100; // X- current [10] // tlm[1][D] = (int) (99.5 - strtof(ina219[SENSOR_41 + CURRENTV], NULL)/10) % 100; // +Y current [7] tlm[1][D] = (int) (99.5 - current[PLUS_Y]/10) % 100; // +Y current [7] - tlm[2][A] = (int) (99.5 - y_current/10) % 100; // -Y current [10] +// tlm[2][A] = (int) (99.5 - y_current/10) % 100; // -Y current [10] + tlm[2][A] = (int) (99.5 - current[MINUS_Y]/10) % 100; // -Y current [10] // tlm[2][B] = (int) (99.5 - strtof(ina219[SENSOR_44 + CURRENTV], NULL)/10) % 100; // +Z current [10] // was 70/2m transponder power, AO-7 didn't have a Z panel tlm[2][B] = (int) (99.5 - current[PLUS_Z]/10) % 100; // +Z current [10] // was 70/2m transponder power, AO-7 didn't have a Z panel - tlm[2][C] = (int) (99.5 - z_current/10) % 100; // -Z current (was timestamp) +// tlm[2][C] = (int) (99.5 - z_current/10) % 100; // -Z current (was timestamp) + tlm[2][C] = (int) (99.5 - current[MINUS_Z]/10) % 100; // -Z current (was timestamp) // tlm[2][C] = (int)((time(NULL) - timestamp) / 15) % 100; // tlm[2][D] = (int)(50.5 + strtof(ina219[SENSOR_45 + CURRENTV], NULL)/10.0) % 100; // NiMH Battery current