HAHCentral/JeenodeApplet issues

5 replies [Last post]
kevin9
Offline
Lincolnshire, United Kingdom
Joined: 24 May 2010

I am havng a couple of problems with my HAHCentral and Roomnode2 setup which I am struggling to resolve

I sourced the arduino code from googlecode and loaded it via the IDE and apart from changing the serial flag and removing the PIR define (for simplicity/elimination) it is standard

I have one device configured as HAHCentral and two as Roomnode2, one in an Airwick and one on the bench connected to the serial monitor

The first problem is that the temperature is misrepresented, so instead of showing up as a 3 digit number in a xAP Serial message it comes up as a two digit number. In addition the lobat is inverted. This happens for a while and eventualy it comes right, then a bit later it happens again. This happens on both roomnodes, not always at the same time. Resetting the roomnodes has no effect. 

A typical message being transmitted from the roomnode (ie, as displayed on the serial monitor anyway) would be

ROOM 175 0 0 256 0


and the equivilant xAP  serial message would be

xap-header
{
v=12
hop=1
uid=FF00D500
class=Serial.Comms
source=dbzoo.livebox.1.Serial
}
Serial.Received
{
port=/dev/ttyUSB0
data=OK 4 175 0 12 1
}

The second problem is that the serial daemon sometimes reports messages which crash JeenodeApplet.lua, eg

xap-header
{
v=12
hop=1
uid=FF00D500
class=Serial.Comms
source=dbzoo.livebox.1.Serial
}
Serial.Received
{
port=/dev/ttyUSB0
data=OK 4 176 0 03 192 0 12 1
}

Which combines parts of two messages from nodes 4 and then 3

The xap-plugboard.log shows

lua: /usr/share/lua/5.1/xap/jeenode.lua:51: invalid value (nil) at index 4 in table for 'concat'
stack traceback:
 [C]: in function 'concat'
 /usr/share/lua/5.1/xap/jeenode.lua:51: in function 'stream2bin'
 /usr/share/lua/5.1/xap/jeenode.lua:65: in function 'bitslicer'
 /usr/share/lua/5.1/xap/roomnode.lua:44: in function 'process'
 /usr/share/lua/5.1/xap/jeenode.lua:96: in function 'callback'
 /usr/share/lua/5.1/xap/init.lua:392: in function 'dispatch'
 /usr/share/lua/5.1/xap/init.lua:97: in function 'fun'
 /usr/share/lua/5.1/pl/list.lua:360: in function 'foreach'
 /usr/share/lua/5.1/xap/init.lua:96: in function 'callback'
 /usr/share/lua/5.1/xap/init.lua:203: in function 'dispatch'
 /usr/share/lua/5.1/xap/init.lua:117: in function 'process'
 /etc_ro_fs/plugboard/plugboard.lua:73: in main chunk
 [C]: ?
Loading /etc/plugboard/jeenodeApplet.lua        [ JeeNode ]
Running...

This is the only lua script running

I have tried two different devices as HAHCentral

Any suggestions?

kevint 

 

kevin9
Offline
Lincolnshire, United Kingdom
Joined: 24 May 2010
Resolved

I have been doing some work on this and came to the conclusion that the problem was lack of handshaking.

When I connected the HAHCentral to a PC the data was never corrupted and the data was always as expected. Although the Serial Daemon is capable of xon/xoff handshaking it is not setup for it in the jeenodeApplet.lua because the Arduino/jeenode/HAHnode is not capable of it.

My solution was to add a delay(2000); to the end of each serial transmission from the HAHCentral device to the Livebox. It may be that this can be reduced, but it has been working reliably now for 3 or 4 days with no corrupt data or concatenated messages.

 kevint

brett
Offline
Providence, United States
Joined: 9 Jan 2010
That's stange as xap-serial

That's stange as xap-serial IS capable of being setup to do flow control.   Its all about how the PORT is open by the JeenodeApplet.lua plugboard applet.

Recall this definition in the jeenodeApplet.lua this is setting up the serial port communications for HAHCentral.

local jeemon={
      port="/dev/ttyUSB0",
      baud=57600,
      stop=1,
      databits=8,
      parity="none",
      flow="none"     <--- this is about setting the flow control.
}

By default its set to NONE, obviously this causes an issue, so instead of putting in a delay(2000) did you try adjusting this setting?

Valid values for 'flow' are: hardware, xonxoff, none

I would try adjusting to 'hardware' as the serial port can do DTR/CTS over USB and removing your delay() and see what happens.  But you might be right this would still require the Arduino to be implementing this hardware handshaking.     XONXOFF I know won't work as this is definately not implemented in the software.

Brett

brett
Offline
Providence, United States
Joined: 9 Jan 2010
CRAP - I've commented out the
CRAP - I've commented out the hardware flow control setting in xap-serial!
OK this would certainly explain why hardware flow control can't be enabled :)

http://livebox-hah.googlecode.com/svn/trunk/userapps/hah/xap-serial/seri...

} /* else if(strcasecmp("hardware", s_flow) == 0) { p->tios.c_cflag |= CNEW_RTSCTS; } */

I'll find out why I did this. I must have had a reason, but I can't recall.
Brett
kevin9
Offline
Lincolnshire, United Kingdom
Joined: 24 May 2010
flow control

I had noticed hardware flow control was disabled in the code.

Although the FTDI connector has RTS/CTS this is between the adapter and the arduino, I think RTS/CTS is not implemented over the USB connection.

xon/xoff is not supported by the basic Arduino serial interface 

As I say it may be that the delay can be reduced, but I am comfortable with it because the light, temperature, humidty data is not so fast moving that this likely to be a problem in an y real application.

kevint

kevin9
Offline
Lincolnshire, United Kingdom
Joined: 24 May 2010
Current setup

Currently running 1 x HAHcentral and 3 x Roomnode and working fine

kevint 

Hardware Info