Hey Johannes,
I guess you mean [list fromsymbol] to convert symbols to their byte-representation ? ;) ++
Jack
Le 24/01/2019 à 18:07, IOhannes m zmölnig a écrit :
On 1/24/19 5:33 PM, RT wrote:
I'm trying to turn on and off a device using Pd by sending a URL. At the moment to turn the device on I just type in a url in the browser and to turn it off I type in another one url . To turn the device on I send http://192.168.1.123/relay/0/?turn=on To turn the device off I send http://192.168.1.123/relay/0/?turn=off
I can connect to the device using *connect* and *netsend* but I couldn't find an example / correct syntax / format on how to send the required url out of Pd.
This is what I'm using below
#N canvas 162 516 623 513 10; #X msg 535 750 ; pd dsp 1; #X obj 536 724 loadbang; #X obj 248 207 netsend; #X msg 272 110 disconnect; #X floatatom 218 272 0 0 0 0 - - -; #X obj 280 275 print; #X msg 403 171 send /relay/0/?turn=off; #X msg 404 136 send /relay/0/?turn=on;
that won't work. when using [send ...(, Pd will use FUDI [1] at the application layer. but you want to communicate with a webserver, so you need to use HTTP as the application layer protocol. the *actual* string (in HTTP) you want to send is something like:
GET /relay/0/?turn=off HTTP/1.0
you can use [netsend] to send raw bytes (using the "-b" mode). you also can use [list totext] to convert symbols to their byte-representation (translating the characters to ASCII). since [list totext] only takes single symbols (and not entire messages), an even easier way would be to use [fudiformat], which will convert a message into it's FUDI representation (with trailing semicolon, and everything). just strip of the unwanted characters (the trailing semicolon), and append proper CRLF terminators and you should be done.
something like:
| [symbol on] | [GET /relay/0/?turn=$1 HTTP/1.0( | [fudiformat] | [t l l] | [list length] | [- 2] [list split] | [list append 13 10 13 10] | [list prepend send] | [list trim] | [netsend -b]
fgmadsr IOhannes
[1] https://en.wikipedia.org/wiki/FUDI
Pd-list@lists.iem.at mailing list UNSUBSCRIBE and account-management -> https://lists.puredata.info/listinfo/pd-list