Getting data from xap messages

4 replies [Last post]
allanayr
Offline
Ayr, United Kingdom
Joined: 25 Sep 2011

I'm afraid I'm struggling with xap messages again.

I'm feeding temperature data into xap-serial and I can see the xap messages on xfx viewer as follows

xap-header
{
v=12
hop=1
uid=FF00D500
class=Serial.Comms
source=dbzoo.livebox.Serial
}
Serial.Received
{
port=/dev/ttyUSB1
data=20.0
}

 

Unfortunately when I apply a filter like:

f:add ("xap-header","source","dbzoo.livebox.Serial")

f:add("xap-header","class","Serial.Comms")

and then in my callback function I try to use

frame:getValue("Serial.Received","data")

to extract the data element but it returns a nil value.

What should my callback function be looking for?

 

Allan

brett
Offline
Providence, United States
Joined: 9 Jan 2010
I use something like this in
I use something like this in the jeenode.lua library class and I know jeenodes are working.

local f = xap.Filter()
f:add("xap-header","class","serial.comms") f:add("serial.received","port",t.port) f:callback(serialHandler, config)

Try using lowercase perhaps this is another instance of not being case agnostic.

Brett
allanayr
Offline
Ayr, United Kingdom
Joined: 25 Sep 2011
BrettThanks again for your

Brett

Thanks again for your help here. I try not to just lauch questions onto the forum without trying quite hard to understand what's going on. One thing that I have learned over the last couple of months is that Lua Linux and C can be very particular about the case (upper or lower) of letters in variables and commands etc. So I was very careful when reading the messages in xfx viewer to take careful note of the exact spelling and capitalisation of the characters.

It would seem however, that in this instance all lower case seems to do the trick. It looks like I was pretty close with my attempts but that I was defeated by the small matter of capitalisation. I had tried many, many different ways of extracting the data and nothing seemed to work even though I thought I must be near.

Here's what seems to work in the end:

local f = xap.Filter()
    f:add("xap-header", "source", "dbzoo.livebox.serial")
    f:add("xap-header","class","serial.comms")



There have been quite a few times when I would probably have had to give up if you had not come to my rescue. So please be assured that I am VERY grateful for your expert help.

I can now read the temperature from my (Heath-Robinson) portable, wireless, temperature sensor and use the information to more finely tune my heating system.

Allan

brett
Offline
Providence, United States
Joined: 9 Jan 2010
You should also include PORT

You should also include PORT otherwise if you ever attach a jeenode your program is going to get bombed with serial message from other sources.   I know you only have one at the moment but its best to cover your bases.

I thought I made a change in that API call to be case agnostic in builds >302 ? What build are you on?

http://code.google.com/p/livebox-hah/source/detail?r=364

Brett

allanayr
Offline
Ayr, United Kingdom
Joined: 25 Sep 2011
I'm using 302/3.4

Thanks Brett. I'll have a go at including the port, it will probably save me much grief at some stage in the future.

I'm using build 302/3.4 at the moment. (Still struggilng with no landline or Broadband internet connection.)

Hardware Info