• Coalman

    thats great, I am going out of town for a few days but excited to give it a try. Will send feedback. great!

    posted in patch~ read more
  • Coalman

    I was searching for something else but landed on this, downloaded the old version and will give it a test. Would love to see the new version too, it looks like a nicer version of something I was working on a while back!
    cheers,
    J

    posted in patch~ read more
  • Coalman

    Thanks everyone!
    Great and informative answers!
    Jorge

    posted in technical issues read more
  • Coalman

    hi,
    Recently someone posted something over on the Pd list that had this question inside part of a bigger question. I was interested in it but it didn't seem to get an answer so I thought I would try here...I know that Max has limits for list length but I was wondering if in Pd there is a maximum number of elements that can be listed?
    Likewise are the maximum limits to what can go into a message box?
    What about an array?

    I am sure someone has asked this before but I did not see any results when I searched for it.
    thanks in advance!
    jorge

    posted in technical issues read more
  • Coalman

    First off thank you all for your help and suggestions!
    I managed to find a solution with a little help from my friends.

    So, my main problem turned out to be that I needed to create my socket BEFORE defining my function. Then only after both of these are done I could set up the string to send to Pd (because Python does this sort of weird recursivey thing).

    Also as some of you suggested my string was named badly, first I was using a the wrong variable data type ("b") then I tried to make a string using "str" as a name which confuses Python as "str" is the string data type. So for anyone else dealing with this be sure to call your string something like "data" or "lsdfdjkhgs" but not "str"!

    Anyway, it works now and I can send data over to [netrecieve]
    incidentally @whale-av 's suggestion to use Pd's built in messaging scripts located in the application folder (pdsend & pdreceive) brought up a lot of interesting possibilities that I will be exploring later and for anybody wanting to send messages between Pd and other programs this looks like a cool way to do it.

    anyway, I will share the code here in hopes it will help someone else:

    import socket
    from obspy.clients.seedlink.easyseedlink import create_client
    
    # first get all the socket declaration out of the way
    s = socket.socket()
    host = 'localhost'
    port =  #put (your) open port here, this is also part of Pd's [netreceive] argument
    s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    s.connect((host, port))
    
    # then we define our callback which happens when we receive data
    # out socket is already set up so we can reference it here in the callback
    def handle_data(trace):
        # trace is an obspy.trace class so we must convert to string
        # I have to mess around with this "trace" because it is part of the class my client code is using
       data = str(trace)
    
       # we can then neatly append a ; with a "f-string" to make it work with Pd's FUDI protocol (Pd messages end in ";")
       data = f'{data};'
    
       # or
       # data = str(trace) + ';'
       # if you like
       
       # and send it over our socket
       s.sendall(data.encode('utf-8'))
    
    #then AFTER all this my code connecting to the server (that returns the data as a string "trace" above, but the entire part for communicating with Pd is up there, and surprisingly simple despite the 'strange loops'!
    
    

    posted in technical issues read more
  • Coalman

    @whale-av , @ingox , @FFW
    Thank you so much for these detailed suggestions and examples. I have been submerged in other stuff this morning, but I will look through all of these and report back with the solution for the next person trying to do this.
    I think with all this to look at I should be able to sort one, these examples look great.

    best,
    Jorge

    posted in technical issues read more
  • Coalman

    @seb-harmonik-ar I think you are right about the variable type, a string would be better since the data type returned from the server is a mixture of alpha-numerics, spaces, and periods

    I have tried these things and despite trying several combinations of ways of writing the variable and encoding it I still don't seem to be able to send across what prints from the code above. I basically want to send to Pd the same data I am able to print from the ```
    print(trace)
    above, of course isn't necessary to print it first, and I am successfully sending strings across without printing it first
    the odd thing is that I can send an arbitrary string across fine and receive it in Pd
    (like yelkdsjf 032742n sdkjfh \ sldfjsldfkjlkdsjf 8493 sends fine using the code above (in place of "yello")
    but the data I am getting from the server (a line of which looks like "
    IU.SFJD.00.BHZ | 2021-08-19T12:45:49.019538Z - 2021-08-19T12:46:05.269538Z | 20.0 Hz, 326 samples
    doesn't send.
    in both cases I am adding the ";" at the end as Pd requires for messages...so it must be something about how I am dealing with the data I am receiving from the server because the actual data doesn't seem any weirder or to have any other prohibited characters than my arbitrary test data and it sends ok.

    so it must be that I am writing it to a variable wrong somehow, or
    maybe utf-8
    isn't the best encoding for something like that
    will continue to dig....

    posted in technical issues read more
  • Coalman

    that sounds cool, I might download that and give it a try when some time opens up!
    I don't think banging pots and pans around is such a bad idea either, but your track was a lot more sophisticated than that in any case!

    posted in output~ read more
  • Coalman

    I notice the bottom of the code box is cut off in my browser, so if that doesn't make sense for you, try to click the box and scroll up to see the rest of the code.

    posted in technical issues read more
  • Coalman

    @seb-harmonik-ar thanks for helping think this through, I am at a very low level with python myself, but it is useful for this kind of stuff.

    I don't think the problem is sending the variable over, because, as you say you could send a variable over in a simple way. Its more of how to assign dynamically updated values (from the server) to a variable.

    I will try to show you what I mean:
    here I define a function:

    import socket
    
    def handle_data(trace):
        #print('Received the following trace:')
        print(trace)
        print()````
    
    #(I am leaving out the code that sets up a client and queries data from a server because it is a bit #long, 
    #but I am using a package called obspy which is a package for doing this with seismographic data)
    
    #then I do this:
    
    s = socket.socket()
    host = 'localhost'
    port = #put an open port here
    
    s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    
    s.connect((host, port))
    
    b = client.run()
    
    s.sendall(b + ";")
    
    # problem is to get the data that prints from the client.run() sent over.  
    #That is what I have been trying here with "b".  
    #The way I do it for a static value is this 
    #(posting this because it might actually help someone else doing this stuff)
    
    s.connect((host, port))
    mess = "yello"
    Msg = mess + " ;"
    s.send(Msg.encode('utf-8'))
    
    # the ";" is because Pd likes messages in this 'FUDI' format 
    #which I think needs the semicolon like normal message boxes in Pd 
    #(and also if I am not mistaken there should be tab-separations between 
    #parts of. a message so that they can be separated as lists are in Pd)

    posted in technical issues read more

Internal error.

Oops! Looks like something went wrong!