mirror of
https://github.com/oliverschmidt/contiki.git
synced 2024-12-22 10:30:13 +00:00
Added a crude hack for drawing lines between nodes
This commit is contained in:
parent
2886e03f57
commit
f5b08ff115
@ -30,13 +30,14 @@
|
||||
*
|
||||
* Author: Adam Dunkels <adam@sics.se>
|
||||
*
|
||||
* $Id: contiki-main.c,v 1.26 2008/01/14 09:38:16 adamdunkels Exp $
|
||||
* $Id: contiki-main.c,v 1.27 2008/02/03 20:49:50 adamdunkels Exp $
|
||||
*/
|
||||
|
||||
#include "contiki.h"
|
||||
#include "contiki-net.h"
|
||||
#include "contiki-lib.h"
|
||||
|
||||
#include "dev/serial.h"
|
||||
#include "net/rime.h"
|
||||
|
||||
#ifdef __CYGWIN__
|
||||
@ -54,6 +55,10 @@
|
||||
#include "ether.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#ifndef HAVE_SNPRINTF
|
||||
int snprintf(char *str, size_t size, const char *format, ...);
|
||||
#endif /* HAVE_SNPRINTF */
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <sys/select.h>
|
||||
#include <unistd.h>
|
||||
|
@ -24,7 +24,7 @@
|
||||
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
|
||||
* OF SUCH DAMAGE.
|
||||
*
|
||||
* $Id: display.c,v 1.7 2008/01/14 09:38:16 adamdunkels Exp $
|
||||
* $Id: display.c,v 1.8 2008/02/03 20:49:50 adamdunkels Exp $
|
||||
*
|
||||
* Author: Adam Dunkels <adam@sics.se>
|
||||
*
|
||||
@ -207,6 +207,21 @@ display_redraw(void)
|
||||
y * SCALE + 2,
|
||||
4, 4);
|
||||
}
|
||||
if(n->linex != 0 && n->liney != 0) {
|
||||
gdk_draw_line(pixmap,
|
||||
green,
|
||||
x * SCALE,
|
||||
y * SCALE,
|
||||
n->linex * SCALE,
|
||||
n->liney * SCALE);
|
||||
gdk_draw_rectangle(pixmap,
|
||||
green,
|
||||
TRUE,
|
||||
n->linex * SCALE - 2,
|
||||
n->liney * SCALE - 2,
|
||||
4, 4);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -30,7 +30,7 @@
|
||||
*
|
||||
* Author: Adam Dunkels <adam@sics.se>
|
||||
*
|
||||
* $Id: ether.c,v 1.11 2008/01/14 09:38:16 adamdunkels Exp $
|
||||
* $Id: ether.c,v 1.12 2008/02/03 20:49:50 adamdunkels Exp $
|
||||
*/
|
||||
/**
|
||||
* \file
|
||||
@ -86,6 +86,7 @@ static clock_time_t timer;
|
||||
|
||||
static int s, sc;
|
||||
|
||||
#define PTYPE_NONE 0
|
||||
#define PTYPE_CLOCK 1
|
||||
#define PTYPE_DATA 2
|
||||
#define PTYPE_SENSOR 3
|
||||
@ -100,6 +101,7 @@ struct ether_hdr {
|
||||
int type;
|
||||
struct sensor_data sensor_data;
|
||||
clock_time_t clock;
|
||||
int linex, liney;
|
||||
int signal;
|
||||
int srcx, srcy;
|
||||
int srcpid;
|
||||
@ -121,6 +123,9 @@ static int num_drops = 0;
|
||||
#include <sys/time.h>
|
||||
|
||||
static struct timeval t1;
|
||||
|
||||
static int linex, liney;
|
||||
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
void
|
||||
ether_print_stats(void)
|
||||
@ -336,6 +341,7 @@ ether_server_poll(void)
|
||||
perror("ether_poll: read");
|
||||
return;
|
||||
}
|
||||
nodes_set_line(hdr->srcx, hdr->srcy, hdr->linex, hdr->liney);
|
||||
switch(hdr->type) {
|
||||
case PTYPE_DATA:
|
||||
PRINTF("ether_poll: read %d bytes from (%d, %d)\n",
|
||||
@ -538,7 +544,8 @@ ether_send(char *data, int len)
|
||||
/* hdr->srcnodetype = node.type;*/
|
||||
hdr->srcid = node.id;
|
||||
|
||||
|
||||
hdr->linex = linex;
|
||||
hdr->liney = liney;
|
||||
node_send_packet(tmpbuf, len + sizeof(struct ether_hdr));
|
||||
|
||||
return UIP_FW_OK;
|
||||
@ -556,6 +563,8 @@ ether_set_leds(int leds)
|
||||
hdr.leds = leds;
|
||||
/* hdr.srcnodetype = node.type;*/
|
||||
hdr.srcid = node.id;
|
||||
hdr.linex = linex;
|
||||
hdr.liney = liney;
|
||||
|
||||
node_send_packet((char *)&hdr, sizeof(struct ether_hdr));
|
||||
|
||||
@ -572,6 +581,8 @@ ether_set_text(char *text)
|
||||
strncpy(hdr.text, text, NODES_TEXTLEN);
|
||||
/* hdr.srcnodetype = node.type;*/
|
||||
hdr.srcid = node.id;
|
||||
hdr.linex = linex;
|
||||
hdr.liney = liney;
|
||||
|
||||
node_send_packet((char *)&hdr, sizeof(struct ether_hdr));
|
||||
|
||||
@ -644,3 +655,22 @@ ether_send_serial(char *str)
|
||||
send_packet((char *)&hdr, sizeof(struct ether_hdr), nodes_base_node_port);
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
void
|
||||
ether_set_line(int x, int y)
|
||||
{
|
||||
struct ether_hdr hdr;
|
||||
|
||||
linex = x;
|
||||
liney = y;
|
||||
|
||||
|
||||
hdr.srcx = node.x;
|
||||
hdr.srcy = node.y;
|
||||
hdr.type = PTYPE_NONE;
|
||||
hdr.srcid = node.id;
|
||||
hdr.linex = linex;
|
||||
hdr.liney = liney;
|
||||
|
||||
node_send_packet((char *)&hdr, sizeof(struct ether_hdr));
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
@ -30,7 +30,7 @@
|
||||
*
|
||||
* Author: Adam Dunkels <adam@sics.se>
|
||||
*
|
||||
* $Id: ether.h,v 1.7 2008/01/14 09:38:16 adamdunkels Exp $
|
||||
* $Id: ether.h,v 1.8 2008/02/03 20:49:50 adamdunkels Exp $
|
||||
*/
|
||||
#ifndef __ETHER_H__
|
||||
#define __ETHER_H__
|
||||
@ -83,4 +83,7 @@ void ether_set_drop_probability(double p);
|
||||
|
||||
void ether_print_stats(void);
|
||||
|
||||
void ether_set_line(int x, int y);
|
||||
|
||||
|
||||
#endif /* __ETHER_H__ */
|
||||
|
@ -30,7 +30,7 @@
|
||||
*
|
||||
* Author: Adam Dunkels <adam@sics.se>
|
||||
*
|
||||
* $Id: nodes.c,v 1.6 2008/01/14 09:38:16 adamdunkels Exp $
|
||||
* $Id: nodes.c,v 1.7 2008/02/03 20:49:50 adamdunkels Exp $
|
||||
*/
|
||||
#include <signal.h>
|
||||
#include <stdio.h>
|
||||
@ -116,6 +116,20 @@ nodes_set_text(int x, int y, char *text)
|
||||
}
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
void
|
||||
nodes_set_line(int x, int y, int linex, int liney)
|
||||
{
|
||||
int i;
|
||||
|
||||
for(i = numnodes; i >= 0; --i) {
|
||||
if(nodes[i].x == x && nodes[i].y == y) {
|
||||
nodes[i].linex = linex;
|
||||
nodes[i].liney = liney;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
struct nodes_node *
|
||||
nodes_find_pid(pid_t pid)
|
||||
{
|
||||
|
@ -30,7 +30,7 @@
|
||||
*
|
||||
* Author: Adam Dunkels <adam@sics.se>
|
||||
*
|
||||
* $Id: nodes.h,v 1.4 2008/01/14 09:38:16 adamdunkels Exp $
|
||||
* $Id: nodes.h,v 1.5 2008/02/03 20:49:50 adamdunkels Exp $
|
||||
*/
|
||||
#ifndef __NODES_H__
|
||||
#define __NODES_H__
|
||||
@ -44,6 +44,7 @@ void nodes_add(int pid, int x, int y, int port, int id);
|
||||
void nodes_kill(void);
|
||||
void nodes_set_leds(int x, int y, int leds);
|
||||
void nodes_set_text(int x, int y, char *text);
|
||||
void nodes_set_line(int x, int y, int linex, int liney);
|
||||
|
||||
void nodes_done(int id);
|
||||
|
||||
@ -58,6 +59,7 @@ struct nodes_node {
|
||||
int port;
|
||||
int leds;
|
||||
int done;
|
||||
int linex, liney;
|
||||
char text[NODES_TEXTLEN];
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user