Project

General

Profile

Revision 201

Stuff!

View differences:

data_requests.c
1 1
#include "data_requests.h"
2 2
#include <stdlib.h>
3 3
#include <stdio.h>
4
#include <pthread.h>
4 5
#include "../../../libwireless/lib/wireless.h"
5 6

  
6 7
PacketGroupHandler pgh;
8
pthread_t* dr_thread;
7 9

  
8 10
void receive_handle(char type, int source, unsigned char* packet, int length);
9 11

  
......
29 31

  
30 32

  
31 33
void request_bom_data(int robot_id){
32
  wl_send_robot_to_robot_packet(DATA_REQUEST_GROUP,BOM_TYPE,NULL,0,robot_id,0);
34
  wl_send_robot_to_robot_global_packet(DATA_REQUEST_GROUP,BOM_TYPE,NULL,0,robot_id,0);
33 35
}
34 36

  
35 37
void request_IR_data(int robot_id){
36
  wl_send_robot_to_robot_packet(DATA_REQUEST_GROUP,IR_TYPE,NULL,0,robot_id,0);
38
  wl_send_robot_to_robot_global_packet(DATA_REQUEST_GROUP,IR_TYPE,NULL,0,robot_id,0);
37 39
}
38 40

  
39 41
void request_encoder_data(int robot_id){
40
  wl_send_robot_to_robot_packet(DATA_REQUEST_GROUP,ENCODER_TYPE,NULL,0,robot_id,0);
42
  wl_send_robot_to_robot_global_packet(DATA_REQUEST_GROUP,ENCODER_TYPE,NULL,0,robot_id,0);
41 43
}
42 44

  
43
void receive_handle(char type, int source, unsigned char* packet, int length){
45
void* pthread_handle(void* arg){
46
  
47
  RawData* data = (RawData*)arg;
48
  unsigned char* packet = data->packet;
49
  int length = data->length;
50
  char type = data->type;
51
  
44 52
  int i=0;
45 53
  BomNode* head;
46 54
  switch(type){
......
84 92
      break;
85 93
  }
86 94
}
95
void receive_handle(char type, int source, unsigned char* packet, int length){
96
  RawData data;
97
  data.packet=packet;
98
  data.source=source;
99
  data.length=length;
100
  data.type=type;
101
  pthread_create(dr_thread,NULL,pthread_handle,(void*)&data);
102
}

Also available in: Unified diff