[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [sc-users] Regexp with incoming OSC
On Sun, Mar 10, 2019 at 11:31 PM <kv.syntaxerror@xxxxxxxxx> wrote:
> Elegantly curated thanks AdC.
>
> [ '/tsharky', '1954 767.352825 192.168.1.108 → 74.125.140.189 TCP 66 55095 → 443 [ACK] Seq=3804 Ack=5335 Win=2047 Len=0 TSval=432028419 TSecr=3650450475' ]
> -> - ~sharkfunc runs -
> -> ~valdict is now: ( )
>
> The dict seems to be empty. Am I missing something,
Yes -- two previous posters advised you to change the incoming message
format. Then you ran an example of how to handle the alternate message
format, but without changing your input. Of course it won't work.
> I reckon that the osc function does the key value pair apropos to all incoming, right?
Ideally, the sender formats the OSC message in key-value pairs, not as a string.
But if you can't do that:
z = "1954 767.352825 192.168.1.108 → 74.125.140.189 TCP 66 55095 → 443
[ACK] Seq=3804 Ack=5335 Win=2047 Len=0 TSval=432028419
TSecr=3650450475";
// () are groups to be isolated in the findRegexp result
// [] are character groups to match; + means "1 or more"
x = z.findRegexp("([A-Za-z]+)=([0-9]+)");
-> [ [ 76, Seq=3804 ], [ 76, Seq ], [ 80, 3804 ], [ 85, Ack=5335 ], [
85, Ack ], [ 89, 5335 ], [ 94, Win=2047 ], [ 94, Win ], [ 98, 2047 ],
[ 103, Len=0 ], [ 103, Len ], [ 107, 0 ], [ 109, TSval=432028419 ], [
109, TSval ], [ 115, 432028419 ], [ 125, TSecr=3650450475 ], [ 125,
TSecr ], [ 131, 3650450475 ] ]
forBy(1, x.size, 3, { |i| "Key = %, value = %\n".postf(x[i][1], x[i+1][1]) });
Key = Seq, value = 3804
Key = Ack, value = 5335
Key = Win, value = 2047
Key = Len, value = 0
Key = TSval, value = 432028419
Key = TSecr, value = 3650450475
But Scott and Alberto are right. You're using a kind of bad OSC
message format. You can simplify your life a lot by having the sender
produce a more reasonable OSC message.
One inefficiency: Every one of those big symbols coming in lives in
the SC symbol table forever, wasting memory.
hjh
_______________________________________________
sc-users mailing list
info (subscription, etc.): http://www.birmingham.ac.uk/facilities/ea-studios/research/supercollider/mailinglist.aspx
archive: https://listarc.bham.ac.uk/marchives/sc-users/
search: https://listarc.bham.ac.uk/lists/sc-users/search/