Beispiel #1
0
/* u3_sist_put(): moronic key-value store put.
*/
void
u3_sist_put(const c3_c* key_c, const c3_y* val_y, size_t siz_i)
{
  c3_c ful_c[2048];
  c3_i ret_i;
  c3_i fid_i;

  ret_i = snprintf(ful_c, 2048, "%s/.urb/sis/_%s", u3_Host.dir_c, key_c);
  c3_assert(ret_i < 2048);

  if ( (fid_i = open(ful_c, O_CREAT | O_TRUNC | O_WRONLY, 0600)) < 0 ) {
    uL(fprintf(uH, "sist: could not put %s\n", key_c));
    perror("open");
    u3_lo_bail();
  }
  if ( (ret_i = write(fid_i, val_y, siz_i)) != siz_i ) {
    uL(fprintf(uH, "sist: could not write %s\n", key_c));
    if ( ret_i < 0 ) {
      perror("write");
    }
    u3_lo_bail();
  }
  ret_i = c3_sync(fid_i);
  if ( ret_i < 0 ) {
    perror("sync");
  }
  ret_i = close(fid_i);
  c3_assert(0 == ret_i);
}
Beispiel #2
0
char c3_open(uint8_t jr)
{
	/* Open, setup and take the image */
	if(c3_sync() != 0) return(-1);
	if(c3_setup(CT_JPEG, 0, jr) != 0) return(-2);
	if(c3_set_package_size(RXBUF_LEN) != 0) return(-3);
	if(c3_snapshot(ST_JPEG, 0) != 0) return(-4);
	if(c3_get_picture(PT_SNAPSHOT, &image_len) != 0) return(-5);
	
	image_read = 0;
	package = NULL;
	package_len = 0;
	package_id = 0;
	
	return(0);
}
Beispiel #3
0
char c3_open(uint8_t jr)
{
	/* In case of a reset, finish a previously started image */
	c3_finish_picture();
	
	/* Open, setup and take the image */
	if(c3_sync() != 0) return(-1);
	if(c3_setup(CT_JPEG, 0, jr) != 0) return(-2);
	if(c3_set_package_size(RXBUF_LEN) != 0) return(-3);
	if(c3_snapshot(ST_JPEG, 0) != 0) return(-4);
	if(c3_get_picture(PT_SNAPSHOT, &image_len) != 0) return(-5);
	
	image_read = 0;
	package = NULL;
	package_len = 0;
	package_id = 0;
	
	return(0);
}
Beispiel #4
0
int main(void)
{
	uint32_t count = 0;
	int32_t lat, lon, alt, temp1, temp2, pressure;
	uint8_t hour, minute, second;
	uint16_t mv;
	char msg[100];
	uint8_t i, r;
	bmp085_t bmp;
	
	/* Set the LED pin for output */
	DDRB |= _BV(DDB7);
	
	adc_init();
	rtx_init();
	bmp085_init(&bmp);
	
#ifdef APRS_ENABLED
	ax25_init();
#endif

#ifdef SSDV_ENABLED
	c3_init();
#endif
	
	sei();
	
	gps_setup();
	
	/* Enable the radio and let it settle */
	rtx_enable(1);
	_delay_ms(1000);
	
	rtx_string_P(PSTR(RTTY_CALLSIGN " starting up\n"));
	
	/* Scan the 1-wire bus, up to 16 devices */
	rtx_string_P(PSTR("Scanning 1-wire bus:\n"));
	for(i = 0; i < 16; i++)
	{
		r = ds_search_rom(id[i], i);
		
		if(r == DS_OK || r == DS_MORE)
		{
			/* A device was found, display the address */
			rtx_wait();
			snprintf_P(msg, 100, PSTR("%i> %02X-%02X-%02X-%02X-%02X-%02X-%02X-%02X\n"),
				i,
				id[i][0], id[i][1], id[i][2], id[i][3],
				id[i][4], id[i][5], id[i][6], id[i][7]);
				rtx_string(msg);
		}
		else
		{
			/* Device not responding or no devices found */
			rtx_wait();
			snprintf_P(msg, 100, PSTR("%i> Error %i\n"), i, r);
			rtx_string(msg);
		}
		
		/* No more devices? */
		if(r != DS_MORE) break;
	}
	rtx_string_P(PSTR("Done\n"));
	
	while(1)
	{
		/* Set the GPS navmode every 10 strings */
		if(count % 10 == 0)
		{
			/* Mode 6 is "Airborne with <1g Acceleration" */
			if(gps_set_nav(6) != GPS_OK)
			{
				rtx_string_P(PSTR("$$" RTTY_CALLSIGN ",Error setting GPS navmode\n"));
			}
		}
		
		/* Get the latitude and longitude */
		if(gps_get_pos(&lat, &lon, &alt) != GPS_OK)
		{
			rtx_string_P(PSTR("$$" RTTY_CALLSIGN ",No or invalid GPS response\n"));
			lat = lon = alt = 0;
		}
		
		/* Get the GPS time */
		if(gps_get_time(&hour, &minute, &second) != GPS_OK)
		{
			rtx_string_P(PSTR("$$" RTTY_CALLSIGN ",No or invalid GPS response\n"));
			hour = minute = second = 0;
		}
		
		/* Read the battery voltage */
		mv = adc_read();
		
		/* Read the temperature from sensor 0 */
		ds_read_temperature(&temp1, id[0]);
		
		/* Read the temperature from sensor 1 */
		ds_read_temperature(&temp2, id[1]);
		
		/* Read the pressure from the BMP085 */
		if(bmp085_sample(&bmp, 3) != BMP_OK) pressure = 0;
		else pressure = bmp085_calc_pressure(&bmp);
		
		/* Build up the string */
		rtx_wait();
		
		snprintf_P(msg, 100, PSTR("$$%s,%li,%02i:%02i:%02i,%s%li.%04li,%s%li.%04li,%li,%i.%01i,%li,%li,%li,%c"),
			RTTY_CALLSIGN, count++,
			hour, minute, second,
			(lat < 0 ? "-" : ""), labs(lat) / 10000000, labs(lat) % 10000000 / 1000,
			(lon < 0 ? "-" : ""), labs(lon) / 10000000, labs(lon) % 10000000 / 1000,
			alt / 1000,
			mv / 1000, mv / 100 % 10,
			temp1 / 10000,
			temp2 / 10000,
			pressure,
			(geofence_test(lat, lon) ? '1' : '0'));
		crccat(msg);
		rtx_string(msg);
		
#ifdef APRS_ENABLED
		tx_aprs(lat, lon, alt);
		{ int i; for(i = 0; i < 60; i++) _delay_ms(1000); }
#endif

#ifdef SSDV_ENABLED
		if(tx_image() == -1)
		{
			/* The camera goes to sleep while transmitting telemetry,
			 * sync'ing here seems to prevent it. */
			c3_sync();
		}
#endif
	}
}