Merge pull request #48 from alanbjohnston/dev

Dev
pull/52/head
alanbjohnston 6 years ago committed by GitHub
commit 236654dd9c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -4,7 +4,7 @@ The CubeSat Simulator https://github.com/alanbjohnston/CubeSatSim/wiki is a low
There are several hardware versions and software branches to go with them - see below for information.
See the Wiki Software Install page for more details: https://github.com/alanbjohnston/CubeSatSim/wiki/Software-Install. To build and run the software on a Raspberry Pi 3B, 3B+, or Pi Zero W (doesn't work on Pi 4 since rpitx doesn't work on it yet):
See the Wiki Software Install page for more details: https://github.com/alanbjohnston/CubeSatSim/wiki/Software-Install. To build and run the software on a Raspberry Pi 3B, 3B+, Pi Zero or Pi Zero W (doesn't work on Pi 4 since rpitx doesn't work on it yet):
Requires:
- Raspbian Stretch or Buster, full desktop or Lite
- wiringpi
@ -14,9 +14,15 @@ Requires:
- Direwolf
- rpitx
See the Wiki Software Install page for more details: https://github.com/alanbjohnston/CubeSatSim/wiki/Software-Install. To build and run the software on a Raspberry Pi 3B, 3B+, or Pi Zero W (Does NOT work on a Pi 4 since rpitx does not work on it yet):
See the Wiki Software Install page for more details: https://github.com/alanbjohnston/CubeSatSim/wiki/Software-Install. Runs on a Raspberry Pi 3B, 3B+, or Pi Zero W (Does NOT work on a Pi 4 since rpitx does not work on it yet). The Pi Zero W or Pi Zero are recommended since they are draw the least power and will result in the best performance under battery power.
`sudo apt-get install -y wiringpi git libasound2-dev i2c-tools`
These instructions assume a Pi Zero W with WiFi connectivity. If you have a Pi Zero, follow these instructions to get connectivity: https://desertbot.io/blog/headless-pi-zero-ssh-access-over-usb-windows
To begin the software install, after logging in type:
`sudo apt update -y && sudo apt dist-upgrade -y`
`sudo apt install -y wiringpi git libasound2-dev i2c-tools`
Run raspi-config and enable the I2C bus by selecting Option 5 Interfacing Options and then Option 5 I2C and selecting Y to enable the ARM I2C bus:
@ -80,6 +86,9 @@ Create a sim.cfg configuration file with your amateur radio callsign (in all cap
`echo "callsign" >> sim.cfg`
`echo "ARG1=f" >> .mode`
This will set the telemetry mode to FSK. To set it to AFSK or BPSK, change it to ARG1=a or ARG1=b
Compile the code:
`make rebuild`
@ -125,6 +134,10 @@ To make the demo.sh script run automatically on boot:
`sudo systemctl enable cubesatsim`
`sudo cp ~/CubeSatSim/systemd/rpitx.service /etc/systemd/system/rpitx.service`
`sudo systemctl enable rpitx`
Now reboot for all the changes to take effect:
`sudo reboot now`
@ -133,13 +146,25 @@ After rebooting, tune your radio or SDR to 434.9 MHz FM, and you should get a si
On the Main Board, the green LED will be on when the CubeSatSim software is running. The red LED when charging is occuring either through the micro USB or through the solar panels. The blue LED will illuminate when the CubeSatSim is transmitting.
The demo.sh script alternates between two modes:
1. Continuous DUV FSK telmetry, decodeable by FoxTelem
2. Alternativing between APRS AFSK, FSK, and BPSK telemetry
The push button with the pi-power-button software will cause the Pi to reboot, change telemetry mode, or shutdown. Pressing and holding the pushbutton will make the green power LED blink first once, then two times, then three times, then blinks slowly. Depending on when you release the button, different things will happen. Here's what happens if you:
Press and release (don't hold button in at all): reboots CubeSatSim. The green LED will go out, and after 30 seconds, the CubeSatSim will be transmitting again.
Press and release after one blink of green LED: switches to AFSK telemetry mode. After about 5 seconds, the telemetry mode will switch to AFSK.
Press and release after two blinks of green LED: switches to FSK mode. After about 5 seconds, the telemetry mode will switch to FSK.
Press and release after three blinks of green LED: switches to BPSK mode. After about 5 seconds, the telemetry mode will switch to BPSK.
Press and release after green LED begins slow blinking: shuts down CubeSatSim.
Once the CubeSatSim shuts down, the RBF pin can then be safely inserted. Removing the RBF pin or pressing the push button will cause the CubeSatSim to start up again. It will use the same mode it was running when it was shutdown.
You can also change the telemetry mode using the command line. Edit the CubeSatSim/.mode file and change the value to change the mode. A value of ARG1=a will give you AFSK, ARG1=f will give you FSK, and ARG2=b gives BPSK. After saving the .mode file, restart the cubesatsim service to switch the mode by typing:
Pressing and releasing the push button will cause the Pi to reboot and change mode. The green LED will go off as it reboots.
`sudo systemctl restart cubesatsim`
Pressing and holding the pushbutton for 3 seconds will cause the green LED to flash, then the Pi will shutdown. The RBF pin can then be safely inserted. Removing the RBF pin or pressing the push button will cause the Pi to start.
Note that to get FoxTelem to decode BPSK, you need to be in BPSK Fox/Husky mode (depending on which version of FoxTelem). Also, you usually need to click on the center of the FFT. For the first 30 seconds, it is just a carrier, so there will be no lock. After that, it should lock and the Phasor will show a line that jumps around, and the Frame count should start increasing at the bottom of the FoxTelem window.
You can stop the service when it is running by SSH into the Pi and typing:

@ -90,9 +90,11 @@ int testCount = 0;
short int buffer[2336400]; // max size for 10 frames count of BPSK
#define S_RATE (48000) // (44100)
#define FSK 0
#define BPSK 1
#define AFSK 2
#define AFSK 1
#define FSK 2
#define BPSK 3
#define CW 4
int rpitxStatus = -1;
@ -120,8 +122,8 @@ char call[5];
int bitRate, mode, bufLen, rsFrames, payloads, rsFrameLen, dataLen, headerLen, syncBits, syncWord, parityLen, samples, frameCnt, samplePeriod;
float sleepTime;
int sampleTime = 0;
int cycle = OFF, cw_id = ON;
int sampleTime = 0, frames_sent = 0;
int cw_id = ON;
int vB4 = FALSE, vB5 = FALSE, ax5043 = FALSE, transmit = FALSE, onLed, onLedOn, onLedOff, txLed, txLedOn, txLedOff, payload = OFF;
float batteryThreshold = 0;
@ -256,8 +258,8 @@ int main(int argc, char *argv[]) {
}
else if (*argv[1] == 'c')
{
cycle = ON;
printf("Mode cycle on\n");
mode = CW;
printf("Mode CW\n");
}
else
{
@ -304,17 +306,15 @@ int main(int argc, char *argv[]) {
if (fgetc(file) == 48)
{
printf("SPI is enabled!\n");
file = popen("ls /dev/spidev0.* 2>&1", "r");
// printf("Result: %d char: %c \n",file, getc(file));
FILE *file2 = popen("ls /dev/spidev0.* 2>&1", "r");
// printf("Result getc: %c \n", getc(file2));
if (fgetc(file) != 'l')
if (fgetc(file2) != 'l')
{
printf("SPI devices present!\n");
// }
pclose(file2);
setSpiChannel(SPI_CHANNEL);
setSpiSpeed(SPI_SPEED);
initializeSpi();
@ -327,7 +327,7 @@ int main(int argc, char *argv[]) {
ax5043 = TRUE;
cw_id = OFF;
mode = AFSK;
cycle = OFF;
// cycle = OFF;
printf("Mode AFSK with AX5043\n");
transmit = TRUE;
}
@ -339,7 +339,7 @@ int main(int argc, char *argv[]) {
// {
// printf("SPI not enabled!\n");
// }
pclose(file);
txLed = 0; // defaults for vB3 board without TFB
txLedOn = LOW;
txLedOff = HIGH;
@ -399,11 +399,17 @@ int main(int argc, char *argv[]) {
}
pinMode (txLed, OUTPUT);
digitalWrite (txLed, txLedOff);
#ifdef DEBUG_LOGGING
printf("Tx LED Off\n");
#endif
pinMode (onLed, OUTPUT);
digitalWrite (onLed, onLedOn);
#ifdef DEBUG_LOGGING
printf("Tx LED On\n");
#endif
if ((cycle == ON) && !ax5043) // don't cycle modes if using AX5043
mode = (reset_count) % 3; // alternate between the three modes
// if ((cycle == ON) && !ax5043) // don't cycle modes if using AX5043
// mode = (reset_count) % 3; // alternate between the three modes
config_file = fopen("sim.cfg","w");
fprintf(config_file, "%s %d", call, reset_count);
@ -495,15 +501,16 @@ else
//uint8_t data[1024];
tx_freq_hz -= tx_channel * 50000;
/*
if (transmit == FALSE)
{
fprintf(stderr,"\nNo CubeSatSim Band Pass Filter detected. No transmissions after the CW ID.\n");
fprintf(stderr, " See http://cubesatsim.org/wiki for info about building a CubeSatSim\n\n");
}
// Send ID in CW (Morse Code)
cw_id = OFF;
if (cw_id == ON) // Don't send CW if using AX5043 or in mode cycling or set by 3rd argument
{
char cw_str[200];
@ -517,7 +524,10 @@ if (cw_id == ON) // Don't send CW if using AX5043 or in mode cycling or set by 3
strcat(cw_str, cw_footer);
//printf("Before 1st strcpy\n");
digitalWrite (txLed, txLedOn);
printf("Before cmd\n");
#ifdef DEBUG_LOGGING
printf("Tx LED On\n");
#endif
//printf("Before cmd\n");
//printf("CW String: %s\n", cw_str);
// FILE* f;
system(cw_str);
@ -527,13 +537,16 @@ printf("After command\n");
// sleep(7);
//printf("Before Write\n");
digitalWrite (txLed, txLedOn);
#ifdef DEBUG_LOGGING
printf("Tx LED On\n");
#endif
//printf("After Write\n");
}
//printf("Done CW!\n");
*/
while (loop-- != 0)
{
frames_sent++;
float batteryVoltage = read_sensor_data(sensor[BAT]).voltage;
#ifdef DEBUG_LOGGING
fprintf(stderr,"INFO: Battery voltage: %f V Battery Threshold %f V\n", batteryVoltage, batteryThreshold);
@ -592,7 +605,7 @@ while (loop-- != 0)
fprintf(stderr,"INFO: Getting TLM Data\n");
#endif
if (mode == AFSK)
if ((mode == AFSK) || (mode == CW))
{
get_tlm();
}
@ -609,10 +622,16 @@ while (loop-- != 0)
if (mode == BPSK)
{
digitalWrite (txLed, txLedOn);
#ifdef DEBUG_LOGGING
printf("Tx LED On\n");
#endif
printf("Sleeping to allow BPSK transmission to finish.\n");
sleep(loop_count * 5);
printf("Done sleeping\n");
digitalWrite (txLed, txLedOff);
#ifdef DEBUG_LOGGING
printf("Tx LED Off\n");
#endif
}
else if (mode == FSK)
{
@ -620,14 +639,21 @@ while (loop-- != 0)
sleep(loop_count);
printf("Done sleeping\n");
}
/*
// int transmit = popen("timeout 1 sudo /home/pi/rpitx/rpitx -i- -m RF -f 434.897e3","r");
int txResult = popen("sudo killall -9 rpitx > /dev/null 2>&1", "r");
int txResult = popen("sudo killall -9 rpitx > /dev/null 2>&1", "r");
pclose(txResult);
txResult = popen("sudo killall -9 sendiq > /dev/null 2>&1", "r");
pclose(txResult);
txResult = popen("sudo fuser -k 8080/tcp > /dev/null 2>&1", "r");
pclose(txResult);
if(cw_id == ON) // only turn off Power LED if CW ID is enabled (i.e. not demo.sh mode cycling)
digitalWrite (onLed, onLedOff);
#ifdef DEBUG_LOGGING
printf("Tx LED Off\n");
#endif
*/
return 0;
}
@ -677,6 +703,9 @@ int get_tlm(void) {
for (int j = 0; j < frameCnt; j++)
{
digitalWrite (txLed, txLedOn);
#ifdef DEBUG_LOGGING
printf("Tx LED On\n");
#endif
int tlm[7][5];
memset(tlm, 0, sizeof tlm);
@ -730,9 +759,10 @@ for (int j = 0; j < frameCnt; j++)
#endif
tlm[4][B] = (int)((95.8 - cpuTemp)/1.48 + 0.5) % 100;
fclose (cpuTempSensor);
}
fclose (cpuTempSensor);
tlm[6][B] = 0 ;
tlm[6][D] = 49 + rand() % 3;
@ -752,6 +782,7 @@ for (int j = 0; j < frameCnt; j++)
char header_str[] = "\x03\xf0hi hi ";
char header_str3[] = "echo '";
char header_str2[] = ">CQ:hi hi ";
char header_str4[] = "hi hi ";
char footer_str1[] = "\' > t.txt && echo \'";
char footer_str[] = ">CQ:hi hi ' >> t.txt && gen_packets -o telem.wav t.txt -r 48000 > /dev/null 2>&1 && cat telem.wav | csdr convert_i16_f | csdr gain_ff 7000 | csdr convert_f_samplerf 20833 | sudo /home/pi/rpitx/rpitx -i- -m RF -f 434.897e3 > /dev/null 2>&1";
@ -762,8 +793,14 @@ for (int j = 0; j < frameCnt; j++)
else
{
strcpy(str, header_str3);
strcat(str, call);
strcat(str, header_str2);
if (mode != CW)
{
strcat(str, call);
strcat(str, header_str2);
} else
{
strcat(str, header_str4);
}
}
int channel;
@ -776,11 +813,47 @@ for (int j = 0; j < frameCnt; j++)
// printf("%s",tlm_str);
strcat(str, tlm_str);
}
// CW
char cw_str2[500];
char cw_header2[] = "echo '";
char cw_footer2[] = "' > id.txt && gen_packets -M 20 id.txt -o morse.wav -r 48000 > /dev/null 2>&1 && cat morse.wav | csdr convert_i16_f | csdr gain_ff 7000 | csdr convert_f_samplerf 20833 | sudo /home/pi/rpitx/rpitx -i- -m RF -f 434.897e3";
strcpy(cw_str2, cw_header2);
//printf("Before 1st strcpy\n");
strcat(cw_str2, str);
//printf("Before 1st strcpy\n");
strcat(cw_str2, cw_footer2);
//printf("Before 1st strcpy\n");
digitalWrite (txLed, txLedOn);
#ifdef DEBUG_LOGGING
printf("Tx LED On\n");
#endif
//printf("Before cmd\n");
//printf("CW telem String: %s\n", cw_str2);
// FILE* f;
if (mode == CW)
system(cw_str2);
// printf("File %d \n", f);
// printf("close: %d \n", pclose(f)); // execute command and wait for termination before continuing
//printf("After command\n");
// sleep(7);
//printf("Before Write\n");
digitalWrite (txLed, txLedOn);
#ifdef DEBUG_LOGGING
printf("Tx LED On\n");
#endif
//printf("After Write\n");
//}
//printf("Done CW!\n");
if (ax5043)
{
digitalWrite (txLed, txLedOn);
fprintf(stderr,"INFO: Transmitting X.25 packet\n");
#ifdef DEBUG_LOGGING
printf("Tx LED On\n");
#endif
fprintf(stderr,"INFO: Transmitting X.25 packet using AX5043\n");
memcpy(data, str, strnlen(str, 256));
int ret = ax25_tx_frame(&hax25, &hax5043, data, strnlen(str, 256));
if (ret) {
@ -791,6 +864,9 @@ for (int j = 0; j < frameCnt; j++)
}
ax5043_wait_for_transmit();
digitalWrite (txLed, txLedOff);
#ifdef DEBUG_LOGGING
printf("Tx LED Off\n");
#endif
if (ret) {
fprintf(stderr,
@ -817,17 +893,26 @@ for (int j = 0; j < frameCnt; j++)
fprintf(stderr, " See http://cubesatsim.org/wiki for info about building a CubeSatSim\n\n");
}
digitalWrite (txLed, txLedOff);
#ifdef DEBUG_LOGGING
printf("Tx LED Off\n");
#endif
sleep(3);
digitalWrite (txLed, txLedOn);
#ifdef DEBUG_LOGGING
printf("Tx LED On\n");
#endif
}
//digitalWrite (txLed, txLedOff);
}
printf("End of get_tlm and rpitx =========================================================\n");
//printf("End of get_tlm and rpitx =========================================================\n");
digitalWrite (txLed, txLedOff);
#ifdef DEBUG_LOGGING
printf("Tx LED Off\n");
#endif
return;
}
@ -903,11 +988,17 @@ if (firstTime != ON)
{
// delay for sample period
digitalWrite (txLed, txLedOn);
#ifdef DEBUG_LOGGING
printf("Tx LED On\n");
#endif
while ((millis() - sampleTime) < samplePeriod)
sleep(sleepTime);
digitalWrite (txLed, txLedOff);
#ifdef DEBUG_LOGGING
printf("Tx LED Off\n");
#endif
printf("Sample period: %d\n",millis() - sampleTime);
sampleTime = millis();
@ -950,7 +1041,8 @@ if (firstTime != ON)
IHUcpuTemp = (int)((cpuTemp * 10.0) + 0.5);
}
fclose(cpuTempSensor);
memset(rs_frame,0,sizeof(rs_frame));
memset(parities,0,sizeof(parities));
@ -1000,16 +1092,14 @@ if (firstTime != ON)
if (payload == ON)
STEMBoardFailure = 0;
/*
posXv = 10, negXv = 20, posYv = 30, negYv = 40, posZv = 50, negZv = 60;
posXi = 110, negXi = 120, posYi = 130, negYi = 140, posZi = 150, negZi = 160;
*/
encodeA(b, 0 + head_offset, batt_a_v);
encodeB(b, 1 + head_offset, batt_b_v);
encodeA(b, 3 + head_offset, batt_c_v);
encodeA(b, 9 + head_offset, battCurr);
if (mode == FSK)
{
encodeA(b, 12 + head_offset,posXv);
encodeB(b, 13 + head_offset,negXv);
encodeA(b, 15 + head_offset,posYv);
@ -1023,20 +1113,31 @@ if (firstTime != ON)
encodeB(b, 25 + head_offset,negYi);
encodeA(b, 27 + head_offset,posZi);
encodeB(b, 28 + head_offset,negZi);
}
else // BPSK
{
encodeA(b, 12 + head_offset,posXv);
encodeB(b, 13 + head_offset,posYv);
encodeA(b, 15 + head_offset,posZv);
encodeB(b, 16 + head_offset,negXv);
encodeA(b, 18 + head_offset,negYv);
encodeB(b, 19 + head_offset,negZv);
encodeA(b, 21 + head_offset,posXi);
encodeB(b, 22 + head_offset,posYi);
encodeA(b, 24 + head_offset,posZi);
encodeB(b, 25 + head_offset,negXi);
encodeA(b, 27 + head_offset,negYi);
encodeB(b, 28 + head_offset,negZi);
}
encodeA(b, 30 + head_offset,PSUVoltage);
encodeB(b, 46 + head_offset,PSUCurrent);
encodeA(b, 39 + head_offset, IHUcpuTemp);
encodeB(b, 51 + head_offset, STEMBoardFailure);
/* batt_c_v += 10;
battCurr -= 10;
encodeA(b, 3 + head_offset, batt_c_v);
encodeA(b, 9 + head_offset, battCurr);
*/
short int data10[headerLen + rsFrames * (rsFrameLen + parityLen)];
short int data8[headerLen + rsFrames * (rsFrameLen + parityLen)];
@ -1212,42 +1313,46 @@ if (firstTime != ON)
// printf("\n");
// rpitx
/*
char cmdbuffer[1000];
FILE* txResult;
if ((rpitxStatus != mode)) // || (mode == BPSK))
if ((rpitxStatus != mode)) // || ((loop % 1000) == 0))
{ // change rpitx mode
rpitxStatus = mode;
printf("Changing rpitx mode!\n");
// txResult = popen("ps -ef | grep rpitx | grep -v grep | awk '{print $2}' | sudo xargs kill -9 > /dev/null 2>&1", "r");
txResult = popen("sudo killall -9 rpitx > /dev/null 2>&1", "r");
pclose(txResult);
// printf("1\n");
// sleep(1);
// txResult = popen("ps -ef | grep sendiq | grep -v grep | awk '{print $2}' | sudo xargs kill -9 > /dev/null 2>&1", "r");
txResult = popen("sudo killall -9 sendiq > /dev/null 2>&1", "r");
txResult = popen("sudo killall -9 sendiq > /dev/null 2>&1", "r");
pclose(txResult);
// printf("2\n");
// digitalWrite (txLed, txLedOn);
sleep(1);
txResult = popen("sudo fuser -k 8080/tcp > /dev/null 2>&1", "r");
txResult = popen("sudo fuser -k 8080/tcp > /dev/null 2>&1", "r");
pclose(txResult);
socket_open = 0;
// printf("3\n");
sleep(1);
// digitalWrite (txLed, txLedOff);
if (transmit)
{
if (mode == FSK) {
// txResult = popen("sudo nc -l 8080 | csdr convert_i16_f | csdr gain_ff 7000 | csdr convert_f_samplerf 20833 | sudo /home/pi/rpitx/rpitx -i- -m RF -f 434.896e3&", "r");
txResult = popen("sudo nc -l 8080 | csdr convert_i16_f | csdr gain_ff 7000 | csdr convert_f_samplerf 20833 | sudo /home/pi/rpitx/rpitx -i- -m RF -f 434.897e3&", "r");
// printf("4\n");
txResult = popen("sudo nc -l 8080 | csdr convert_i16_f | csdr gain_ff 7000 | csdr convert_f_samplerf 20833 | while true; do sudo timeout -k 1 60m /home/pi/rpitx/rpitx -i- -m RF -f 434.897e3; done &", "r");
pclose(txResult);
// printf("4\n");
} else if (mode == BPSK) {
// txResult = popen("sudo nc -l 8080 | csdr convert_i16_f | csdr fir_interpolate_cc 2 | csdr dsb_fc | csdr bandpass_fir_fft_cc 0.002 0.06 0.01 | csdr fastagc_ff | sudo /home/pi/CubeSatSim/rpitx/sendiq -i /dev/stdin -s 96000 -f 434.8925e6 -t float 2>&1&", "r");
txResult = popen("sudo nc -l 8080 | csdr convert_i16_f | csdr fir_interpolate_cc 2 | csdr dsb_fc | csdr bandpass_fir_fft_cc 0.002 0.06 0.01 | csdr fastagc_ff | sudo /home/pi/rpitx/sendiq -i /dev/stdin -s 96000 -f 434.8945e6 -t float 2>&1&", "r");
}
txResult = popen("sudo nc -l 8080 | csdr convert_i16_f | csdr fir_interpolate_cc 2 | csdr dsb_fc | csdr bandpass_fir_fft_cc 0.002 0.06 0.01 | csdr fastagc_ff | while true; do sudo timeout -k 1 60m /home/pi/rpitx/sendiq -i /dev/stdin -s 96000 -f 434.8945e6 -t float 2>&1; done &", "r");
pclose(txResult); }
// fgets(cmdbuffer, 1000, txResult);
pclose(txResult);
}
else
{
@ -1257,6 +1362,7 @@ if (firstTime != ON)
sleep(2);
// printf("Results of transmit command: %s\n", cmdbuffer);
}
*/
// socket write
@ -1326,7 +1432,11 @@ if (firstTime != ON)
fprintf(stderr, " See http://cubesatsim.org/wiki for info about building a CubeSatSim\n\n");
}
// digitalWrite (0, HIGH);
firstTime = 0;
if (mode == FSK)
firstTime = 0;
else if (frames_sent > 0) //5)
firstTime = 0;
return 0;
}

@ -2,28 +2,15 @@
echo -e "\nDemo of CubeSatSim at 434.9 MHz\n"
#exit
sudo systemctl restart rpitx
y=$(last reboot | grep ^reboot | wc -l)
echo $y
if (( $y % 2 == 0 ))
then
echo -e "\n Continuous FSK Mode\n\n"
/home/pi/CubeSatSim/radioafsk f
else
echo -e "\n Alternating FSK, BPSK, and AFSK telemetry Mode \n\n"
/home/pi/CubeSatSim/radioafsk afsk 5 y
while true; do
echo -e "\n Changing mode ******\n\n"
/home/pi/CubeSatSim/radioafsk fsk 5 n
/home/pi/CubeSatSim/radioafsk bpsk 5 n
# sleep 24
sleep 1
sudo killall -9 sendiq
sudo killall -9 sendiq
sleep 1
/home/pi/CubeSatSim/radioafsk afsk 5 n
done
if [ "$1" = "a" ]; then
echo "Mode is continuous AFSK"
/home/pi/CubeSatSim/radioafsk afsk
elif [ "$1" = "b" ]; then
echo "Mode is continuous BPSK"
/home/pi/CubeSatSim/radioafsk bpsk
else
echo "Mode is continuous FSK"
/home/pi/CubeSatSim/radioafsk fsk
fi

@ -22,4 +22,3 @@ sudo killall -9 gqrx &>/dev/null
#/usr/bin/chromium-browser --noerrdialogs --disable-infobars http://localhost:8073 &>/dev/null &
$SHELL

@ -1,4 +1,4 @@
#!/bin/bash
#!/bin/bash
# script to run RTL-TCP Server
#
# On SDR client, use 10.3.141.1:1234 to connect
@ -31,8 +31,6 @@ sudo systemctl stop openwebrx
sudo killall -9 rtl_tcp &>/dev/null
sudo killall -9 gqrx &>/dev/null
sudo systemctl start rtl_tcp
$SHELL

@ -1,3 +1,4 @@
[Unit]
Description=RTL-TCP
[Service]

@ -8,7 +8,9 @@ echo -e "IP Address to use in web browsers is: "
hostname -I|cut -f1 -d ' '
./kill_all.sh
#./kill_all.sh
sudo systemctl stop rtl_tcp
cd ~/openwebrx

@ -21,14 +21,6 @@ sudo killall -9 java &>/dev/null
sudo systemctl stop rtl_tcp
sudo killall -9 rtl_tcp &>/dev/null
sudo killall -9 gqrx &>/dev/null
sudo systemctl stop openwebrx
#sudo cp /etc/openwebrx/config_webrx_vhf.py /etc/openwebrx/config_webrx.py
sudo systemctl restart openwebrx
/usr/bin/chromium-browser --noerrdialogs --disable-infobars http://localhost:8073 &>/dev/null &

@ -0,0 +1,46 @@
#!/usr/bin/env python
import RPi.GPIO as GPIO
import subprocess
import time
import os
import sys
GPIO.setmode(GPIO.BCM)
GPIO.setwarnings(False)
GPIO.setup(27, GPIO.IN, pull_up_down=GPIO.PUD_UP)
GPIO.setup(12, GPIO.IN, pull_up_down=GPIO.PUD_UP)
transmit = False
if GPIO.input(12) == False:
transmit = True
if GPIO.input(27) == False:
transmit = True
print(transmit)
file = open("/home/pi/CubeSatSim/sim.cfg")
callsign = file.readline().split(" ")[0]
print(callsign)
os.system("echo 'de " + callsign + "' > id.txt && gen_packets -M 20 id.txt -o morse.wav -r 48000 > /dev/null 2>&1 && cat morse.wav | csdr convert_i16_f | csdr gain_ff 7000 | csdr convert_f_samplerf 20833 | sudo /home/pi/rpitx/rpitx -i- -m RF -f 434.9e3")
time.sleep(2)
if __name__ == "__main__":
print 'Length: ', len(sys.argv)
if (len(sys.argv)) > 1:
# print("There are arguments!")
if (('a' == sys.argv[1]) or ('afsk' in sys.argv[1])):
print("AFSK")
while True:
time.sleep(5)
elif (('b' == sys.argv[1]) or ('bpsk' in sys.argv[1])):
print("BPSK")
os.system("sudo nc -l 8080 | csdr convert_i16_f | csdr fir_interpolate_cc 2 | csdr dsb_fc | csdr bandpass_fir_fft_cc 0.002 0.06 0.01 | csdr fastagc_ff | sudo /home/pi/rpitx/sendiq -i /dev/stdin -s 96000 -f 434.9e6 -t float")
else:
print("FSK")
os.system("sudo nc -l 8080 | csdr convert_i16_f | csdr gain_ff 7000 | csdr convert_f_samplerf 20833 | sudo /home/pi/rpitx/rpitx -i- -m RF -f 434.9e3")
else:
print("FSK")
os.system("sudo nc -l 8080 | csdr convert_i16_f | csdr gain_ff 7000 | csdr convert_f_samplerf 20833 | sudo /home/pi/rpitx/rpitx -i- -m RF -f 434.9e3")

@ -0,0 +1,5 @@
#!/bin/bash
echo -e "\nrpitx for CubeSatSim at 434.9 MHz using python\n"
python /home/pi/CubeSatSim/rpitx.py $1

@ -7,10 +7,15 @@ sudo cp ~/CubeSatSim/systemd/cubesatsim.service /etc/systemd/system/cubesatsim.s
sudo systemctl enable cubesatsim
sudo cp ~/CubeSatSim/systemd/rpitx.service /etc/systemd/system/rpitx.service
sudo systemctl enable rpitx
Reboot to start the autoboot service:
sudo reboot now
Now after the Pi starts up, the demo.sh script will run automatically, and the console will log to ~/CubeSatSim/log.txt To see it:
Now after the Pi starts up, the demo.sh script will run automatically, to see the console:
sudo journalctl -u cubesatsim
tail ~/CubeSatSim/log.txt

@ -1,8 +1,10 @@
[Unit]
Description=My service
Description=CubeSatSim demo service
[Service]
ExecStart=/home/pi/CubeSatSim/demo.sh > /home/pi/CubeSatSim/log.txt 2>&1
TimeoutStopSec=5
EnvironmentFile=/home/pi/CubeSatSim/.mode
ExecStart=/home/pi/CubeSatSim/demo.sh $ARG1
WorkingDirectory=/home/pi/CubeSatSim
StandardOutput=inherit
StandardError=inherit

@ -0,0 +1,15 @@
[Unit]
Description=CubeSatSim rpitx service
[Service]
TimeoutStopSec=5
EnvironmentFile=/home/pi/CubeSatSim/.mode
ExecStart=/home/pi/CubeSatSim/rpitx.sh $ARG1
WorkingDirectory=/home/pi/CubeSatSim
StandardOutput=inherit
StandardError=inherit
Restart=always
User=root
[Install]
WantedBy=default.target
Loading…
Cancel
Save

Powered by TurnKey Linux.