Beispiel #1
0
int main()
{
	int i = 0;
	while( i++ < 100)
		showprogress(i);
	return 0;
}
Beispiel #2
0
void __start(void)
{
    const uint32_t *src;
    uint32_t *dest;

    /* Configure the uart so that we can get debug output as soon as possible */

    stm32_clockconfig();
    stm32_fpuconfig();
    stm32_lowsetup();
    stm32_gpioinit();
    showprogress('A');

    /* Clear .bss.  We'll do this inline (vs. calling memset) just to be
     * certain that there are no issues with the state of global variables.
     */

    for (dest = &_sbss; dest < &_ebss; )
    {
        *dest++ = 0;
    }
    showprogress('B');

    /* Move the intialized data section from his temporary holding spot in
     * FLASH into the correct place in SRAM.  The correct place in SRAM is
     * give by _sdata and _edata.  The temporary location is in FLASH at the
     * end of all of the other read-only data (.text, .rodata) at _eronly.
     */

    for (src = &_eronly, dest = &_sdata; dest < &_edata; )
    {
        *dest++ = *src++;
    }
    showprogress('C');

    /* Perform early serial initialization */

#ifdef USE_EARLYSERIALINIT
    up_earlyserialinit();
#endif
    showprogress('D');

    /* Initialize onboard resources */

    stm32_boardinitialize();
    showprogress('E');

    /* Then start NuttX */

    showprogress('\r');
    showprogress('\n');
    os_start();

    /* Shoulnd't get here */

    for(;;);
}
Beispiel #3
0
void FormEphem:: tlefilesread(QString str)
{

    QObject::disconnect(&downloadmanager, SIGNAL(finished(QString)), this, SLOT(tlefilesread(QString)));
    QObject::disconnect(&downloadmanager, SIGNAL(startnext(QString)), this, SLOT(showprogress(QString)));


    ui->edtUpdateTLE->setPlainText(ui->edtUpdateTLE->toPlainText() + "\n" + str);
    sats->ReloadList();
    showAvailSat();

}
Beispiel #4
0
void FormEphem::on_btnUpdateTLE_clicked()
{
    downloadmanager.clearqueue();

    ui->edtUpdateTLE->clear();

    ui->edtUpdateTLE->setPlainText("Start download \n");
    downloadmanager.append(opts.tlesources);
    QObject::connect(&downloadmanager, SIGNAL(finished(QString)), this, SLOT(tlefilesread(QString)));
    //QObject::connect(&downloadmanager, SIGNAL(progress(QString)), this, SLOT(showprogress(QString)));
    QObject::connect(&downloadmanager, SIGNAL(startnext(QString)), this, SLOT(showprogress(QString)));

}
Beispiel #5
0
void __start(void)
{
  const uint32_t *src;
  uint32_t *dest;

  /* Disable the watchdog */

  putreg32(0, KL_SIM_COPC);

  /* Configure the uart so that we can get debug output as soon as possible */

  kl_clockconfig();
  kl_lowsetup();
  showprogress('A');

  /* Clear .bss.  We'll do this inline (vs. calling memset) just to be
   * certain that there are no issues with the state of global variables.
   */

  for (dest = &_sbss; dest < &_ebss; )
    {
      *dest++ = 0;
    }
  showprogress('B');

  /* Move the initialized data section from his temporary holding spot in
   * FLASH into the correct place in SRAM.  The correct place in SRAM is
   * give by _sdata and _edata.  The temporary location is in FLASH at the
   * end of all of the other read-only data (.text, .rodata) at _eronly.
   */

  for (src = &_eronly, dest = &_sdata; dest < &_edata; )
    {
      *dest++ = *src++;
    }
  showprogress('C');

  /* Perform early serial initialization */

#ifdef USE_EARLYSERIALINIT
  up_earlyserialinit();
#endif
  showprogress('D');

  /* For the case of the separate user-/kernel-space build, perform whatever
   * platform specific initialization of the user memory is required.
   * Normally this just means initializing the user space .data and .bss
   * segments.
   */

#ifdef CONFIG_NUTTX_KERNEL
  kl_userspace();
  showprogress('E');
#endif

  /* Initialize onboard resources */

  kl_boardinitialize();
  showprogress('F');

  /* Then start NuttX */

  showprogress('\r');
  showprogress('\n');

  os_start();

  /* Shoulnd't get here */

  for (;;);
}
Beispiel #6
0
void trim_logs(time_t cutoff)
{
	filelist_t *fwalk;
	DIR *ldir = NULL, *sdir = NULL;
	struct dirent *sent, *lent;
	time_t ltime;
	char fn1[PATH_MAX], fn2[PATH_MAX];
	int itemno = 0;

	/* We have a list of directories to trim, so process them */
	for (fwalk = flhead; (fwalk); fwalk = fwalk->next) {
		dbgprintf("Processing %s\n", fwalk->fname);
		itemno++; if (progressinfo && ((itemno % progressinfo) == 0)) showprogress(itemno); 

		switch (fwalk->ftype) {
		  case F_DROPIT:
			/* It's an orphan, and we want to delete it */
			dropdirectory(fwalk->fname, 0);
			break;

		  case F_PURGELOGS:
			sdir = opendir(fwalk->fname);
			if (sdir == NULL) {
				errprintf("Cannot process directory %s: %s\n", fwalk->fname, strerror(errno));
				break;
			}

			while ((sent = readdir(sdir)) != NULL) {
				int allgone = 1;
				if (*(sent->d_name) == '.') continue;

				sprintf(fn1, "%s/%s", fwalk->fname, sent->d_name);
				ldir = opendir(fn1);
				if (ldir == NULL) {
					errprintf("Cannot process directory %s: %s\n", fn1, strerror(errno));
					continue;
				}

				while ((lent = readdir(ldir)) != NULL) {
					if (*(lent->d_name) == '.') continue;

					ltime = logtime(lent->d_name);
					if ((ltime > 0) && (ltime < cutoff)) {
						sprintf(fn2, "%s/%s", fn1, lent->d_name);
						if (unlink(fn2) == -1) {
							errprintf("Failed to unlink %s: %s\n", fn2, strerror(errno));
						}
					}
					else allgone = 0;
				}

				closedir(ldir);

				/* Is it empty ? Then remove it */
				if (allgone) rmdir(fn1);
			}

			closedir(sdir);
			break;

		  default:
			break;
		}
	}
}
Beispiel #7
0
void trim_files(time_t cutoff)
{
	filelist_t *fwalk;
	FILE *infd, *outfd;
	char outfn[PATH_MAX];
	struct stat st;
	struct utimbuf tstamp;
	int itemno = 0;

	/* We have a list of files to trim, so process them */
	for (fwalk = flhead; (fwalk); fwalk = fwalk->next) {
		dbgprintf("Processing %s\n", fwalk->fname);
		itemno++; if (progressinfo && ((itemno % progressinfo) == 0)) showprogress(itemno); 

		if (fwalk->ftype == F_DROPIT) {
			/* It's an orphan, and we want to delete it */
			unlink(fwalk->fname); 
			continue;
		}

		if (stat(fwalk->fname, &st) == -1) {
			errprintf("Cannot stat input file %s: %s\n", fwalk->fname, strerror(errno));
			continue;
		}
		tstamp.actime = time(NULL);
		tstamp.modtime = st.st_mtime;

		infd = fopen(fwalk->fname, "r");
		if (infd == NULL) {
			errprintf("Cannot open input file %s: %s\n", fwalk->fname, strerror(errno));
			continue;
		}

		if (outdir) {
			sprintf(outfn, "%s/%s", outdir, fwalk->fname);
		}
		else {
			sprintf(outfn, "%s.tmp", fwalk->fname);
		}
		outfd = fopen(outfn, "w");
		if (outfd == NULL) {
			errprintf("Cannot create output file %s: %s\n", outfn, strerror(errno));
			fclose(infd);
			continue;
		}

		trim_history(infd, outfd, fwalk->ftype, cutoff);
		if (fwalk->ftype == F_ALLEVENTS) {
			char pidfn[PATH_MAX];
			FILE *fd;
			long pid = -1;

			sprintf(pidfn, "%s/hobbitd_history.pid", xgetenv("BBSERVERLOGS"));
			fd = fopen(pidfn, "r");
			if (fd) {
				char l[100];
				fgets(l, sizeof(l), fd);
				fclose(fd);
				pid = atol(l);
			}

			if (pid > 0) kill(pid, SIGHUP);
		}

		fclose(infd);
		fclose(outfd);
		utime(outfn, &tstamp);	/* So the access time is consistent with the last update */

		/* Final check to make sure the file didn't change while we were processing it */
		if ((stat(fwalk->fname, &st) == 0) && (st.st_mtime == tstamp.modtime)) {
			if (!outdir) rename(outfn, fwalk->fname);
		}
		else {
			errprintf("File %s changed while processing it - not trimmed\n", fwalk->fname);
			unlink(outfn);
		}
	}
}
void __start(void)
{
  const uint32_t *src;
  uint32_t *dest;

  /* Configure the uart so that we can get debug output as soon as possible */

  efm32_clockconfig();
  efm32_fpuconfig();
  efm32_lowsetup();
  showprogress('A');

  /* Clear .bss.  We'll do this inline (vs. calling memset) just to be
   * certain that there are no issues with the state of global variables.
   */

  for (dest = &_sbss; dest < &_ebss; )
    {
      *dest++ = 0;
    }

  showprogress('B');

  /* Move the initialized data section from his temporary holding spot in
   * FLASH into the correct place in SRAM.  The correct place in SRAM is
   * give by _sdata and _edata.  The temporary location is in FLASH at the
   * end of all of the other read-only data (.text, .rodata) at _eronly.
   */

  for (src = &_eronly, dest = &_sdata; dest < &_edata; )
    {
      *dest++ = *src++;
    }

  showprogress('C');

  /* Perform early serial initialization */

  up_earlyserialinit();
  showprogress('D');

  /* For the case of the separate user-/kernel-space build, perform whatever
   * platform specific initialization of the user memory is required.
   * Normally this just means initializing the user space .data and .bss
   * segments.
   */

#ifdef CONFIG_NUTTX_KERNEL
  efm32_userspace();
  showprogress('E');
#endif

  /* Initialize onboard resources */

  efm32_boardinitialize();
  showprogress('F');

  /* Then start NuttX */

  showprogress('\r');
  showprogress('\n');

#ifdef CONFIG_STACK_COLORATION
  /* Set the IDLE stack to the coloration value and jump into os_start() */

  go_os_start((FAR void *)&_ebss, CONFIG_IDLETHREAD_STACKSIZE);
#else
  /* Call os_start() */

  os_start();

  /* Shouldn't get here */

  for(;;);
#endif
}
void __start(void)
{
  const uint32_t *src;
  uint32_t *dest;

  /* Reset as many of the LPC43 peripherals as possible. This is necessary
   * because the LPC43 does not provide any way of performing a full system
   * reset under debugger control.  So, if CONFIG_DEBUG is set (indicating
   * that a debugger is being used?), the boot logic will call this
   * function on all restarts.
   */

#ifdef CONFIG_DEBUG
  lpc43_softreset();
#endif

  /* Make sure that any exceptions (such as hard faults) that occur before
   * we are initialized are caught by the BOOT ROM.
   */

  lpc43_setbootrom();

  /* Configure the CGU clocking and the console uart so that we can get
   * debug output as soon as possible.
   */

  lpc43_clockconfig();
  lpc43_lowsetup();
  showprogress('A');

  /* If we are executing from external FLASH, then enable buffering */

  lpc43_enabuffering();

  /* Clear .bss.  We'll do this inline (vs. calling memset) just to be
   * certain that there are no issues with the state of global variables.
   */

  for (dest = &_sbss; dest < &_ebss; )
    {
      *dest++ = 0;
    }
  showprogress('B');

  /* Move the initialized data section from his temporary holding spot in
   * FLASH into the correct place in SRAM.  The correct place in SRAM is
   * give by _sdata and _edata.  The temporary location is in FLASH at the
   * end of all of the other read-only data (.text, .rodata) at _eronly.
   */

  for (src = &_eronly, dest = &_sdata; dest < &_edata; )
    {
      *dest++ = *src++;
    }
  showprogress('C');

  /* Initialize the FPU (if configured) */

  lpc43_fpuconfig();
  showprogress('D');

  /* Perform early serial initialization */

#ifdef USE_EARLYSERIALINIT
  up_earlyserialinit();
#endif
  showprogress('E');

  /* For the case of the separate user-/kernel-space build, perform whatever
   * platform specific initialization of the user memory is required.
   * Normally this just means initializing the user space .data and .bss
   * segments.
   */

#ifdef CONFIG_NUTTX_KERNEL
  lpc43_userspace();
  showprogress('F');
#endif

  /* Initialize onboard resources */

  lpc43_boardinitialize();
  showprogress('G');

  /* Then start NuttX */

  showprogress('\r');
  showprogress('\n');
  os_start();

  /* Shouldn't get here */

  for (;;);
}
Beispiel #10
0
int main(int argc, char *argv[])
{
    char waitforuser_exit = 1;
    char hostip[20];
    double progress;
    PORT = PORTNO;
    strcpy(hostip, HOSTNAME_SERVER);

    //custom settings check
    if (argc > 1)
    {
        for (int i = 1; i < argc; i++)
        {
            if (strcmp(argv[i], "-fast") == 0)
            {
                waitforuser_exit = 0;
            }
            if (strcmp(argv[i], "-port") == 0)
            {
                PORT = atoi(argv[++i]);
            }
            if (strcmp(argv[i], "-host") == 0)
            {
                strcmp(hostip, argv[++i]);
            }
            if (strcmp(argv[i], "-nocurses") == 0)
            {
                printf("No curses mode\n");
                ncurses_off = true;
            }
            if (strcmp(argv[i], "-help") == 0)
            {
                printf("Usage: %s [options] <parameters>\n"
                       "Option: -fast (dont display all the crap)\n"
                       "Option: -port n (change to port n)\n"
                       "Option: -host a.b.c.d (change to ip a.b.c.d)\n"
                       "Option: -nocurses (run text-based only)\n"
                       "Option: -help (display this dialog\n"
                       "Copyright © 2012-13 Ethan Laur (phyrrus9)\n"
                       "<*****@*****.**>\n",
                       argv[0]);
                exit(0);
            }
        }
    }

#ifndef _WIN32
    //initialize the ncurses windows
    if (!ncurses_off)
    {
        initscr();
        noecho();
        refresh();
        w = newwin(5,140,0,0); //lines cols start_y start_x
        p = newwin(6, 140, 5, 0); //look above
        wclear(p);
        wclear(w);
        wrefresh(w);
        wrefresh(p);
        //display status message
        wprintw(w, "Connecting to server...\n");
        wrefresh(w);
    }
    else
    {
        printf("Connecting to server...\n");
    }
#else
    system("cls")
    //display status message
    printf("Connecting to server...\n");
#endif
    //define buffers and main networking variables
    int sockfd = 0, n = 0;
    unsigned char recvBuff[15]; //1 mb filesize
    struct sockaddr_in serv_addr;

    memset(recvBuff, 0,sizeof(recvBuff)); //initialize the buffer
    //create a socket (pipe)
    if((sockfd = socket(AF_INET, SOCK_STREAM, 0)) < 0)
    {
#ifndef _WIN32
        if (!ncurses_off)
        {
            endwin();
        }
#endif
        printf("\n Error : Could not create socket \n");
        return 1;
    }

    memset(&serv_addr, 0, sizeof(serv_addr)); //initialize the server details

    //set up the socket
    serv_addr.sin_family = AF_INET;
    serv_addr.sin_port = htons(PORT);

    if(inet_pton(AF_INET, hostip, &serv_addr.sin_addr)<=0)
    {
#ifndef _WIN32
        if (!ncurses_off)
        {
            endwin();
        }
#endif
        printf("\n inet_pton error occured\n");
        return 1;
    }

    //connect to the remote server
    if( connect(sockfd, (struct sockaddr *)&serv_addr, sizeof(serv_addr)) < 0)
    {
#ifndef _WIN32
        if (!ncurses_off)
        {
            endwin();
        }
#endif
        printf("\n Error : Connect Failed \n");
        return 1;
    }

#ifndef _WIN32
    if (!ncurses_off)
    {
        //wclear(w);
        wrefresh(w);
    }
#endif
    //begin downloading the file
    FILE *f;
    long stime = time(0); //get the start time (for speed calculation)
    char firstcall = 1;
    {
        //recvBuff[n] = 0;
        unsigned int length = 0;
        unsigned int sendtime = 0;
        unsigned int serveruptime = 0;
        unsigned char magic_size[4]; //header variable
        unsigned char error_code[1]; //between the magic size and the time
        n = read(sockfd, magic_size, 4); //read the header from the pipe
        length = c4toi(magic_size); //determine the size of the file to come
        n = read(sockfd, error_code, 1); //one-byte header error codes
        if (length == 0)
        {
            if (!ncurses_off)
            {
                endwin();
            }
            printf("Server denied your connection, try again later\n");
            printf("Error code: %d\n", error_code[0]);
            exit(0);
        }
        n = read(sockfd, magic_size, 4); //read the header from the pipe
        time_t rawtime_s = c4toi(magic_size); //determine the size of the file to come
        n = read(sockfd, magic_size, 4); //read the header from the pipe
        time_t rawtime_u = c4toi(magic_size); //determine the size of the file to come

        //display the file size (formatted)
        int level = 0;
        double o_length = length;
        while (o_length > 1024)
        {
            level++;
            o_length /= 1024;
        }
#ifndef _WIN32
        struct tm * timeinfo;
        struct tm * uptime;
        timeinfo = localtime(&rawtime_s);
        //wprintw(w, "Send time: %d\n", asctime(timeinfo));
        uptime = localtime(&rawtime_u);
        //wprintw(w, "Server up: %d\n", asctime(uptime));
        if (!ncurses_off)
        {
            wprintw(w, "File size: %0.2f", o_length);
        }
        else
        {
            printf("File size: %0.02f", o_length);
        }
#define printstatement(b)\
if (!ncurses_off)\
{\
    wprintw(w, b);\
}\
else\
{\
    printf("b\n");\
}
#else
        printf("File size: %0.02f", o_length);
#define printstatement(b) printf(b);
#endif
        switch (level)
        {
        case 0:
            printstatement("B")
            break;
        case 1:
            printstatement("KB")
            break;
        case 2:
            printstatement("MB")
            break;
        }
#ifndef _WIN32
        if (!ncurses_off)
        {
            wrefresh(w);
        }
#endif
        f = fopen("./fotd.zip", "wb"); //open the output file in write+binary+trunc mode
        sleep(1);
        //initialize data variables
        n = 0;
        int lcount = 0;
        unsigned char c[3];
        double netspeed;
        while (n < length)
        {
            if ( lcount % ( 1024 * 5 ) == 0) //( 1024 * x ) x=KB per update
            {
                progress = ( (double)n / length ) * 100; //calculate % done
                showprogress(progress); //see function
                if ( lcount % ( 1024 * 15 ) == 0 )
                {
                    netspeed = ( (double)n / (time(0) - stime) ) / 1024; //calculate speed in kbps
                }
                if (!ncurses_off)
                {
                    wprintw(p, "Speed: %0.0f kb/s", netspeed);
                    wrefresh(p);
                }
            }
            //read the stream 1 byte at a time and write it to the file
            int t = 0;
            t = read(sockfd, c, 1);
            if (t == 0)
                n = length;
            n += t;
            fprintf(f, "%c", c[0]);
            lcount++;
        }
    }

    if(n < 0)
    {
        printf("\n Read error \n");
    }

    fclose(f);
#ifndef _WIN32
    showprogress(progress);
    if (waitforuser_exit)
    {
        if (!ncurses_off)
        {
            wprintw(p, "\nFile downloaded, press any key to exit..\n");
            wrefresh(p);
            getch();
        }
        else
        {
            printf("\nFile downloaded..\n");
        }
    }
    if (!ncurses_off)
    {
        endwin();
    }
#else
    printf("\nFile downloaded...\n");
#endif
    return 0;
}
void __start(void)
{
  const uint32_t *src;
  uint32_t *dest;

  /* Clear .bss.  We'll do this inline (vs. calling memset) just to be
   * certain that there are no issues with the state of global variables.
   */

  for (dest = &_sbss; dest < &_ebss; )
    {
      *dest++ = 0;
    }

  /* Move the initialized data section from his temporary holding spot in
   * FLASH into the correct place in SRAM.  The correct place in SRAM is
   * give by _sdata and _edata.  The temporary location is in FLASH at the
   * end of all of the other read-only data (.text, .rodata) at _eronly.
   */

  for (src = &_eronly, dest = &_sdata; dest < &_edata; )
    {
      *dest++ = *src++;
    }

#ifdef NEED_WDT_DISABLE
  /* Disable the watchdog timer */
#  warning Missing logic
#endif

  /* Copy any necessary code sections from FLASH to RAM.  The correct
   * destination in SRAM is geive by _sramfuncs and _eramfuncs.  The
   * temporary location is in flash after the data initalization code
   * at _framfuncs.  This must be done before sam_clockconfig() can be
   * called (at least for the SAM4L family).
   */

#ifdef CONFIG_ARCH_RAMFUNCS
  for (src = &_framfuncs, dest = &_sramfuncs; dest < &_eramfuncs; )
    {
      *dest++ = *src++;
    }
#endif

  /* Configure the uart so that we can get debug output as soon as possible */

  sam_clockconfig();
  sam_lowsetup();
  showprogress('A');

  /* Perform early serial initialization */

#ifdef USE_EARLYSERIALINIT
  up_earlyserialinit();
#endif
  showprogress('B');

  /* For the case of the separate user-/kernel-space build, perform whatever
   * platform specific initialization of the user memory is required.
   * Normally this just means initializing the user space .data and .bss
   * segements.
   */

#ifdef CONFIG_NUTTX_KERNEL
  sam_userspace();
  showprogress('C');
#endif

  /* Initialize onboard resources */

  sam_boardinitialize();
  showprogress('D');

  /* Then start NuttX */

  showprogress('\r');
  showprogress('\n');
  os_start();

  /* Shouldn't get here */

  for(;;);
}
Beispiel #12
0
void __start(void)
{
  const uint32_t *src;
  uint32_t *dest;

  /* Make sure that interrupts are disabled */

  __asm__ __volatile__ ("\tcpsid  i\n");

  /* Configure the clocking and the console uart so that we can get debug
   * output as soon as possible.  NOTE: That this logic must not assume that
   * .bss or .data have beeninitialized.
   */

  nrf52_clockconfig();
  nrf52_lowsetup();
  showprogress('A');

  /* Clear .bss.  We'll do this inline (vs. calling memset) just to be
   * certain that there are no issues with the state of global variables.
   */

  for (dest = &_sbss; dest < &_ebss; )
    {
      *dest++ = 0;
    }

  showprogress('B');

  /* Move the initialized data section from his temporary holding spot in
   * FLASH into the correct place in SRAM.  The correct place in SRAM is
   * give by _sdata and _edata.  The temporary location is in FLASH at the
   * end of all of the other read-only data (.text, .rodata) at _eronly.
   */

  for (src = &_eronly, dest = &_sdata; dest < &_edata; )
    {
      *dest++ = *src++;
    }

  showprogress('C');

  /* Initialize the FPU (if configured) */

  nrf52_fpuconfig();
  showprogress('D');

  /* Perform early serial initialization */

#ifdef USE_EARLYSERIALINIT
  nrf52_earlyserialinit();
#endif
  showprogress('E');

  /* For the case of the separate user-/kernel-space build, perform whatever
   * platform specific initialization of the user memory is required.
   * Normally this just means initializing the user space .data and .bss
   * segments.
   */

#ifdef CONFIG_BUILD_PROTECTED
  nrf52_userspace();
  showprogress('F');
#endif

  /* Initialize onboard resources */

  nrf52_board_initialize();
  showprogress('G');

  /* Then start NuttX */

  showprogress('\r');
  showprogress('\n');
  os_start();

  /* Shouldn't get here */

  for (; ; );
}