Changeset - b22a378398b3
[Not reviewed]
default
0 5 0
ethanzonca@CL-ENS241-08.cedarville.edu - 12 years ago 2013-04-16 15:14:27
ethanzonca@CL-ENS241-08.cedarville.edu
fixed configuration issues
5 files changed with 21 insertions and 23 deletions:
0 comments (0 inline, 0 general)
master/master/config.h
Show inline comments
 
@@ -145,56 +145,56 @@
 
#define D_CALLSIGN      "APRS"
 
#define D_CALLSIGN_ID   0
 

	
 
// Digipeating paths:
 
// (read more about digipeating paths here: http://wa8lmf.net/DigiPaths/ )
 
// The recommended digi path for a balloon is WIDE2-1 or pathless. The default
 
// is pathless. Uncomment the following two lines for WIDE2-1 path:
 
#define DIGI_PATH1      "WIDE2"
 
#define DIGI_PATH1_TTL  1
 
 
// Transmit the APRS sentence every X milliseconds
 
#define APRS_TRANSMIT_PERIOD 35000
 

	
 

	
 
// --------------------------------------------------------------------------
 
// Logger config (logger.c)
 
// --------------------------------------------------------------------------
 
 
// Log number EEPROM address (this number is incremented on boot, used for filenames)
 
#define LOGGER_ID_EEPROM_ADDR 0x10
 
 
// Watchdog save/restore of program timer
 
#define WATCHDOG_PROGTIMER_EEPROM_ADDR 0x20
 
 
// Written to the beginning of every log file
 
#define LOGGER_HEADERTEXT "HAB Master v1.2\n"
 
 
// Log to SD card every X milliseconds
 
#define LOGGER_RATE 1000 
 
 
// LED cycle indicator speed
 
#define LEDCYCLE_RATE 100 
 
 
 
 
// --------------------------------------------------------------------------
 
// Dynamic Configuration (iniparse.c) - You probably don't want to change this
 
// --------------------------------------------------------------------------
 
#include <stdbool.h>
 
typedef struct
 
{
 
	bool blackout_enable;
 
	uint32_t blackout_timeout;
 
	int8_t heater_threshold;
 
	uint32_t buzzer_failsafe_duration;
 
	uint32_t buzzer_trigger_minduration;
 
	uint32_t buzzer_trigger_maxaltitude;
 
	uint32_t datarequest_rate;
 
	char s_callsign[10];
 
	char s_callsign[7];
 
	uint8_t s_callsign_id;
 
	uint32_t aprs_transmit_period;
 
} configuration;
 
 
configuration* sysconfig;
 
 
#endif /* CONFIG_H_ */
 
\ No newline at end of file
master/master/lib/aprs.c
Show inline comments
 
/*
 
 * Master Firmware: APRS
 
 *
 
 * Wireless Observational Modular Aerial Network
 
 * 
 
 * Ethan Zonca
 
 * Matthew Kanning
 
 * Kyle Ripperger
 
 * Matthew Kroening
 
 *
 
 */
 
 
#include "../config.h"
 
#include "aprs.h"
 
#include "ax25.h"
 
#include "gps.h"
 
#include "sensordata.h"
 
#include <stdio.h>
 
#include <stdlib.h>
 
#include <string.h>
 

	
 
float meters_to_feet(float m)
 
int32_t meters_to_feet(int32_t m)
 
{
 
  // 10000 ft = 3048 m
 
  return m / 0.3048;
 
  return (float)m / 0.3048;
 
}
 

	
 
void aprs_send()
 
{
 
  const struct s_address addresses[] = { 
 
    {D_CALLSIGN, D_CALLSIGN_ID},  // Destination callsign
 
    {sysconfig->s_callsign, sysconfig->s_callsign_id},  // Source callsign (-11 = balloon, -9 = car)
 
    {"", sysconfig->s_callsign_id},  // Source callsign (-11 = balloon, -9 = car)
 
		//{S_CALLSIGN, S_CALLSIGN_ID},
 
#ifdef DIGI_PATH1
 
    {DIGI_PATH1, DIGI_PATH1_TTL}, // Digi1 (first digi in the chain)
 
#endif
 
#ifdef DIGI_PATH2
 
    {DIGI_PATH2, DIGI_PATH2_TTL}, // Digi2 (second digi in the chain)
 
#endif
 
  };
 

	
 
  strncpy(addresses[1].callsign, sysconfig->s_callsign, 7);
 
  
 
	// emz: modified this to get the size of the first address rather than the size of the struct itself, which fails
 
  ax25_send_header(addresses, sizeof(addresses)/sizeof(addresses[0]));
 
  ax25_send_byte('/');                // Report w/ timestamp, no APRS messaging. $ = NMEA raw data
 
  // ax25_send_string("021709z");     // 021709z = 2nd day of the month, 17:09 zulu (UTC/GMT)
 
  ax25_send_string(get_dayofmonth()); ///! Needs to be day hour minute        // 170915 = 17h:09m:15s zulu (not allowed in Status Reports)
 
  ax25_send_string(get_timestamp()); 
 
  ax25_send_byte('z'); // zulu time. h for nonzulu
 
  ax25_send_string(get_latitudeTrimmed());     // Lat: 38deg and 22.20 min (.20 are NOT seconds, but 1/100th of minutes)
 
  ax25_send_byte('N');
 
  ax25_send_byte('/');                // Symbol table
 
  ax25_send_string(get_longitudeTrimmed());     // Lon: 000deg and 25.80 min
 
  ax25_send_byte('W');
 
  ax25_send_byte('O');                // Symbol: O=balloon, -=QTH
 
  
 
  //snprintf(temp, 4, "%03d", (int)(get_course() + 0.5));  
 
  // !!!TODO: ENSURE THAT THE COURSE IS FORMATTED CORRECTLY!
 
  ax25_send_string(get_course());             // Course (degrees)
 
  
 
  ax25_send_byte('/');                // and
 
  
 
  // !!!TODO: Check the speed!
 
  //snprintf(temp, 4, "%03d", (int)(gps_speed + 0.5));
 
  ax25_send_string(get_speedKnots());             // speed (knots)
 
  
 
  /*
 
  int32_t alt = meters_to_feet(strtol(get_gpsaltitude(), NULL, 10));
 
  
 
  char temp[7];
 
  ax25_send_string("/A=");            // Altitude (feet). Goes anywhere in the comment area
 
  snprintf(temp, 7, "%06ld", (long)(meters_to_feet(gps_altitude) + 0.5));
 
  ax25_send_string(temp);
 
  ax25_send_string("/Ti=");
 
  snprintf(temp, 6, "%d", 122);//sensors_int_lm60()); -- PUT SENSOR DATA HERE
 
  snprintf(temp, 7, "%ld", alt);
 
  ax25_send_string(temp);
 
  ax25_send_string("/Te=");
 
  snprintf(temp, 6, "%d", 123);//sensors_ext_lm60());
 
  ax25_send_string(temp);
 
  ax25_send_string("/V=");
 
  snprintf(temp, 6, "%d", 123);//sensors_vin());
 
  ax25_send_string(temp);
 
  */
 
  
 
  ax25_send_byte(' ');
 
  
 
  #define COMMENTBUFFER_SIZE 128
 
  char commentBuffer[COMMENTBUFFER_SIZE];
 
  ax25_send_string(slavesensors_getAPRScomment(commentBuffer, COMMENTBUFFER_SIZE));
 
  
 
  ax25_send_footer();
 
  ax25_flush_frame();                 // Tell the modem to go
 
}
master/master/lib/gps.c
Show inline comments
 
@@ -390,96 +390,97 @@ void parse_gps_transmission(void){
 
				serial0_sendString("found quality byte\r\n");
 
				#endif
 
				
 
				quality = byte; //maybe reset if invalid data ??
 
				setParserState(GGA_QUALITY);
 
			}
 
		}
 
	
 
		//number of satellites
 
		else if (decodeState == GGA_SATELLITES)
 
		{
 
			if (byte == ',') //end of this data type
 
			{
 
				numSatellites[numBytes] = 0x00;
 
				setParserState(GGA_HDOP);
 
				numBytes = 0; //prep for next phase of parse
 
			}
 
			else //store data
 
			{
 
				numSatellites[numBytes] = byte; //adjust number of bytes to fit array
 
				numBytes++;
 
				setParserState(GGA_SATELLITES);
 
			}
 
		}
 
	
 
		//HDOP
 
		else if (decodeState == GGA_HDOP)
 
		{
 
			if (byte == ',' ) //end of this data type
 
			{
 
				hdop[numBytes] = 0x00;
 
				setParserState(GGA_ALTITUDE);
 
				numBytes = 0; //prep for next phase of parse
 
				skipBytes = 0;
 
			}
 
			else //store data
 
			{
 
				hdop[numBytes] = byte; //adjust number of bytes to fit array
 
				numBytes++;
 
				setParserState(GGA_HDOP);
 
			}
 
		}
 
	
 
		//altitude
 
		else if (decodeState == GGA_ALTITUDE)
 
		{
 
			if (byte == ',' && skipBytes == 0) //discard this byte
 
			{
 
				altitude[numBytes] = 0x00;
 
				skipBytes = 1;
 
				setParserState(GGA_ALTITUDE);
 
			}
 
			else if(byte == ',') //end of this data type
 
			{
 
				altitude[numBytes] = 0x00;
 
				setParserState(GGA_WGS84);
 
				numBytes = 0; //prep for next phase of parse
 
			}
 
			else //store data
 
			{
 
				altitude[numBytes] = byte; //adjust number of bytes to fit array
 
				numBytes++;
 
				setParserState(GGA_ALTITUDE);
 
			}
 
		}
 
	
 
		//WGS84 Height
 
		else if (decodeState == GGA_WGS84)
 
		{
 
			if (byte == ',' && skipBytes == 0) //discard this byte
 
			{
 
				skipBytes = 1;
 
				setParserState(GGA_WGS84);
 
			}
 
			else if(byte == ',') //end of this data type
 
			{
 
				wgs84Height[numBytes] = 0x00;
 
				setParserState(GGA_LAST_UPDATE);
 
				skipBytes = 0; //prep for next phase of parse
 
				numBytes = 0;
 
			}
 
			else //store data
 
			{
 
				wgs84Height[numBytes] = byte; //adjust number of bytes to fit array
 
				numBytes++;
 
				setParserState(GGA_WGS84);
 
			}
 
		}
 
	
 
		//last GGA DGPS update
 
		else if (decodeState == GGA_LAST_UPDATE)
 
		{
 
			if (byte == ',') //end of this data type
 
			{
 
				lastUpdated[numBytes] = 0x00;
 
				setParserState(GGA_STATION_ID);
 
				numBytes = 0; //prep for next phase of parse
master/master/lib/iniparse.c
Show inline comments
 
@@ -7,112 +7,115 @@
 
 * Matthew Kanning
 
 * Kyle Ripperger
 
 * Matthew Kroening
 
 *
 
 */
 

	
 
#include "../config.h"
 
#include <stdbool.h>
 
#include <stdlib.h>
 
#include <string.h>
 
#include "iniparse.h"
 
#include "ini/ini.h"
 
#include "logger.h"
 
 
static int handler(void* user, const char* section, const char* name, const char* value)
 
{
 
	
 
	configuration* pconfig = (configuration*)user;
 
 
	#define MATCH(s, n) strcmp(section, s) == 0 && strcmp(name, n) == 0
 
		
 
	if (MATCH("general", "temp")) {
 
		pconfig->heater_threshold = atoi(value);
 
		
 
		
 
	} else if (MATCH("general", "reqrate")) {
 
		pconfig->datarequest_rate = strtol(value, NULL, 10);
 
		
 
		
 
	} else if (MATCH("blackout", "enable")) {
 
		pconfig->blackout_enable = strncmp(value, "false", 4);
 
		
 
		
 
	} else if (MATCH("blackout", "timeout")) {
 
		pconfig->blackout_timeout = strtol(value, NULL, 10);
 
		
 
		
 
	} else if (MATCH("buzzer", "failsafe")) {
 
		pconfig->buzzer_failsafe_duration = strtol(value, NULL, 10);
 
		
 
		
 
	} else if (MATCH("buzzer", "mintime")) {
 
		pconfig->buzzer_trigger_minduration = strtol(value, NULL, 10);
 
		
 
	} else if (MATCH("buzzer", "maxalt")) {
 
		pconfig->buzzer_trigger_maxaltitude = strtol(value, NULL, 10);
 
		
 
	} else if (MATCH("aprs", "call")) {
 
		strncpy(pconfig->s_callsign, value, 10);
 
		snprintf(pconfig->s_callsign, 7, "%s", &value[1], 6);
 
		//pconfig->s_callsign = strdup(value);
 
		
 
		
 
	} else if (MATCH("aprs", "call_id")) {
 
		pconfig->s_callsign_id = atoi(value);
 
		
 
		
 
	} else if (MATCH("aprs", "period")) {
 
		pconfig->aprs_transmit_period = strtol(value, NULL, 10);
 
		
 
	} else {
 
		error_log_msg(ERROR_CONFIGPARSE,false,"bad entry");
 
		return 0;  /* unknown section/name, error */
 
	}
 
	
 
	
 
	return 1;
 
}
 

	
 
configuration config = {
 
	#ifdef BLACKOUT_ENABLE
 
	.blackout_enable = true,
 
	#else
 
	.blackout_enable = false,
 
	#endif
 
		
 
	.blackout_timeout = BLACKOUT_TIMEOUT,
 
	.heater_threshold = HEATER_THRESHOLD,
 
	.buzzer_failsafe_duration = BUZZER_FAILSAFE_DURATION,
 
	.buzzer_trigger_minduration = BUZZER_TRIGGER_MINDURATION,
 
	.buzzer_trigger_maxaltitude = BUZZER_TRIGGER_MAXALTITUDE,
 
	.datarequest_rate = DATAREQUEST_RATE,
 
	.s_callsign = S_CALLSIGN,
 
	
 
	.s_callsign_id = S_CALLSIGN_ID,
 
	.aprs_transmit_period = APRS_TRANSMIT_PERIOD
 
};
 

	
 
void iniparse_getconfig()
 
{
 
	// Init configuration with default values from config.h
 
 
	snprintf(config.s_callsign, 10, "KD8TDF");
 
	config.s_callsign[6] = NULL;
 
	
 
	
 
	if (ini_parse(handler, &config) < 0) {
 
		// ERROR: Make new error code here!
 
		error_log(ERROR_CONFIGPARSE, false);
 
	}
 
 
	sysconfig = &config;
 
	
 
	// Print configuration to err
 
	error_log_rawwrite("\nConf:\n");
 
		
 
	char msg[50];
 
	snprintf(msg, 50,"reqrate: %lu\n",sysconfig->datarequest_rate);
 
	error_log_rawwrite(msg);
 
	snprintf(msg, 50,"call: %s\n",sysconfig->s_callsign);
 
	error_log_rawwrite(msg);
 
	snprintf(msg, 50,"callID: %u\n",sysconfig->s_callsign_id);
 
	error_log_rawwrite(msg);
 
	snprintf(msg, 50,"aprsperiod: %lu\n\n",sysconfig->aprs_transmit_period);
 
	error_log_rawwrite(msg);
 
	
 
	return;
 
}
 
\ No newline at end of file
master/master/lib/iniparse.h
Show inline comments
 
/*
 
 * Master Firmware: INI Parser
 
 *
 
 * Wireless Observational Modular Aerial Network
 
 * 
 
 * Ethan Zonca
 
 * Matthew Kanning
 
 * Kyle Ripperger
 
 * Matthew Kroening
 
 *
 
 */
 
 
 
#ifndef INIPARSE_H_
 
#define INIPARSE_H_
 
 
 
void iniparse_getconfig();
 
 
 
#endif /* INIPARSE_H_ */
 
\ No newline at end of file
0 comments (0 inline, 0 general)