[PD] TCP/IP communication from the unix server to the Pure Data

Martin Peach martin.peach at sympatico.ca
Sat Mar 9 17:15:55 CET 2013


It's probably safer to get the server to send the numbers as ASCII text, 
to avoid disagreements about endianness and floating-point representation.
Then, to extract the numbers, you could use [moocow/bytes2any] or make a 
custom parser using [pdlua].

Martin


On 2013-03-09 10:55, Petar Jercic wrote:
> Apparently [netclient] on the Pure Data side cannot receive nothing else
> than ; delimited messages.
> So the solution for the problem:
> *My question is, is there a way to send something other than string
> message to Pure Data, like byte-stream or serialized number stream? Can
> Pure Data receive such messages?*
>
> The solution is to use [tcpclient], it can receive byte-stream data.
>
> Now I have another problem regarding the data read, on how to convert it
> back to usable numbers.
>
>  From my UNIX server I am sending a structure
>
> typedef struct {
>      int     var_code;
>      int    sample_time;
>      int     hr;
>      float    hs;
> } phy_data;
>
> Sample data might be 2 1000000 51 2000.56
>
> When received and printed  in Pure Data I get output like this:
>
>  >>>: 2 0 0 0 104 34 9 0 51 0 0 0 235 50 48 69
>
> You can notice number 2 and number 51 clearly, I guess the others are
> correct as well. Might be some network inversion of LSB/MSB.
>
> *How can I get these numbers back to a usable format and get them in
> separate variables?
>
> *//Petar*
> *
>
>
> _______________________________________________
> Pd-list at iem.at mailing list
> UNSUBSCRIBE and account-management -> http://lists.puredata.info/listinfo/pd-list
>




More information about the Pd-list mailing list