String tokens and associated string
i adding function mrmp periodically poll new records bridge controller , send email selected records using xport.
i send... ig1v#rg1vr2,970,48#
a typical record reply this...
r1gvr,970,48,5,77,0,0,1239762623,65#
using limited ram , string functions in stdlib.h trying parse string , associate tokens (77) expanded strings mean reader of email message.
for example, token "77" (ascii 's') means "stopped"
so trying various methods create function takes token , returns address of associated string.
i have spent many hours googlng examples, success.
is there better, smaller more efficient way accomplish this?
i pass address of array[] , walk index. far haven't solved syntax.
if woul learn more mrmp...
http://www.mmcs.com/~gmatthews/fav1-00012d85/s00050299-00050299
i send... ig1v#rg1vr2,970,48#
a typical record reply this...
r1gvr,970,48,5,77,0,0,1239762623,65#
using limited ram , string functions in stdlib.h trying parse string , associate tokens (77) expanded strings mean reader of email message.
for example, token "77" (ascii 's') means "stopped"
so trying various methods create function takes token , returns address of associated string.
i have spent many hours googlng examples, success.
is there better, smaller more efficient way accomplish this?
i pass address of array[] , walk index. far haven't solved syntax.
code: [select]
#include <stdlib.h>
char stdata[64] = "970,0,5,97,1,2,-1234567890,151"; // testing
// token $ expanded string null token $ expanded string null token $ expanded string null
char* stcontrollertokens[] = {
"2", "s$slave", "g$garage\0b$house", "p$pond"};
char* stalarmtokens[] = {
"7", "a$triggered", "h$horn sounding", "s$stopped", "o$delay entry", "i$instant", "m$maintenance", "c$close"};
char* stalarmlooptokens[] = {
"7", "2$instant-windows", "3$always-glass", "4$delay-door", "5$interior", "6$button-press", "7$motion" "11$set", "15$heat-fire\0"};
char stunknown[] = "unknown";
char *parmadd=0; // parameter address pointer
char *nextparmadd=0; // next parameter address
long parameterlond=0;
int chksum=0; // checksum last parameter
/* sources 2 dimentional array of strings.
format...
token$expanded string\0 token$expanded string\0 token$expanded string\0
token 1 or more characters ending '$' following null terminated expanded string.
parmadd address of expanded string.
*/
char* findstralarmloop(const char *find) // pointer address, parameter string delimiter
{
int e;
e = atoi(stalarmtokens[0]); // 0th element holds number of tokens
for (int = 1; <= e; i++)
{
parmadd=(strstr(stalarmtokens[i],find));
if(parmadd)
{
return parmadd+strlen(find);
}
}
}
void setup()
{
serial.begin(9600);
}
void loop()
{
serial.print(findstralarmloop("s$"));
delay(200);
}
if woul learn more mrmp...
http://www.mmcs.com/~gmatthews/fav1-00012d85/s00050299-00050299
Arduino Forum > Forum 2005-2010 (read only) > Software > Syntax & Programs > String tokens and associated string
arduino
Comments
Post a Comment