-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathuarts_test.c
55 lines (47 loc) · 1.16 KB
/
uarts_test.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#include <stdio.h>
#include <string.h>
#include "contiki.h"
#include "mc1322x.h"
#include "contiki-uart.h"
#include "dev/leds.h"
#include "uart2_handler.h"
#include "dev/serial-line.h"
#include "commands.h"
#include "shell.h"
/*---------------------------------------------------------------------------*/
PROCESS(uarts_test, "UART2 TEST");
/*---------------------------------------------------------------------------*/
#define FLASH_LED(l) {leds_on(l); clock_delay_msec(50); leds_off(l); clock_delay_msec(50);}
static char u1tou2;
// tester thread
PROCESS_THREAD(uarts_test, ev, data)
{
static struct etimer timer;
static char msg[] = "Data\n";
char* ptr = msg;
PROCESS_BEGIN();
u1tou2 = 0;
while(1)
{
PROCESS_WAIT_EVENT();
if(ev == serial_line1_event_message)
{
FLASH_LED(LEDS_GREEN);
printf("UART1 received: %s\n\r", data);
//if(u1tou2)
//process_start(&uart2_send, data);
}
if(ev == serial_line2_event_message)
{
printf("UART2 received: %s\n\r", data);
//for router
//shell_input(data, strlen(data));
}
}
PROCESS_END();
}
void
uarts_test_init()
{
process_start(&uarts_test, NULL);
}