Here's a pdlua script to do that, it should work with pd-extended. It's quite simple to customize for any ascii packet such as yours that has a fixed structure.

Martin

On 2012-02-16 11:50, Pagano, Patrick wrote:
i cannot find iemnet for OSX

using bytes to any and mr peach's tcpclient
i am able to get the data back to the same thing max was spitting out

print: [[[6171 , 520]] , [[590 , 655]]]
but i cannot seem to strip off the brackets correctly

i can strip off one delineator so it seems

i will try gridflow next





________________________________________
From: [email protected] [[email protected]] on behalf of Roman 
Haefeli [[email protected]]
Sent: Thursday, February 16, 2012 11:41 AM
To: [email protected]
Subject: Re: [PD] socket object?

On Thu, 2012-02-16 at 16:58 +0100, IOhannes m zmölnig wrote:
On 02/16/12 16:46, Pagano, Patrick wrote:
Hi and thanks
We are listening for tcp
in max i get the lines read as
LaserOutput: [[[2705,246]],[[1358,402]]]

and in pd using mrpeach's tcpclient it reads back
91 91 91 50 54 54 49 44 50 56 54 93 93 44 91 91 49 51 54 53 44 52 49 56 93 93 
93 13 10

i of course want to strip off the brackets and close brackets and just get to 
the numbers inside the strings
is this possible? Can i convert the bytes to characters/numbers?

moocow's "pdstring" library might come in handy.

you could also try to do something like this:

[tcpclient 7777]
|
[list append 59 10]
|
[list prepend send]
|
[list trim]
|
[udpsend]<-[connect localhost 7777(

This won't work, because TCP is a stream-based protocol and you cannot
be sure, that the whole _message_ comes in one chunk, or that one chunk
contains only one message. It's anyway only mrpeach's [tcpclient] that
outputs the incoming stream as chunks (Pd lists). iemnet's [tcpclient]
outputs the incoming stream as a stream of Pd floats (which is IMHO the
appropriate way).

Roman



_______________________________________________
[email protected] mailing list
UNSUBSCRIBE and account-management ->  
http://lists.puredata.info/listinfo/pd-list

_______________________________________________
[email protected] mailing list
UNSUBSCRIBE and account-management ->  
http://lists.puredata.info/listinfo/pd-list



#N canvas 741 608 450 300 10;
#X obj 43 76 bytes2pp;
#X msg 43 35 91 91 91 50 54 54 49 44 50 56 54 93 93 44 91 91 49 51
54 53 44 52 49 56 93 93 93 13 10;
#X floatatom 43 159 5 0 0 0 - - -;
#X floatatom 80 159 5 0 0 0 - - -;
#X floatatom 117 160 5 0 0 0 - - -;
#X floatatom 155 160 5 0 0 0 - - -;
#X connect 0 0 2 0;
#X connect 0 1 3 0;
#X connect 0 2 4 0;
#X connect 0 3 5 0;
#X connect 1 0 0 0;
--[[ 

    str2ms
    Tries to convert lists of floats like 
    91 91 91 50 54 54 49 44 50 56 54 93 93 44 91 91 49 51 54 53 44 52 49 56 93 
93 93 13 10
    to four floats
    --{{{2705,246}},{{1358,402}}} square brackets

    MP 20120216 
    Written by Martin Peach 
--]]

-- Pd class

local bytes2pp = pd.Class:new():register("bytes2pp")
local result -- save most recent result for bang

function bytes2pp:initialize(sel, atoms)
    self.inlets = 1
    self.outlets = 4
--pd.post("bytes2pp init")
    return true
end

function bytes2pp:in_1(sel, atoms)
    local n = 0
    local str = ''

--pd.post("bytes2pp:in1:"..sel.." "..#atoms.." atoms")

    if sel == "list" then -- float is already in milliseconds
        for i = 1, #atoms  do
            if (type(atoms[i]) ~= "number") then
                pd.post(self._name..": "..atoms[i].." is not a float, it'a a 
"..type(atoms[i]))
                return            
            end
            str = str..string.char(atoms[i])
        end
--pd.post(str)
        i = 1
        for w in string.gmatch(str, "%d+") do
--pd.post(w.." is a "..type(w)) -- a string
            n = 0 + w -- force it to be a number
            self:outlet(i, "float", {n})
            i = i+1 -- next outlet
        end
    else
        pd.post(self._name..": no method for "..sel)
    end
end
_______________________________________________
[email protected] mailing list
UNSUBSCRIBE and account-management -> 
http://lists.puredata.info/listinfo/pd-list

Reply via email to