None of these appear likely to have caused actual problems.
Signed-off-by: Keith Packard <keithp@keithp.com>
exit(1);
}
-void
-done(struct cc_usb *cc, int code)
-{
- cc_usb_close(cc);
- exit (code);
-}
-
-static int
-ends_with(char *whole, char *suffix)
-{
- int whole_len = strlen(whole);
- int suffix_len = strlen(suffix);
-
- if (suffix_len > whole_len)
- return 0;
- return strcmp(whole + whole_len - suffix_len, suffix) == 0;
-}
-
-static int
-starts_with(char *whole, char *prefix)
-{
- int whole_len = strlen(whole);
- int prefix_len = strlen(prefix);
-
- if (prefix_len > whole_len)
- return 0;
- return strncmp(whole, prefix, prefix_len) == 0;
-}
-
static char **
tok(char *line) {
char **strs = malloc (sizeof (char *)), *str;
return strs;
}
-static void
-free_strs(char **strs) {
- char *str;
- int i;
-
- for (i = 0; (str = strs[i]) != NULL; i++)
- free(str);
- free(strs);
-}
-
struct flash {
struct flash *next;
char line[512];
return head;
}
-static void
-free_flash(struct flash *b) {
- struct flash *n;
-
- while (b) {
- n = b->next;
- free_strs(b->strs);
- free(b);
- b = n;
- }
-}
-
-char **
+static char **
find_flash(struct flash *b, char *word0) {
- int i;
for (;b; b = b->next) {
if (strstr(b->line, word0))
return b->strs;
return NULL;
}
-void
-await_key(void)
-{
- struct termios termios, termios_save;
- char buf[512];
-
- tcgetattr(0, &termios);
- termios_save = termios;
- cfmakeraw(&termios);
- tcsetattr(0, TCSAFLUSH, &termios);
- read(0, buf, sizeof (buf));
- tcsetattr(0, TCSAFLUSH, &termios_save);
-}
-
-int
+static int
do_save(struct cc_usb *usb)
{
int ret = 0;
return ret;
}
-int
+static int
do_output(char *output, int cur_cal)
{
printf ("Saving calibration value to file \"%s\"\n", output);
return ret;
}
-int
+static int
do_cal(char *tty, int save, char *output)
{
struct cc_usb *usb = NULL;
main (int argc, char **argv)
{
char *device = NULL;
- char *filename;
- Elf *e;
- unsigned int s;
- int i;
int c;
- int tries;
char *tty = NULL;
- int success;
int verbose = 0;
int save = 1;
int ret = 0;
- int expected_size;
char *output = NULL;
while ((c = getopt_long(argc, argv, "vnT:D:o:", options, NULL)) != -1) {
int kernel_active;
};
-libusb_device_handle *
+static libusb_device_handle *
chaoskey_match(libusb_device *dev, char *match_serial)
{
struct libusb_device_descriptor desc;
return 0;
}
-struct chaoskey *
+static struct chaoskey *
chaoskey_open(char *serial)
{
struct chaoskey *ck;
return NULL;
}
-void
-chaoskey_close(struct chaoskey *ck)
-{
- libusb_release_interface(ck->handle, 0);
- if (ck->kernel_active)
- libusb_attach_kernel_driver(ck->handle, 0);
- libusb_close(ck->handle);
- libusb_exit(ck->ctx);
- free(ck);
-}
-
#define COOKED_ENDPOINT 0x85
#define RAW_ENDPOINT 0x86
#define FLASH_ENDPOINT 0x87
-int
+static int
chaoskey_read(struct chaoskey *ck, int endpoint, void *buffer, int len)
{
uint8_t *buf = buffer;
return command_error;
length = (int) end - (int) start + 1;
status = ccdbg_read_memory(s51_dbg, start + 0xff00, memory, length);
+ (void) status;
dump_bytes(memory, length, start, "0x%02x ");
return command_success;
}
return command_error;
length = (int) end - (int) start + 1;
status = ccdbg_read_sfr(s51_dbg, start, memory, length);
+ (void) status;
dump_bytes(memory, length, start, "0x%02x ");
return command_success;
}
return command_error;
length = (int) end - (int) start + 1;
status = ccdbg_read_memory(s51_dbg, start, memory, length);
+ (void) status;
dump_bytes(memory, length, start, "0x%04x ");
return command_success;
}
enable_breakpoint(b);
}
-enum command_result
+static enum command_result
set_breakpoint(uint16_t address, int temporary)
{
int b;
- uint8_t status;
for (b = 0; b < CC_NUM_BREAKPOINTS; b++) {
if (breakpoints[b].enabled == 0)
break;
return command_success;
}
-enum command_result
+static enum command_result
clear_breakpoint(uint16_t address, int temporary)
{
int b;
- uint8_t status;
for (b = 0; b < CC_NUM_BREAKPOINTS; b++) {
if (breakpoints[b].enabled != 0 &&
}
-int
+static int
find_breakpoint(uint16_t address)
{
int b;
enum command_result
command_clear (int argc, char **argv)
{
- int b;
uint16_t address;
enum command_result result;
return clear_breakpoint(address, 0);
}
-void
+static void
cc_stopped(uint8_t status)
{
uint16_t pc;
}
}
-uint8_t
+static uint8_t
cc_step(uint16_t pc)
{
int b;
info_breakpoints(int argc, char **argv)
{
int b;
- uint16_t address;
- enum command_result result;
if (argc == 1) {
s51_printf("Num Type Disp Hit Cnt Address What\n");
}
return command_success;
}
-
+ return command_syntax;
}
static enum command_result
exit(1);
}
-void s51_sigint()
+static void
+s51_sigint(int signum)
{
s51_interrupted = 1;
}
int
main(int argc, char **argv)
{
- int flags, opt;
+ int opt;
char *endptr;
while ((opt = getopt_long(argc, argv, "PVvHhmt:X:c:r:Z:s:S:p:T:", options, NULL)) != -1) {
{
struct pollfd input;
int r;
- int c;
input.fd = fileno(s51_input);
input.events = POLLIN;
#define TRUE 1
#endif
-static int
-string_to_int(char *s, int *v)
-{
- char *endptr;
-
- if (isdigit(s[0]) || s[0] == '-' || s[0] == '+') {
- *v = strtol(s, &endptr, 0);
- if (endptr == s)
- return FALSE;
- } else if (*s == '\'') {
- s++;
- if (*s == '\\') {
- s++;
- switch (*s) {
- case 'n':
- *v = '\n';
- break;
- case 't':
- *v = '\t';
- break;
- default:
- *v = (int) *s;
- break;
- }
- } else
- *v = (int) *s;
- s++;
- if (*s != '\'')
- return FALSE;
- }
- else
- return FALSE;
- return TRUE;
-}
-
struct command_function *
command_string_to_function(struct command_function *functions, char *name)
{
#include <ccdbg.h>
#include <cc.h>
+#include <ctype.h>
extern char *s51_prompt;
extern struct ccdbg *s51_dbg;
#include <unistd.h>
#include <getopt.h>
#include <string.h>
+#include <ctype.h>
#include "cc-usb.h"
#include "cc.h"
exit(1);
}
-static uint8_t
-log_checksum(int d[8])
-{
- uint8_t sum = 0x5a;
- int i;
-
- for (i = 0; i < 8; i++)
- sum += (uint8_t) d[i];
- return -sum;
-}
-
static int get_nonwhite(struct cc_usb *cc, int timeout)
{
int c;
char *tty = NULL;
char *device = NULL;
int c;
- char line[8192];
int nsamples;
int i;
int crc;
int c;
char line[8192];
FILE *out;
- char *filename;
int serial_number = 0;
int freq = 434550;
char *call = "N0CALL";
- int flight = 0;
- char cmd;
int block;
int addr;
int received_addr;
int data[8];
- int done;
int i;
- int column;
int remote = 0;
- int any_valid;
- int invalid;
int storage_size = 0;
- char *out_name;
+ char *out_name = NULL;
while ((c = getopt_long(argc, argv, "T:D:F:C:o:R", options, NULL)) != -1) {
switch (c) {
static void
dump_saved(void);
-void
+static void
doit(union ao_telemetry_all *telem)
{
double lat, lon;
main (int argc, char **argv)
{
char line[80];
- int c, i, ret;
- char *s;
+ int c, i, ret = 0;
FILE *file;
- int serial;
+
while ((c = getopt_long(argc, argv, "l:L:", options, NULL)) != -1) {
switch (c) {
case 'L':
ret++;
continue;
}
- s = strstr(argv[i], "-serial-");
- if (s)
- serial = atoi(s + 8);
- else
- serial = 0;
while (fgets(line, sizeof (line), file)) {
union ao_telemetry_all telem;
main (int argc, char **argv)
{
struct ccdbg *dbg;
- uint8_t status;
- uint16_t pc;
struct ao_hex_file *hex;
struct ao_hex_image *image;
char *filename;
static void
send_telem(struct cc_usb *cc, union ao_telemetry_all *telem)
{
- int rssi = (int8_t) telem->generic.rssi / 2 - 74;
int i;
uint8_t *b;
char line[80];
int c, i, ret = 0;
int freq = 434550;
- char *s;
FILE *file;
- int serial;
uint16_t last_tick;
int started;
int realtime = 0;
if (fake) {
union ao_telemetry_all telem;
- uint16_t tick;
int i;
memset(&telem, '\0', sizeof (telem));
size = ftell(file);
rewind(file);
- sprintf(message, "BINSIZE = %d Checksum = %d Loopnumber = %d ", size, cksum, 1);
+ sprintf(message, "BINSIZE = %ld Checksum = %d Loopnumber = %d ", size, cksum, 1);
ret = skytraq_cmd_wait(fd, message, strlen(message) + 1, "OK", 20000);
if (ret < 0)
#include <stdint.h>
#include <stdarg.h>
#include <getopt.h>
+#include <unistd.h>
#include "cc.h"
static const struct option options[] = {
{ .name = "tty", .has_arg = 1, .val = 'T' },
{ .name = "device", .has_arg = 1, .val = 'D' },
- { .name = "loader", .has_arg = 1, .val = 'l' },
{ .name = "firmware", .has_arg = 1, .val = 'f' },
{ .name = "query", .has_arg = 0, .val = 'q' },
{ .name = "raw", .has_arg = 0, .val = 'r' },
fprintf(stderr,
"usage: %s [--tty <tty-name>]\n"
" [--device <device-name>]\n"
- " [--loader <srec bootloader file>]\n"
" [--firmware <binary firmware file>]\n"
" [--query]\n"
" [--quiet]\n"
exit(1);
}
-int
+static int
skytraq_expect(int fd, uint8_t want, int timeout) {
int c;
return 0;
}
-int
+static int
skytraq_wait_reply(int fd, uint8_t reply, uint8_t *buf, uint8_t reply_len) {
for(;;) {
uint8_t a, b;
- uint8_t cksum_computed, cksum_read;
+ uint8_t cksum_computed;
int len;
switch (skytraq_expect(fd, 0xa0, 10000)) {
case -1:
main(int argc, char **argv)
{
int fd;
- char buf[512];
int ret;
- FILE *input;
- long size;
- unsigned char cksum;
int c;
- char message[1024];
char *tty = NULL;
char *device = NULL;
- char *loader = "srec_115200.bin";
char *file = NULL;
int query = 0;
int raw = 0;
case 'D':
device = optarg;
break;
- case 'l':
- loader = optarg;
- break;
case 'f':
file = optarg;
break;
skytraq_setcomm(int fd, int baudrate);
int
-skytraq_write(int fd, const char *data, int len);
+skytraq_write(int fd, const void *data, int len);
int
skytraq_waitchar(int fd, int timeout);
void
skytraq_flush(int fd);
+int
+skytraq_millis(void);
+
+void
+skytraq_dbg_newline(void);
+
int
skytraq_cmd_wait(int fd, const char *message, int len, const char *status, int timeout);
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
*/
-#define _BSD_SOURCE
+#define _DEFAULT_SOURCE 1
#include <termios.h>
#include <unistd.h>
#include <sys/types.h>
#define US_PER_CHAR (1000000 / BPS)
int
-skytraq_write(int fd, const char *data, int len)
+skytraq_write(int fd, const void *d, int len)
{
- const char *d = data;
+ const char *data = d;
int r;
- int us;
skytraq_dbg_printf (0, "%4d: ", len);
if (len < 70)
r = write(fd, data, this_time);
if (r <= 0)
return r;
- us = r * US_PER_CHAR;
usleep(r * US_PER_CHAR);
data += r;
len -= r;
int i;
uint8_t cksum;
- int target_baudrate;
+ int target_baudrate = 0;
switch(baudrate)
{
case 4800:
main (int argc, char **argv)
{
char line[80];
- int c, i, ret;
- char *s;
+ int c, i, ret = 0;
FILE *file;
int serial;
int ignore_crc = 0;
exit(1);
}
-void
+static void
done(struct cc_usb *cc, int code)
{
/* cc_usb_printf(cc, "a\n"); */
exit (code);
}
-static int
-ends_with(char *whole, char *suffix)
-{
- int whole_len = strlen(whole);
- int suffix_len = strlen(suffix);
-
- if (suffix_len > whole_len)
- return 0;
- return strcmp(whole + whole_len - suffix_len, suffix) == 0;
-}
-
-static int
-starts_with(char *whole, char *prefix)
-{
- int whole_len = strlen(whole);
- int prefix_len = strlen(prefix);
-
- if (prefix_len > whole_len)
- return 0;
- return strncmp(whole, prefix, prefix_len) == 0;
-}
-
static char **
tok(char *line) {
char **strs = malloc (sizeof (char *)), *str;
}
}
-char **
+static char **
find_baro(struct baro *b, char *word0) {
- int i;
for (;b; b = b->next)
if (b->strs[0] && !strcmp(b->strs[0], word0))
return b->strs;
return NULL;
}
-int
+static int
do_baro(struct cc_usb *usb) {
struct baro *b = baro(usb);
char **temp = find_baro(b, "Temperature:");
main (int argc, char **argv)
{
char *device = NULL;
- char *filename;
- Elf *e;
- unsigned int s;
- int i;
int c;
- int tries;
struct cc_usb *cc = NULL;
char *tty = NULL;
- int success;
int verbose = 0;
int ret = 0;
exit(1);
}
-void
+static void
done(struct cc_usb *cc, int code)
{
cc_usb_close(cc);
exit (code);
}
-static int
-ends_with(char *whole, char *suffix)
-{
- int whole_len = strlen(whole);
- int suffix_len = strlen(suffix);
-
- if (suffix_len > whole_len)
- return 0;
- return strcmp(whole + whole_len - suffix_len, suffix) == 0;
-}
-
-static int
-starts_with(char *whole, char *prefix)
-{
- int whole_len = strlen(whole);
- int prefix_len = strlen(prefix);
-
- if (prefix_len > whole_len)
- return 0;
- return strncmp(whole, prefix, prefix_len) == 0;
-}
-
static char **
tok(char *line) {
char **strs = malloc (sizeof (char *)), *str;
}
}
-char **
+static char **
find_flash(struct flash *b, char *word0) {
- int i;
for (;b; b = b->next) {
if (strstr(b->line, word0))
return b->strs;
return NULL;
}
-int
+static int
do_flash(struct cc_usb *usb, int expected_size) {
struct flash *b = flash(usb);
char **size = find_flash(b, "Storage size:");
main (int argc, char **argv)
{
char *device = NULL;
- char *filename;
- Elf *e;
- unsigned int s;
- int i;
int c;
- int tries;
struct cc_usb *cc = NULL;
char *tty = NULL;
- int success;
int verbose = 0;
int ret = 0;
- int expected_size;
while ((c = getopt_long(argc, argv, "rT:D:c:s:v:", options, NULL)) != -1) {
switch (c) {
exit(1);
}
-void
+static void
done(struct cc_usb *cc, int code)
{
/* cc_usb_printf(cc, "a\n"); */
exit (code);
}
-static int
-ends_with(char *whole, char *suffix)
-{
- int whole_len = strlen(whole);
- int suffix_len = strlen(suffix);
-
- if (suffix_len > whole_len)
- return 0;
- return strcmp(whole + whole_len - suffix_len, suffix) == 0;
-}
-
-static int
-starts_with(char *whole, char *prefix)
-{
- int whole_len = strlen(whole);
- int prefix_len = strlen(prefix);
-
- if (prefix_len > whole_len)
- return 0;
- return strncmp(whole, prefix, prefix_len) == 0;
-}
-
static char **
tok(char *line) {
char **strs = malloc (sizeof (char *)), *str;
}
}
-char **
+static char **
find_gps(struct gps *b, char *word0) {
- int i;
for (;b; b = b->next)
if (b->strs[0] && !strcmp(b->strs[0], word0))
return b->strs;
return NULL;
}
-int
+static int
do_gps(struct cc_usb *usb) {
int count = 0;
main (int argc, char **argv)
{
char *device = NULL;
- char *filename;
- Elf *e;
- unsigned int s;
- int i;
int c;
- int tries;
struct cc_usb *cc = NULL;
char *tty = NULL;
- int success;
int verbose = 0;
int ret = 0;
exit(1);
}
-void
+static void
done(struct cc_usb *cc, int code)
{
/* cc_usb_printf(cc, "a\n"); */
exit (code);
}
-static int
-ends_with(char *whole, char *suffix)
-{
- int whole_len = strlen(whole);
- int suffix_len = strlen(suffix);
-
- if (suffix_len > whole_len)
- return 0;
- return strcmp(whole + whole_len - suffix_len, suffix) == 0;
-}
-
-static int
-starts_with(char *whole, char *prefix)
-{
- int whole_len = strlen(whole);
- int prefix_len = strlen(prefix);
-
- if (prefix_len > whole_len)
- return 0;
- return strncmp(whole, prefix, prefix_len) == 0;
-}
-
struct igniter {
struct igniter *next;
char name[512];
cc_usb_getline(usb, line, sizeof (line));
if (strstr(line, "software-version"))
break;
- if (sscanf(line, "Igniter: %s Status: %s", &name, &status) == 2) {
+ if (sscanf(line, "Igniter: %s Status: %s", name, status) == 2) {
struct igniter *i = malloc (sizeof (struct igniter));
strcpy(i->name, name);
strcpy(i->status, status);
for (; i; i = i->next)
if (strcmp(i->name, name) == 0)
return i;
+ return NULL;
}
static int
struct igniter *this = find_igniter(all, name);
if (!this) {
struct igniter *i;
- printf("no igniter %s found in");
+ printf("no igniter %s found in", name);
for (i = all; i; i = i->next)
printf(" %s", i->name);
printf("\n");
main (int argc, char **argv)
{
char *device = NULL;
- char *filename;
- Elf *e;
- unsigned int s;
int i;
int c;
- int tries;
struct cc_usb *cc = NULL;
char *tty = NULL;
- int success;
int verbose = 0;
int ret = 0;
exit(1);
}
-void
+static void
done(struct cc_usb *cc, int code)
{
/* cc_usb_printf(cc, "a\n"); */
return len;
}
-int
+static int
putucs4(uint32_t c, FILE *file)
{
char d;
{
char *device = NULL;
char *filename;
- Elf *e;
int raw = 0;
char *serial_end;
unsigned int serial = 0;
- char *serial_ucs2;
- int serial_ucs2_len;
- char serial_int[2];
- unsigned int s;
- int i;
- int string_num;
uint32_t cal = 0;
- char cal_int[4];
char *cal_end;
int c;
int was_flashed = 0;
struct ao_hex_image *load;
- int tries;
struct cc_usb *cc = NULL;
char *tty = NULL;
int success;
exit(1);
}
-void
+static void
done(struct cc_usb *cc, int code)
{
cc_usb_close(cc);
main (int argc, char **argv)
{
char *device = NULL;
- char *filename;
int i;
int c;
struct cc_usb *cc = NULL;
static bool
rewrite(struct ao_hex_image *load, unsigned address, uint8_t *data, int length)
{
- int i;
-
if (address < load->address || load->address + load->length < address + length)
return false;
struct ao_hex_record *record = NULL;
enum ao_hex_read_state state = read_marker;
char c;
- int nhexbytes;
- uint32_t hex;
- uint32_t ndata;
+ int nhexbytes = 0;
+ uint32_t hex = 0;
+ uint32_t ndata = 0;
uint8_t checksum;
while (state != read_done) {
free(image);
}
-uint32_t min(uint32_t a, uint32_t b) { return a < b ? a : b; }
-uint32_t max(uint32_t a, uint32_t b) { return a > b ? a : b; }
+static uint32_t min(uint32_t a, uint32_t b) { return a < b ? a : b; }
+static uint32_t max(uint32_t a, uint32_t b) { return a > b ? a : b; }
struct ao_hex_image *
ao_hex_image_cat(struct ao_hex_image *a, struct ao_hex_image *b)
* 2.82V * 2047 / 3.3 counts/V = 1749 counts/115 kPa
*/
-static const double counts_per_kPa = 27 * 2047 / 3300;
-static const double counts_at_101_3kPa = 1674.0;
-
double
cc_barometer_to_pressure(double count)
{
{
struct cc_flightraw *f;
char line[8192];
- double ground_pres;
- int ground_pres_count;
+ double ground_pres = 0.0;
+ int ground_pres_count = 0;
f = calloc(1, sizeof (struct cc_flightraw));
if (!f)
cc_flight_cook(struct cc_flightraw *raw)
{
struct cc_flightcooked *cooked;
- double flight_start;
- double flight_stop;
+ double flight_start = 0;
+ double flight_stop = 0;
int start_set = 0;
int stop_set = 0;
int i;
struct dirent **namelist;
int interface;
int num_interfaces;
- char endpoint_base[20];
+ char endpoint_base[64];
char *endpoint_full;
char *tty_dir;
int ntty;