Esempio n. 1
0
int
main (int argc, char **argv)
{
  unsigned int i;
  unsigned int k;
  unsigned int table_size[] = {1, 2, 3, 4, 5, 23, 53};
  Hash_table *ht;
  Hash_tuning tuning;

  hash_reset_tuning (&tuning);
  tuning.shrink_threshold = 0.3;
  tuning.shrink_factor = 0.707;
  tuning.growth_threshold = 1.5;
  tuning.growth_factor = 2.0;
  tuning.is_n_buckets = true;

  if (1 < argc)
    {
      unsigned int seed;
      if (get_seed (argv[1], &seed) != 0)
        {
          fprintf (stderr, "invalid seed: %s\n", argv[1]);
          exit (EXIT_FAILURE);
        }

      srand (seed);
    }

  for (i = 0; i < ARRAY_CARDINALITY (table_size); i++)
    {
      size_t sz = table_size[i];
      ht = hash_initialize (sz, NULL, hash_pjw, hash_compare_strings, NULL);
      ASSERT (ht);
      insert_new (ht, "a");
      {
        char *str1 = strdup ("a");
        char *str2;
        ASSERT (str1);
        str2 = hash_insert (ht, str1);
        ASSERT (str1 != str2);
        ASSERT (STREQ (str1, str2));
        free (str1);
      }
      insert_new (ht, "b");
      insert_new (ht, "c");
      i = 0;
      ASSERT (hash_do_for_each (ht, walk, &i) == 3);
      ASSERT (i == 7);
      {
        void *buf[5] = { NULL };
        ASSERT (hash_get_entries (ht, NULL, 0) == 0);
        ASSERT (hash_get_entries (ht, buf, 5) == 3);
        ASSERT (STREQ (buf[0], "a") || STREQ (buf[0], "b") || STREQ (buf[0], "c"));
      }
      ASSERT (hash_delete (ht, "a"));
      ASSERT (hash_delete (ht, "a") == NULL);
      ASSERT (hash_delete (ht, "b"));
      ASSERT (hash_delete (ht, "c"));

      ASSERT (hash_rehash (ht, 47));
      ASSERT (hash_rehash (ht, 467));

      /* Free an empty table. */
      hash_clear (ht);
      hash_free (ht);

      ht = hash_initialize (sz, NULL, hash_pjw, hash_compare_strings, NULL);
      ASSERT (ht);

      insert_new (ht, "z");
      insert_new (ht, "y");
      insert_new (ht, "x");
      insert_new (ht, "w");
      insert_new (ht, "v");
      insert_new (ht, "u");

      hash_clear (ht);
      ASSERT (hash_get_n_entries (ht) == 0);
      hash_free (ht);

      /* Test pointer hashing.  */
      ht = hash_initialize (sz, NULL, NULL, NULL, NULL);
      ASSERT (ht);
      {
        char *str = strdup ("a");
        ASSERT (str);
        insert_new (ht, "a");
        insert_new (ht, str);
        ASSERT (hash_lookup (ht, str) == str);
        free (str);
      }
      hash_free (ht);
    }

  hash_reset_tuning (&tuning);
  tuning.shrink_threshold = 0.3;
  tuning.shrink_factor = 0.707;
  tuning.growth_threshold = 1.5;
  tuning.growth_factor = 2.0;
  tuning.is_n_buckets = true;
  /* Invalid tuning.  */
  ht = hash_initialize (4651, &tuning, hash_pjw, hash_compare_strings,
                        hash_freer);
  ASSERT (!ht);

  /* Alternate tuning.  */
  tuning.growth_threshold = 0.89;

  /* Run with default tuning, then with custom tuning settings.  */
  for (k = 0; k < 2; k++)
    {
      Hash_tuning const *tune = (k == 0 ? NULL : &tuning);
      /* Now, each entry is malloc'd.  */
      ht = hash_initialize (4651, tune, hash_pjw,
                            hash_compare_strings, hash_freer);
      ASSERT (ht);
      for (i = 0; i < 10000; i++)
        {
          unsigned int op = rand () % 10;
          switch (op)
            {
            case 0:
            case 1:
            case 2:
            case 3:
            case 4:
            case 5:
              {
                char buf[50];
                char const *p = uinttostr (i, buf);
                char *p_dup = strdup (p);
                ASSERT (p_dup);
                insert_new (ht, p_dup);
              }
              break;

            case 6:
              {
                size_t n = hash_get_n_entries (ht);
                ASSERT (hash_rehash (ht, n + rand () % 20));
              }
              break;

            case 7:
              {
                size_t n = hash_get_n_entries (ht);
                size_t delta = rand () % 20;
                if (delta < n)
                  ASSERT (hash_rehash (ht, n - delta));
              }
              break;

            case 8:
            case 9:
              {
                /* Delete a random entry.  */
                size_t n = hash_get_n_entries (ht);
                if (n)
                  {
                    size_t kk = rand () % n;
                    void const *p;
                    void *v;
                    for (p = hash_get_first (ht); kk;
                         --kk, p = hash_get_next (ht, p))
                      {
                        /* empty */
                      }
                    ASSERT (p);
                    v = hash_delete (ht, p);
                    ASSERT (v);
                    free (v);
                  }
                break;
              }
            }
          ASSERT (hash_table_ok (ht));
        }

      hash_free (ht);
    }

  return 0;
}
Esempio n. 2
0
/*
 *  Entry point of the SNMP server.
 */
PROCESS_THREAD(snmpd_process, ev, data) {
	PROCESS_BEGIN();

        #if !(CONTIKI_TARGET_AVR_RAVEN || CONTIKI_TARGET_AVR_ZIGBIT)
        systemStartTime = clock_time();
        #endif
	
	/*Switch LED on @ANY Brick On if SNMPD started and set other LEDs as Output*/
	DDRB |= (1 << PIN5);
	DDRB |= (1 << PIN6);
	DDRB |= (1 << PIN7);
	PORTB &= ~(1 << PIN7);
	PORTB |= (1 << PIN6);
	PORTB |= (1 << PIN5);

	/*END LED @ANY Brick*/

	
        #if CHECK_STACK_SIZE
		printf("Starte füllen mit Bit Pattern\n");
        u16t i = 0;
        u32t pointer;
        u32t* p = &pointer;
        for (i = 0; i < 500; i++) {
            *p = 0xAAAAAAAA;
            p--;
        }
        marker = &pointer;
        #endif

	udpconn = udp_new(NULL, UIP_HTONS(0), NULL);
	udp_bind(udpconn, UIP_HTONS(LISTEN_PORT));

	/*sz*/
	#if ENABLE_SNMPv3
	incMsgAuthoritativeEngineBoots();
	#endif
	/*sz*/

	/*sz*/
	#if ENABLE_SNMPv3
	srandom(get_seed());
	privacyLow = random();
	//srandom(get_seed());
	privacyHigh = random();
#if PDEBUG
	printf("Privacy 32Bit Pseudo Random Number: \n%u \n%u\n",privacyLow, privacyHigh);
#endif
	#endif
	/*sz*/


        /* init MIB */
        if (mib_init() != -1) {

            while(1) {
                PROCESS_YIELD();
                udp_handler(ev, data);
            }
        } else {
            snmp_log("error occurs while initializing the MIB\n");
        }
	PROCESS_END();
}
Esempio n. 3
0
MAIN_RETURN_TYPE main(void) {
	int argc=0;
	char *argv[1];
#else
MAIN_RETURN_TYPE main(int argc, char *argv[]) {
#endif
	ee_u16 i,j=0,num_algorithms=0;
	ee_s16 known_id=-1,total_errors=0;
	ee_u16 seedcrc=0;
	CORE_TICKS total_time;
	core_results results[MULTITHREAD];
#if (MEM_METHOD==MEM_STACK)
	ee_u8 stack_memblock[TOTAL_DATA_SIZE*MULTITHREAD];
#endif
	/* first call any initializations needed */
	portable_init(&(results[0].port), &argc, argv);
	/* First some checks to make sure benchmark will run ok */
	if (sizeof(struct list_head_s)>128) {
		ee_printf("list_head structure too big for comparable data!\n");
		return MAIN_RETURN_VAL;
	}
	results[0].seed1=get_seed(1);
	results[0].seed2=get_seed(2);
	results[0].seed3=get_seed(3);
	results[0].iterations=get_seed_32(4);
#if CORE_DEBUG
	results[0].iterations=1;
#endif
    // Bob: change the interation times to make it faster
	results[0].iterations=800;

	results[0].execs=get_seed_32(5);
	if (results[0].execs==0) { /* if not supplied, execute all algorithms */
		results[0].execs=ALL_ALGORITHMS_MASK;
	}
		/* put in some default values based on one seed only for easy testing */
	if ((results[0].seed1==0) && (results[0].seed2==0) && (results[0].seed3==0)) { /* validation run */
		results[0].seed1=0;
		results[0].seed2=0;
		results[0].seed3=0x66;
	}
	if ((results[0].seed1==1) && (results[0].seed2==0) && (results[0].seed3==0)) { /* perfromance run */
		results[0].seed1=0x3415;
		results[0].seed2=0x3415;
		results[0].seed3=0x66;
	}
#if (MEM_METHOD==MEM_STATIC)
	results[0].memblock[0]=(void *)static_memblk;
	results[0].size=TOTAL_DATA_SIZE;
	results[0].err=0;
	#if (MULTITHREAD>1)
	#error "Cannot use a static data area with multiple contexts!"
	#endif
#elif (MEM_METHOD==MEM_MALLOC)
	for (i=0 ; i<MULTITHREAD; i++) {
		ee_s32 malloc_override=get_seed(7);
		if (malloc_override != 0) 
			results[i].size=malloc_override;
		else
			results[i].size=TOTAL_DATA_SIZE;
		results[i].memblock[0]=portable_malloc(results[i].size);
		results[i].seed1=results[0].seed1;
		results[i].seed2=results[0].seed2;
		results[i].seed3=results[0].seed3;
		results[i].err=0;
		results[i].execs=results[0].execs;
	}
#elif (MEM_METHOD==MEM_STACK)
	for (i=0 ; i<MULTITHREAD; i++) {
		results[i].memblock[0]=stack_memblock+i*TOTAL_DATA_SIZE;
		results[i].size=TOTAL_DATA_SIZE;
		results[i].seed1=results[0].seed1;
		results[i].seed2=results[0].seed2;
		results[i].seed3=results[0].seed3;
		results[i].err=0;
		results[i].execs=results[0].execs;
	}
#else
#error "Please define a way to initialize a memory block."
#endif
	/* Data init */ 
	/* Find out how space much we have based on number of algorithms */
	for (i=0; i<NUM_ALGORITHMS; i++) {
		if ((1<<(ee_u32)i) & results[0].execs)
			num_algorithms++;
	}
	for (i=0 ; i<MULTITHREAD; i++) 
		results[i].size=results[i].size/num_algorithms;
	/* Assign pointers */
	for (i=0; i<NUM_ALGORITHMS; i++) {
		ee_u32 ctx;
		if ((1<<(ee_u32)i) & results[0].execs) {
			for (ctx=0 ; ctx<MULTITHREAD; ctx++)
				results[ctx].memblock[i+1]=(char *)(results[ctx].memblock[0])+results[0].size*j;
			j++;
		}
	}
	/* call inits */
	for (i=0 ; i<MULTITHREAD; i++) {
		if (results[i].execs & ID_LIST) {
			results[i].list=core_list_init(results[0].size,results[i].memblock[1],results[i].seed1);
		}
		if (results[i].execs & ID_MATRIX) {
			core_init_matrix(results[0].size, results[i].memblock[2], (ee_s32)results[i].seed1 | (((ee_s32)results[i].seed2) << 16), &(results[i].mat) );
		}
		if (results[i].execs & ID_STATE) {
			core_init_state(results[0].size,results[i].seed1,results[i].memblock[3]);
		}
	}
	
	/* automatically determine number of iterations if not set */
	if (results[0].iterations==0) { 
		secs_ret secs_passed=0;
		ee_u32 divisor;
		results[0].iterations=1;
		while (secs_passed < (secs_ret)1) {
			results[0].iterations*=10;
			start_time();
			iterate(&results[0]);
			stop_time();
			secs_passed=time_in_secs(get_time());
		}
		/* now we know it executes for at least 1 sec, set actual run time at about 10 secs */
		divisor=(ee_u32)secs_passed;
		if (divisor==0) /* some machines cast float to int as 0 since this conversion is not defined by ANSI, but we know at least one second passed */
			divisor=1;
		results[0].iterations*=1+10/divisor;
	}
	/* perform actual benchmark */
	start_time();
#if (MULTITHREAD>1)
	if (default_num_contexts>MULTITHREAD) {
		default_num_contexts=MULTITHREAD;
	}
	for (i=0 ; i<default_num_contexts; i++) {
		results[i].iterations=results[0].iterations;
		results[i].execs=results[0].execs;
		core_start_parallel(&results[i]);
	}
	for (i=0 ; i<default_num_contexts; i++) {
		core_stop_parallel(&results[i]);
	}
#else
	iterate(&results[0]);
#endif
	stop_time();
	total_time=get_time();
	/* get a function of the input to report */
	seedcrc=crc16(results[0].seed1,seedcrc);
	seedcrc=crc16(results[0].seed2,seedcrc);
	seedcrc=crc16(results[0].seed3,seedcrc);
	seedcrc=crc16(results[0].size,seedcrc);
	
	switch (seedcrc) { /* test known output for common seeds */
		case 0x8a02: /* seed1=0, seed2=0, seed3=0x66, size 2000 per algorithm */
			known_id=0;
			ee_printf("6k performance run parameters for coremark.\n");
			break;
		case 0x7b05: /*  seed1=0x3415, seed2=0x3415, seed3=0x66, size 2000 per algorithm */
			known_id=1;
			ee_printf("6k validation run parameters for coremark.\n");
			break;
		case 0x4eaf: /* seed1=0x8, seed2=0x8, seed3=0x8, size 400 per algorithm */
			known_id=2;
			ee_printf("Profile generation run parameters for coremark.\n");
			break;
		case 0xe9f5: /* seed1=0, seed2=0, seed3=0x66, size 666 per algorithm */
			known_id=3;
			ee_printf("2K performance run parameters for coremark.\n");
			break;
		case 0x18f2: /*  seed1=0x3415, seed2=0x3415, seed3=0x66, size 666 per algorithm */
			known_id=4;
			ee_printf("2K validation run parameters for coremark.\n");
			break;
		default:
			total_errors=-1;
			break;
	}
	if (known_id>=0) {
		for (i=0 ; i<default_num_contexts; i++) {
			results[i].err=0;
			if ((results[i].execs & ID_LIST) && 
				(results[i].crclist!=list_known_crc[known_id])) {
				ee_printf("[%u]ERROR! list crc 0x%04x - should be 0x%04x\n",i,results[i].crclist,list_known_crc[known_id]);
				results[i].err++;
			}
			if ((results[i].execs & ID_MATRIX) &&
				(results[i].crcmatrix!=matrix_known_crc[known_id])) {
				ee_printf("[%u]ERROR! matrix crc 0x%04x - should be 0x%04x\n",i,results[i].crcmatrix,matrix_known_crc[known_id]);
				results[i].err++;
			}
			if ((results[i].execs & ID_STATE) &&
				(results[i].crcstate!=state_known_crc[known_id])) {
				ee_printf("[%u]ERROR! state crc 0x%04x - should be 0x%04x\n",i,results[i].crcstate,state_known_crc[known_id]);
				results[i].err++;
			}
			total_errors+=results[i].err;
		}
	}
	total_errors+=check_data_types();
	/* and report results */
	ee_printf("CoreMark Size    : %lu\n",(ee_u32)results[0].size);
	ee_printf("Total ticks      : %lu\n",(ee_u32)total_time);
#if HAS_FLOAT
	ee_printf("Total time (secs): %f\n",time_in_secs(total_time));
	if (time_in_secs(total_time) > 0)
		ee_printf("Iterations/Sec   : %f\n",default_num_contexts*results[0].iterations/time_in_secs(total_time));
#else 
	ee_printf("Total time (secs): %d\n",time_in_secs(total_time));
	if (time_in_secs(total_time) > 0)
		ee_printf("Iterations/Sec   : %d\n",default_num_contexts*results[0].iterations/time_in_secs(total_time));
#endif
	if (time_in_secs(total_time) < 10) {
		ee_printf("ERROR! Must execute for at least 10 secs for a valid result!\n");
		total_errors++;
	}

	ee_printf("Iterations       : %lu\n",(ee_u32)default_num_contexts*results[0].iterations);
	ee_printf("Compiler version : %s\n",COMPILER_VERSION);
	ee_printf("Compiler flags   : %s\n",COMPILER_FLAGS);
#if (MULTITHREAD>1)
	ee_printf("Parallel %s : %d\n",PARALLEL_METHOD,default_num_contexts);
#endif
	ee_printf("Memory location  : %s\n",MEM_LOCATION);
	/* output for verification */
	ee_printf("seedcrc          : 0x%04x\n",seedcrc);
	if (results[0].execs & ID_LIST)
		for (i=0 ; i<default_num_contexts; i++) 
			ee_printf("[%d]crclist       : 0x%04x\n",i,results[i].crclist);
	if (results[0].execs & ID_MATRIX) 
		for (i=0 ; i<default_num_contexts; i++) 
			ee_printf("[%d]crcmatrix     : 0x%04x\n",i,results[i].crcmatrix);
	if (results[0].execs & ID_STATE)
		for (i=0 ; i<default_num_contexts; i++) 
			ee_printf("[%d]crcstate      : 0x%04x\n",i,results[i].crcstate);
	for (i=0 ; i<default_num_contexts; i++) 
		ee_printf("[%d]crcfinal      : 0x%04x\n",i,results[i].crc);
	if (total_errors==0) {
		ee_printf("Correct operation validated. See readme.txt for run and reporting rules.\n");
#if HAS_FLOAT
		if (known_id==3) {
			ee_printf("CoreMark 1.0 : %f / %s %s",default_num_contexts*results[0].iterations/time_in_secs(total_time),COMPILER_VERSION,COMPILER_FLAGS);
#if defined(MEM_LOCATION) && !defined(MEM_LOCATION_UNSPEC)
			ee_printf(" / %s",MEM_LOCATION);
#else
			ee_printf(" / %s",mem_name[MEM_METHOD]);
#endif

#if (MULTITHREAD>1)
			ee_printf(" / %d:%s",default_num_contexts,PARALLEL_METHOD);
#endif
			ee_printf("\n");
		}
#endif
	}
	if (total_errors>0)
		ee_printf("Errors detected\n");
	if (total_errors<0)
		ee_printf("Cannot validate operation for these seed values, please compare with results on a known platform.\n");

#if (MEM_METHOD==MEM_MALLOC)
	for (i=0 ; i<MULTITHREAD; i++) 
		portable_free(results[i].memblock[0]);
#endif
	/* And last call any target specific code for finalizing */
	portable_fini(&(results[0].port));

    float coremark_dmips = (results[0].iterations*1000000)/(float)total_time;

#if HAS_FLOAT
    ee_printf ("\n");
    ee_printf ("\n");
    ee_printf ("Print Personal Added Addtional Info to Easy Visual Analysis\n");
    ee_printf ("\n");
    ee_printf (" (*) Assume core running at 1 MHz\n");
    ee_printf ("     So the CoreMark/MHz can be caculated by: \n");
    ee_printf ("     (Iterations*1000000/total_ticks) = %2.6f CoreMark/MHz\n", coremark_dmips);
    //float coremark_dmips_2 = default_num_contexts*results[0].iterations/time_in_secs(total_time) / 8.388;
    //ee_printf ("     (Iterations/Sec/total_cycles) = %2.6f CoreMark/MHz\n", coremark_dmips_2);
    ee_printf ("\n");
#endif

	return MAIN_RETURN_VAL;	
}
Esempio n. 4
0
void main_game::init(rect viewport) {
    game_base::init(viewport);
    game_base::init_ui("data/ui.json");

	// add loader
	hub.add("resource_loader", &loader);

    // init ui
    create_ui_callbacks();

    // load geometry shader
    resource<shader> geometry_shader = hub.create<shader>("geometry-shader");
    geometry_shader->load_source("data/Shader/GeometryShader.vs", shader_type::vertex);
    geometry_shader->load_source("data/Shader/GeometryShader.fs", shader_type::fragment);
    geometry_shader->compile();
    geometry_shader->set_vec3("object_position", vec3::zero);

    // load ship shader
    resource<shader> ship_shader = hub.create<shader>("ship-shader");
    ship_shader->load_source("data/Shader/ShipShader.vs", shader_type::vertex);
    ship_shader->load_source("data/Shader/ShipShader.fs", shader_type::fragment);
    ship_shader->compile();

	// load sprite shader
	resource<shader> sprite_shader = hub.create<shader>("sprite-shader");
	sprite_shader->load_source("data/Shader/SpriteShader.vs", shader_type::vertex);
	sprite_shader->load_source("data/Shader/SpriteShader.fs", shader_type::fragment);
	sprite_shader->compile();

	// load line shader
	resource<shader> line_shader = hub.create<shader>("line-shader");
	line_shader->load_source("data/Shader/LineShader.vs", shader_type::vertex);
	line_shader->load_source("data/Shader/LineShader.geom", shader_type::geometry);
	line_shader->load_source("data/Shader/LineShader.fs", shader_type::fragment);
	line_shader->compile();


    // add system resources
	hub.add("world", &world);
    hub.add("renderer", &renderer);
    hub.add("bullet-particle-system", &bullet_particle_system);
    hub.add("spark-particle-system", &sparks_particle_system);
    hub.add("keyboard", keyboard);
    hub.add("mouse", mouse);
    hub.add("ui", &ui);

    blur_effect.init(hub);
    hub.add("blur_effect", &blur_effect);

	waypoint_visualizer = hub.add("waypoint-visualizer", world.create_sys<waypoint_visualizer_system>(&hub));
	trails_renderer = hub.add("trails-renderer",world.create_sys<trails_renderer_system>(&hub));


    // create systems
    init_particle_system();
    collision_sys = hub.add("collision-system", world.create_sys<collision_system>());
    hub.add("ship-manager", &ship_sys);
	nebular_background = hub.add("nebular-background", world.create_bev<nebular_background_behaviour>(&hub, get_seed()));
	nebular_background->show();

	star_background = world.create_bev<star_background_behaviour>(&hub);
	star_background->show();
	nearby_star_background = world.create_bev<nearby_star_background_behaviour>(&hub);
	nearby_star_background->show();

	// init managers
	ship_sys.init(hub);

    // create teams
	// player team
    teams.push_back(team());
    teams[0].team_index = 0;
    teams[0].name = "player";
	teams[0].team_color = color::alice_blue;

	// computer team
    teams.push_back(team()); 
    teams[1].team_index = 1;
    teams[1].name = "computer";
	teams[1].team_color = color::red;

    // load ship resources
    init_ship_models();

    // init ai's 
    init_ais();

	host_window->maximize();
	state = game_state::none;
	switch_level<menu_level>();
}
Esempio n. 5
0
void random_init()
{
  random_val = get_seed(RANDOM_EEPROM_BEGIN, (uint32_t*)RANDOM_EEPROM_END);
  for (uint8_t i=0; i<10; ++i)
    random_xorshift32();
}
Esempio n. 6
0
File: main.c Progetto: sli92/netcon
int main(void)
{
        uint32_t lastperiodic = 0;
        uint32_t lastarp = 0;
        uint32_t lastupdate = 0;

        uint8_t i; // , x;
        // char buffer[32];

        uart_init();
        clock_init();
        sei();

        while(get_clock() < CLOCK_TICKS_PER_SECOND * 3);

        serconn_init();
        lastupdate = get_clock();

        memcpy_P(uip_ethaddr.addr, mac_addr, sizeof(uip_ethaddr.addr));

        enc28j60_init(uip_ethaddr.addr);

        uip_init();
        uip_arp_init();

        /* Seed fuer den Zufallsgenerator setzen. */
        srandom(get_seed());

        tcp_app_init();
        udp_app_init();

        while(1 > 0) {
                uip_len = enc28j60_receive(uip_buf, UIP_CONF_BUFFER_SIZE);
                if(uip_len > 0) {
                        if(UIP_BUFFER->type == HTONS(UIP_ETHTYPE_IP)) {
                                uip_arp_ipin();
                                uip_input();

                                if(uip_len > 0) {
                                        uip_arp_out();
                                        enc28j60_transmit(uip_buf, uip_len);
                                }

                        } else if(UIP_BUFFER->type == HTONS(UIP_ETHTYPE_ARP)) {
                                uip_arp_arpin();
                                if(uip_len > 0)
                                        enc28j60_transmit(uip_buf, uip_len);
                        }

                } else if((get_clock() - lastperiodic) > CLOCK_TICKS_PER_SECOND / 2) {
                        lastperiodic = get_clock();

                        for(i = 0; i < UIP_CONNS; i++) {
                                uip_periodic(i);

                                if(uip_len > 0) {
                                        uip_arp_out();
                                        enc28j60_transmit(uip_buf, uip_len);
                                }
                        }


                        for(i = 0; i < UIP_UDP_CONNS; i++) {
                                uip_udp_periodic(i);

                                if(uip_len > 0) {
                                        uip_arp_out();
                                        enc28j60_transmit(uip_buf, uip_len);
                                }
                        }
                }

                if((get_clock() - lastarp) > CLOCK_TICKS_PER_SECOND * 10) {
                        lastarp = get_clock();
                        uip_arp_timer();

/*
                        x = 0;
                        for(i = 0; i < UIP_CONNS; i++) {
                                if(uip_conn_active(i))
                                        x++;
                        }

                        sprintf(buffer, "Active connections: %d\n", x);
                        uart_puts(buffer);
*/
                }

                if((get_clock() - lastupdate) > CLOCK_TICKS_PER_SECOND / 2){
                        serconn_update();
                        lastupdate = get_clock();
                }
        }
}