|
|
|
@ -1352,7 +1352,7 @@ void get_tlm_fox() {
|
|
|
|
long int sync = syncWord;
|
|
|
|
long int sync = syncWord;
|
|
|
|
int cam = ON;
|
|
|
|
int cam = ON;
|
|
|
|
|
|
|
|
|
|
|
|
smaller = (int) (S_RATE / (2 * freq_Hz));
|
|
|
|
smaller = (int)(S_RATE / (2 * freq_Hz));
|
|
|
|
|
|
|
|
|
|
|
|
short int b[dataLen];
|
|
|
|
short int b[dataLen];
|
|
|
|
short int b_max[dataLen];
|
|
|
|
short int b_max[dataLen];
|
|
|
|
@ -1382,14 +1382,13 @@ void get_tlm_fox() {
|
|
|
|
|
|
|
|
|
|
|
|
short int buffer_test[bufLen];
|
|
|
|
short int buffer_test[bufLen];
|
|
|
|
int buffSize;
|
|
|
|
int buffSize;
|
|
|
|
buffSize = (int) sizeof(buffer_test);
|
|
|
|
buffSize = (int)sizeof(buffer_test);
|
|
|
|
|
|
|
|
|
|
|
|
if (failureMode == FAIL_NONE)
|
|
|
|
if (failureMode == FAIL_NONE) printf("No Simulated Failure!\n");
|
|
|
|
printf("No Simulated Failure!\n");
|
|
|
|
// if (failureMode == -1) {
|
|
|
|
// if (failureMode == -1) {
|
|
|
|
// failureMode = (int) rnd_float(1, FAIL_COUNT);
|
|
|
|
// failureMode = (int) rnd_float(1, FAIL_COUNT);
|
|
|
|
// printf("Random Failure\n");
|
|
|
|
// printf("Random Failure\n");
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
|
|
|
|
if (failureMode == FAIL_UNPLUG) {
|
|
|
|
if (failureMode == FAIL_UNPLUG) {
|
|
|
|
voltage[map[PLUS_Y]] = rnd_float(0.8, 0.95);
|
|
|
|
voltage[map[PLUS_Y]] = rnd_float(0.8, 0.95);
|
|
|
|
current[map[PLUS_Y]] = 0.0;
|
|
|
|
current[map[PLUS_Y]] = 0.0;
|
|
|
|
@ -1447,63 +1446,54 @@ void get_tlm_fox() {
|
|
|
|
|
|
|
|
|
|
|
|
// for (int frames = 0; frames < FRAME_CNT; frames++)
|
|
|
|
// for (int frames = 0; frames < FRAME_CNT; frames++)
|
|
|
|
for (int frames = 0; frames < frameCnt; frames++) {
|
|
|
|
for (int frames = 0; frames < frameCnt; frames++) {
|
|
|
|
|
|
|
|
// if (firstTime != ON) {
|
|
|
|
// if (firstTime != ON) {
|
|
|
|
|
|
|
|
if (TRUE) {
|
|
|
|
if (TRUE) {
|
|
|
|
// delay for sample period
|
|
|
|
// delay for sample period
|
|
|
|
|
|
|
|
|
|
|
|
/**/
|
|
|
|
/**/
|
|
|
|
// while ((millis() - sampleTime) < (unsigned int)samplePeriod)
|
|
|
|
// while ((millis() - sampleTime) < (unsigned int)samplePeriod)
|
|
|
|
int startSleep = millis();
|
|
|
|
int startSleep = millis();
|
|
|
|
if ((millis() - sampleTime) < ((unsigned int)frameTime - 750 + pi_zero_2_offset)) // was 250 100 500 for FSK
|
|
|
|
if ((millis() - sampleTime) < ((unsigned int)frameTime - 750 + pi_zero_2_offset)) // was 250 100 500 for FSK
|
|
|
|
// sleep(2.0); // 0.5); // 25); // initial period
|
|
|
|
// sleep(2.0); // 0.5); // 25); // initial period
|
|
|
|
sleep(1.0); // 0.5); // 25); // initial period
|
|
|
|
sleep(1.0); // 0.5); // 25); // initial period
|
|
|
|
while ((millis() - sampleTime) < ((unsigned int)frameTime - 750 + pi_zero_2_offset)) // was 250 100
|
|
|
|
while ((millis() - sampleTime) < ((unsigned int)frameTime - 750 + pi_zero_2_offset)) // was 250 100
|
|
|
|
sleep(0.1); // 25); // 0.5); // 25);
|
|
|
|
sleep(0.1); // 25); // 0.5); // 25);
|
|
|
|
// sleep((unsigned int)sleepTime);
|
|
|
|
// sleep((unsigned int)sleepTime);
|
|
|
|
/**/
|
|
|
|
/**/
|
|
|
|
printf("Start sleep %d Sleep period: %d while period: %d\n", startSleep, millis() - startSleep, (unsigned int)frameTime - 750 + pi_zero_2_offset);
|
|
|
|
printf("Start sleep %d Sleep period: %d while period: %d\n", startSleep, millis() - startSleep, (unsigned int)frameTime - 750 + pi_zero_2_offset);
|
|
|
|
fflush(stdout);
|
|
|
|
fflush(stdout);
|
|
|
|
|
|
|
|
|
|
|
|
sampleTime = (unsigned int) millis();
|
|
|
|
sampleTime = (unsigned int)millis();
|
|
|
|
} else
|
|
|
|
} else
|
|
|
|
printf("first or second time - no sleep\n");
|
|
|
|
printf("first or second time - no sleep\n");
|
|
|
|
|
|
|
|
|
|
|
|
printf("++++ Loop time: %5.3f sec +++++\n", (millis() - loopTime)/1000.0);
|
|
|
|
printf("++++ Loop time: %5.3f sec +++++\n", (millis() - loopTime) / 1000.0);
|
|
|
|
fflush(stdout);
|
|
|
|
fflush(stdout);
|
|
|
|
loopTime = millis();
|
|
|
|
loopTime = millis();
|
|
|
|
|
|
|
|
|
|
|
|
// if (mode == FSK)
|
|
|
|
// if (mode == FSK)
|
|
|
|
{ // just moved
|
|
|
|
{ // just moved
|
|
|
|
for (int count1 = 0; count1 < 8; count1++) {
|
|
|
|
for (int count1 = 0; count1 < 8; count1++) {
|
|
|
|
if (voltage[count1] < voltage_min[count1])
|
|
|
|
if (voltage[count1] < voltage_min[count1]) voltage_min[count1] = voltage[count1];
|
|
|
|
voltage_min[count1] = voltage[count1];
|
|
|
|
if (current[count1] < current_min[count1]) current_min[count1] = current[count1];
|
|
|
|
if (current[count1] < current_min[count1])
|
|
|
|
|
|
|
|
current_min[count1] = current[count1];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (voltage[count1] > voltage_max[count1])
|
|
|
|
if (voltage[count1] > voltage_max[count1]) voltage_max[count1] = voltage[count1];
|
|
|
|
voltage_max[count1] = voltage[count1];
|
|
|
|
if (current[count1] > current_max[count1]) current_max[count1] = current[count1];
|
|
|
|
if (current[count1] > current_max[count1])
|
|
|
|
|
|
|
|
current_max[count1] = current[count1];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// printf("Vmin %4.2f Vmax %4.2f Imin %4.2f Imax %4.2f \n", voltage_min[count1], voltage_max[count1], current_min[count1], current_max[count1]);
|
|
|
|
// printf("Vmin %4.2f Vmax %4.2f Imin %4.2f Imax %4.2f \n", voltage_min[count1], voltage_max[count1], current_min[count1], current_max[count1]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
for (int count1 = 0; count1 < 3; count1++) {
|
|
|
|
for (int count1 = 0; count1 < 3; count1++) {
|
|
|
|
if (other[count1] < other_min[count1])
|
|
|
|
if (other[count1] < other_min[count1]) other_min[count1] = other[count1];
|
|
|
|
other_min[count1] = other[count1];
|
|
|
|
if (other[count1] > other_max[count1]) other_max[count1] = other[count1];
|
|
|
|
if (other[count1] > other_max[count1])
|
|
|
|
|
|
|
|
other_max[count1] = other[count1];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// printf("Other min %f max %f \n", other_min[count1], other_max[count1]);
|
|
|
|
// printf("Other min %f max %f \n", other_min[count1], other_max[count1]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (mode == FSK)
|
|
|
|
if (mode == FSK) {
|
|
|
|
{
|
|
|
|
|
|
|
|
if (loop % 32 == 0) { // was 8
|
|
|
|
if (loop % 32 == 0) { // was 8
|
|
|
|
// printf("Sending MIN frame \n");
|
|
|
|
// printf("Sending MIN frame \n");
|
|
|
|
frm_type = 0x03;
|
|
|
|
frm_type = 0x03;
|
|
|
|
for (int count1 = 0; count1 < SENSOR_FIELDS; count1++) {
|
|
|
|
for (int count1 = 0; count1 < SENSOR_FIELDS; count1++) {
|
|
|
|
if (count1 < 3)
|
|
|
|
if (count1 < 3) other[count1] = other_min[count1];
|
|
|
|
other[count1] = other_min[count1];
|
|
|
|
|
|
|
|
if (count1 < 8) {
|
|
|
|
if (count1 < 8) {
|
|
|
|
voltage[count1] = voltage_min[count1];
|
|
|
|
voltage[count1] = voltage_min[count1];
|
|
|
|
current[count1] = current_min[count1];
|
|
|
|
current[count1] = current_min[count1];
|
|
|
|
@ -1513,11 +1503,10 @@ void get_tlm_fox() {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if ((loop + 16) % 32 == 0) { // was 8
|
|
|
|
if ((loop + 16) % 32 == 0) { // was 8
|
|
|
|
// printf("Sending MAX frame \n");
|
|
|
|
// printf("Sending MAX frame \n");
|
|
|
|
frm_type = 0x02;
|
|
|
|
frm_type = 0x02;
|
|
|
|
for (int count1 = 0; count1 < SENSOR_FIELDS; count1++) {
|
|
|
|
for (int count1 = 0; count1 < SENSOR_FIELDS; count1++) {
|
|
|
|
if (count1 < 3)
|
|
|
|
if (count1 < 3) other[count1] = other_max[count1];
|
|
|
|
other[count1] = other_max[count1];
|
|
|
|
|
|
|
|
if (count1 < 8) {
|
|
|
|
if (count1 < 8) {
|
|
|
|
voltage[count1] = voltage_max[count1];
|
|
|
|
voltage[count1] = voltage_max[count1];
|
|
|
|
current[count1] = current_max[count1];
|
|
|
|
current[count1] = current_max[count1];
|
|
|
|
@ -1526,32 +1515,30 @@ void get_tlm_fox() {
|
|
|
|
sensor[count1] = sensor_max[count1];
|
|
|
|
sensor[count1] = sensor_max[count1];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else
|
|
|
|
else
|
|
|
|
|
|
|
|
frm_type = 0x02; // BPSK always send MAX MIN frame
|
|
|
|
frm_type = 0x02; // BPSK always send MAX MIN frame
|
|
|
|
}
|
|
|
|
}
|
|
|
|
sensor_payload[0] = 0; // clear for next payload
|
|
|
|
sensor_payload[0] = 0; // clear for next payload
|
|
|
|
|
|
|
|
|
|
|
|
// if (mode == FSK) { // remove this
|
|
|
|
// if (mode == FSK) { // remove this
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
memset(rs_frame, 0, sizeof(rs_frame));
|
|
|
|
memset(rs_frame, 0, sizeof(rs_frame));
|
|
|
|
memset(parities, 0, sizeof(parities));
|
|
|
|
memset(parities, 0, sizeof(parities));
|
|
|
|
|
|
|
|
|
|
|
|
h[0] = (short int) ((h[0] & 0xf8) | (id & 0x07)); // 3 bits
|
|
|
|
h[0] = (short int)((h[0] & 0xf8) | (id & 0x07)); // 3 bits
|
|
|
|
if (uptime != 0) // if uptime is 0, leave reset count at 0
|
|
|
|
if (uptime != 0) // if uptime is 0, leave reset count at 0
|
|
|
|
{
|
|
|
|
{
|
|
|
|
h[0] = (short int) ((h[0] & 0x07) | ((reset_count & 0x1f) << 3));
|
|
|
|
h[0] = (short int)((h[0] & 0x07) | ((reset_count & 0x1f) << 3));
|
|
|
|
h[1] = (short int) ((reset_count >> 5) & 0xff);
|
|
|
|
h[1] = (short int)((reset_count >> 5) & 0xff);
|
|
|
|
h[2] = (short int) ((h[2] & 0xf8) | ((reset_count >> 13) & 0x07));
|
|
|
|
h[2] = (short int)((h[2] & 0xf8) | ((reset_count >> 13) & 0x07));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
h[2] = (short int) ((h[2] & 0x0e) | ((uptime & 0x1f) << 3));
|
|
|
|
h[2] = (short int)((h[2] & 0x0e) | ((uptime & 0x1f) << 3));
|
|
|
|
h[3] = (short int) ((uptime >> 5) & 0xff);
|
|
|
|
h[3] = (short int)((uptime >> 5) & 0xff);
|
|
|
|
h[4] = (short int) ((uptime >> 13) & 0xff);
|
|
|
|
h[4] = (short int)((uptime >> 13) & 0xff);
|
|
|
|
h[5] = (short int) ((h[5] & 0xf0) | ((uptime >> 21) & 0x0f));
|
|
|
|
h[5] = (short int)((h[5] & 0xf0) | ((uptime >> 21) & 0x0f));
|
|
|
|
h[5] = (short int) ((h[5] & 0x0f) | (frm_type << 4));
|
|
|
|
h[5] = (short int)((h[5] & 0x0f) | (frm_type << 4));
|
|
|
|
|
|
|
|
|
|
|
|
if (mode == BPSK)
|
|
|
|
if (mode == BPSK) h[6] = 99;
|
|
|
|
h[6] = 99;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
posXi = (int)(current[map[PLUS_X]] + 0.5) + 2048;
|
|
|
|
posXi = (int)(current[map[PLUS_X]] + 0.5) + 2048;
|
|
|
|
posYi = (int)(current[map[PLUS_Y]] + 0.5) + 2048;
|
|
|
|
posYi = (int)(current[map[PLUS_Y]] + 0.5) + 2048;
|
|
|
|
@ -1572,13 +1559,12 @@ void get_tlm_fox() {
|
|
|
|
BAT2Voltage = (int)(voltage[map[BAT2]] * 100);
|
|
|
|
BAT2Voltage = (int)(voltage[map[BAT2]] * 100);
|
|
|
|
BAT2Current = (int)(current[map[BAT2]] + 0.5) + 2048;
|
|
|
|
BAT2Current = (int)(current[map[BAT2]] + 0.5) + 2048;
|
|
|
|
|
|
|
|
|
|
|
|
if (payload == ON)
|
|
|
|
if (payload == ON) STEMBoardFailure = 0;
|
|
|
|
STEMBoardFailure = 0;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// read payload sensor if available
|
|
|
|
// read payload sensor if available
|
|
|
|
|
|
|
|
|
|
|
|
// encodeA(b, 0 + head_offset, batt_a_v); // replaced by XS2 and XS3 below
|
|
|
|
// encodeA(b, 0 + head_offset, batt_a_v); // replaced by XS2 and XS3 below
|
|
|
|
// encodeB(b, 1 + head_offset, batt_b_v);
|
|
|
|
// encodeB(b, 1 + head_offset, batt_b_v);
|
|
|
|
encodeA(b, 3 + head_offset, batt_c_v);
|
|
|
|
encodeA(b, 3 + head_offset, batt_c_v);
|
|
|
|
|
|
|
|
|
|
|
|
encodeB(b, 4 + head_offset, (int)(sensor[ACCEL_X] * 100 + 0.5) + 2048); // Xaccel
|
|
|
|
encodeB(b, 4 + head_offset, (int)(sensor[ACCEL_X] * 100 + 0.5) + 2048); // Xaccel
|
|
|
|
@ -1655,16 +1641,14 @@ void get_tlm_fox() {
|
|
|
|
encodeB(b_max, 43 + head_offset, (int)(sensor_max[GYRO_Z] + 0.5) + 2048);
|
|
|
|
encodeB(b_max, 43 + head_offset, (int)(sensor_max[GYRO_Z] + 0.5) + 2048);
|
|
|
|
|
|
|
|
|
|
|
|
encodeA(b_max, 48 + head_offset, (int)(sensor_max[DTEMP] * 10 + 0.5) + 2048);
|
|
|
|
encodeA(b_max, 48 + head_offset, (int)(sensor_max[DTEMP] * 10 + 0.5) + 2048);
|
|
|
|
// encodeB(b_max, 49 + head_offset, (int)(sensor_max[XS1] * 10 + 0.5) + 2048);
|
|
|
|
// encodeB(b_max, 49 + head_offset, (int)(sensor_max[XS1] * 10 + 0.5) + 2048);
|
|
|
|
encodeB(b_max, 10 + head_offset, (int)(sensor_max[TEMP] * 10 + 0.5));
|
|
|
|
encodeB(b_max, 10 + head_offset, (int)(sensor_max[TEMP] * 10 + 0.5));
|
|
|
|
encodeA(b_max, 45 + head_offset, (int)(sensor_max[HUMI] * 10 + 0.5));
|
|
|
|
encodeA(b_max, 45 + head_offset, (int)(sensor_max[HUMI] * 10 + 0.5));
|
|
|
|
|
|
|
|
|
|
|
|
encodeB(b_max, 49 + head_offset, (int)(sensor_max[XS1]));
|
|
|
|
encodeB(b_max, 49 + head_offset, (int)(sensor_max[XS1]));
|
|
|
|
encodeA(b_max, 0 + head_offset, (int)(sensor_max[XS2]));
|
|
|
|
encodeA(b_max, 0 + head_offset, (int)(sensor_max[XS2]));
|
|
|
|
encodeB(b_max, 1 + head_offset, (int)(sensor_max[XS3]));
|
|
|
|
encodeB(b_max, 1 + head_offset, (int)(sensor_max[XS3]));
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
encodeB(b_max, 4 + head_offset, 2048); // 0
|
|
|
|
encodeB(b_max, 4 + head_offset, 2048); // 0
|
|
|
|
encodeA(b_max, 6 + head_offset, 2048); // 0
|
|
|
|
encodeA(b_max, 6 + head_offset, 2048); // 0
|
|
|
|
encodeB(b_max, 7 + head_offset, 2048); // 0
|
|
|
|
encodeB(b_max, 7 + head_offset, 2048); // 0
|
|
|
|
@ -1674,7 +1658,7 @@ void get_tlm_fox() {
|
|
|
|
encodeB(b_max, 43 + head_offset, 2048);
|
|
|
|
encodeB(b_max, 43 + head_offset, 2048);
|
|
|
|
|
|
|
|
|
|
|
|
encodeA(b_max, 48 + head_offset, 2048);
|
|
|
|
encodeA(b_max, 48 + head_offset, 2048);
|
|
|
|
// encodeB(b_max, 49 + head_offset, 2048);
|
|
|
|
// encodeB(b_max, 49 + head_offset, 2048);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
encodeA(b_min, 12 + head_offset, (int)(voltage_min[map[PLUS_X]] * 100));
|
|
|
|
encodeA(b_min, 12 + head_offset, (int)(voltage_min[map[PLUS_X]] * 100));
|
|
|
|
encodeB(b_min, 13 + head_offset, (int)(voltage_min[map[PLUS_Y]] * 100));
|
|
|
|
encodeB(b_min, 13 + head_offset, (int)(voltage_min[map[PLUS_Y]] * 100));
|
|
|
|
@ -1712,16 +1696,14 @@ void get_tlm_fox() {
|
|
|
|
encodeB(b_min, 43 + head_offset, (int)(sensor_min[GYRO_Z] + 0.5) + 2048);
|
|
|
|
encodeB(b_min, 43 + head_offset, (int)(sensor_min[GYRO_Z] + 0.5) + 2048);
|
|
|
|
|
|
|
|
|
|
|
|
encodeA(b_min, 48 + head_offset, (int)(sensor_min[DTEMP] * 10 + 0.5) + 2048);
|
|
|
|
encodeA(b_min, 48 + head_offset, (int)(sensor_min[DTEMP] * 10 + 0.5) + 2048);
|
|
|
|
// encodeB(b_min, 49 + head_offset, (int)(sensor_min[XS1] * 10 + 0.5) + 2048);
|
|
|
|
// encodeB(b_min, 49 + head_offset, (int)(sensor_min[XS1] * 10 + 0.5) + 2048);
|
|
|
|
encodeB(b_min, 10 + head_offset, (int)(sensor_min[TEMP] * 10 + 0.5));
|
|
|
|
encodeB(b_min, 10 + head_offset, (int)(sensor_min[TEMP] * 10 + 0.5));
|
|
|
|
encodeA(b_min, 45 + head_offset, (int)(sensor_min[HUMI] * 10 + 0.5));
|
|
|
|
encodeA(b_min, 45 + head_offset, (int)(sensor_min[HUMI] * 10 + 0.5));
|
|
|
|
|
|
|
|
|
|
|
|
encodeB(b_min, 49 + head_offset, (int)(sensor_min[XS1]));
|
|
|
|
encodeB(b_min, 49 + head_offset, (int)(sensor_min[XS1]));
|
|
|
|
encodeA(b_min, 0 + head_offset, (int)(sensor_min[XS2]));
|
|
|
|
encodeA(b_min, 0 + head_offset, (int)(sensor_min[XS2]));
|
|
|
|
encodeB(b_min, 1 + head_offset, (int)(sensor_min[XS3]));
|
|
|
|
encodeB(b_min, 1 + head_offset, (int)(sensor_min[XS3]));
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
encodeB(b_min, 4 + head_offset, 2048); // 0
|
|
|
|
encodeB(b_min, 4 + head_offset, 2048); // 0
|
|
|
|
encodeA(b_min, 6 + head_offset, 2048); // 0
|
|
|
|
encodeA(b_min, 6 + head_offset, 2048); // 0
|
|
|
|
encodeB(b_min, 7 + head_offset, 2048); // 0
|
|
|
|
encodeB(b_min, 7 + head_offset, 2048); // 0
|
|
|
|
@ -1731,7 +1713,7 @@ void get_tlm_fox() {
|
|
|
|
encodeB(b_min, 43 + head_offset, 2048);
|
|
|
|
encodeB(b_min, 43 + head_offset, 2048);
|
|
|
|
|
|
|
|
|
|
|
|
encodeA(b_min, 48 + head_offset, 2048);
|
|
|
|
encodeA(b_min, 48 + head_offset, 2048);
|
|
|
|
// encodeB(b_min, 49 + head_offset, 2048);
|
|
|
|
// encodeB(b_min, 49 + head_offset, 2048);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
encodeA(b, 30 + head_offset, BAT2Voltage);
|
|
|
|
encodeA(b, 30 + head_offset, BAT2Voltage);
|
|
|
|
@ -1741,26 +1723,25 @@ void get_tlm_fox() {
|
|
|
|
encodeA(b, 33 + head_offset, (int)(sensor[PRES] + 0.5)); // Pressure
|
|
|
|
encodeA(b, 33 + head_offset, (int)(sensor[PRES] + 0.5)); // Pressure
|
|
|
|
encodeB(b, 34 + head_offset, (int)(sensor[ALT] / 10.0 + 0.5)); // Altitude
|
|
|
|
encodeB(b, 34 + head_offset, (int)(sensor[ALT] / 10.0 + 0.5)); // Altitude
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
encodeB(b_min, 49 + head_offset, (int)(sensor_min[XS1]));
|
|
|
|
encodeB(b_min, 49 + head_offset, (int)(sensor_min[XS1]));
|
|
|
|
encodeA(b_min, 0 + head_offset, (int)(sensor_min[XS2]));
|
|
|
|
encodeA(b_min, 0 + head_offset, (int)(sensor_min[XS2]));
|
|
|
|
encodeB(b_min, 1 + head_offset, (int)(sensor_min[XS3]));
|
|
|
|
encodeB(b_min, 1 + head_offset, (int)(sensor_min[XS3]));
|
|
|
|
}
|
|
|
|
// }
|
|
|
|
else
|
|
|
|
// else
|
|
|
|
{
|
|
|
|
// {
|
|
|
|
encodeB(b_min, 4 + head_offset, 2048); // 0
|
|
|
|
// encodeB(b_min, 4 + head_offset, 2048); // 0
|
|
|
|
encodeA(b_min, 6 + head_offset, 2048); // 0
|
|
|
|
// encodeA(b_min, 6 + head_offset, 2048); // 0
|
|
|
|
encodeB(b_min, 7 + head_offset, 2048); // 0
|
|
|
|
// encodeB(b_min, 7 + head_offset, 2048); // 0
|
|
|
|
|
|
|
|
//
|
|
|
|
encodeB(b_min, 40 + head_offset, 2048);
|
|
|
|
// encodeB(b_min, 40 + head_offset, 2048);
|
|
|
|
encodeA(b_min, 42 + head_offset, 2048);
|
|
|
|
// encodeA(b_min, 42 + head_offset, 2048);
|
|
|
|
encodeB(b_min, 43 + head_offset, 2048);
|
|
|
|
// encodeB(b_min, 43 + head_offset, 2048);
|
|
|
|
|
|
|
|
//
|
|
|
|
encodeA(b_min, 48 + head_offset, 2048);
|
|
|
|
// encodeA(b_min, 48 + head_offset, 2048);
|
|
|
|
// encodeB(b_min, 49 + head_offset, 2048);
|
|
|
|
// // encodeB(b_min, 49 + head_offset, 2048);
|
|
|
|
}
|
|
|
|
// }
|
|
|
|
|
|
|
|
//
|
|
|
|
}
|
|
|
|
// }
|
|
|
|
encodeA(b, 30 + head_offset, BAT2Voltage);
|
|
|
|
encodeA(b, 30 + head_offset, BAT2Voltage);
|
|
|
|
|
|
|
|
|
|
|
|
encodeB(b, 31 + head_offset, ((int)(other[SPIN] * 10)) + 2048);
|
|
|
|
encodeB(b, 31 + head_offset, ((int)(other[SPIN] * 10)) + 2048);
|
|
|
|
@ -1773,7 +1754,6 @@ void get_tlm_fox() {
|
|
|
|
encodeA(b, 36 + head_offset, Resets);
|
|
|
|
encodeA(b, 36 + head_offset, Resets);
|
|
|
|
encodeB(b, 37 + head_offset, (int)(other[RSSI] + 0.5) + 2048);
|
|
|
|
encodeB(b, 37 + head_offset, (int)(other[RSSI] + 0.5) + 2048);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
encodeB(b, 40 + head_offset, (int)(sensor[GYRO_X] + 0.5) + 2048);
|
|
|
|
encodeB(b, 40 + head_offset, (int)(sensor[GYRO_X] + 0.5) + 2048);
|
|
|
|
encodeA(b, 42 + head_offset, (int)(sensor[GYRO_Y] + 0.5) + 2048);
|
|
|
|
encodeA(b, 42 + head_offset, (int)(sensor[GYRO_Y] + 0.5) + 2048);
|
|
|
|
encodeB(b, 43 + head_offset, (int)(sensor[GYRO_Z] + 0.5) + 2048);
|
|
|
|
encodeB(b, 43 + head_offset, (int)(sensor[GYRO_Z] + 0.5) + 2048);
|
|
|
|
@ -1785,19 +1765,18 @@ void get_tlm_fox() {
|
|
|
|
encodeB(b, 46 + head_offset, BAT2Current);
|
|
|
|
encodeB(b, 46 + head_offset, BAT2Current);
|
|
|
|
encodeA(b, 39 + head_offset, (int)(other[IHU_TEMP] * 10 + 0.5));
|
|
|
|
encodeA(b, 39 + head_offset, (int)(other[IHU_TEMP] * 10 + 0.5));
|
|
|
|
|
|
|
|
|
|
|
|
// encodeB(b, 49 + head_offset, (int)(sensor[XS1] * 10 + 0.5) + 2048);
|
|
|
|
// encodeB(b, 49 + head_offset, (int)(sensor[XS1] * 10 + 0.5) + 2048);
|
|
|
|
|
|
|
|
|
|
|
|
FILE * command_count_file = fopen("/home/pi/CubeSatSim/command_count.txt", "r");
|
|
|
|
FILE* command_count_file = fopen("/home/pi/CubeSatSim/command_count.txt", "r");
|
|
|
|
if (command_count_file != NULL) {
|
|
|
|
if (command_count_file != NULL) {
|
|
|
|
char count_string[10];
|
|
|
|
char count_string[10];
|
|
|
|
if ( (fgets(count_string, 10, command_count_file)) != NULL)
|
|
|
|
if ((fgets(count_string, 10, command_count_file)) != NULL) groundCommandCount = atoi(count_string);
|
|
|
|
groundCommandCount = atoi(count_string);
|
|
|
|
// fclose(command_count_file);
|
|
|
|
// fclose(command_count_file);
|
|
|
|
|
|
|
|
} else
|
|
|
|
} else
|
|
|
|
printf("Error opening command_count.txt!\n");
|
|
|
|
printf("Error opening command_count.txt!\n");
|
|
|
|
fclose(command_count_file);
|
|
|
|
fclose(command_count_file);
|
|
|
|
|
|
|
|
|
|
|
|
// printf("Command count: %d\n", groundCommandCount);
|
|
|
|
// printf("Command count: %d\n", groundCommandCount);
|
|
|
|
int simulated;
|
|
|
|
int simulated;
|
|
|
|
simulated = sim_mode;
|
|
|
|
simulated = sim_mode;
|
|
|
|
if (failureMode != FAIL_NONE) {
|
|
|
|
if (failureMode != FAIL_NONE) {
|
|
|
|
@ -1807,18 +1786,17 @@ void get_tlm_fox() {
|
|
|
|
int i2c_1, i2c_3;
|
|
|
|
int i2c_1, i2c_3;
|
|
|
|
i2c_1 = i2c_bus1;
|
|
|
|
i2c_1 = i2c_bus1;
|
|
|
|
i2c_3 = i2c_bus3;
|
|
|
|
i2c_3 = i2c_bus3;
|
|
|
|
// printf("Bus1: %d Bus2: %d \n", i2c_1, i2c_3);
|
|
|
|
// printf("Bus1: %d Bus2: %d \n", i2c_1, i2c_3);
|
|
|
|
if (failureMode == FAIL_I2C1) {
|
|
|
|
if (failureMode == FAIL_I2C1) {
|
|
|
|
i2c_1 = OFF;
|
|
|
|
i2c_1 = OFF;
|
|
|
|
// printf("I2C Bus 1 Simulated Failure\n");
|
|
|
|
// printf("I2C Bus 1 Simulated Failure\n");
|
|
|
|
} else if (failureMode == FAIL_I2C3) {
|
|
|
|
} else if (failureMode == FAIL_I2C3) {
|
|
|
|
i2c_3 = OFF;
|
|
|
|
i2c_3 = OFF;
|
|
|
|
// printf("I2C Bus 3 Simulated Failure\n");
|
|
|
|
// printf("I2C Bus 3 Simulated Failure\n");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// int status = STEMBoardFailure + SafeMode * 2 + sim_mode * 4 + PayloadFailure1 * 8 +
|
|
|
|
// int status = STEMBoardFailure + SafeMode * 2 + sim_mode * 4 + PayloadFailure1 * 8 +
|
|
|
|
// (i2c_bus0 == OFF) * 16 + (i2c_bus1 == OFF) * 32 + (i2c_bus3 == OFF) * 64 + (camera == OFF) * 128 + groundCommandCount * 256;
|
|
|
|
// (i2c_bus0 == OFF) * 16 + (i2c_bus1 == OFF) * 32 + (i2c_bus3 == OFF) * 64 + (camera == OFF) * 128 + groundCommandCount * 256;
|
|
|
|
int status = STEMBoardFailure + SafeMode * 2 + simulated * 4 + PayloadFailure1 * 8 +
|
|
|
|
int status = STEMBoardFailure + SafeMode * 2 + simulated * 4 + PayloadFailure1 * 8 + (i2c_bus0 == OFF) * 16 + (i2c_1 == OFF) * 32 + (i2c_3 == OFF) * 64 + (cam == OFF) * 128 + groundCommandCount * 256;
|
|
|
|
(i2c_bus0 == OFF) * 16 + (i2c_1 == OFF) * 32 + (i2c_3 == OFF) * 64 + (cam == OFF) * 128 + groundCommandCount * 256;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
encodeA(b, 51 + head_offset, status);
|
|
|
|
encodeA(b, 51 + head_offset, status);
|
|
|
|
encodeB(b, 52 + head_offset, rxAntennaDeployed + txAntennaDeployed * 2 + c2cStatus * 4);
|
|
|
|
encodeB(b, 52 + head_offset, rxAntennaDeployed + txAntennaDeployed * 2 + c2cStatus * 4);
|
|
|
|
@ -1864,28 +1842,21 @@ void get_tlm_fox() {
|
|
|
|
data8[ctr1++] = rs_frame[j][i];
|
|
|
|
data8[ctr1++] = rs_frame[j][i];
|
|
|
|
// printf ("data8[%d] = %x \n", ctr1 - 1, rs_frame[j][i]);
|
|
|
|
// printf ("data8[%d] = %x \n", ctr1 - 1, rs_frame[j][i]);
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
if (mode == FSK)
|
|
|
|
if (mode == FSK) {
|
|
|
|
{
|
|
|
|
|
|
|
|
rs_frame[j][i] = b[ctr3 % dataLen];
|
|
|
|
rs_frame[j][i] = b[ctr3 % dataLen];
|
|
|
|
update_rs(parities[j], b[ctr3 % dataLen]);
|
|
|
|
update_rs(parities[j], b[ctr3 % dataLen]);
|
|
|
|
} else // BPSK
|
|
|
|
} else // BPSK
|
|
|
|
if ((int)(ctr3/dataLen) == 3)
|
|
|
|
if ((int)(ctr3 / dataLen) == 3) {
|
|
|
|
{
|
|
|
|
|
|
|
|
rs_frame[j][i] = b_max[ctr3 % dataLen];
|
|
|
|
rs_frame[j][i] = b_max[ctr3 % dataLen];
|
|
|
|
update_rs(parities[j], b_max[ctr3 % dataLen]);
|
|
|
|
update_rs(parities[j], b_max[ctr3 % dataLen]);
|
|
|
|
}
|
|
|
|
} else if ((int)(ctr3 / dataLen) == 4) {
|
|
|
|
else if ((int)(ctr3/dataLen) == 4)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
rs_frame[j][i] = b_min[ctr3 % dataLen];
|
|
|
|
rs_frame[j][i] = b_min[ctr3 % dataLen];
|
|
|
|
update_rs(parities[j], b_min[ctr3 % dataLen]);
|
|
|
|
update_rs(parities[j], b_min[ctr3 % dataLen]);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
rs_frame[j][i] = b[ctr3 % dataLen];
|
|
|
|
rs_frame[j][i] = b[ctr3 % dataLen];
|
|
|
|
update_rs(parities[j], b[ctr3 % dataLen]);
|
|
|
|
update_rs(parities[j], b[ctr3 % dataLen]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
{
|
|
|
|
{}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// printf("%d rs_frame[%d][%d] = %x %d \n",
|
|
|
|
// printf("%d rs_frame[%d][%d] = %x %d \n",
|
|
|
|
// ctr1, j, i, b[ctr3 % DATA_LEN], ctr3 % DATA_LEN);
|
|
|
|
// ctr1, j, i, b[ctr3 % DATA_LEN], ctr3 % DATA_LEN);
|
|
|
|
@ -1897,36 +1868,36 @@ void get_tlm_fox() {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef DEBUG_LOGGING
|
|
|
|
#ifdef DEBUG_LOGGING
|
|
|
|
// printf("\nAt end of data8 write, %d ctr1 values written\n\n", ctr1);
|
|
|
|
// printf("\nAt end of data8 write, %d ctr1 values written\n\n", ctr1);
|
|
|
|
/*
|
|
|
|
/*
|
|
|
|
printf("Parities ");
|
|
|
|
printf("Parities ");
|
|
|
|
for (int m = 0; m < parityLen; m++) {
|
|
|
|
for (int m = 0; m < parityLen; m++) {
|
|
|
|
printf("%d ", parities[0][m]);
|
|
|
|
printf("%d ", parities[0][m]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
printf("\n");
|
|
|
|
printf("\n");
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
int ctr2 = 0;
|
|
|
|
int ctr2 = 0;
|
|
|
|
memset(data10, 0, sizeof(data10));
|
|
|
|
memset(data10, 0, sizeof(data10));
|
|
|
|
|
|
|
|
|
|
|
|
for (i = 0; i < dataLen * payloads + headerLen; i++) // 476 for BPSK
|
|
|
|
for (i = 0; i < dataLen * payloads + headerLen; i++) // 476 for BPSK
|
|
|
|
{
|
|
|
|
{
|
|
|
|
data10[ctr2] = (Encode_8b10b[rd][((int) data8[ctr2])] & 0x3ff);
|
|
|
|
data10[ctr2] = (Encode_8b10b[rd][((int)data8[ctr2])] & 0x3ff);
|
|
|
|
nrd = (Encode_8b10b[rd][((int) data8[ctr2])] >> 10) & 1;
|
|
|
|
nrd = (Encode_8b10b[rd][((int)data8[ctr2])] >> 10) & 1;
|
|
|
|
// printf ("data10[%d] = encoded data8[%d] = %x \n",
|
|
|
|
// printf ("data10[%d] = encoded data8[%d] = %x \n",
|
|
|
|
// ctr2, ctr2, data10[ctr2]);
|
|
|
|
// ctr2, ctr2, data10[ctr2]);
|
|
|
|
|
|
|
|
|
|
|
|
rd = nrd; // ^ nrd;
|
|
|
|
rd = nrd; // ^ nrd;
|
|
|
|
ctr2++;
|
|
|
|
ctr2++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// {
|
|
|
|
// {
|
|
|
|
for (i = 0; i < parityLen; i++) {
|
|
|
|
for (i = 0; i < parityLen; i++) {
|
|
|
|
for (int j = 0; j < rsFrames; j++) {
|
|
|
|
for (int j = 0; j < rsFrames; j++) {
|
|
|
|
if ((uptime != 0) || (i != 0)) // don't correctly update parties if uptime is 0 so the frame will fail the FEC check and be discarded
|
|
|
|
if ((uptime != 0) || (i != 0)) // don't correctly update parties if uptime is 0 so the frame will fail the FEC check and be discarded
|
|
|
|
data10[ctr2++] = (Encode_8b10b[rd][((int) parities[j][i])] & 0x3ff);
|
|
|
|
data10[ctr2++] = (Encode_8b10b[rd][((int)parities[j][i])] & 0x3ff);
|
|
|
|
nrd = (Encode_8b10b[rd][((int) parities[j][i])] >> 10) & 1;
|
|
|
|
nrd = (Encode_8b10b[rd][((int)parities[j][i])] >> 10) & 1;
|
|
|
|
// printf ("data10[%d] = encoded parities[%d][%d] = %x \n",
|
|
|
|
// printf ("data10[%d] = encoded parities[%d][%d] = %x \n",
|
|
|
|
// ctr2 - 1, j, i, data10[ctr2 - 1]);
|
|
|
|
// ctr2 - 1, j, i, data10[ctr2 - 1]);
|
|
|
|
|
|
|
|
|
|
|
|
@ -1934,17 +1905,17 @@ void get_tlm_fox() {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
#ifdef DEBUG_LOGGING
|
|
|
|
#ifdef DEBUG_LOGGING
|
|
|
|
// printf("\nAt end of data10 write, %d ctr2 values written\n\n", ctr2);
|
|
|
|
// printf("\nAt end of data10 write, %d ctr2 values written\n\n", ctr2);
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
int data;
|
|
|
|
int data;
|
|
|
|
int val;
|
|
|
|
int val;
|
|
|
|
//int offset = 0;
|
|
|
|
// int offset = 0;
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef DEBUG_LOGGING
|
|
|
|
#ifdef DEBUG_LOGGING
|
|
|
|
// printf("\nAt start of buffer loop, syncBits %d samples %d ctr %d\n", syncBits, samples, ctr);
|
|
|
|
// printf("\nAt start of buffer loop, syncBits %d samples %d ctr %d\n", syncBits, samples, ctr);
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
for (i = 1; i <= syncBits * samples; i++) {
|
|
|
|
for (i = 1; i <= syncBits * samples; i++) {
|
|
|
|
write_wave(ctr, buffer);
|
|
|
|
write_wave(ctr, buffer);
|
|
|
|
@ -1962,17 +1933,16 @@ void get_tlm_fox() {
|
|
|
|
if (data == 0) {
|
|
|
|
if (data == 0) {
|
|
|
|
phase *= -1;
|
|
|
|
phase *= -1;
|
|
|
|
if ((ctr - smaller) > 0) {
|
|
|
|
if ((ctr - smaller) > 0) {
|
|
|
|
for (int j = 1; j <= smaller; j++)
|
|
|
|
for (int j = 1; j <= smaller; j++) buffer[ctr - j] = buffer[ctr - j] * 0.4;
|
|
|
|
buffer[ctr - j] = buffer[ctr - j] * 0.4;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
flip_ctr = ctr;
|
|
|
|
flip_ctr = ctr;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#ifdef DEBUG_LOGGING
|
|
|
|
#ifdef DEBUG_LOGGING
|
|
|
|
// printf("\n\nValue of ctr after header: %d Buffer Len: %d\n\n", ctr, buffSize);
|
|
|
|
// printf("\n\nValue of ctr after header: %d Buffer Len: %d\n\n", ctr, buffSize);
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
for (i = 1; i <= (10 * (headerLen + dataLen * payloads + rsFrames * parityLen) * samples); i++) // 572
|
|
|
|
for (i = 1; i <= (10 * (headerLen + dataLen * payloads + rsFrames * parityLen) * samples); i++) // 572
|
|
|
|
{
|
|
|
|
{
|
|
|
|
write_wave(ctr, buffer);
|
|
|
|
write_wave(ctr, buffer);
|
|
|
|
@ -1990,8 +1960,7 @@ void get_tlm_fox() {
|
|
|
|
if (data == 0) {
|
|
|
|
if (data == 0) {
|
|
|
|
phase *= -1;
|
|
|
|
phase *= -1;
|
|
|
|
if ((ctr - smaller) > 0) {
|
|
|
|
if ((ctr - smaller) > 0) {
|
|
|
|
for (int j = 1; j <= smaller; j++)
|
|
|
|
for (int j = 1; j <= smaller; j++) buffer[ctr - j] = buffer[ctr - j] * 0.4;
|
|
|
|
buffer[ctr - j] = buffer[ctr - j] * 0.4;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
flip_ctr = ctr;
|
|
|
|
flip_ctr = ctr;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@ -1999,12 +1968,12 @@ void get_tlm_fox() {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#ifdef DEBUG_LOGGING
|
|
|
|
#ifdef DEBUG_LOGGING
|
|
|
|
// printf("\nValue of ctr after looping: %d Buffer Len: %d\n", ctr, buffSize);
|
|
|
|
// printf("\nValue of ctr after looping: %d Buffer Len: %d\n", ctr, buffSize);
|
|
|
|
// printf("\ctr/samples = %d ctr/(samples*10) = %d\n\n", ctr/samples, ctr/(samples*10));
|
|
|
|
// printf("\ctr/samples = %d ctr/(samples*10) = %d\n\n", ctr/samples, ctr/(samples*10));
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
//int error = 0;
|
|
|
|
// int error = 0;
|
|
|
|
// int count;
|
|
|
|
// int count;
|
|
|
|
// for (count = 0; count < dataLen; count++) {
|
|
|
|
// for (count = 0; count < dataLen; count++) {
|
|
|
|
// printf("%02X", b[count]);
|
|
|
|
// printf("%02X", b[count]);
|
|
|
|
@ -2014,7 +1983,7 @@ void get_tlm_fox() {
|
|
|
|
// socket write
|
|
|
|
// socket write
|
|
|
|
|
|
|
|
|
|
|
|
socket_send(ctr);
|
|
|
|
socket_send(ctr);
|
|
|
|
/*
|
|
|
|
/*
|
|
|
|
if (!socket_open && transmit) {
|
|
|
|
if (!socket_open && transmit) {
|
|
|
|
printf("Opening socket!\n");
|
|
|
|
printf("Opening socket!\n");
|
|
|
|
// struct sockaddr_in address;
|
|
|
|
// struct sockaddr_in address;
|
|
|
|
@ -2042,9 +2011,9 @@ void get_tlm_fox() {
|
|
|
|
printf("\nConnection Failed \n");
|
|
|
|
printf("\nConnection Failed \n");
|
|
|
|
printf("Error: %s\n", strerror(errno));
|
|
|
|
printf("Error: %s\n", strerror(errno));
|
|
|
|
error = 1;
|
|
|
|
error = 1;
|
|
|
|
// FILE * transmit_restartf2 = popen("sudo systemctl restart transmit", "r");
|
|
|
|
// FILE * transmit_restartf2 = popen("sudo systemctl restart transmit", "r");
|
|
|
|
// pclose(transmit_restartf2);
|
|
|
|
// pclose(transmit_restartf2);
|
|
|
|
// sleep(10); // was 5 // sleep if socket connection refused
|
|
|
|
// sleep(10); // was 5 // sleep if socket connection refused
|
|
|
|
|
|
|
|
|
|
|
|
// try again
|
|
|
|
// try again
|
|
|
|
error = 0;
|
|
|
|
error = 0;
|
|
|
|
@ -2068,14 +2037,14 @@ void get_tlm_fox() {
|
|
|
|
printf("\nConnection Failed \n");
|
|
|
|
printf("\nConnection Failed \n");
|
|
|
|
printf("Error: %s\n", strerror(errno));
|
|
|
|
printf("Error: %s\n", strerror(errno));
|
|
|
|
error = 1;
|
|
|
|
error = 1;
|
|
|
|
// FILE * transmit_restartf = popen("sudo systemctl restart transmit", "r");
|
|
|
|
// FILE * transmit_restartf = popen("sudo systemctl restart transmit", "r");
|
|
|
|
// pclose(transmit_restartf);
|
|
|
|
// pclose(transmit_restartf);
|
|
|
|
// sleep(10); // was 5 // sleep if socket connection refused
|
|
|
|
// sleep(10); // was 5 // sleep if socket connection refused
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (error == 1) {
|
|
|
|
if (error == 1) {
|
|
|
|
printf("Socket error count: %d\n", error_count);
|
|
|
|
printf("Socket error count: %d\n", error_count);
|
|
|
|
// ; //transmitStatus = -1;
|
|
|
|
// ; //transmitStatus = -1;
|
|
|
|
if (error_count++ > 5) {
|
|
|
|
if (error_count++ > 5) {
|
|
|
|
printf("Restarting transmit\n");
|
|
|
|
printf("Restarting transmit\n");
|
|
|
|
FILE * transmit_restartf = popen("sudo systemctl restart transmit", "r");
|
|
|
|
FILE * transmit_restartf = popen("sudo systemctl restart transmit", "r");
|
|
|
|
@ -2094,16 +2063,16 @@ void get_tlm_fox() {
|
|
|
|
// printf("Sending %d buffer bytes over socket after %d ms!\n", ctr, (long unsigned int)millis() - start);
|
|
|
|
// printf("Sending %d buffer bytes over socket after %d ms!\n", ctr, (long unsigned int)millis() - start);
|
|
|
|
start = millis();
|
|
|
|
start = millis();
|
|
|
|
int sock_ret = send(sock, buffer, (unsigned int)(ctr * 2 + 2), 0);
|
|
|
|
int sock_ret = send(sock, buffer, (unsigned int)(ctr * 2 + 2), 0);
|
|
|
|
// printf("socket send 1 %d ms bytes: %d \n\n", (unsigned int)millis() - start, sock_ret);
|
|
|
|
// printf("socket send 1 %d ms bytes: %d \n\n", (unsigned int)millis() - start, sock_ret);
|
|
|
|
fflush(stdout);
|
|
|
|
fflush(stdout);
|
|
|
|
|
|
|
|
|
|
|
|
if (sock_ret < (ctr * 2 + 2)) {
|
|
|
|
if (sock_ret < (ctr * 2 + 2)) {
|
|
|
|
// printf("Not resending\n");
|
|
|
|
// printf("Not resending\n");
|
|
|
|
sleep(0.5);
|
|
|
|
sleep(0.5);
|
|
|
|
sock_ret = send(sock, &buffer[sock_ret], (unsigned int)(ctr * 2 + 2 - sock_ret), 0);
|
|
|
|
sock_ret = send(sock, &buffer[sock_ret], (unsigned int)(ctr * 2 + 2 - sock_ret), 0);
|
|
|
|
// printf("socket send 2 %d ms bytes: %d \n\n", millis() - start, sock_ret);
|
|
|
|
// printf("socket send 2 %d ms bytes: %d \n\n", millis() - start, sock_ret);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
loop_count++;
|
|
|
|
loop_count++;
|
|
|
|
if ((firstTime == 1) || (((loop_count % 180) == 0) && (mode == FSK)) || (((loop_count % 80) == 0) && (mode == BPSK))) // do first time and was every 180 samples
|
|
|
|
if ((firstTime == 1) || (((loop_count % 180) == 0) && (mode == FSK)) || (((loop_count % 80) == 0) && (mode == BPSK))) // do first time and was every 180 samples
|
|
|
|
@ -2116,52 +2085,50 @@ void get_tlm_fox() {
|
|
|
|
max = 4; // 5; // was 6
|
|
|
|
max = 4; // 5; // was 6
|
|
|
|
else
|
|
|
|
else
|
|
|
|
max = 3;
|
|
|
|
max = 3;
|
|
|
|
else
|
|
|
|
else if (firstTime == 1)
|
|
|
|
if (firstTime == 1)
|
|
|
|
|
|
|
|
max = 5; // 5; // was 6
|
|
|
|
max = 5; // 5; // was 6
|
|
|
|
else
|
|
|
|
else
|
|
|
|
max = 4;
|
|
|
|
max = 4;
|
|
|
|
|
|
|
|
|
|
|
|
for (int times = 0; times < max; times++)
|
|
|
|
for (int times = 0; times < max; times++) {
|
|
|
|
{
|
|
|
|
/// start = millis(); // send frame until buffer fills
|
|
|
|
/// start = millis(); // send frame until buffer fills
|
|
|
|
|
|
|
|
socket_send(ctr);
|
|
|
|
socket_send(ctr);
|
|
|
|
/// sock_ret = send(sock, buffer, (unsigned int)(ctr * 2 + 2), 0);
|
|
|
|
/// sock_ret = send(sock, buffer, (unsigned int)(ctr * 2 + 2), 0);
|
|
|
|
// printf("socket send %d in %d ms bytes: %d \n\n",times + 2, (unsigned int)millis() - start, sock_ret);
|
|
|
|
// printf("socket send %d in %d ms bytes: %d \n\n",times + 2, (unsigned int)millis() - start, sock_ret);
|
|
|
|
|
|
|
|
|
|
|
|
/// if ((millis() - start) > 500) {
|
|
|
|
/// if ((millis() - start) > 500) {
|
|
|
|
/// printf("Buffer over filled!\n");
|
|
|
|
/// printf("Buffer over filled!\n");
|
|
|
|
/// break;
|
|
|
|
/// break;
|
|
|
|
/// }
|
|
|
|
/// }
|
|
|
|
|
|
|
|
|
|
|
|
/// if (sock_ret < (ctr * 2 + 2)) {
|
|
|
|
/// if (sock_ret < (ctr * 2 + 2)) {
|
|
|
|
// printf("Not resending\n");
|
|
|
|
// printf("Not resending\n");
|
|
|
|
/// sleep(0.5);
|
|
|
|
/// sleep(0.5);
|
|
|
|
/// sock_ret = send(sock, &buffer[sock_ret], (unsigned int)(ctr * 2 + 2 - sock_ret), 0);
|
|
|
|
/// sock_ret = send(sock, &buffer[sock_ret], (unsigned int)(ctr * 2 + 2 - sock_ret), 0);
|
|
|
|
/// printf("socket resend %d in %d ms bytes: %d \n\n",times, millis() - start, sock_ret);
|
|
|
|
/// printf("socket resend %d in %d ms bytes: %d \n\n",times, millis() - start, sock_ret);
|
|
|
|
/// }
|
|
|
|
/// }
|
|
|
|
}
|
|
|
|
}
|
|
|
|
sampleTime = (unsigned int) millis(); // resetting time for sleeping
|
|
|
|
sampleTime = (unsigned int)millis(); // resetting time for sleeping
|
|
|
|
// fflush(stdout);
|
|
|
|
// fflush(stdout);
|
|
|
|
// if (firstTime == 1)
|
|
|
|
// if (firstTime == 1)
|
|
|
|
// max -= 1;
|
|
|
|
// max -= 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// if (sock_ret == -1) {
|
|
|
|
/// if (sock_ret == -1) {
|
|
|
|
/// printf("Error: %s \n", strerror(errno));
|
|
|
|
/// printf("Error: %s \n", strerror(errno));
|
|
|
|
/// socket_open = 0;
|
|
|
|
/// socket_open = 0;
|
|
|
|
//transmitStatus = -1;
|
|
|
|
// transmitStatus = -1;
|
|
|
|
/// }
|
|
|
|
/// }
|
|
|
|
/// }
|
|
|
|
/// }
|
|
|
|
if (!transmit) {
|
|
|
|
if (!transmit) {
|
|
|
|
fprintf(stderr, "\nNo CubeSatSim Band Pass Filter detected. No transmissions after the CW ID.\n");
|
|
|
|
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");
|
|
|
|
fprintf(stderr, " See http://cubesatsim.org/wiki for info about building a CubeSatSim\n\n");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// if (socket_open == 1)
|
|
|
|
/// if (socket_open == 1)
|
|
|
|
/// firstTime = 0;
|
|
|
|
/// firstTime = 0;
|
|
|
|
// else if (frames_sent > 0) //5)
|
|
|
|
// else if (frames_sent > 0) //5)
|
|
|
|
// firstTime = 0;
|
|
|
|
// firstTime = 0;
|
|
|
|
|
|
|
|
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|