Forums > MaxMSP

parsing simple HTML

August 2, 2011 | 12:21 pm

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!

below is what i got so far:

– Pasted Max Patch, click to expand. –

August 3, 2011 | 12:04 pm

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…

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.

– Pasted Max Patch, click to expand. –

August 3, 2011 | 1:02 pm

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

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.

– Pasted Max Patch, click to expand. –

August 3, 2011 | 9:34 pm

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.

– Pasted Max Patch, click to expand. –

August 4, 2011 | 7:18 am

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"

i put the HTML here: http://mikrogalleriet.net/test/arduino_website.html


August 4, 2011 | 7:18 am

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"

i put the HTML here: http://mikrogalleriet.net/test/arduino_website.html


August 4, 2011 | 10:22 pm

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.


August 4, 2011 | 10:22 pm

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.


August 5, 2011 | 6:51 am

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)

[attachment=168261,2509]


August 5, 2011 | 6:51 am

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)

[attachment=168261,2509]

Attachments:
  1. parsingerror.png

August 5, 2011 | 10:59 am

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)


August 5, 2011 | 10:59 am

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)


Viewing 12 posts - 1 through 12 (of 12 total)