[PD] tcpip binary into pd

Christof Ressi info at christofressi.com
Fri Feb 21 18:29:19 CET 2020


Ok, I see. I don't know the [netclient] object, but TCP networking 
objects like [netreceive -b] or [iemnet/tcpreceive] all output a stream 
of bytes. In your case, just collect the bytes into a list until you hit 
byte 13 (CR), then you can split the resulting list by byte 59 (";"). 
Now you need to convert each sublist to a proper Pd message:

Ideally, you know in advance which type you expect for each item. If you 
need an item as a Pd symbol, you can send the (sub)list to [list 
tosymbol], which will output a single Pd symbol - even if the string 
contains whitespace! If the item is numeric, you can pass it to 
[fudiparse], which wil output a Pd float.

Otherwise, you can just pass the (sub)list to [fudiparse] 
unconditionally, but a string like "Affectiva AFFDEX Landmarks" will 
yield a Pd message with 3 symbols, because whitespace is the delimiter 
for Pd message atoms. You can catch this with [list length]: if the 
resulting Pd list has more than 1 item, this means that a string 
originally contained whitespace and you can concatenate the symbols (if 
needed).

In your case, you can actually just pass the *whole* message to 
[fudiparse] and it will automatically split it into invididual Pd 
messages (because ";" happens to be the FUDI message delimiter), but 
watch out for the problem with whitespace in strings as described above.

Hope this helps!

Christof


On 21.02.2020 17:35, Markus Brandt wrote:
> I would like to use data of biosensers in pd. They are coming via 
> tcpip from a data collecting software called iMotions ( 
> https://imotions.com/?creative=287840870074&keyword=imotions&matchtype=b&network=g&device=m&gclid=Cj0KCQiAnL7yBRD3ARIsAJp_oLZFxXz6JiAVeJxfYrWYUf_CVE5qN7Dvsw5NCCDyX4Nwz2BXcSU_Rw8aAj3jEALw_wcB 
>
>
> Every item of the list is separated with ; which makes it unusable for 
> me in pd. Putty shows symbols, integers and floats. Wireshark shows 
> hex, as I assume. Only [netclient] in pd did show numbers, but only 
> one after the other and was heavily busy. The trial to print it to the 
> console freezed pd.
>
> Maybe there is way to do the conversation outside pd, but not for me, 
> caused by being only a patcher.
>
> Any help apriciated and thank you in advance
>
> Markus
>
>
>
>
>
> Christof Ressi <info at christofressi.com 
> <mailto:info at christofressi.com>> schrieb am Fr., 21. Feb. 2020, 16:59:
>
>     You can represent *any* string in Pd as a list of bytes and
>     convert from to Pd symbols with [list fromsymbol] / [list
>     tosymbol]. What do you need to do exactly?
>
>     Christof
>
>     On 18.02.2020 13:01, Markus Brandt wrote:
>>     dear list!
>>
>>     Has anyone of you an idea, how i can get a string like the the
>>     one mentioned below into pd? google was not very helpful.
>>
>>     00143526;Affectiva AFFDEX/Affectiva AFFDEX;Affectiva AFFDEX
>>     Landmarks;111657390223;-1;640;360;0;281.437683105469;215.941543579102;1;299.180236816406;248.484008789063;2;331.411010742188;263.274017333984;3;353.788421630859;247.519012451172;4;364.189880371094;217.078216552734;5;295.818267822266;182.501235961914;6;310.803680419922;181.085037231445;7;326.133361816406;184.873413085938;8;340.625579833984;184.74821472168;9;352.791717529297;181.521224975586;10;364.170654296875;183.068405151367;11;333.677062988281;192.564483642578;12;335.351531982422;218.070205688477;13;320.754211425781;218.482315063477;14;333.53564453125;222.660614013672;15;345.12890625;218.542205810547;16;302.288482666016;190.564224243164;17;320.241851806641;191.9140625;18;342.417999267578;191.955337524414;19;359.31201171875;191.504974365234;20;313.495849609375;235.9033203125;21;328.546875;234.737197875977;22;332.560852050781;236.656478881836;23;335.996704101563;234.80632019043;24;347.231048583984;236.135192871094;25;341.493438720703;239.761047363281;26;332.551513671875;241.566482543945;27;322.011535644531;239.544494628906;28;332.268127441406;238.743255615234;29;332.486145019531;237.6025390625;30;311.081359863281;188.53076171875;31;311.056701660156;194.007522583008;32;350.860046386719;188.921142578125;33;351.064697265625;194.802459716797
>>
>>     it is terminated with cr
>>
>>     thanks in advance
>>
>>     cheers
>>     markus
>>
>>     _______________________________________________
>>     Pd-list at lists.iem.at  <mailto:Pd-list at lists.iem.at>  mailing list
>>     UNSUBSCRIBE and account-management ->https://lists.puredata.info/listinfo/pd-list
>     _______________________________________________
>     Pd-list at lists.iem.at <mailto:Pd-list at lists.iem.at> mailing list
>     UNSUBSCRIBE and account-management ->
>     https://lists.puredata.info/listinfo/pd-list
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puredata.info/pipermail/pd-list/attachments/20200221/8b1b60a8/attachment-0001.html>


More information about the Pd-list mailing list