Skip to content
This repository has been archived by the owner on Jan 28, 2023. It is now read-only.

Multiple execution of same command in console but no response to iPhone.. #551

Closed
deepesh-agarwal opened this issue Jul 19, 2013 · 4 comments

Comments

@deepesh-agarwal
Copy link

I am using this plugin command ::

def get_temp()

        # Say a random response:
        say @responses[rand(@responses.size)]+@master_name

        Thread.new {

            begin
                output = `/home/pi/RaspberryScripts/loldht`
                #output.scan(/Temp = (\d++.\d++) *C Hum = (\d++.\d++)/) do |temp, hum|
                #   say "Temperature #{temp} Degree Celsius and Humidity #{hum} %"
                #Temp = 25.00 *C Hum = 41.00 %
                #end

                output = output.delete("^0-9.")
                say "Live Temperature in your room is #{output[0,2]} Degree Celsius and Humidity #{output[5,2]} %"
                rescue Exception => e

                say "Sorry, Deepesh I encountered an error: #{e.inspect}"

                ensure

                request_completed

            end

        }

    end 

Intercepted via this regex ::

    listen_for /(room temperature|temperature|live temperature|life temperature)/i do
        get_temp()
    end

Which results in this output at console ::

[Info - iPhone] Received Object: SpeechPacket
[Info - iPhone] Received Object: SpeechPacket
[Info - iPhone] Received Object: FinishSpeech
[Info - iPhone] Received Object: SetBackgroundContext
[Info - Guzzoni] Received Object: AssistantLoaded
[Info - Guzzoni] Received Object: SetConnectionHeader
[Info - Guzzoni] Received Object: GetAnchorsResponse
[Info - Guzzoni] Received Object: GetAnchorsResponse
[Info - Guzzoni] Received Object: RollbackSucceeded
[Info - Guzzoni] Received Object: CommandFailed
[Info - Guzzoni] Received Object: SpeechRecognized
[Info - Plugin Manager] Processing 'Temperature'
[Info - Plugin Manager] Processing plugin Example
[Info - Plugin Manager] Processing plugin Arduino
[Info - Plugin Manager] Matches (?i-mx:(room temperature|temperature|live temperature|life temperature))
[Info - Plugin Manager] Applicable states:
[Info - Plugin Manager] Current state:
[Info - Plugin Manager] Matches, executing block
[Info - Plugin Manager] Say: Just a moment., Deepesh
[Info - Plugin Manager] Say: Live Temperature in your room is 26 Degree Celsius and Humidity 45 %
[Info - Plugin Manager] Sending Request Completed
[Info - Plugin Manager] Plugins loaded: Example, Arduino
[Info - iPhone] Received Object: LoadAssistant
[Info - iPhone] Received Object: GetAnchors
[Info - iPhone] Received Object: GetAnchors
[Info - iPhone] Received Object: SetRestrictions
[Info - iPhone] Received Object: ClearContext
[Info - iPhone] Received Object: SetRestrictions
[Info - iPhone] Received Object: ClearContext
[Info - iPhone] Received Object: RollbackRequest
[Info - iPhone] Received Object: RollbackRequest
[Info - iPhone] Received Object: RollbackRequest
[Info - iPhone] Received Object: RollbackRequest
[Info - iPhone] Received Object: RollbackRequest
[Info - iPhone] Received Object: RollbackRequest
[Info - iPhone] Received Object: StartSpeechRequest
[Info - iPhone] Received Object: SetRequestOrigin
[Info - iPhone] Received Object: SpeechPacket
[Info - iPhone] Received Object: SpeechPacket
[Info - iPhone] Received Object: SpeechPacket
[Info - iPhone] Received Object: SpeechPacket
[Info - iPhone] Received Object: SpeechPacket
[Info - iPhone] Received Object: SpeechPacket
[Info - iPhone] Received Object: SpeechPacket
[Info - iPhone] Received Object: SpeechPacket
[Info - iPhone] Received Object: SpeechPacket
[Info - iPhone] Received Object: SpeechPacket
[Info - iPhone] Received Object: SpeechPacket
[Info - iPhone] Received Object: SpeechPacket
[Info - iPhone] Received Object: FinishSpeech
[Info - iPhone] Received Object: SetBackgroundContext
[Info - Guzzoni] Received Object: AssistantLoaded
[Info - Guzzoni] Received Object: SetConnectionHeader
[Info - Guzzoni] Received Object: GetAnchorsResponse
[Info - Guzzoni] Received Object: GetAnchorsResponse
[Info - Guzzoni] Received Object: CommandFailed
[Info - Guzzoni] Received Object: CommandFailed
[Info - Guzzoni] Received Object: RollbackSucceeded
[Info - Guzzoni] Received Object: CommandFailed
[Info - Guzzoni] Received Object: SpeechRecognized
[Info - Plugin Manager] Processing 'Temperature'
[Info - Plugin Manager] Processing plugin Example
[Info - Plugin Manager] Processing plugin Arduino
[Info - Plugin Manager] Matches (?i-mx:(room temperature|temperature|live temperature|life temperature))
[Info - Plugin Manager] Applicable states:
[Info - Plugin Manager] Current state:
[Info - Plugin Manager] Matches, executing block
[Info - Plugin Manager] Say: Please hold., Deepesh
[Info - Plugin Manager] Plugins loaded: Example, Arduino
[Info - Plugin Manager] Plugins loaded: Example, Arduino
[Info - Plugin Manager] Plugins loaded: Example, Arduino
[Info - iPhone] Received Object: LoadAssistant
[Info - iPhone] Received Object: ClearContext
[Info - Guzzoni] Received Object: AssistantLoaded
[Info - Guzzoni] Received Object: SetConnectionHeader
[Info - Guzzoni] Received Object: GetAnchorsResponse
[Info - Guzzoni] Received Object: GetAnchorsResponse
[Info - Guzzoni] Received Object: CommandFailed
[Info - Guzzoni] Received Object: CommandFailed
[Info - Guzzoni] Received Object: CommandFailed
[Info - Guzzoni] Received Object: CommandFailed
[Info - Guzzoni] Received Object: RollbackSucceeded
[Info - Guzzoni] Received Object: CommandFailed
[Info - Guzzoni] Received Object: SpeechRecognized
[Info - Plugin Manager] Processing 'Temperature'
[Info - Plugin Manager] Processing plugin Example
[Info - Plugin Manager] Processing plugin Arduino
[Info - Plugin Manager] Matches (?i-mx:(room temperature|temperature|live temperature|life temperature))
[Info - Plugin Manager] Applicable states:
[Info - Plugin Manager] Current state:
[Info - Plugin Manager] Matches, executing block
[Info - Plugin Manager] Say: Hang on a second., Deepesh
[Info - Plugin Manager] Plugins loaded: Example, Arduino
[Info - Plugin Manager] Plugins loaded: Example, Arduino
[Info - Plugin Manager] Say: Live Temperature in your room is 26 Degree Celsius and Humidity 45 %
[Info - Plugin Manager] Sending Request Completed
[Info - Plugin Manager] Say: Live Temperature in your room is .. Degree Celsius and Humidity .. %
[Info - Plugin Manager] Sending Request Completed

As you can see the command is getting executed multiple times but no response gets received on phone and all I see is the endless spin.

@elvisimprsntr
Copy link
Collaborator

If I had to guess, I would suspect the problem is with the begin-resuce-ensure-end. First try getting it to work without it, then try replacing ensure with end remove one of the other end statements.

More info: http://stackoverflow.com/questions/2191632/begin-rescue-and-ensure-in-ruby.

@elvisimprsntr
Copy link
Collaborator

Also, does your script really take that long that you need to start as a new thread?

@deepesh-agarwal
Copy link
Author

Thanks, I will look into this. I was using a new thread to execute python code with other matches, and when not using a new thread Siri skipped the "Say" statements on my phone executing the command (the task get executed but no response is sent to phone).

@elvisimprsntr
Copy link
Collaborator

Here is an example from one of my plugins that works, although I'm not calling python.
https://github.com/elvisimprsntr/siriproxy-redeye/blob/master/lib/siriproxy-redeye.rb#L53

I have read some posts about necessary tricks to return from python from within ruby. Post a question on stackoverflow if you don't find what you are looking for.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants