Hi,
I am working on a task to have a timestamp every time my shimmer2 send data
via Bluetooth, but my timestamp data doesn't seem to give me correct
timestamp,
This is a part of my code I have tried.
void preparePacket() {
uint16_t *p_packet, *p_ADCsamples, crc, *ADC;
uint32_t p8_packet[2];
int data;
if(current_buffer == 0) {
p_ADCsamples = &sbuf0[0];
p8_packet[0] = timestamp0 & 0xff;
p8_packet[1] = (timestamp0 >> 8) & 0xff;
current_buffer = 1;
//ADC = &buf0[0];
//tx_packet[5] = timestamp0 & 0xff;
//tx_packet[6] = (timestamp0 >> 8) & 0xff;
}
else {
p_ADCsamples = &sbuf1[0];
p8_packet[0] = timestamp1 & 0xff;
p8_packet[1] = (timestamp1 >> 8) & 0xff;
current_buffer = 0;
}
sprintf(buffer, "X%04dY%04dZ%04dU%04dP%04dT%dt%d\n",
calc_integer(p_ADCsamples++),calc_integer(p_ADCsamples++),
calc_integer(p_ADCsamples++),calc_integer(p_ADCsamples++),speed_counter,calc_integer(p8_packet[0]),calc_integer(p8_packet[1]));
atomic speed_counter = 0;
}
int calc_integer(uint8_t *ptr) {
int int_value;
int_value = 0;
int_value=(int)(ptr[0])|((ptr[1])<<8);
return int_value;
}
async event void DMA0.transferDone(error_t success) {
if(current_buffer == 0){
call DMA0.repeatTransfer((void*)ADC12MEM0_, (void*)sbuf1,
NBR_ADC_CHANS);
atomic timestamp1 = call LocalTime.get();
current_buffer = 1;
}
else {
call DMA0.repeatTransfer((void*)ADC12MEM0_, (void*)sbuf0,
NBR_ADC_CHANS);
atomic timestamp0 = call LocalTime.get();
current_buffer = 0;
}
post sendSensorData();
}
_______________________________________________
Tinyos-help mailing list
[email protected]
https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help