|
|
|
|
@ -131,139 +131,6 @@ float batteryThreshold = 3.0, batteryVoltage;
|
|
|
|
|
const char pythonCmd[] = "python3 /home/pi/CubeSatSim/python/voltcurrent.py ";
|
|
|
|
|
char pythonStr[100], pythonConfigStr[100], busStr[10];
|
|
|
|
|
int map[8] = { 0, 1, 2, 3, 4, 5, 6, 7};
|
|
|
|
|
/*
|
|
|
|
|
struct SensorConfig {
|
|
|
|
|
int fd;
|
|
|
|
|
uint16_t config;
|
|
|
|
|
int calValue;
|
|
|
|
|
int powerMultiplier;
|
|
|
|
|
int currentDivider;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct SensorData {
|
|
|
|
|
double current;
|
|
|
|
|
double voltage;
|
|
|
|
|
double power;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief Read the data from one of the i2c current sensors.
|
|
|
|
|
*
|
|
|
|
|
* Reads the current data from the requested i2c current sensor configuration and
|
|
|
|
|
* stores it into a SensorData struct. An invalid file descriptor (i.e. less than zero)
|
|
|
|
|
* results in a SensorData struct being returned that has both its #current and #power members
|
|
|
|
|
* set to NAN.
|
|
|
|
|
*
|
|
|
|
|
* @param sensor A structure containing sensor configuration including the file descriptor.
|
|
|
|
|
* @return struct SensorData A struct that contains the current, voltage, and power readings
|
|
|
|
|
* from the requested sensor.
|
|
|
|
|
*
|
|
|
|
|
struct SensorData read_sensor_data(struct SensorConfig sensor) {
|
|
|
|
|
struct SensorData data = {
|
|
|
|
|
.current = 0,
|
|
|
|
|
.voltage = 0,
|
|
|
|
|
.power = 0 };
|
|
|
|
|
|
|
|
|
|
if (sensor.fd < 0) {
|
|
|
|
|
return data;
|
|
|
|
|
}
|
|
|
|
|
// doesn't read negative currents accurately, shows -0.1mA
|
|
|
|
|
wiringPiI2CWriteReg16(sensor.fd, INA219_REG_CALIBRATION, sensor.calValue);
|
|
|
|
|
wiringPiI2CWriteReg16(sensor.fd, INA219_REG_CONFIG, sensor.config);
|
|
|
|
|
wiringPiI2CWriteReg16(sensor.fd, INA219_REG_CALIBRATION, sensor.calValue);
|
|
|
|
|
sleep(0.01);
|
|
|
|
|
int value = wiringPiI2CReadReg16(sensor.fd, INA219_REG_CURRENT);
|
|
|
|
|
if (value == -1)
|
|
|
|
|
{
|
|
|
|
|
sensor.fd = -1;
|
|
|
|
|
return data;
|
|
|
|
|
}
|
|
|
|
|
data.current = (float) twosToInt(value, 16) / (float) sensor.currentDivider;
|
|
|
|
|
|
|
|
|
|
wiringPiI2CWrite(sensor.fd, INA219_REG_BUSVOLTAGE);
|
|
|
|
|
delay(1); // Max 12-bit conversion time is 586us per sample
|
|
|
|
|
value = (wiringPiI2CRead(sensor.fd) << 8 ) | wiringPiI2CRead (sensor.fd);
|
|
|
|
|
data.voltage = ((float)(value >> 3) * 4) / 1000;
|
|
|
|
|
// power has very low resolution, seems to step in 512mW values
|
|
|
|
|
data.power = (float) wiringPiI2CReadReg16(sensor.fd, INA219_REG_POWER) * (float) sensor.powerMultiplier;
|
|
|
|
|
|
|
|
|
|
return data;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief Configures an i2c current sensor.
|
|
|
|
|
*
|
|
|
|
|
* Calculates the configuration values of the i2c sensor so that
|
|
|
|
|
* current, voltage, and power can be read using read_sensor_data.
|
|
|
|
|
* Supports 16V 400mA and 16V 2.0A settings.
|
|
|
|
|
*
|
|
|
|
|
* @param sensor A file descriptor that can be used to read from the sensor.
|
|
|
|
|
* @param milliAmps The mA configuration, either 400mA or 2A are supported.
|
|
|
|
|
* @return struct SensorConfig A struct that contains the configuraton of the sensor.
|
|
|
|
|
*
|
|
|
|
|
//struct SensorConfig config_sensor(int sensor, int milliAmps) {
|
|
|
|
|
struct SensorConfig config_sensor(char *bus, int address, int milliAmps) {
|
|
|
|
|
struct SensorConfig data;
|
|
|
|
|
|
|
|
|
|
if (access(bus, W_OK | R_OK) < 0) { // Test if I2C Bus is missing
|
|
|
|
|
printf("ERROR: %s bus not present\n Check raspi-config Interfacing Options/I2C and /boot/config.txt \n", bus);
|
|
|
|
|
data.fd = OFF;
|
|
|
|
|
return (data);
|
|
|
|
|
}
|
|
|
|
|
char result[128];
|
|
|
|
|
int pos = strlen(bus) / sizeof(bus[0]) - 1;
|
|
|
|
|
// printf("Bus size %d \n", pos);
|
|
|
|
|
// printf("Bus value %d \n", atoi(&bus[pos]));
|
|
|
|
|
char command[50] = "timeout 10 i2cdetect -y ";
|
|
|
|
|
strcat (command, &bus[pos]);
|
|
|
|
|
FILE *i2cdetect = popen(command, "r");
|
|
|
|
|
|
|
|
|
|
while (fgets(result, 128, i2cdetect) != NULL) {
|
|
|
|
|
;
|
|
|
|
|
// printf("result: %s", result);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int error = pclose(i2cdetect)/256;
|
|
|
|
|
|
|
|
|
|
// printf("%s error: %d \n", &command, error);
|
|
|
|
|
if (error != 0)
|
|
|
|
|
{
|
|
|
|
|
printf("ERROR: %s bus has a problem \n Check I2C wiring and pullup resistors \n", bus);
|
|
|
|
|
data.fd = OFF;
|
|
|
|
|
return (data);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
data.fd = wiringPiI2CSetupInterface(bus, address);
|
|
|
|
|
|
|
|
|
|
data.config = INA219_CONFIG_BVOLTAGERANGE_32V |
|
|
|
|
|
INA219_CONFIG_GAIN_1_40MV |
|
|
|
|
|
INA219_CONFIG_BADCRES_12BIT |
|
|
|
|
|
INA219_CONFIG_SADCRES_12BIT_1S_532US |
|
|
|
|
|
INA219_CONFIG_MODE_SANDBVOLT_CONTINUOUS;
|
|
|
|
|
|
|
|
|
|
if (milliAmps == 400) { // INA219 16V 400mA configuration
|
|
|
|
|
data.calValue = 8192;
|
|
|
|
|
data.powerMultiplier = 1;
|
|
|
|
|
data.currentDivider = 20; // 40; in Adafruit config
|
|
|
|
|
}
|
|
|
|
|
else { // INA219 16V 2A configuration
|
|
|
|
|
data.calValue = 40960;
|
|
|
|
|
data.powerMultiplier = 2;
|
|
|
|
|
data.currentDivider = 10; // 20; in Adafruit config
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#ifdef DEBUG_LOGGING
|
|
|
|
|
printf("Sensor %s %x configuration: %d %d %d %d %d\n", bus, address, data.fd,
|
|
|
|
|
data.config, data.calValue, data.currentDivider, data.powerMultiplier);
|
|
|
|
|
#endif
|
|
|
|
|
return data;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
struct SensorConfig sensor[8]; // 8 current sensors in Solar Power PCB vB4/5
|
|
|
|
|
struct SensorData reading[8]; // 8 current sensors in Solar Power PCB vB4/5
|
|
|
|
|
struct SensorConfig tempSensor;
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
char src_addr[5] = "";
|
|
|
|
|
char dest_addr[5] = "CQ";
|
|
|
|
|
|
|
|
|
|
@ -444,52 +311,21 @@ int main(int argc, char *argv[]) {
|
|
|
|
|
|
|
|
|
|
if (vB4)
|
|
|
|
|
{
|
|
|
|
|
/* sensor[PLUS_X] = config_sensor("/dev/i2c-1", 0x40, 400);
|
|
|
|
|
sensor[PLUS_Y] = config_sensor("/dev/i2c-1", 0x41, 400);
|
|
|
|
|
sensor[BUS] = config_sensor("/dev/i2c-1", 0x44, 400);
|
|
|
|
|
sensor[BAT] = config_sensor("/dev/i2c-1", 0x45, 400);
|
|
|
|
|
sensor[PLUS_Z] = config_sensor("/dev/i2c-0", 0x40, 400);
|
|
|
|
|
sensor[MINUS_X] = config_sensor("/dev/i2c-0", 0x41, 400);
|
|
|
|
|
sensor[MINUS_Y] = config_sensor("/dev/i2c-0", 0x44, 400);
|
|
|
|
|
sensor[MINUS_Z] = config_sensor("/dev/i2c-0", 0x45, 400); */
|
|
|
|
|
map[BAT] = BUS;
|
|
|
|
|
map[BUS] = BAT;
|
|
|
|
|
strcpy(busStr,"1 0");
|
|
|
|
|
}
|
|
|
|
|
else if (vB5)
|
|
|
|
|
{
|
|
|
|
|
/* sensor[PLUS_X] = config_sensor("/dev/i2c-1", 0x40, 400);
|
|
|
|
|
sensor[PLUS_Y] = config_sensor("/dev/i2c-1", 0x41, 400);
|
|
|
|
|
sensor[BAT] = config_sensor("/dev/i2c-1", 0x44, 400);
|
|
|
|
|
sensor[BUS] = config_sensor("/dev/i2c-1", 0x45, 400); */
|
|
|
|
|
|
|
|
|
|
if (access("/dev/i2c-11", W_OK | R_OK) >= 0) { // Test if I2C Bus 11 is present
|
|
|
|
|
printf("/dev/i2c-11 is present\n\n");
|
|
|
|
|
/* sensor[PLUS_Z] = config_sensor("/dev/i2c-11", 0x40, 400);
|
|
|
|
|
sensor[MINUS_X] = config_sensor("/dev/i2c-11", 0x41, 400);
|
|
|
|
|
sensor[MINUS_Y] = config_sensor("/dev/i2c-11", 0x44, 400);
|
|
|
|
|
sensor[MINUS_Z] = config_sensor("/dev/i2c-11", 0x45, 400); */
|
|
|
|
|
strcpy(busStr,"1 11");
|
|
|
|
|
} else {
|
|
|
|
|
/* sensor[PLUS_Z] = config_sensor("/dev/i2c-3", 0x40, 400);
|
|
|
|
|
sensor[MINUS_X] = config_sensor("/dev/i2c-3", 0x41, 400);
|
|
|
|
|
sensor[MINUS_Y] = config_sensor("/dev/i2c-3", 0x44, 400);
|
|
|
|
|
sensor[MINUS_Z] = config_sensor("/dev/i2c-3", 0x45, 400); */
|
|
|
|
|
strcpy(busStr,"1 3");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
/* sensor[PLUS_X] = config_sensor("/dev/i2c-1", 0x40, 400);
|
|
|
|
|
sensor[PLUS_Y] = config_sensor("/dev/i2c-1", 0x41, 400);
|
|
|
|
|
sensor[PLUS_Z] = config_sensor("/dev/i2c-1", 0x44, 400);
|
|
|
|
|
sensor[BAT] = config_sensor("/dev/i2c-1", 0x45, 400);
|
|
|
|
|
sensor[BUS] = config_sensor("/dev/i2c-1", 0x4a, 2000);
|
|
|
|
|
sensor[MINUS_X] = config_sensor("/dev/i2c-0", 0x40, 400);
|
|
|
|
|
sensor[MINUS_Y] = config_sensor("/dev/i2c-0", 0x41, 400);
|
|
|
|
|
sensor[MINUS_Z] = config_sensor("/dev/i2c-0", 0x44, 400);
|
|
|
|
|
|
|
|
|
|
tempSensor = config_sensor("/dev/i2c-3", 0x48, 0); */
|
|
|
|
|
map[BUS] = MINUS_Z;
|
|
|
|
|
map[BAT] = BUS;
|
|
|
|
|
map[PLUS_Z] = BAT;
|
|
|
|
|
@ -498,7 +334,7 @@ else
|
|
|
|
|
batteryThreshold = 8.0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
strcpy(pythonStr, pythonCmd);
|
|
|
|
|
strcpy(pythonStr, pythonCmd);
|
|
|
|
|
strcat(pythonStr, busStr);
|
|
|
|
|
strcat(pythonConfigStr, pythonStr);
|
|
|
|
|
strcat(pythonConfigStr, " c");
|
|
|
|
|
@ -559,49 +395,7 @@ 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];
|
|
|
|
|
char cw_header[] = "echo 'de ";
|
|
|
|
|
char cw_footer[] = "' > 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_str, cw_header);
|
|
|
|
|
//printf("Before 1st strcpy\n");
|
|
|
|
|
strcat(cw_str, call);
|
|
|
|
|
//printf("Before 1st strcpy\n");
|
|
|
|
|
strcat(cw_str, cw_footer);
|
|
|
|
|
//printf("Before 1st strcpy\n");
|
|
|
|
|
digitalWrite (txLed, txLedOn);
|
|
|
|
|
#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);
|
|
|
|
|
// 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");
|
|
|
|
|
*/
|
|
|
|
|
while (loop-- != 0)
|
|
|
|
|
{
|
|
|
|
|
frames_sent++;
|
|
|
|
|
@ -712,21 +506,7 @@ 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");
|
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -820,17 +600,7 @@ for (int j = 0; j < frameCnt; j++)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
/*
|
|
|
|
|
int count;
|
|
|
|
|
for (count = 0; count < 8; count++)
|
|
|
|
|
{
|
|
|
|
|
reading[count] = read_sensor_data(sensor[count]);
|
|
|
|
|
#ifdef DEBUG_LOGGING
|
|
|
|
|
// printf("Read sensor[%d] % 4.2fV % 6.1fmA % 6.1fmW \n",
|
|
|
|
|
// count, reading[count].voltage, reading[count].current, reading[count].power);
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
tlm[1][A] = (int)(voltage[map[BUS]] /15.0 + 0.5) % 100; // Current of 5V supply to Pi
|
|
|
|
|
tlm[1][B] = (int) (99.5 - current[map[PLUS_X]]/10.0) % 100; // +X current [4]
|
|
|
|
|
tlm[1][C] = (int) (99.5 - current[map[MINUS_X]]/10.0) % 100; // X- current [10]
|
|
|
|
|
@ -845,24 +615,7 @@ for (int j = 0; j < frameCnt; j++)
|
|
|
|
|
tlm[3][B] = (int)(voltage[map[BUS]] * 10.0) % 100; // 5V supply to Pi
|
|
|
|
|
|
|
|
|
|
batteryVoltage = voltage[map[BAT]];
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
if (ax5043)
|
|
|
|
|
{
|
|
|
|
|
if (tempSensor.fd != OFF) {
|
|
|
|
|
int tempValue = wiringPiI2CReadReg16(tempSensor.fd, 0);
|
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
FILE *cpuTempSensor = fopen("/sys/class/thermal/thermal_zone0/temp", "r");
|
|
|
|
|
if (cpuTempSensor) {
|
|
|
|
|
double cpuTemp;
|
|
|
|
|
@ -1148,33 +901,7 @@ if (firstTime != ON)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// printf("\n");
|
|
|
|
|
/*
|
|
|
|
|
int count;
|
|
|
|
|
for (count = 0; count < 8; count++)
|
|
|
|
|
{
|
|
|
|
|
reading[count] = read_sensor_data(sensor[count]);
|
|
|
|
|
reading[count] = read_sensor_data(sensor[count]);
|
|
|
|
|
#ifdef DEBUG_LOGGING
|
|
|
|
|
// printf("Read sensor[%d] % 4.2fV % 6.1fmA % 6.1fmW \n",
|
|
|
|
|
// count, reading[count].voltage, reading[count].current, reading[count].power);
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
*/
|
|
|
|
|
/*
|
|
|
|
|
if (tempSensor.fd != OFF) {
|
|
|
|
|
int tempValue = wiringPiI2CReadReg16(tempSensor.fd, 0);
|
|
|
|
|
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
|
|
|
|
|
|
|
|
|
|
TxTemp = (int)((temp * 10.0) + 0.5);
|
|
|
|
|
encodeB(b, 34 + head_offset, TxTemp);
|
|
|
|
|
}
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
FILE *cpuTempSensor = fopen("/sys/class/thermal/thermal_zone0/temp", "r");
|
|
|
|
|
if (cpuTempSensor) {
|
|
|
|
|
double cpuTemp;
|
|
|
|
|
@ -1215,28 +942,6 @@ if (firstTime != ON)
|
|
|
|
|
|
|
|
|
|
if (mode == BPSK)
|
|
|
|
|
h[6] = 99;
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
// posXv = reading[PLUS_X].current;
|
|
|
|
|
posXi = (int)reading[PLUS_X].current + 2048;
|
|
|
|
|
posYi = (int)reading[PLUS_Y].current + 2048;
|
|
|
|
|
posZi = (int)reading[PLUS_Z].current + 2048;
|
|
|
|
|
negXi = (int)reading[MINUS_X].current + 2048;
|
|
|
|
|
negYi = (int)reading[MINUS_Y].current + 2048;
|
|
|
|
|
negZi = (int)reading[MINUS_Z].current + 2048;
|
|
|
|
|
|
|
|
|
|
posXv = (int)(reading[PLUS_X].voltage * 100);
|
|
|
|
|
posYv = (int)(reading[PLUS_Y].voltage* 100);
|
|
|
|
|
posZv = (int)(reading[PLUS_Z].voltage * 100);
|
|
|
|
|
negXv = (int)(reading[MINUS_X].voltage * 100);
|
|
|
|
|
negYv = (int)(reading[MINUS_Y].voltage * 100);
|
|
|
|
|
negZv = (int)(reading[MINUS_Z].voltage * 100);
|
|
|
|
|
|
|
|
|
|
batt_c_v = (int)(reading[BAT].voltage * 100);
|
|
|
|
|
battCurr = (int)reading[BAT].current + 2048;
|
|
|
|
|
PSUVoltage = (int)(reading[BUS].voltage * 100);
|
|
|
|
|
PSUCurrent = (int)reading[BUS].current + 2048;
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
posXi = (int)current[map[PLUS_X]] + 2048;
|
|
|
|
|
posYi = (int)current[map[PLUS_Y]] + 2048;
|
|
|
|
|
@ -1474,64 +1179,11 @@ if (firstTime != ON)
|
|
|
|
|
|
|
|
|
|
int error = 0;
|
|
|
|
|
int count;
|
|
|
|
|
// for (count = 0; count < DATA_LEN; count++) {
|
|
|
|
|
// for (count = 0; count < dataLen; count++) {
|
|
|
|
|
// printf("%02X", b[count]);
|
|
|
|
|
// }
|
|
|
|
|
// printf("\n");
|
|
|
|
|
|
|
|
|
|
// rpitx
|
|
|
|
|
/*
|
|
|
|
|
char cmdbuffer[1000];
|
|
|
|
|
FILE* txResult;
|
|
|
|
|
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");
|
|
|
|
|
pclose(txResult);
|
|
|
|
|
// printf("2\n");
|
|
|
|
|
// digitalWrite (txLed, txLedOn);
|
|
|
|
|
sleep(1);
|
|
|
|
|
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 | 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 | 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);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
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");
|
|
|
|
|
}
|
|
|
|
|
sleep(2);
|
|
|
|
|
// printf("Results of transmit command: %s\n", cmdbuffer);
|
|
|
|
|
}
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
// socket write
|
|
|
|
|
|
|
|
|
|
if (!socket_open && transmit)
|
|
|
|
|
|