1 #include <stdio.h> // perror
2 #include <stdlib.h> // exit
3 #include <unistd.h> // sleep
7 #define PUT_ERROR(s) {perror (s); exit (-1);}
12 // #define ENABLE_LOGGING
20 #include <drivers/console_switcher.h>
21 #include <misc/logger.h>
23 #define LOG_DEVICE LOG_ETHERNET
29 printf(" press Enter...");
36 frescan_send_params_t params;
39 frescan_init_params_t init_params;
41 init_params.net = NETWORK;
42 init_params.node = LOCAL_NODE;
43 init_params.tx_fp_max_prio = 10;
44 init_params.rx_num_of_channels = 5;
45 init_params.rx_channel_max_prio = NULL;
49 ret = logger_init(LOG_DEVICE);
52 printf("Changing to membuffer console\n");
53 MEMBUFFER_CONSOLE_INIT();
57 ret = frescan_init(&init_params);
58 if (ret != 0) PUT_ERROR ("could not init FRESCAN");
60 printf("FRESCAN initialized (local node: %u)\n", LOCAL_NODE);
65 params.flags = FRESCAN_FP | FRESCAN_ASYNC;
70 for (i=0; i<=2; i++) {
71 written = snprintf(msg, sizeof(msg), "his number is... %d", i);
72 ret = frescan_send(¶ms, (uint8_t *)msg, written);
73 if (ret != 0) PUT_ERROR ("could not send message\n");
74 printf("SENT: %d\n", i);
77 while (logger_manual_call() > 0);
91 frescan_recv_params_t params;
95 frescan_init_params_t init_params;
98 init_params.net = NETWORK;
99 init_params.node = LOCAL_NODE;
100 init_params.tx_fp_max_prio = 10;
101 init_params.rx_num_of_channels = 5;
102 init_params.rx_channel_max_prio = NULL;
104 ret = frescan_init(&init_params);
105 if (ret != 0) PUT_ERROR ("could not init FRESCAN");
107 printf("FRESCAN initialized (local node: %u)\n", LOCAL_NODE);
109 params.net = NETWORK;
111 params.flags = FRESCAN_SYNC;
114 printf("RECEIVING...\n");
115 ret = frescan_recv(¶ms, (uint8_t *)msg, sizeof(msg),
116 &recv_bytes, &from, &prio);
117 if (ret != 0) PUT_ERROR ("could not send message");
119 msg[recv_bytes] = '\0';
120 printf("RECEIVED: %s with prio:%u from:%u\n", msg, prio, from);
122 // for (i=0; i<recv_bytes; i++) {
123 // printf("msg[%d] = 0x%X;\n", i, msg[i]);