Working with uint8_t encoded data (virtualwire)
as usual have managed solve problems while failing solve others. stuck on translation of data. building cheap tranceiver using radio transmitters , receivers have got sparkfun. able send address , receive addresses of others transmitting theirs.
the trick trying pull off in larger view want send tranceivers each individual tranceiver can see. able send data variables follows- 0:1,2 0 tranceiver can see 1 , 2. however, 1 , 2 hard coded not variable address.
i having trouble parsing uint8_t data receive. have worked out script translate string integers , delineation. cannot uint8_t data convert char can strcat string parsing int's.
here script needs go.
i have tried many things (removed because failed). typically error either cannot convert uint8_t const *char or cannot convert char *char.
what proper method parsing uint8_t char. far can print msg var cannot useful it.
thanks
the trick trying pull off in larger view want send tranceivers each individual tranceiver can see. able send data variables follows- 0:1,2 0 tranceiver can see 1 , 2. however, 1 , 2 hard coded not variable address.
i having trouble parsing uint8_t data receive. have worked out script translate string integers , delineation. cannot uint8_t data convert char can strcat string parsing int's.
here script needs go.
code: [select]
char msg[30]="";
///////////////////////////////////////////receive data
void rx(){
// vw_rx_start();
// serial.println("receive");//debug only
uint8_t buf[vw_max_message_len];
uint8_t buflen = vw_max_message_len;
vw_wait_rx();
if (vw_get_message(buf, &buflen)) // check see if has been received
{
for (int i=0;i<buflen;i++) msg[i]=0;
int i;
// message checksum received.
serial.print("got: ");
(int = 0; < buflen; i++)
{
serial.print(buf[i], byte);
msg[i]=buf[i];
}
serial.println();
}
}i have tried many things (removed because failed). typically error either cannot convert uint8_t const *char or cannot convert char *char.
what proper method parsing uint8_t char. far can print msg var cannot useful it.
thanks
thanks anyways, need write problem out figure out. it clicked not long after posted this. here answer allowing receive data transmitter , convert integers after creating single string data.
code: [select]
///////////////////////////////////////////receive data
void rx(){
// vw_rx_start();
// serial.println("receive");//debug only
uint8_t buf[vw_max_message_len];
uint8_t buflen = vw_max_message_len;
vw_wait_rx();
if (vw_get_message(buf, &buflen)) // check see if has been received
{
for (int i=0;i<buflen;i++) msg[i]=0;
{
int i;
char vbuff[30]="";
// message checksum received.
// serial.print("got: ");
for (int = 0; < buflen; i++)
{
// serial.print(buf[i], byte);
msg[i]=buf[i];
}
serial.println();
//create string received data
strcat(vbuff, msg);
//convert individual integers char
char *rxstring = vbuff;
char *str[30];
int convert[30];
int j=0;
while((str[j] = strtok_r(rxstring, ":,", &rxstring)) !=null){ // delimiter : , ,
convert[j]=atoi(str[j]);
if(j==0){
serial.print("sensor= ");
serial.println(convert[j]);
}else{
serial.print("near= ");
serial.println(convert[j]);
}
j++;
}
}
}
}
Arduino Forum > Forum 2005-2010 (read only) > Software > Syntax & Programs > Working with uint8_t encoded data (virtualwire)
arduino
Comments
Post a Comment