Please login or register.

Login with username, password and session length
Advanced search  

News:

The X10Hub (PiX10Hub) is here! Created by the Community, for the Community.:)% #:)

Author Topic: RecvAction from Motion Sensors  (Read 21760 times)

andrew rodgers

  • Newbie
  • Helpful Post Rating: 0
  • Posts: 1
RecvAction from Motion Sensors
« on: December 12, 2005, 04:41:00 PM »

Could anyone kindly give me some direction
on how to write a simple bit of code to play
a sound whenever a motion sensor is
triggered?  I'm using C++ on windows but i'd
be glad to see code in any language for any
platform.

I've been pluging away at this for over a
month now, at just can't seem to be able to
properly capture the event.  The SDK
documentation seems to be more oriented to
towards sending instructions to modules
rather than receiving events.  I'm using the
CM15A interface with 5 RMS18 sensors.
Logged

USdangerboy

  • Full Member
  • ***
  • Helpful Post Rating: 1
  • Posts: 32
Re: RecvAction from Motion Sensors
« Reply #1 on: December 28, 2008, 05:27:42 AM »

I'm writing my app in VB first, then when it's tuned, I'll switch it over to C++ but this is faster for me.  I got this working in a couple hours after getting the SDK today actually (just shows how damn simple VB is :-)

Here's how you call it ...
Code: [Select]
' -- Call the entire file name, with extension (MP3 files allowed later)
PlayBackgroundSoundFile("Alert_FrontFoyerLightAction.wav")

Here's what does the work
Code: [Select]
   
Sub PlayBackgroundSoundFile(ByVal strFile2Play As String)
        ' -- Give me the name of the file to be sure of file not found issues debugging
        Console.WriteLine("NOTE: Sound file: " + strFile2Play + " about to be played")
        ' -- Build the string with the exact path to the WAVs directory
        strFile2Play = "c:\AHPFiles\wavs\" + strFile2Play
        ' -- Let the system to the work, no need to call WMPlayer, etc.
        My.Computer.Audio.Play(strFile2Play, AudioPlayMode.Background)
End Sub

Now WHERE you put the logic to decide on calling this of course, is another matter.  You'll have to test the vParm1 and vParm2 values to see if you are in a condition to play the file.  Such as ...


Code: [Select]
If LCase(vParm1) = "m4" and LCase(vParm2) = "off" Then
     ActiveHome_SendCommand("m4 bright 80")
     PlayBackgroundSoundFile("Notice_RaisingFamilyLights.wav")
End If

My problem at present is I am getting 3-7 signals on the code for an event.  I get so many transmissions, I can't act on each one, not sure but I think the end units are eating up the extra but the computer app wants to deal with each one!  Very frustrating ... so this code above, for example, would fire 3 or more times because I am getting many transmissions for a single push of a button as shown in my log below from events.

When I press the M4 off button for example, I get this in my readout ...

ACTION->recvrf  CODE->m4        CMD->Off        PAR3-> 0        PAR4-> 12/28/2008 9:50:45 AM    PAR5->
------------------------------------------------------------------------------
ACTION->recvrf  CODE->m4        CMD->Off        PAR3-> 0        PAR4-> 12/28/2008 9:50:45 AM    PAR5->
------------------------------------------------------------------------------
ACTION->recvrf  CODE->m4        CMD->Off        PAR3-> -1       PAR4-> 12/28/2008 9:50:45 AM    PAR5->
------------------------------------------------------------------------------
ACTION->recvrf  CODE->m4        CMD->Off        PAR3-> 0        PAR4-> 12/28/2008 9:50:45 AM    PAR5->
------------------------------------------------------------------------------
ACTION->recvrf  CODE->m4        CMD->Off        PAR3-> -1       PAR4-> 12/28/2008 9:50:45 AM    PAR5->
------------------------------------------------------------------------------
ACTION->recvrf  CODE->m4        CMD->Off        PAR3-> -1       PAR4-> 12/28/2008 9:50:46 AM    PAR5->
------------------------------------------------------------------------------
ACTION->RecvPlc CODE->m4        CMD->Off        PAR3->  PAR4->  PAR5->
------------------------------------------------------------------------------
ACTION->RecvPlc CODE->m4        CMD->Off        PAR3->  PAR4->  PAR5->
------------------------------------------------------------------------------
ACTION->RecvPlc CODE->m4        CMD->Off        PAR3->  PAR4->  PAR5->
------------------------------------------------------------------------------


I have NO idea why, I have everything unplugged except for my computer and one EE and two modules for wireless keypad and a lamp controller.  I guess the receivers eat up the extra codes or something.  Let me know if you come across this, I'm trying to find it in a topic somwhere, but no luck!!
Logged
If at first you don't succeed, skydiving is not for you.

Tuicemen

  • Administrator
  • Hero Member
  • ****
  • Helpful Post Rating: 265
  • Posts: 9434
  • I don't work for X10, I use it successfuly!
    • Tuicemen Software
Re: RecvAction from Motion Sensors
« Reply #2 on: December 28, 2008, 01:40:51 PM »

USdangerboy
I've only started to play with the RF funtion of this myself so what I can tell you is limited!
The send rf 0 and 1 code corespond to remote buton down and up movement!
The fact that you are seeing plc recieve tend to show you have another tranciever in your mix!
These generaly arn't needed with the CM15A!
The CM15A sends out a PLC command after recieving the RF!
All activity should only show twice!(2 recvRF(0), 2 recvRF(1), 2 SendPLC )
hope this helps!
Logged
Please Read Topic:
General Forum Etiquette
Before you post!

Find extra info @ My forum

admeeral

  • Jr. Member
  • **
  • Helpful Post Rating: 0
  • Posts: 15
Re: RecvAction from Motion Sensors
« Reply #3 on: February 11, 2009, 10:41:25 AM »

I have been using SendAction to send rf commands for some time.   No problem.  C++ and with code modified from the sample.
The receive rf function seems to have very little documentation - just a brief comment.  The only function in the classl is
PutOnRevcAction  and I tried using this - no answer.  At least it doesn't crash!!!   Do I have to use a SendAction first???
Any one out that has used this successfully?
Logged

Tuicemen

  • Administrator
  • Hero Member
  • ****
  • Helpful Post Rating: 265
  • Posts: 9434
  • I don't work for X10, I use it successfuly!
    • Tuicemen Software
Re: RecvAction from Motion Sensors
« Reply #4 on: February 11, 2009, 03:38:38 PM »

I code in VB so you can convert
You need to add this to your class
 
Code: [Select]
'recievaction
    Dim action As String
    Dim Param1 As String
    Dim Param2 As String
    Dim Param3 As String
    Dim Param4 As String
    Dim Param5 As String
  Public Sub ActiveHome_Received(ByVal bszAction As Object, ByVal bszParam1 As Object, ByVal bszParam2 As Object, ByVal bszParam3 As Object, ByVal bszParam4 As Object, ByVal bszParam5 As Object, ByVal bszReserved As Object) Handles _AHObj.RecvAction
        '    'Since this is an ActiveX Object we should convert the objects to strings which is what they really are

        Try
            action = CType(bszAction, String)   'recvplc, recvrf
            Param1 = CType(bszParam1, String)   'e1 on, e1 bright
            Param2 = CType(bszParam2, String)   '50 as in bright 50%
            Param3 = CType(bszParam3, String)   '?
            Param4 = CType(bszParam4, String)   '?
            Param5 = CType(bszParam5, String)   '?
            Reserved = CType(bszReserved, String)
        Catch ex As Exception
            'Since we could get floods of x10 messages its best not to put any message boxes here
            Console.WriteLine(ex.ToString())
        End Try
  End Sub

Hope that helps!
 >!
Logged
Please Read Topic:
General Forum Etiquette
Before you post!

Find extra info @ My forum

admeeral

  • Jr. Member
  • **
  • Helpful Post Rating: 0
  • Posts: 15
Re: RecvAction from Motion Sensors
« Reply #5 on: February 11, 2009, 05:07:03 PM »

I didn't generate the class.  It must match what is in x10net.dll.  Otherwise I would be calling a fictitious function.
Are you saying that there is a receive function in the dll other than what is listed ion the SDK header file?

I noticed that the SDK documentation is a couple of years old but I have a much more recent x10net.dll  Is there more recent
documentation?

admeeral
Logged

Tuicemen

  • Administrator
  • Hero Member
  • ****
  • Helpful Post Rating: 265
  • Posts: 9434
  • I don't work for X10, I use it successfuly!
    • Tuicemen Software
Re: RecvAction from Motion Sensors
« Reply #6 on: February 11, 2009, 06:06:11 PM »

I'm using the original SDK.
how are you calling sends?
you need this in the class as well
Code: [Select]
  Public WithEvents _AHObj As ActiveHomeI pulled the info out of the sample folder of the SDK for the VB project
Logged
Please Read Topic:
General Forum Etiquette
Before you post!

Find extra info @ My forum

admeeral

  • Jr. Member
  • **
  • Helpful Post Rating: 0
  • Posts: 15
Re: RecvAction from Motion Sensors
« Reply #7 on: February 11, 2009, 06:55:27 PM »

All operations are called through x10net.dll which is the fundamental connection to the CM15A

Functions within the dll are defined in ahscript.tlh so if I compile with this header included I know when I link there will be a
match.   SendAction is defined as a function available publically within the class IActiveHome.  RecvAction is not.
It is possible that x10net.dll, since it postdates the ahscript.tlh header file may contain other public available functions.
This definition is not available to me.

I could modify ahscript and it would compile but if the function I define is not in the dll it,of course, will not link.
So I ask... what functions are available within the dll... and how do we know them?

admeeral
Logged

Tuicemen

  • Administrator
  • Hero Member
  • ****
  • Helpful Post Rating: 265
  • Posts: 9434
  • I don't work for X10, I use it successfuly!
    • Tuicemen Software
Re: RecvAction from Motion Sensors
« Reply #8 on: February 11, 2009, 08:45:26 PM »

The ahscript.chm file in the SDK has all the powerline and RF commands available listed.
Quote
It is possible that x10net.dll, since it postdates the ahscript.tlh header file may contain other public available functions.
This definition is not available to me.
I'm sure if X10 wanted the definitions to be available they would be! ::) :'
Logged
Please Read Topic:
General Forum Etiquette
Before you post!

Find extra info @ My forum
 

X10.com | About X10 | X10 Security Systems | Cameras| Package Deals
© Copyright 2014-2016 X10.com All rights reserved.