Beispiel #1
0
/*---------------------------------------------------------------------------*/
void
putchar(char c)
{
#if SLIP_ARCH_CONF_ENABLE
#define SLIP_END     0300
  static char debug_frame = 0;

  if(!debug_frame) {            /* Start of debug output */
    uart1_writeb(SLIP_END);
    uart1_writeb('\r');     /* Type debug line == '\r' */
    debug_frame = 1;
  }
#endif

  uart1_writeb((char)c);

#if SLIP_ARCH_CONF_ENABLE
  /*
   * Line buffered output, a newline marks the end of debug output and
   * implicitly flushes debug output.
   */
  if(c == '\n') {
    uart1_writeb(SLIP_END);
    debug_frame = 0;
  }
#endif
}
Beispiel #2
0
/*---------------------------------------------------------------------------*/
#if ! WITH_UIP /* If WITH_UIP is defined, putchar() is defined by the SLIP driver */
int
putchar(int c)
{
  uart1_writeb((char)c);
  if(((char)c)=='\n')
	uart1_writeb('\r');
  return c;
}
Beispiel #3
0
/*---------------------------------------------------------------*/
PROCESS_THREAD(null_app_process,ev,data)
{
	PROCESS_BEGIN();
	printf("Hello world\n");
	printf("This node has id %u\n",node_id);

	uint8_t i;
	for(i = 0; i < 256; i++)
	{
		//printf("%u,",i);
		uart1_writeb(i);
		uart1_writeb('\n');
	}

	PROCESS_END();
}
Beispiel #4
0
int putchar(int c)
{
#if LWB_HSLP

    if(!ui8_dbg_frm_start) {
        // Start of debug printf
        ui8_dbg_frm_start = 1;
        lwb_hslp_write_start();

        LWB_HSLP_SET_PKT_MAIN_TYPE(LHSLP_PKT_TYPE_DBG_DATA, ui8_pkt_type);
        LWB_HSLP_SET_PKT_SUB_TYPE(LHSLP_PKT_SUB_TYPE_DBG_DATA, ui8_pkt_type);
        lwb_hslp_write_byte(ui8_pkt_type);
    }

    lwb_hslp_write_byte(c);

    if (c == '\n') {
        lwb_hslp_write_end();
        ui8_dbg_frm_start = 0;
    }

#else
    uart1_writeb((char)c);
#endif
    return c;
}
/* TX function for UART1 */
static void 
string2uart1(uint8_t *c)
{
  while (*c!= '\0') {
    uart1_writeb(*c);
    c++;
  }
}
Beispiel #6
0
int
putchar(int c)
{
  uart1_writeb((char)c);

  lcd_write_char((char)c);
  return c;
}
Beispiel #7
0
//APP Callback function
static void app_recv(void)
{
	PROCESS_CONTEXT_BEGIN(&null_app_process);

	uint8_t *data = packetbuf_dataptr();

	rimeaddr_t *sent_sn_addr = packetbuf_addr(PACKETBUF_ADDR_SENDER);

	uint8_t rx_sn_id = sent_sn_addr->u8[0];
	uint8_t pkt_seq = packetbuf_attr(PACKETBUF_ATTR_PACKET_ID);
	uint8_t payload_len = packetbuf_datalen();
/*
	uart1_writeb(rx_sn_id);
	uart1_writeb(pkt_seq);
	uart1_writeb(payload_len);
*/
	if(node_id != 0)
	{
		printf("%u,%u,%u\n",rx_sn_id,pkt_seq,payload_len);
	}
	else
	{
		//printf("%u,%u,%u,",rx_sn_id,pkt_seq,payload_len);
		putchar(rx_sn_id);
		putchar(pkt_seq);
		putchar(payload_len);
		
		//printf("%u",rx_sn_id);
		uint8_t i = 0;
	
		for(i = 0; i < (payload_len); i++)
		{
			//printf("%d,",((data[2*i+1]<<8)|data[2*i]));
			putchar(data[i]);
		}

	
	}

/*
	for(i = 0; i < payload_len; i++)
	{
		uart1_writeb(data[i]);
	}
*/
	uart1_writeb('\n');


	PROCESS_CONTEXT_END(&null_app_process);

}
Beispiel #8
0
void print_mpu_sample_acc_gyro(mpu_data_acc_gyro_union *samples)
{
    uart1_writeb((unsigned char)samples->reg.x_h);
    uart1_writeb((unsigned char)samples->reg.x_l);
    uart1_writeb((unsigned char)samples->reg.y_h);
    uart1_writeb((unsigned char)samples->reg.y_l);
    uart1_writeb((unsigned char)samples->reg.z_h);
    uart1_writeb((unsigned char)samples->reg.z_l);
}
Beispiel #9
0
/*---------------------------------------------------------------------------*/
static int
prepare(const void *payload, unsigned short payload_len)
{
	unsigned char txBuf[108]; // 108 is the maximum buffer size needed
	int ptr;
	unsigned char chksum;

	/* drop the packet if payload is bigger than max XBee packet size */
	if(payload_len > XBEE_PACKET_SIZE)
	{
		/* loop forever for debug purpose */
		while(1);
	}

	/* Prepare XBee API frame here */
	ptr = 0;
	txBuf[ptr++] = XBEE_DELIMITER;
	txBuf[ptr++] = 0;
	txBuf[ptr++] = payload_len + 5;
	txBuf[ptr++] = XBEE_API_TX;
	txBuf[ptr++] = 0; // Frame ID 0, ACK disabled
	txBuf[ptr++] = 0xFF; // broadcast address
	txBuf[ptr++] = 0xFF; // broadcast address
	txBuf[ptr++] = 0;
	memcpy(txBuf+ptr,payload,payload_len);
	ptr += payload_len;
	/* calculate checksum */
	chksum =  0;
	for(int i=3; i<ptr;i++)
	{
		chksum += txBuf[i];
	}
	chksum = 0xFF - chksum;
	txBuf[ptr++] = chksum;
	for(int i=0; i<ptr; i++)
	{
		uart1_writeb(txBuf[i]);
	}
	return 1;
}
Beispiel #10
0
void
slip_arch_writeb(unsigned char c)
{
  uart1_writeb(c);
}
Beispiel #11
0
  __attribute__ ((weak)) putchar(int c)
{
  uart1_writeb(c);
  return c;
}
Beispiel #12
0
/*
 * Print the MPU samples
 */
void print_mpu_sample(mpu_data_union *samples)
{
    uart1_writeb((unsigned char)samples->reg.x_accel_h);
    uart1_writeb((unsigned char)samples->reg.x_accel_l);
    uart1_writeb((unsigned char)samples->reg.y_accel_h);
    uart1_writeb((unsigned char)samples->reg.y_accel_l);
    uart1_writeb((unsigned char)samples->reg.z_accel_h);
    uart1_writeb((unsigned char)samples->reg.z_accel_l);
    uart1_writeb((unsigned char)samples->reg.x_gyro_h);
    uart1_writeb((unsigned char)samples->reg.x_gyro_l);
    uart1_writeb((unsigned char)samples->reg.y_gyro_h);
    uart1_writeb((unsigned char)samples->reg.y_gyro_l);
    uart1_writeb((unsigned char)samples->reg.z_gyro_h);
    uart1_writeb((unsigned char)samples->reg.z_gyro_l);
    uart1_writeb((unsigned char)samples->reg.t_h);
    uart1_writeb((unsigned char)samples->reg.t_l);
}
Beispiel #13
0
//APP Callback function
static void app_recv(void)
{
	PROCESS_CONTEXT_BEGIN(&null_app_process);

	uint8_t *data = packetbuf_dataptr();

	rimeaddr_t *sent_sn_addr = packetbuf_addr(PACKETBUF_ADDR_SENDER);

	uint8_t rx_sn_id = sent_sn_addr->u8[0];
	uint8_t pkt_seq = packetbuf_attr(PACKETBUF_ATTR_PACKET_ID);
	uint8_t payload_len = packetbuf_datalen();

/*
	If this node is base station, then print out received messages.

	The current print function prints the output in ASCII code because
	the execution time can be reduced significantly. If the execution
	time is not a constraint, then printf should work as well.

	Please see readUSB_MPU6050_BS.py
*/

	if(node_id == 0)
	{
		//start byte
		putchar(126);
		putchar(126);

		// packet information

		packet_counter = packet_counter + 1;
		packet_counter = ((packet_counter == 10) ? 11 : packet_counter);

		 putchar(rx_sn_id);
		 putchar(packet_counter);
		 putchar(pkt_seq);
		 putchar(payload_len);
		//putchar(0);

		// //printf("%u",rx_sn_id);
		uint8_t i = 0;

		for(i = 0; i < (payload_len); i++)
		{
			//printf("%d,",((data[2*i+1]<<8)|data[2*i]));
			putchar(data[i]);
		}



	}



	uart1_writeb('\n');
	uart1_writeb('\n');


	PROCESS_CONTEXT_END(&null_app_process);

}
/*---------------------------------------------------------------------------*/
void
putchar(char c)
{
  /* UART1 used for debugging on Sensinode products. */
  uart1_writeb(c);
}
//APP Callback function
static void app_recv(void)
{
	PROCESS_CONTEXT_BEGIN(&null_app_process);

#ifdef SF_MOTE_TYPE_AP
	if(disable_sending == 0)
		return;

	//uint8_t *data = packetbuf_dataptr();

	rimeaddr_t *sent_sn_addr = packetbuf_addr(PACKETBUF_ADDR_SENDER);

	uint8_t rx_sn_id = sent_sn_addr->u8[0];
	uint8_t pkt_seq = packetbuf_attr(PACKETBUF_ATTR_PACKET_ID);
	uint8_t payload_len = packetbuf_datalen();
	uint8_t num_sample = (uint8_t)(payload_len/MPU_DATA_ACC_GYRO_SIZE);

	//only print my information
	if (rx_sn_id != MY_SN_ID)
		return;
/*
	If this node is base station, then print out received messages.

	The current print function prints the output in ASCII code because
	the execution time can be reduced significantly. If the execution
	time is not a constraint, then printf should work as well.

	Please see readUSB_MPU6050_BS.py
*/

	mpu_data_acc_gyro_union SensorData[40];
	memcpy((uint8_t*)SensorData,packetbuf_dataptr(),num_sample*MPU_DATA_ACC_GYRO_SIZE);

	uint8_t i = 0;

	for(i = 0; i < num_sample; i++)
	{
		printf("%u,%d,%d,%d",pkt_seq,SensorData[i].data.x,SensorData[i].data.y,SensorData[i].data.z);
		uart1_writeb('\n');
	}



//	uart1_writeb('\n');
//	uart1_writeb('\n');
#endif

#ifdef SF_MOTE_TYPE_SENSOR
	rimeaddr_t *sent_sn_addr = packetbuf_addr(PACKETBUF_ADDR_SENDER);

	uint8_t rx_sn_id = sent_sn_addr->u8[0];
	uint8_t pkt_seq = packetbuf_attr(PACKETBUF_ATTR_PACKET_ID);
	uint8_t payload_len = packetbuf_datalen();

	if(rx_sn_id == 0)
	{
		printf("RX packet %u and %u bytes from BS\n",pkt_seq,payload_len);
	}
	
#endif
	

	PROCESS_CONTEXT_END(&null_app_process);

}