Beispiel #1
0
void DMXMonitor::SetData(const uint8_t nPort, const uint8_t *pData, const uint16_t nLength) {
    uint8_t row = TOP_ROW;
    uint8_t *p = (uint8_t *)pData;
    uint16_t slot = 0;
    uint8_t i, j;

    for (i = 0; (i < 16) && (slot < nLength); i++) {

        console_set_cursor(4, ++row);

        for (j = 0; (j < 32) && (slot < nLength); j++) {
            const uint8_t d = *p++;
            if (d == (uint8_t) 0) {
                console_puts(" 0");
            } else {
                console_puthex_fg_bg(d, (uint16_t)(d > 92 ? CONSOLE_BLACK : CONSOLE_WHITE), (uint16_t)RGB(d,d,d));
            }
            (void) console_putc((int) ' ');
            slot++;
        }

        for (; j < 32; j++) {
            console_puts("-- ");
        }
    }

    for (; i < 16; i++) {
        console_set_cursor(4, ++row);
        console_puts("-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --");
    }

}
Beispiel #2
0
void console_message(enum console_type t, const char *s, ...)
{
    va_list args;

    glue_call(console, color, COLOR_GREY);
    glue_call(console, putc, '[');

    switch (t)
    {
        case T_INF:
            glue_call(console, color, COLOR_BLUE);
            console_puts("IF");
            break;
        case T_ERR:
            glue_call(console, color, COLOR_RED);
            console_puts("KO");
            break;
        case T_OK:
            glue_call(console, color, COLOR_GREEN);
            console_puts("OK");
            break;
    }

    glue_call(console, color, COLOR_GREY);
    glue_call(console, putc, ']');
    glue_call(console, putc, ' ');

    va_start(args, s);

    console_vprintf(s, args);

    va_end(args);

    glue_call(console, putc, '\n');
}
/**
 * Used to process a data frame that has just been uploaded.
 */
void block_uploaded(struct rx_frame* rx) {
  uint32_t mem_addr;
  uint32_t checksum, actual_checksum;

  if (rx->length >= MEMORY_RECORD_SIZE) {
    /* Copy the record from the radio packet. Skip the header and memory address */
    memcpy(record, rx->data+5, MEMORY_RECORD_SIZE);

    /* Calculate the checksum */
    actual_checksum = calculate_checksum(record);
    /* Read the checksum */
    checksum = get_checksum(record);

    if (checksum == actual_checksum) {
      /* Extract the memory address */
      mem_addr = get_memory_address_from_rx(rx);

      /* Acknowledge the frame */
      send_upload_ack(rx->source_address, mem_addr, checksum);

      /* Write the record out to memory */
      put_sample(record);

      console_puts("Radio Upload Frame OK\n");
    } else {
      console_puts("Radio Upload Frame Checksum Error!\n");
      console_printf("Frame: %04x\nCalc: %04x\n", checksum, actual_checksum);
    }
  } else {
    console_puts("Radio Upload Frame too short!\n");
  }
}
Beispiel #4
0
/**
 * @brief exception handler ISR: just show msg, enter infinite loop
 *
 * All of our Exception handling Interrupt Service Routines will
 * point to this function. This will tell us what exception has
 * happened! Right now, we simply halt the system by hitting an
 * endless loop. All ISRs disable interrupts while they are being
 * serviced as a 'locking' mechanism to prevent an IRQ from
 * happening and messing up kernel data structures
 */
void fault_handler(struct regs *r)
{
    if (r->int_no < 32)
    {
        console_puts(exception_messages[r->int_no]);
        console_puts(" Exception. System Halted!\n");
        for (;;);
    }
}
Beispiel #5
0
static void handle_bool(const bool b) {
	if (b) {
		console_save_color();
		console_set_fg_color(CONSOLE_GREEN);
		console_puts("Yes");
		console_restore_color();
	} else {
		console_puts("No");
	}
}
Beispiel #6
0
static void print_header() {
    console_clear();

    console_puts("Welcome to the K-OS Secure Data Erasure Tool!\n\nCopyright (c) 2013 Keeley Hoek\nAll rights reserved.\n\n");

    console_color(0x0C);
    console_puts("WARNING: ");
    console_color(0x07);
    console_puts("This software irreversably and indescriminatley destroys data.\n\n");
}
Beispiel #7
0
void task_dbg_dumplist(void *lst)
{
  char s[10];
  struct TASK *tsk,*head=lst;
  list_for_each(head,tsk) {
    console_puts("T(");
    int2dec(tsk->id,s);
    console_puts(s);
    console_puts(",");
    int2dec(tsk->status,s);
    console_puts(s);
    console_puts(")");
  }
Beispiel #8
0
static void bus_spi_start(void)
{
    spi_cs_assert();

    console_puts("CS ENABLED");
    console_newline();
}
/*
 * int console_gets(char *s, int len)
 *
 * Wait for a string to be entered on the console, limited
 * support for editing characters (back space and delete)
 * end when a <CR> character is received.
 */
int console_gets(char *s, int len)
{
	char *t = s;
	char c;

	*t = '\000';
	/* read until a <CR> is received */
	while ((c = console_getc(1)) != '\r') {
		if ((c == '\010') || (c == '\127')) {
			if (t > s) {
				/* send ^H ^H to erase previous character */
				console_puts("\010 \010");
				t--;
			}
		} else {
			*t = c;
			console_putc(c);
			if ((t - s) < len) {
				t++;
			}
		}
		/* update end of string with NUL */
		*t = '\000';
	}
	return t - s;
}
Beispiel #10
0
// used from Lua
int console_vprintf(const char* fmt, va_list ap) // don't DebugMsg from here!
{
    char buf[256];
    int len = vsnprintf( buf, 255, fmt, ap );
    console_puts(buf);
	return len;
}
Beispiel #11
0
static void bus_spi_write(uint8_t c)
{
    spi_write8(c);
    console_puts("WRITE: 0x");
    console_puthex8(c);
    console_newline();
}
Beispiel #12
0
void TimeCode::Start(void) {
	console_save_cursor();
	console_set_cursor(COLUMN, ROW);
	console_set_fg_color(CONSOLE_CYAN);
	console_puts(timecode);
	console_restore_cursor();
}
Beispiel #13
0
static void bus_spi_stop(void)
{
    spi_cs_deassert();

    console_puts("CS DISABLED");
    console_newline();
}
Beispiel #14
0
void kmain(uint32_t r0, uint32_t r1, uint32_t atags) {
    // Enable logging, the first thing we do
    log_init();

    // Initialize the GPU at 800x600 resolution
    gpu_init(800, 600);
    // Clear to a black color
    gpu_clear(0);

    // Test to write a character
    gpu_putchar('A', 10, 10, RGB(255, 0, 0));

    // Test the console
    console_init(800, 600);
    console_puts("ABCDEFGHIJKLMNOPQRSTUVXYZ abcdefghijklmnopqrstuvxyz \n0123456789\n");
    console_puts("Hejj\b du!\n");
}
Beispiel #15
0
static void bus_spi_read(void)
{
    uint8_t c;
    c = spi_write8(0xFF);
    console_puts("READ: 0x");
    console_puthex8(c);
    console_newline();
}
Beispiel #16
0
int main()
{
    char input_line[256];
    int got;

    console_init(init_vga(VGA_MODE_640x480), 640, 480);
    console_set_colors(WHITE, BLACK);
    console_puts("\n !\"#$%&'()*+,-./0123456789:;<=>?@[\\]^_`{|}~\n");
    console_puts(" ABCDEFGHIJKLMNOPQRSTUVWXYZ\n");
    console_puts(" abcdefghijklmnopqrstuvwxyz\n");
    console_puts(" AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz\n");
    console_puts(" The quick brown fox jumped over the lazy dog.\n");
    console_set_colors(BLACK, WHITE);
    console_puts(" Inverse text\n");
    console_set_colors(WHITE, BLACK);
    while (1)
    {
        console_puts("> ");
        got = console_read_line(input_line, sizeof(input_line));
        input_line[got] = '\0';
        printf("%s\n", input_line);
    }

    return 0;
}
Beispiel #17
0
int syscall_dbg_locputs(int x, int y, char *s)
{
  int pos;
  pos = console_getpos();
  console_locatepos(x,y);
  console_puts(s);
  console_putpos(pos);
  return 0;
}
Beispiel #18
0
int console_printf(const char* fmt, ...) // don't DebugMsg from here!
{
    char buf[256];
    va_list         ap;
    va_start( ap, fmt );
    int len = vsnprintf( buf, 255, fmt, ap );
    va_end( ap );
    console_puts(buf);
	return len;
}
Beispiel #19
0
void panic (const char *msg, ...)
{
  va_list ap;
  
  va_start (ap, msg);
  
  console_puts (syscon, "\033[0;31mpanic: ");
  console_vprintf (syscon, msg, ap);
  console_putchar (syscon, '\n');
}
Beispiel #20
0
void load_rom(file_descr_t *entry)
{
	file_t file;
	int i;
	DWORD size;

	console_clear();
	console_puts("Loading ");
	for (i=0; i<8; i++) {
		console_putc(entry->name[i]);
	}
	console_putc('.');
	for (i=8; i<11; i++) {
		console_putc(entry->name[i]);
	}
	console_puts("\n\n");

	fat_open_file(&file, entry->cluster);
	size = 0;
	while (1) {
		UBYTE* data;
		if ((size&0x3fff)==0) {
			// switch page 1
			*((UBYTE*)0xffff) = (size>>14)&0xff;
		}
		// write to page 2
		data = 0x8000+(size&0x3fff);
		data = fat_load_file_sector(&file,data);
		if (data==0) {
			console_puts("Error while reading file\n");
		} else if (data==FAT_EOF) {
			console_gotoxy(0,2);
			return;
		} else {
			// process data
			size += 0x200;
			if ((size)%16384 == 0)
			   console_puts(".");
			//console_gotoxy(0,3);
			//console_print_dword(size);
			//console_puts(" bytes loaded");
		}
	}
Beispiel #21
0
void DMXMonitor::Start(void) {
    for (int i = TOP_ROW; i < (TOP_ROW + 17); i++) {
        console_clear_line(i);
    }

    console_set_cursor(0, TOP_ROW);
    console_puts("    00 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31\n");

    for (int i = 1; i < (int)(16 * 32) ; i = i + (int)32) {
        printf("%3d\n", i);
    }
}
Beispiel #22
0
void monitor_update(void) {
	// Handle Active Sensing messages
	switch (midi_get_active_sense_state()) {
	case MIDI_ACTIVE_SENSE_ENABLED:
		console_save_cursor();
		console_set_cursor(70, 3);
		console_set_fg_bg_color(CONSOLE_BLACK, CONSOLE_CYAN);
		(void) console_puts("ACTIVE SENSING          ");
		console_restore_cursor();
		break;
	case MIDI_ACTIVE_SENSE_FAILED:
		console_save_cursor();
		console_set_cursor(70, 3);
		console_set_fg_bg_color(CONSOLE_RED, CONSOLE_WHITE);
		(void) console_puts("ACTIVE SENSING - Failed!");
		console_restore_cursor();
		break;
	default:
		break;
	}
}
Beispiel #23
0
void choose_mode(int sd_ok)
{
	int i = 0;
	console_gotoxy(9,10);
	if (sd_ok) {
		//console_puts("load from SD card");
		pick_and_load_rom();
	} else {
		console_puts("retry SD/MMC card");
	}
	//console_gotoxy(9,12);
	//console_puts("boot SRAM");

	for (;;) {
		int key;
		console_gotoxy(6,10);
		if (i==0) { console_puts(">"); } else { console_puts("  "); }
		console_gotoxy(6,12);
		if (i==1) { console_puts(">"); } else { console_puts("  "); }
		key = wait_key();
		switch (key) {
		case JOY_UP:
			i = 0;
			break;
	//	case JOY_DOWN:
	//		i = 1;
	//		break;
		case JOY_FIREA:
		case JOY_FIREB:
			if (i==0) {
				if (sd_ok) {
					pick_and_load_rom();
				}
			} else {
				start_rom();
			}
			return;
		}
	}
}
Beispiel #24
0
int kprintf(const char *format, ...)
{
	va_list args;
	int i;

	va_start(args, format);
	i = kvsprintf(_buf, format, args);
	va_end(args);

    console_puts(_buf);

	return i;
}
Beispiel #25
0
int pr_print(int level, const char *fmt, ...)
{
	va_list args;
	uint i;
	char printbuffer[CFG_PBSIZE];

	va_start(args, fmt);
	i = vsprintf(printbuffer, fmt, args);
	va_end(args);

	console_puts(CONSOLE_STDOUT, printbuffer);

	return i;
}
Beispiel #26
0
static void run_script(const char *script)
{
    extern int ml_started;
    while (!ml_started) msleep(100); // for startup scripts

    script_state = SCRIPT_RUNNING;

    msleep(500);
    
    console_clear();
    console_show();
    console_set_help_text("SET: show/hide");
    console_set_status_text("Script running...");
    
    int exit_code = tcc_compile_and_run(get_script_path(script_selected));
    if (exit_code == 0)
    {
        console_puts(    "Script finished.\n");
    }
    else
    {
        console_printf(  "Script error: %d.\n", exit_code);
        msleep(500);
        gui_stop_menu();
        msleep(500);
        console_show();
    }
    
    // restore some settings to normal, if script changed them
    //~ script_cleanup_af();
    bmp_draw_to_idle(0);
    canon_gui_enable_front_buffer(0);
    
    beep();
    script_state = SCRIPT_JUST_FINISHED;
    console_set_status_text("Script finished. ");
    msleep(500);
    redraw();
    msleep(500);
    for (int i = 0; i < 100; i++)
    {
        msleep(100);
        if (gui_menu_shown()) break;
        if (get_halfshutter_pressed()) break;
    }
    console_hide();
    script_state = SCRIPT_IDLE;
    console_set_status_text("");
}
Beispiel #27
0
int console_error(const char *s) {
	char c;
	int i = 0;;

	uint16_t fore_current = cur_fore;
	uint16_t back_current = cur_back;

	cur_fore = CONSOLE_RED;
	cur_back = CONSOLE_BLACK;

	(void) console_puts("Error <");

	while ((c = *s++) != (char) 0) {
		i++;
		(void) console_putc((int) c);
	}

	(void) console_puts(">\n");

	cur_fore = fore_current;
	cur_back = back_current;

	return i;
}
Beispiel #28
0
//prints a hex value of a string
void console_puth(const uint8_t *str,uint8_t count)
{
    uint8_t a;
    for(a=0;a<count;a++){
        console_puts(" 0x");
            if(((*str>>4)&0x0F)<=9)                     //check if the upper nibble is 0-9
                console_putc(((*str>>4)&0x0F)+48);      //hex 0x30 is ASCII 0
            else
                console_putc(((*str>>4)&0x0F)+55);      //hex 0x41 is ASCII 0
            if((*str&0x0F)<=9)                          //check if the upper nibble is 0-9
                console_putc((*str&0x0F)+48);           //hex 0x30 is ASCII 0
            else
                console_putc((*str&0x0F)+55);           //hex 0x41 is ASCII 0
        str++;                                          //increment pointer
    }
Beispiel #29
0
int console_puts_err(const char *s)
{
    uint8_t saved_attr;
    int ret;

    saved_attr = _.attr;

    _.attr = ATTR_RED_ON_BLUE;
    ret = console_puts(s);

    // restore attr
    _.attr = saved_attr;

    return ret;
}
Beispiel #30
0
static BOOL handle_command(const uint8_t *start, const uint8_t *end, BOOL firstToken, const uint8_t *line_end)
{
    uint16_t num;
    const uint8_t *ptr = start;
    uint16_t repeat = 1;

    // handle repeat commands, A:5
    while(ptr != end)
    {
        if (*ptr == ':' && ptr-start > 0)   // found at least one character followed by ':'
        {
            if (parse_number(ptr+1, end - (ptr+1), &repeat))
            {
                end = ptr;    // discard the ":X" part
                break;
            }
            else
                repeat = 0; // parse_number is destructive
        }
        ptr++;
    }
    
    // handle write command (a number)
    if (parse_number(start, end-start, &num))
    {
        while(repeat--)
            bus_spi_write((uint8_t)num);
        return FALSE;
    }
    else
    {
        if (end-start == 1 && (start[0] == 'r' || start[0] == 'R'))
        {   // handle read command
            while(repeat--)
                bus_spi_read();
            return FALSE;
        }
        else
        {   // handle other commands
            // ignore
        }
    }

    console_puts("BadCmd");
    console_newline();

    return FALSE;
}