Search code examples
serial-portcontiki

serial_line_event_message doesn't work ( contiki , zolertia z1)


Hy, I've read several posts on how I can manage to receive data on the UART0 (rx) port of my zolertia z1 but i couldn't manage to make it work. my code:

#include "contiki.h"
#include <stdio.h>/* For printf()*/
#include "dev/leds.h"
#include "dev/serial-line.h"
#define PERIOD (CLOCK_SECOND*10)  

//-----------------------------------------------------------------

PROCESS(simple_uart, "read and write");
AUTOSTART_PROCESSES(&simple_uart);
static struct etimer et; // Define the timer
//-----------------------------------------------------------------
PROCESS_THREAD(simple_uart, ev, data)
{
  PROCESS_BEGIN();
  static struct etimer et;
  uart0_init(BAUD2UBR(57600));
    etimer_set(&et,PERIOD);
    {
          while(1)
          { 
            PROCESS_WAIT_EVENT();
            if(ev ==serial_line_event_message)
            {
            leds_toggle(LEDS_RED);
            }       
            if(etimer_expired(&et))
            {
            printf("sys get ver\r\n");
            leds_toggle(LEDS_GREEN);
            etimer_reset(&et);
            }
          }
    }
  PROCESS_END();
}

The write-part is working , but the reading-part not.The serial_line_event_message is never called. I commented those line in the contiki-z1-main file:

//#if !NETSTACK_CONF_WITH_IPV4 && !NETSTACK_CONF_WITH_IPV6
  uart0_set_input(serial_line_input_byte);
  serial_line_init();
//#endif

Does anyone knows where is my error? thanks!


Solution

  • The problem is solved (I made some changes in the main while programming). To make this code work, I simply replaced the main file by the original version.