help on strtok() function


i need write code count through number of ## pairs (from webpage) extract following information (print out on serial monitor ):
'scanning', (4th entry), signal esno (11th entry), rx power (14th entry) ; note entires start @ 0.

(this used extract info webpage  words variables e.g the  (4th entry )may go "scanning" "fixed".)

code: [select]


void setup() {
 // put setup code here, run once:
serial.begin(9600);
}

void loop() {

char str[] = "0.0.0.0##00:a0:bc:4b:38:64##ut_2.2.0.3.0##ut_9 p3_v3##scanning##12,781##1,777,967##9,914##
1,719,966##000:00:00:00##0##0.0##10%##633715420054##0.0##100%##n/a##0%##inactive##
n/a##0%##single##1119507013##images/modem_status_005_scanning.png##/images/satellite_status_orange.png
##0##<p style="color:red">disconnected</p>##<p style="color:black">n/a</p>##0.00%##0.00%
##0.00s##0%##0################4####0%##0##<p style="color:red">disconnected</p>##0.0 gb##eutelsat##fixed##0##########"

char delim[] = "#";
char* token;

for (token = strtok(str, delim); token; token = strtok(null, delim))
{
serial.println( ("token=%s\n", token));


}
}




this prints out @ moment:


0.0.0.0
00:a0:bc:4b:38:64
ut_2.2.0.3.0
ut_9 p3_v3
scanning
4,188
291,807
3,232
367,961
000:00:00:00
0
0.0
10%
633715420054
0.0
100%
n/a
0%
inactive
n/a
0%
single
1119507013
images/modem_status_005_scanning.png
/images/satellite_status_orange.png
0
<p style="color:red">disconnected</p>
<p style="color:black">n/a</p>
0.00%
0.00%
0.00s
0%
0
4
0%
0
<p style="color:red">disconnected</p>
0.0 gb
eutelsat
fixed

are trying determine string contains "scanning"? if so, strtok() not correct function. strstr() is.


Arduino Forum > Using Arduino > Programming Questions > help on strtok() function


arduino

Comments

Popular posts from this blog

DHT11 Time out error using v0.4.1library

Sketch upload fails with Java error (___REMOVE___/bin/avrdude)!

Arduino Uno + KTY81/210 temperature sensor