Esempio n. 1
0
/*---------------------------------------------------------------------------*/
PROCESS_THREAD(eth64_drv_process, ev, data)
{
  PROCESS_POLLHANDLER(pollhandler());
  
  PROCESS_BEGIN();

  
  uip_setethaddr(addr);
  init_eth64();
  lan91c96_init();

  ctk_window_new(&window, DUMP_WIDTH, DUMP_HEIGHT, "RR-Net dump");
  CTK_WIDGET_ADD(&window, &dumplabel);
  ctk_window_open(&window);
  
  
  SERVICE_REGISTER(eth64_drv_service);

  process_poll(&eth64_drv_process);
  
  while(1) {
    PROCESS_WAIT_EVENT_UNTIL(ev == PROCESS_EVENT_EXIT);
  }

  ctk_window_close(&window);
  
  PROCESS_END();
}
Esempio n. 2
0
PROCESS_THREAD(adc_read_process, ev, data)
{
	
	

        PROCESS_POLLHANDLER(pollhandler());
        
        PROCESS_BEGIN();
        
        PROCESS_PAUSE();
       
        process_poll(&adc_read_process);

	while(1)
        {
		PROCESS_YIELD();

        }




 
    



	PROCESS_END();
}
Esempio n. 3
0
/*---------------------------------------------------------------------------*/
PROCESS_THREAD(cc1101_process, ev, data)
{

  PROCESS_POLLHANDLER(pollhandler());

  PROCESS_BEGIN();

#if 0
  while(1) {
    static struct etimer et;
    uint8_t rxbytes, txbytes;
    etimer_set(&et, CLOCK_SECOND * 4);
    PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&et));
    //    cc1101_rx_interrupt();
    burst_read(CC1101_RXBYTES, &rxbytes, 1);
    burst_read(CC1101_TXBYTES, &txbytes, 1);
    printf("state 0x%02x rxbytes 0x%02x txbytes 0x%02x\n",
     state(), rxbytes, txbytes);
    on();
  }
#endif /* 0 */

  PROCESS_YIELD_UNTIL(ev == PROCESS_EVENT_EXIT);

  PROCESS_END();
}
Esempio n. 4
0
PROCESS_THREAD(freakusb_process, ev, data_proc)
{

	PROCESS_POLLHANDLER(freakusb_pollhandler());

	PROCESS_BEGIN();
	usb_init();
	hw_init();
	cdc_init();

	/* TODO: Implement this when we decide to accept commands over the USB */
	cdc_reg_rx_handler(test_avr_usb_rx_handler);

	/* hook the putchar function to the printf and use it for stdout */
	stdout = &file_str;

	/* kick off the polling function */
	process_poll(&freakusb_process);

	while (1) {
		PROCESS_YIELD();
	}

	PROCESS_END();
}
Esempio n. 5
0
PROCESS_THREAD(mac_process, ev, data)
{

  PROCESS_POLLHANDLER(mac_pollhandler());


  PROCESS_BEGIN();

  radio_status_t return_value;

  /* init radio */
  /** \todo: this screws up if calosc is set to TRUE, find out why? */
  return_value = radio_init(false, NULL, NULL, NULL);

#if DEBUG
  if (return_value == RADIO_SUCCESS) {
    printf("Radio init successful.\n");
  } else {
    printf("Radio init failed with return: %d\n", return_value);
  }
#endif

  uint8_t eeprom_channel;
  uint8_t eeprom_check;
  
  eeprom_channel = eeprom_read_byte((uint8_t *)9);
  eeprom_check = eeprom_read_byte((uint8_t *)10);
  
  if ((eeprom_channel < 11) || (eeprom_channel > 26) || ((uint8_t)eeprom_channel != (uint8_t)~eeprom_check)) {
#if UIP_CONF_USE_RUM
	eeprom_channel = 19; //Default
#else
	eeprom_channel = 24; //Default
#endif
  }

  radio_set_operating_channel(eeprom_channel);
  radio_use_auto_tx_crc(true);
  radio_set_trx_state(TRX_OFF);

  mac_init();

  /* Set up MAC function pointers and sicslowpan callback. */
  pmac_driver->set_receive_function = setinput;
  pmac_driver->send = sicslowmac_dataRequest;
  sicslowpan_init(pmac_driver);

  ieee_15_4_init(&ieee15_4ManagerAddress);

  radio_set_trx_state(RX_AACK_ON);

  while(1) {
    PROCESS_YIELD();
    mac_task(ev, data);

  }

  PROCESS_END();
}
Esempio n. 6
0
PROCESS_THREAD(accmeter_process, ev, data) {
  PROCESS_POLLHANDLER(poll_handler());
  PROCESS_EXITHANDLER();
  PROCESS_BEGIN();
  while(1){
    PROCESS_WAIT_EVENT_UNTIL(0);    // should do nothing in while loop.
  }
  PROCESS_END();
}
Esempio n. 7
0
/*---------------------------------------------------------------------------*/
PROCESS_THREAD(ethernet_process, ev, data)
{
	PROCESS_POLLHANDLER(eth_poll());
	PROCESS_BEGIN();
	eth_init();

	PROCESS_WAIT_EVENT_UNTIL(ev == PROCESS_EVENT_EXIT);

  PROCESS_END();
}
/*--------------------------------------------------------------------------*/
PROCESS_THREAD(adc_reading_process, ev, data)
{
  PROCESS_POLLHANDLER(adc_pollhandler());
  PROCESS_BEGIN();

  leds_off(LEDS_ALL);

  while(1) {
    /* read analog in A7, store the result in adcval and poll this process when done */
    adc_get_poll(A7, &adcval, PROCESS_CURRENT());
    etimer_set(&et, CLOCK_SECOND/8);
    PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&et));
  }
  PROCESS_END();
}
Esempio n. 9
0
PROCESS_THREAD(drvr_process, ev, data)
{
  PROCESS_POLLHANDLER(pollhandler());

  PROCESS_BEGIN();

  // kick off the pollhandler
  process_poll(&drvr_process);

  while (1)
  {
      PROCESS_YIELD();
  }
  PROCESS_END();
}
Esempio n. 10
0
  PROCESS_THREAD(raven_relay_process, ev, data) {
    uip_ipaddr_t ipaddr;
    PROCESS_POLLHANDLER(pollhandler());
    PROCESS_EXITHANDLER(exithandler());

    // see: http://senstools.gforge.inria.fr/doku.php?id=contiki:examples
    PROCESS_BEGIN();
    PRINTF("Relay process startup.\r\n");
    // wait 3 second, in order to have the IP addresses well configured
    etimer_set(&udp_periodic_timer, CLOCK_CONF_SECOND*3);
    // wait until the timer has expired
    PROCESS_WAIT_EVENT_UNTIL(ev == PROCESS_EVENT_TIMER);
    // Define Address of the server that receives our heartbeats.
    // TODO: Make this dynamic
#ifdef UDP_ADDR_A
    uip_ip6addr(&ipaddr,
        UDP_ADDR_A,UDP_ADDR_B,UDP_ADDR_C,UDP_ADDR_D,
        UDP_ADDR_E,UDP_ADDR_F,UDP_ADDR_G,UDP_ADDR_H);
#else /* UDP_ADDR_A */
    uip_ip6addr(&ipaddr,0xbbbb,0,0,0,0xd69a,0x20ff,0xfe07,0x7664);
#endif /* UDP_ADDR_A */

    udpconn = udp_new(NULL, HTONS(0), NULL);

    //udpconn = udp_new(&ipaddr, HTONS(0xF0B0+1), NULL);
    udp_bind(udpconn, HTONS(0xF0B0));
    // udp_attach(udpconn, NULL);

    PRINTF("Created connection with remote peer ");
    PRINT6ADDR(&udpconn->ripaddr);
    PRINTF("\r\nlocal/remote port %u/%u\r\n", HTONS(udpconn->lport),HTONS(udpconn->rport));

    print_local_addresses();
    etimer_set(&udp_periodic_timer, 60*CLOCK_SECOND);

    while(1){
      PRINTF("--- Relay: Waiting for events.\r\n");
      //   tcpip_poll_udp(udpconn);
      PROCESS_WAIT_EVENT();
      //    PROCESS_YIELD();
      udphandler(ev, data);
    }


    PROCESS_END();
  }
Esempio n. 11
0
/*---------------------------------------------------------------------------*/
PROCESS_THREAD(ethernet_process, ev, data)
{
  PROCESS_POLLHANDLER(pollhandler());

  PROCESS_BEGIN();

  ethernet_init((struct ethernet_config *)data);

  tcpip_set_outputfunc(ethernet_output);

  process_poll(&ethernet_process);

  PROCESS_WAIT_UNTIL(ev == PROCESS_EVENT_EXIT);

  ethernet_exit();

  PROCESS_END();
}
Esempio n. 12
0
/*---------------------------------------------------------------------------*/
PROCESS_THREAD(rtl8019_process, ev, data)
{
  PROCESS_POLLHANDLER(pollhandler());

  PROCESS_BEGIN();

  RTL8019dev_init();

  tcpip_set_outputfunc(rtl8019_output);

  process_poll(&rtl8019_process);
  
  PROCESS_WAIT_UNTIL(ev == PROCESS_EVENT_EXIT);

  RTL8019dev_exit();

  PROCESS_END();
}
Esempio n. 13
0
PROCESS_THREAD(blink_process, ev, data) {
  PROCESS_POLLHANDLER();
  PROCESS_EXITHANDLER();
  PROCESS_BEGIN();
  while(1) {
    leds_toggle(LEDS_RED);
    if(adc > 0) {
      time = (CLOCK_SECOND*adc)/1024;
    } else {
      time = CLOCK_SECOND/64;
    }
    if(time == 0) {
      time = 1;
    }
    etimer_set(&etb, time);
    PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&etb));
  }
  PROCESS_END();
}
/*---------------------------------------------------------------------------*/
PROCESS_THREAD(slip_drv_process, ev, data)
{
  PROCESS_POLLHANDLER(pollhandler());
  PROCESS_EXITHANDLER(rs232dev_unload());
  
  PROCESS_BEGIN();

  rs232dev_init();
  
  SERVICE_REGISTER(slip_drv_service);

  process_poll(&slip_drv_process);
  
  while(1) {
    PROCESS_YIELD();
  }
  
  PROCESS_END();
}
Esempio n. 15
0
/*---------------------------------------------------------------------------*/
PROCESS_THREAD(vfd_process, ev, data)
{
  PROCESS_POLLHANDLER();
  PROCESS_EXITHANDLER();
  PROCESS_BEGIN();
  vfd_init();
  vfd_print_char(2, 'A');
  while(1) {
    uint8_t btns;
    btns = vfd_read_btns();
    if(btns) {
      leds_on(LEDS_RED);
    } else {
      leds_off(LEDS_RED);
    }
    PROCESS_PAUSE();
  }
  PROCESS_END();
}
/*---------------------------------------------------------------------------*/
PROCESS_THREAD(ssfire_process, ev, data)
{
  PROCESS_POLLHANDLER(pollhandler());
  
  PROCESS_BEGIN();
  
  ctk_mode_set(CTK_MODE_SCREENSAVER);
  ctk_mouse_hide();
  fire_init();

  
  PROCESS_WAIT_EVENT_UNTIL(ev == ctk_signal_screensaver_stop ||
			   ev == PROCESS_EVENT_EXIT);

  ctk_draw_init();
  ctk_desktop_redraw(NULL);

  PROCESS_END();
}
Esempio n. 17
0
/*---------------------------------------------------------------------------*/
PROCESS_THREAD(tapdev_process, ev, data)
{
  PROCESS_POLLHANDLER(pollhandler());

  PROCESS_BEGIN();

  tapdev_init();
#if !UIP_CONF_IPV6
  tcpip_set_outputfunc(tapdev_output);
#else
  tcpip_set_outputfunc(tapdev_send);
#endif
  process_poll(&tapdev_process);

  PROCESS_WAIT_UNTIL(ev == PROCESS_EVENT_EXIT);

  tapdev_exit();

  PROCESS_END();
}
Esempio n. 18
0
/*---------------------------------------------------------------------------*/
PROCESS_THREAD(rrnet_drv_process, ev, data)
{
  PROCESS_POLLHANDLER(pollhandler());
  
  PROCESS_BEGIN();
  
  uip_setethaddr(addr);
  init_rrnet();
  cs8900a_init();
  
  SERVICE_REGISTER(rrnet_drv_service);

  process_poll(&rrnet_drv_process);
  
  while(1) {
    PROCESS_YIELD();
  }
  
  PROCESS_END();
}
Esempio n. 19
0
/*---------------------------------------------------------------------------*/
PROCESS_THREAD(wpcap_process, ev, data)
{
  PROCESS_POLLHANDLER(pollhandler());

  PROCESS_BEGIN();

  wpcap_init();

#if !UIP_CONF_IPV6
  tcpip_set_outputfunc(wpcap_output);
#else
#if !FALLBACK_HAS_ETHERNET_HEADERS
  tcpip_set_outputfunc(wpcap_send);
#endif
#endif /* !UIP_CONF_IPV6 */

  process_poll(&wpcap_process);

  PROCESS_WAIT_UNTIL(ev == PROCESS_EVENT_EXIT);

  wpcap_exit();

  PROCESS_END();
}
Esempio n. 20
0
PROCESS_THREAD(pwmled_process, ev, data)
{
  PROCESS_POLLHANDLER();
  PROCESS_EXITHANDLER(pwm_all_off(); etimer_stop(&etr););
PROCESS_THREAD(pwmled_process, ev, data)
{
  PROCESS_POLLHANDLER();
  PROCESS_EXITHANDLER();
  PROCESS_BEGIN();

  leds_off(LEDS_ALL);

  /* no need to do simplepwm_confpin() as it no longer changes those. */
  TEST_PORT(IE) &= ~(1 << pin);
  TEST_PORT(DIR) |= (1 << pin);
  TEST_PORT(OUT) |= (1 << pin);
  TEST_PORT(SEL) &= ~(1 << pin);
  TEST_PORT(SEL2) &= ~(1 << pin);

#if 0
  while(1) {
    simple_pwm_on(20);
    etimer_set(&etr, CLOCK_SECOND/2);
    PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&etr));
    simple_pwm_on(40);
    etimer_set(&etr, CLOCK_SECOND/2);
    PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&etr));
    simple_pwm_on(60);
    etimer_set(&etr, CLOCK_SECOND/2);
    PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&etr));
    simple_pwm_on(80);
    etimer_set(&etr, CLOCK_SECOND/2);
    PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&etr));
    simple_pwm_on(100);
    etimer_set(&etr, CLOCK_SECOND/2);
    PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&etr));
  }
#endif /* if 0; commented out code */

  while(1) {
    simple_pwm_on(i);

    /* find next PWM setting */
    if(up) {
      if(i < PWM_MAX - PWM_STEP) {
        i += PWM_STEP;
      } else {
        i = PWM_MAX;
        up = 0;
      }
    } else {
      if(i > PWM_MIN + PWM_STEP) {
        i -= PWM_STEP;
      } else {
        i = PWM_MIN ;
        up = 1;
      }
    }
    
    /* wait a little while */
    etimer_set(&etr, INTERVAL);
    PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&etr));
  }
  PROCESS_END();
}
Esempio n. 22
0
PROCESS_THREAD(hello_process, ev, data)
{
  PROCESS_POLLHANDLER();
  PROCESS_EXITHANDLER(broadcast_close(&bc); unicast_close(&uc););
Esempio n. 23
0
/*---------------------------------------------------------------------------*/
PROCESS_THREAD(cgterm_process, ev, data)
{
  u16_t *ipaddr;
  char *cptr;

  PROCESS_POLLHANDLER(pollhandler());
  
  PROCESS_BEGIN();

  ctk_window_new(&window, 38, 5, "C/G term");
  CTK_WIDGET_ADD(&window, &hostlabel);
  CTK_WIDGET_ADD(&window, &hostentry);
  CTK_WIDGET_ADD(&window, &portlabel);
  CTK_WIDGET_ADD(&window, &portentry);
  CTK_WIDGET_ADD(&window, &connectbutton);
  CTK_WIDGET_ADD(&window, &switchbutton);
  CTK_WIDGET_ADD(&window, &helplabel);
  ctk_window_open(&window);

  while(1) {
    PROCESS_WAIT_EVENT();
  
    if(ev == tcpip_event) {
      appcall(data);
    } else if(ev == ctk_signal_widget_activate) {
      
      if(data == &switchbutton) {
	textmode();
      } else if(data == &connectbutton) {
	serverport = 0;
	for(cptr = port; *cptr != ' ' && *cptr != 0; ++cptr) {
	  if(*cptr < '0' || *cptr > '9') {
	    continue;
	  }
	  serverport = 10 * serverport + *cptr - '0';
	}
	
	ipaddr = serveraddr;
	if(uiplib_ipaddrconv(host, (u8_t *)serveraddr) == 0) {
	  ipaddr = resolv_lookup(host);
	  if(ipaddr == NULL) {
	    resolv_query(host);
	  } else {
	    uip_ipaddr_copy(serveraddr, ipaddr);
	  }
	}
	if(ipaddr != NULL) {      
	  conn = connect(serveraddr, serverport);
	  if(conn != NULL) {
	    memset((char *)0x0400, 0x20, 40*25);
	    memset((char *)0xd800, 0x01, 40*25);
	    textmode();
	  }
	}
      }
    } else if(ev == resolv_event_found) {
      ipaddr = resolv_lookup(host);
      if(ipaddr != NULL) {
	uip_ipaddr_copy(serveraddr, ipaddr);
	
	conn = connect(serveraddr, serverport);
	if(conn != NULL) {
	  memset((char *)0x0400, 0x20, 40*25);
	  memset((char *)0xd800, 0x01, 40*25);
	  textmode();
	}
      }
    } else if(ev == PROCESS_EVENT_EXIT ||
	      ev == ctk_signal_window_close) {
     
      break;
    }
  }
  ctk_window_close(&window);
  
  PROCESS_END();
}