Project

General

Profile

Revision 203

Added the com_port functions to trunk

View differences:

trunk/code/projects/libwireless/lib/wireless.h
126 126
int wl_get_channel(void);
127 127
/**@brief Get the 16-bit address of the XBee module **/
128 128
unsigned int wl_get_xbee_id(void);
129
/**@brief Set the com port on a computer, undefined on the robot.**/
130
void wl_set_com_port(char* port);
129 131

  
130 132
/** @} **/ // end defgroup
131 133

  
trunk/code/projects/libwireless/lib/xbee.c
67 67
/*Global Variables*/
68 68

  
69 69
#ifndef ROBOT
70
char* xbee_com_port;
70 71
int xbee_stream;
71 72
pthread_t* xbee_listen_thread;
72 73
#endif
......
144 145
	#endif
145 146
	sei();
146 147
	#else
147
	xbee_stream = open(XBEE_PORT, O_RDWR);
148
	xbee_stream = open(xbee_com_port, O_RDWR);
148 149
	if (xbee_stream == -1 || lockf(xbee_stream, F_TEST, 0) != 0)
149 150
		xbee_stream = open(XBEE_PORT2, O_RDWR);
150 151
	if (xbee_stream == -1 || lockf(xbee_stream, F_TEST, 0) != 0)
151 152
	{
152
		printf("Failed to open connection to XBee.\r\n");
153
		printf("Failed to open connection to XBee on port %s\r\n",xbee_com_port);
153 154
		exit(0);
154 155
	}
155 156
	lockf(xbee_stream, F_LOCK, 0);
......
748 749
	return xbee_address;
749 750
}
750 751

  
752
#ifndef ROBOT
753
void xbee_set_com_port(char* port){
754
  //printf("Port being passed is %s\n",port);
755
  xbee_com_port = malloc(strlen(port));
756
  strcpy(xbee_com_port,port); 
757
}
758
#endif
759

  
trunk/code/projects/libwireless/lib/xbee.h
70 70
int xbee_get_channel(void);
71 71
/**@brief Get the XBee's 16-bit address **/
72 72
unsigned int xbee_get_address(void);
73
/**@brief Set the com port on a computer, undefined on the robot**/
74
void xbee_set_com_port(char* port);
73 75

  
74 76
/**@}**/ //end defgroup
75 77

  
trunk/code/projects/libwireless/lib/wireless.c
404 404
	return;
405 405
}
406 406

  
407

  
408
#ifndef ROBOT
409
void wl_set_com_port(char* port){
410
  xbee_set_com_port(port);
411
}
412
#endif
413

  
414

  

Also available in: Unified diff