Returning action values from Asynchronous communications

Do you have questions about writing plugins or scripts in Python? Meet the coders here.
Post Reply
rdgerken
Experienced User
Posts: 86
Joined: Fri Sep 21, 2012 7:41 pm

Returning action values from Asynchronous communications

Post by rdgerken » Sat Oct 19, 2013 11:56 pm

Guys / Gals,

Need some help on this one. If I have an asynchronous session going with a device... that is, I send it a command, and it responds - how can I capture the response and return it with the action? The way it works now, the actions that are set up, they just issue commands to the device with no return values, and then the the plugin just generates events for each response coming in - with no relationship or return value for the action generating the command in the first place, and that's great - but if I want to access the return value directly within EG python script actions - it doesn't really work the way it is setup.

Another thing that complicates the matter, is that the remote device will send status updates as things change on the system, which may not be related at all to the last action command sent. So, it's like I need to find someway to have the action send the command - and then wait for a response (confirm that the response is for the action command that was sent), grab the data, and then return it to end out the action. I think that's how I need it to work, but don't have a clue at all how to do it in the python code. This is for the Lutron RadioRA2 plugin if you need to have a look at the source.

Thanks for any help!

User avatar
Pako
Plugin Developer
Posts: 2290
Joined: Sat Nov 11, 2006 1:31 pm
Location: Czech Republic
Contact:

Re: Returning action values from Asynchronous communications

Post by Pako » Mon Nov 11, 2013 5:32 pm

You can see how it's done in some plugins.
For example, VLC or MusicBee (MusicBee used for this purpose a "token").

Pako

rdgerken
Experienced User
Posts: 86
Joined: Fri Sep 21, 2012 7:41 pm

Re: Returning action values from Asynchronous communications

Post by rdgerken » Thu Nov 14, 2013 1:21 am

Thanks Pako, I'll have a look at those.

Post Reply