parsing simple HTML

jsr_'s icon

hello forum,

i am trying to parse a simple HTML document generated on an arduino with a serial shield. the HTML is super simple: it contains the state of three buttons, each with the prefix "B1:","B2:" or "B3:", followed by either '1' or '0' depending on the button state.

so when the arduino IP is typed in on a standard browser this is what loads:

B1:1 B2:1 B3:1

i know i can parse with 'regexp', but i really dont get the perl syntax at all :( so i was hoping someone could help me parse this. thanks!

Max Patch
Copy patch and select New From Clipboard in Max.

below is what i got so far:

jsr_'s icon

please help. i am stuck.

as i am defining the webserver side i can make the arduino make a simple comma seperated list, 3 bytes even. i am just very unfamiliar with max and handling string / documente in this environment that i really don't know how to progress...

Max Patch
Copy patch and select New From Clipboard in Max.

what i tried now is to make a website that only contains the 3 0/1s seperated by spaces. i can sort a simple message, say "1 0 1" the way i would like to sort the HTML download. but i can't pass jit.textfile to the 'unpack' object. at least it gives no result.

nnimar's icon

About jit.uldl and regexp, search the forum and look for Luke Hall !

Max Patch
Copy patch and select New From Clipboard in Max.

With Arduino and multiple sensors, I use a letter + the analog number (a10, b50, ...). It's simple and works well. Here is the regexp for this.

Luke Hall's icon
Max Patch
Copy patch and select New From Clipboard in Max.

If the HTML ends up looking like the example I've included in the comment box then the following patch should work for you. If not then it would be helpful if you gave us an idea of the exact HTML content the page will be delivering.

jsr_'s icon

thanks for the help!
sorry for not including the website, i can see how that would have clarified things.
strange thing is, this still doesn't work for me. even when making a website which matches your example HTML in the comment field exactly? when double clicking 'jit.textfile' i can see the file gets downloaded correctly....?

the max window gives me:
fromsymbol: doesn't understand "int"
flonum: doesn't understand "B"
fromsymbol: doesn't understand "int"
fromsymbol: doesn't understand "float"

Luke Hall's icon

Using the new URL everything works fine for me with the patch you posted. Try placing a message box or a [print] object after the [fromsymbol], maybe you have something grouping the messages in the wrong order.

jsr_'s icon

strange indeed.... its still not working for me?
i put a [print] in there. this is what my patch and max window looks like (attached)

jsr_'s icon

ok so i just upgraded to the last version of max and now it works perfectly. thanks for all the help! (i was on 5.1.0 before)

Java Script's icon

I am learning the new and best concept from this site. you can too learn form here -- > http://www.brotsky.tv/2014/10/17/building-a-website-part-10-intro-to-jquery/