This page last changed on Jul 30, 2013 by juha.

There's a new contribution available for testing. Lawrie Griffiths has added text-to-speech capabilities, easier way to configure email sending in designer and rules, and a direct serial port access to makers who like to interacts with Arduinos and other similar serial controlled devices.

You will need to download a new development binary from OpenRemote-Controller-2.2.0_TTS-Email-Serial.zip

The protocol configurations are currently available in https://composer.openremote.org/preview – IMPORTANT NOTE: if you do use your existing account with 'preview' 2.14 Markab version of the Designer, do NOT go back to using 2.13 'Rosemary' afterwards. This can lead to problems with your account data since the 2.14 'preview' is not backwards compatible with 2.13 Rosemary.

Lawrie will be following up with more detailed information about the new protocols, how to use them, etc.


ttscommand.png (image/png)
say.png (image/png)
email.png (image/png)
fanoff.png (image/png)
power.png (image/png)
emailparam.png (image/png)

Relevant issues to track towards release:

ORCJAVA-387
ORCJAVA-386
ORCJAVA-385

And:

MODELER-511
MODELER-510
MODELER-509

Posted by juha at Aug 01, 2013 11:51

Here is how to use Text to Speech.

How To - Text to Speech

The OpenRemote 2.2 Controller has the capability to convert text to speech using the FreeTTS open source Java software. All defaults are used including the default voice - a male voice called Kevin. I have only tried English. Different voices may need to be created for other languages.

Create a device

The device name and properties are not important. You can use any device.

Add a command

You can type in any text that you want spoken, and can include ${param} if you are invoking the command from a rule, e.g.:

Speaking text from a rule

You can write rules that give spoken alerts, for example:

package org.openremote.controller.protocol

global org.openremote.controller.statuscache.CommandFacade execute;

rule "Execute Scheduled Command"

  timer (int: 0s 30s)

when

  eval(true)
  
then
  
  execute.command("say", "Parameter test");

end
Posted by lawrie at Aug 01, 2013 12:38

Here is how to use the Email protocol.

How To - Email

The OpenRemote 2.2 Controller has the capability to send emails using JavaMail API. So far it has only been tested with gmail as the sending account.

The configuration properties for the Email protocol are in webapps/controller/WEB-INF/classes/config.properties.

You need to set the username and password of the sender, for example:

# EMAIL CONFIGURATION:
# 
# Configuration related to the generic email protocol
##
mail.smtps.host=smtp.gmail.com
mail.smtp.socketFactory.class=javax.net.ssl.SSLSocketFactory
mail.smtp.socketFactory.fallback="false
mail.smtp.port=465
mail.smtp.socketFactory.port=465
mail.smtps.auth=true
mail.smtps.quitwait=false
email.domain=gmail.com
email.username=mygmailuser
email.password=mypassword
email.protocol=smtps
email.charset=utf-8

Create a Device

The device name and properties are not important. You can use any device.

Add a Command

You can type in any text as the subject of the email in the Subject field, and any text you want to send in the Message field. You can include ${param} if you are invoking the command from a rule:

The recipient should be any valid email address that you want the email to be sent to.

Sending emails from a rule

You can write rules that send emails, for example:

package org.openremote.controller.protocol

global org.openremote.controller.statuscache.CommandFacade execute;

rule "Execute Scheduled Command"

  timer (int: 0s 30s)

when

  eval(true)
  
then
  
  execute.command("email", "Parameter test");

end
Posted by lawrie at Aug 12, 2013 11:56

Here is how to use the generic Serial protocol:

How To - Serial

The generic Serial protocol allows you to communicate with serial devices, such as Arduinos. It is not limited to the Arduino, but can be used with other serial devices that use similar serial data parameters to the Arduino.

Devices controlled by this protocol can be connected to your host computer using USB or another type of serial connection. The Java RXTX library is used to communicate with the device.

You can specify the COM port name of the device and its data rate. The connection to the device, once opened, is kept open. More than one OpenRemote device and more than one OpenRemote command can share the same serial connection.

The protocol can be used to send control commands, and also to read values from sensors.

Create a Device

The device name and properties are not important. You can use any device.

Add a Command

The format of the device name is dependant on your host computer. On Microsoft Windows, it is COMn or COMnn.

You should use the com port and data rate that your Arduino or other serial device has been configured to use.

Examples

Controlling a LightwaveRF device

You can use the protocol to control a multitude of different devices. One example is to control LightwaveRF switches and sockets, which are popular in the UK.

This method does not use the LightwaveRF Wifi Link, but controls the LightwaveRF devices directly via their RF protocol. To do this you need a 434Mhz RF transmitter connected to an Arduino or compatible device. You also need a suitable Sketch downloaded to your Arduino.

A suitable sketch is:

#include <LightwaveRF.h>
                     
byte myid[] = {0x6F,0xEB,0xBE,0xED,0xB7,0x7B};

void setup() {
  lw_setup();
  Serial.begin(9600);
}

void loop() {
  if (Serial.available()) {
    char c1 = Serial.read();
    while(!Serial.available());
    char c2 = Serial.read();
   
    if (c2 >= '0' && c2 <= '9') { // device number
      byte d = c2 - '0';
      if (c1 =='1') {
        Serial.println("Switch device on");
        lw_cmd(0,d,LW_ON,myid);
      } else if (c1 == '0') {
        Serial.println("Switch device off");
        lw_cmd(0,d,LW_OFF,myid);
      }
    }
  }
}

This sketch uses a library available at https://github.com/lawrie/LightwaveRF.

You will to change myid to the ID of a LightWaveRF that has been paired with your LightwaveRF socket of light switch.

The protocol that this sketch uses is very simple. Ypu send it two bytes. 1d turnrs the device on and 0d, turns the device off, where d is the channel number on your LightwaveRF remote. The sketch only supports channels 0-9.

The sketch, as supplied, supports up to 10 LightwaveRF devices, but could easily be modified to support 16, or more.

Reading power from an OPenEnergyMonitor emonTx

You can also use the generic serial protocol to read data from sensors.

This example read electrical power readings fom an OpenEnergyMonitor emonTx.

The emonTx transmits data using a HopeRF RFM12B radio at 434 or 868Mhx. You can use a variety of Arduino-compatible devices to read this data including a Jeelink - see http://jeelabs.com/products/jeelink.

A suitable sketch for this is:

#include <JeeLib.h>
#include <avr/eeprom.h>
#include <util/crc16.h>

#define SERIAL_BAUD 57600
#define COLLECT 0x20 // collect mode, i.e. pass incoming without sending acks

#define EMONTX_NODE 10
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// RF12 configuration setup code

typedef struct {
    byte nodeId;
    byte group;
    char msg[RF12_EEPROM_SIZE-4];
    word crc;
} RF12Config;

static RF12Config config;
static int power;

void setup() {
    Serial.begin(SERIAL_BAUD);

    if (rf12_config(0)) {
        config.nodeId = eeprom_read_byte(RF12_EEPROM_ADDR);
        config.group = eeprom_read_byte(RF12_EEPROM_ADDR + 1);
    } else {
        Serial.print("No configuration");
    }
}

void loop() {   
    if (Serial.available()) {
      if (Serial.read() == 'p') { 
        Serial.println(power);
      }
    }
    
    if (rf12_recvDone()) {
        byte n = rf12_len;
        if (rf12_crc == 0) {    
            byte node = (rf12_hdr & 0x1f);
            if (node == EMONTX_NODE) { 
              power = (rf12_data[0] + (rf12_data[1] << 8));;
            }
            if (RF12_WANTS_ACK && (config.nodeId & COLLECT) == 0) {
                rf12_sendStart(RF12_ACK_REPLY, 0, 0);
            }
        } 
    }
}

The command for this looks like:

If you then create a range sensor using this command, you can monitor the power reading from the emonTx.

Posted by lawrie at Aug 12, 2013 14:11

I assume that command email has to be defined first with ${param} in the message field?

Posted by pz1 at Aug 12, 2013 15:16

Yes, similar to the say command above. My example rule will send an email every 30 seconds, so you will ant to change that to something more sensible.

Posted by lawrie at Aug 12, 2013 15:21

Also should the rule action:

execute.command("email", "Parameter test");

use command name "email test" instead to match the command configuration shown in the edit window?

Posted by juha at Aug 12, 2013 15:36

I'll make the description a bit clearer. I was using "email" for the rule case with a parameter, and "email test" for a test using a button, which I have not described.

Posted by lawrie at Aug 12, 2013 15:59

Yes, similar to the say command above

That is how I understood the examples.

Posted by pz1 at Aug 12, 2013 16:17

Hi,
I want to use your serial protocol to communicate with an atmega16 microcontroller (via rs232 - the setup so far beetwen pc and atmega16 works ok --for example I can send "a" and recive "b"(char+1)).
I didn't understand what the attribute command("10" "p") means or how it is defined. All I want for start is to be able to turn on/off a led connected to a uC pin.I'm missing the big picture..
Sorry if this is the wrong place to post didn't want to make another thread.

Ok,now my problem just got much simple. If I send on serial char 'a' my led from uC turns on if I send 's' turns off.How can I make a switch now in designer using serial protocol? I tried to create 2 commands power on/off with the command 'a'/'s' but didn't work.

Posted by joorj at Aug 27, 2013 17:55

George,
First time looking at this.
A couple of assumptions, only the baud rate is being defined in both OpenRemote and the Arduino code, so -
1. The number of data bits is 8?
2. The Parity is None?
So make sure you have your Arduino set the same way.

Looking at the Arduino code, the Commands are the strings that OpenRemote sends to the Arduino. So where it says "10" or "p" means that is the string that is being serial transmitted.
In your case the Command should be "a" for turning ON,and Command should be "s" for turning OFF.
Note - do not include the quotes in the edit box.

Make sure you are using the same letter at either end ie don't put "a" at the OpenRemote end and "A" at the Arduino end.
If you are using a windows platform ,use HyperTerminal to verify what you are actual sending. I.e. in OR have the port set to say COM1 and Hyperterminal set to COM2, Connect a wire from the Tx pin of COM1 to the RX pin of COM2 and see what Hyperterminal is receiving.

In actual fact you could use Hyperterminal to send the "a" and "s" to verify that your Mega code is working correctly.

Neil.

P.S. I use lots of the Atmel Mega chips from Mega8's to Mega128's and XMega's.

Posted by nwe at Aug 29, 2013 12:29

Thank you so much for the answer.
I use atmega16 chip.
Everything you mentioned seems fine.My mega code as you say it's working(if I sent "a" in hyperterm turns on led and "s" turns off)
Now the only option is to check the way you said..but my COM's are usb and I only have one usb->serial.I will buy another one..
but still why isn't working..?

In designer I used the command : power on/9600/a . And I applied this command to a button.So when i press this button in webconsole it should work,right? I got this part right?

Posted by joorj at Aug 29, 2013 13:13

George,
Not sure what you are putting into the Command field (power on/9600/a)?

Using the above "Edit Command" box -

My thinking is for turning the Mega16 output ON

Name = PowerOn (Or whatever you called it)
Protocol = Serial
COM Port = COM1 (Or what ever the USB to serial port you have is set to)
Data rate (bps) = 9600
Command = a

My thinking is for turning the Mega16 output OFF

Name = PowerOFF (Or whatever you called it)
Protocol = Serial
COM Port = COM1 (Or what ever the USB to serial port you have is set to)
Data rate (bps) = 9600
Command = s

I.e. Create to seperate command, one for ON the for OFF.

Neil.

Posted by nwe at Aug 29, 2013 13:23

this is exactly what I did from the beggining but still not working...

Posted by joorj at Aug 29, 2013 13:43

Neil if you have experience with atmega chips can you help with your own version of code.I use atmega16 and have an led on pin PD6.
Maybe with your version of code will work.
Thanks.

Posted by joorj at Aug 30, 2013 16:34

The serial parameters other than the data rate are fixed at parity NONE, data bits 8, and stop bits 1. I could make these parameters if people think this would be a good idea.

George, what you are doing sounds correct, so I don't know why it is not working. Do you get any error or warning messages?

One thing you could try it so download the Arduino IDE and see if your set up works with that, as my code works in a similar way. In the Arduino IDE you should select the COM port for your serial to USB device (from Tools>Serial Port), and then open the Serial Monitor and select the correct data rate, Then try sending your a and s commands and see if you get the expected results.

If this works but this version of OpenRemote Controller does not, then I think I will need to produce a version with debugging in it.

Do your a and s commands return a result? The protocol expects to get a result terminated by a carriage return and line feed and will wait until it receives one. It works like the TCP/IP protocol. The result can be anything for commands, and is ignored. For sensors it must be valid for the type of sensor. All this is the same as for the TCP/IP protocol, as I copied the relevant code from that protocol.

Looking at my code again, it looks as if I should improve the handling of carriage return and line feed, but I doubt if that is anything to do with your problem.

Posted by lawrie at Sep 02, 2013 09:38

Guys it worked in linux(ubuntu)!
Don't really know what I was doing wrong in windows..the only difference in linux /dev/ttyS0 (+chmod 777 /dev/ttyS0 ) instead of COM obviously...and it "magically" worked I'm so happy.
Now I'm having trouble creating a switch . what command should I use for switch sensor? (buttons work)

Thank you very much for implementing serial protocol!Great job!

Posted by joorj at Sep 04, 2013 23:31

Its good to hear that it worked on Linux. I only tested it on Windows.

You can use any commands that you like as long as as the atmega16 (or other serial device) responds to the sensor command and returns the switch value, "on" or "off" terminated by CR and LF.

Posted by lawrie at Sep 05, 2013 10:23

I've just successfully got it working on my raspberry pi!

It took me a while though and after following the guide here, serial wasn't working. In the end it turns out that Java doesn't recognise the /dev/ttyAMA0 serial port on the pi, see: http://www.openremote.org/display/forums/Zwave+problem?focusedCommentId=22414218#comment-22414218

so I entered:

export JAVA_OPTS="$JAVA_OPTS -Dgnu.io.rxtx.SerialPorts=/dev/ttyAMA0"

before ./openremote.sh run

and it worked!! I wasn't sure where to put it in the openremote.sh script so didn't, if anybody could give me a pointer that would be great.

I hope this helps anybody else trying to get serial to work on a raspberry pi.

Posted by westy8563 at Sep 06, 2013 21:36

You could add it in the following part of the openremote.sh, should work:

# Set juli LogManager if it is present
if [ -r "$CATALINA_BASE"/conf/logging.properties ]; then
  JAVA_OPTS="$JAVA_OPTS -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager"
  LOGGING_CONFIG="-Djava.util.logging.config.file=$CATALINA_BASE/conf/logging.properties"
fi



# ===== OPENREMOTE SETUP ==============================================================

# Set up RXTX Serial library properties
JAVA_OPTS="$JAVA_OPTS -Dgnu.io.rxtx.SerialPorts=/dev/ttyAMA0"

# Set up the directory that contains native libraries for the OpenRemote Controller
LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$CATALINA_BASE/webapps/controller/WEB-INF/lib/native"

HTH

Posted by juha at Sep 06, 2013 21:48

I need quick help!Please!
I have some kind of a bug in designer.
I tried to make 2 swithces each for an LED.I created different commands,different devices(in modeler) different everything...
and when I put these 2 switches on a starting panel my LEDs just blink once when I press the switch...the switches are not switching...what might be the problem?
With one switch everything works fine...in a serial terminal everything is fine with both LEDs...

Posted by joorj at Sep 14, 2013 20:46

What do your switches do? Does the on command switch, switch the LED on, and the off command switch it off?

With a single switch, does everything work OK, and does the switch change between on and off status on your screen?

With two switches, you say the LED blinks. Does that mean it receives an on command and an off command, or does just one of those commands make it blink? Do both the LEDs work and keep working? Is the problem just that the switches on the screen do not change status?

I will see if I can reproduce the behaviour using an Arduino device, but I do not fully understand you set-up and any more information you can give me will help.

Posted by lawrie at Sep 14, 2013 21:23

thank you for this fast reply.
So:
I created 2 devices LED1:
Name = PowerOn
Protocol = Serial
COM Port = /dev/ttyS0
Data rate (bps) = 9600
Command = a (returns "ON" string)

Name = PowerOFF
Protocol = Serial
COM Port = COM1
Data rate (bps) = 9600
Command = s (returns "OFF" string)

Name = Status
Protocol = Serial
COM Port = /dev/ttyS0
Data rate (bps) = 9600
Command = X (My controller returns(printf) "on" string if led is on and "off" if off.)

And for LED2 identical just a=b | s=z | X=Y

With one switch it works(switch changes state on screen according to LED on/off)

With 2 switches: If I press a switch,either one,it makes my LED blink one time/pressing and on screen changes to On state then Off state as fast as the LED turns on/off(blinks) so it knows the led state but it doesn't stay on..it's like sending "a" then "s" instantly...so this happens everytime I press the switch.

Posted by joorj at Sep 14, 2013 21:40

I tried all the ways possible..same thing happens...
But maybe here is something relevant for you:

With a device with just one switch created for one LED + plus another device with just the On command for other led: if i place a button on starting screen with the ON command for the 2nd LED it makes my LED blinks like I said above but the switch for first led works OK.How can that be possible?

Posted by joorj at Sep 14, 2013 22:03

I tried to reproduce this, but it works for me.

Could you post or send me your controller.xml file and the code from your serial device. My email is lawrie.griffiths@ntlworld.com.

The details you posted above have the Windows (not Linux) device (COM1) for PowerOFF. Is this what you have in the designer or is it just a typo in the information you posted?

Posted by lawrie at Sep 15, 2013 12:34

I'm using the Ciseco XRF wireless range of transmitters using their LLAP protocol which doesn't finish commands with a CRLN (as far as I can see). As such I am able to send commands, but unfortunately not able to receive commands for use in a sensor. You've mentioned improving handling of line feed, is this something you plan on implementing?

Unfortunately I'm not much of a programmer so don't know where to start otherwise I'd try have a look myself. I'd be more than happy to test any changes for you if this would be of any help?

Posted by westy8563 at Sep 15, 2013 17:25

Yes, I was planning to improve it. It does really need some sort of terminator, as the connection is reused, so there is no good way of telling when the data has ended without a terminator. I could do what the TCP/IP protocol now does and let you specify whether a LF or CRLF terminator is used. Would that solve your problem?

I actually meant to use LF as the terminator and ignore any CR if it occurs (which is does on Windows but not Linux, for example). But currently I am using CR and the terminator and effectively ignoring the LF. That was a mistake. Arduino does use CRLF as the terminator, so the current code worked for me. Would just correcting this bug, help you?

I seem to get a lot of end of file responses when reading from serial connections. I currently ignore them when I am expecting data, so I cannot use that as the terminator.

I could let you specify a terminator character other than CRLF or LF. Would that be better for you?

Posted by lawrie at Sep 15, 2013 19:54

Hi George, The code you sent me looks wrong for the X and Y commands:

if((key_press == 'Y') && (PORTD &= (1<<PD4)))
		printf("on\n");
	else if((key_press == 'Y') && (!(PORTD &= (1<<PD4))))
		printf("off \n");

You should no be using &= as that is changing the LED status. You probably just want &.

Also, I would remove the space at the end of "off".

Finally, you might need to change all the \n characters to \r\n, as a CRLF terminator is currently needed, but perhaps your code is adding that already.

Let me know if those changes fix your problem.

I think the &= explains the led flashing and the fact that the switch does not work, as the sensor is polled continuously and every time you poll the sensor, you are turning off the LED. I do not know why a single switch would have worked.

Posted by lawrie at Sep 15, 2013 20:59

I'm not sure if just using LN would make a difference for me unfortunately, I think it just continues a feed of commands. I understand why a terminator is needed though.

The protocol is always in the format aXXXXXXXXXXX so a 12 character string, would it be possible to use the number of characters as a way of knowing when the data has ended? Alternatively every command starts with an 'a' so perhaps I could use that as a terminator and set up a couple of sensors so that they would terminate each other? If that makes sense?

EDIT: ignore the 'a' terminator thought, I've just realised nothing would actually ever get through because the first 'a' would terminate the data before anything else came through! (It's late!).

Posted by westy8563 at Sep 16, 2013 00:00

What type of sensor do you plan to use with those values? Is the 12-character string numeric? Is so you might be able to define a level or range sensor. I'm not sure how you could use a switch sensor. You might have to use a custom sensor.

I could define optional start and length parameters to extract a number or string from a reply. I'm not sure how generally useful that would be. There are lots of serial devices out there, that work in different ways. It might take a lot of optional parameters to cover them all.

Posted by lawrie at Sep 16, 2013 08:49

I have a wireless dual relay which sends aXYRELAYAON- and aXYRELAYBOFF type commands and a wireless thermometer that sends aXYTEMP+22.0 commands. More info here

A start and length parameter would probably work for me, although agree that it wouldn't be too much use in general terms. I think LLAP lends itself to its own protocol in OR really to take full advantage of it as there are quite a few 'personalities' and commands that can be sent/received. Unfortunately I don't think my programming is anywhere near up to scratch, but it might be something for me to work towards!

I had a look at your blog and it looks like the ciseco wireless devices might be something you're interested in so I'd recomend taking a look if you haven't already.

Posted by westy8563 at Sep 16, 2013 10:30

Just to add my 2 cents worth.
I have done numerous serial string decodes in my time (primarily from weigh scales). Everyone of them had some kind of identifier ie a STX character at the beginning and or ETX character at the end or maybe just a STX or a ETX. And by STX or ETX character I do not necessarily mean a $02 & $03 it could be any characters ie a LF at the end.
As an example [STX]The quick brown[ETX] or The Quick Brown[CR][LF} or [STX]The quick Brown.
Most serial communications have some kind of a reasonably fixed string length ie the above are approximately 16 characters in length and are typically transmitted in a continuous fashion. But not always
So in my decodes, I look for a) A STX and/or ETX character and the 16 characters of the message. To be a valid message, I must have this string received within a certain period of time.
So say the Baud rate is 9600, this is approximately 1ms per character, so if I receive a string "the quick brown[CR][LF]" within 20ms I have a reasonable idea that the message is complete and that I don't have a part of a message from 3 seconds ago combined with a message coming in right now.
This means I need a timer that gets cleared after the [LF] is received, when the first character of the new message starts coming in, I start the timer and if I have not received the next [LF] within 20ms, I known the message has been corrupted and through it out.
Personally in my serial communications, I packet them in this fashion

STX $02
LEN (packet Length) Ie 5 + data size.
Addr (Destination Addr)
Data 1
Data 2
Data 3
CHKSUM Summed Byte of prior bytes in message
ETX $03

This way I know exactly how big each packet should be (good for error checking) and also a checksum byte (more error checking) and then I through in the timer and I have a very robust message.
Send these Polls every 100ms or less and I know exactly what my hardware is doing.

But for OR you could just go with a Terminator ie ETX/CR/LF and I timer.

Neil.

Posted by nwe at Sep 16, 2013 12:55

Hi there,
I am about a week old in openremote and am loving the platform. X10 with mochad working great, about to put together my VLC controls.

I'm attempting a similar implementation using the arduino to get temperatures from a few DS18B20 sensors. I am running linux and was finally able to get openremote to stop giving me errors in the boot.log regarding my installation of RXTXcomm-2.2-pre2.jar and now openremote seems to start correctly. when I was still seeing no temp on my displays I went looking for other logs and found this: "Implementation error in protocol handler org.openremote.controller.protocol.serial.SerialCommand@xxxxxxxx : nulljava.lang.NullPointerException" repeating over and over again which makes me think that openremote is trying to poll my sensor.

I am able to monitor my serial port using both the arduino IDE and GTKTerm and the commands work as expected in both.

any thoughts on where to go from here?

Thanks

Posted by bigcspecv at Sep 17, 2013 00:51

I think your serial port must be failing to open. There should be an error near the start of the log: Serial: Error opening port: <details>.

I would check that your serial port is correct and look at the replies above about problems opening serial ports on Linux.

The error handling after failing to open the port needs improving. It should not be giving you all those null pointer exceptions. I will fix that when I fix other problems reported in this post. Note that this serial protocol is very new and just being tested, and has only had a few users. Also, it is the first OpenRemote development that I have done.

Posted by lawrie at Sep 17, 2013 08:29

Thanks for the quick reply, I didn't have a chance to post yesterday. I was able to get it working by reinstalling rxtx through ubuntu and copying the files installed into the correct directories within /usr/lib/jvm... (If anyone needs more detail let me know.)

That said, I know this is a new protocol and I am anxious to help in any way I can with it's development. I don't know many languages outside of (pretty basic) web design, but I'd be happy to run tests on my platform and submit test data or write how to's. I write work instructions at my job so I have a bit of experience there.

Also, someday soon I'd like to talk to someone about using this platform commercially with the basic setup I've described thus far (Arduino - OpenRemote). I don't know who to talk to or really where to begin as far as legalities and such. If anyone can point me in the direction of whom I'd need to talk to (or show me something I don't know as to why I couldn't) I'm up for collaborating and getting my design ideas shared with the right people.

Again, Thank you so much for your assistance. It pointed me in the right direction. Let me know if/how I can help.

Craig

Posted by bigcspecv at Sep 19, 2013 00:07

Hi, I'm having an issue with a rule and a serial command. My rule is as follows:

rule "30min Advance" when

  Event(source == "Advance Sensor", value == "on")

then

  execute.command("HEATING ON");

end

The HEATING ON command is a serial command to a relay that works fine with a seperate button. When the rule triggers it turns the relay on but then crashes any switches I have on my panel. When I substitute the serial command for another command everything works as expected. Nothing shows up in the console or the logs I've checked.

I'm not sure if this might be a serial issue or rules issue? Does anybody have any ideas?
Thanks.

Posted by westy8563 at Sep 29, 2013 17:58

It would be very nice if it would be possible to enter the serial port command as hex value. (My device needs STX and EOT at the begin and end of the message) I think for the moment I will be able to set this directly in the command.xml.

Posted by thenetstriker at Oct 07, 2013 11:20

I believe you can use hex commands as I copied the command parsing from the TCP/IP protocol. Just start the command 0x.

Posted by lawrie at Oct 07, 2013 11:35

I've just tried this on my BeagleBone Black (Ängström Linux), but I get the following error when entering commands in this format:
ERROR HTTP\-Thread\-1: Serial: Error sending command to port: /dev/ttyUSB0
java.lang.StringIndexOutOfBoundsException: String index out of range: 13
at java.lang.String.charAt(String.java:658)
at org.openremote.controller.protocol.serial.SerialCommand.hexStringToByteArray(SerialCommand.java:139)
at org.openremote.controller.protocol.serial.SerialCommand.requestData(SerialCommand.java:99)
at org.openremote.controller.protocol.serial.SerialCommand.send(SerialCommand.java:82)
at org.openremote.controller.service.impl.ControlCommandServiceImpl.trigger(ControlCommandServiceImpl.java:95)
at org.openremote.controller.rest.ControlCommandRESTServlet.handleRequest(ControlCommandRESTServlet.java:77)
at org.openremote.controller.rest.RESTAPI.doPost(RESTAPI.java:159)
at org.openremote.controller.rest.RESTAPI.doGet(RESTAPI.java:112)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.openremote.controller.rest.support.json.JSONCallbackFilter.doFilter(JSONCallbackFilter.java:63)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:78)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:77)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:845)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:354)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:724)

When I remove the 0x characters the command can be sent. (I've attached my computer to the other end and listened to the port) But it seams that only the first command is sent, when I click the button a second and third time no command is sent. I've also one time got a warning because of the rxtx version, but I don't think that this could be the problem:
WARNING: RXTX Version mismatch
Jar version = RXTX-2.2pre1
native lib Version = RXTX-2.2pre2

Posted by thenetstriker at Oct 07, 2013 20:25

Can you tell me what data you sent exactly, and I will try to reproduce the problem. I don't think I tested sending hex strings but I thought it would work as I copied the code directly from the TCP/IP protocol.

Having a quick look at the code, it looks as of it would fail if there are an odd number of hex digits. Could that have been the problem?

I am about to fix another problem with the error handling in the code and can build a new version if your problem cannot be circumvented.

Posted by lawrie at Oct 07, 2013 20:49

I've tried to send the following commands. (These are commands for opening the relay on my door transponder system: http://www.produktinfo.conrad.com/datenblaetter/750000-774999/750782-an-01-de-Transponder_Zutrittkontrolle.pdf)

0x02FFCR1520x04
0x02FFCR0510x04

I've also created an sh file which sends these commands, using this file it works every time:
#!/bin/sh
/bin/stty -F /dev/ttyUSB0 57600
/bin/echo -e "\x02FFCR152\x04" > /dev/ttyUSB0

Posted by thenetstriker at Oct 07, 2013 21:12

The problem is that you can either send the command as character data, or hex data, but not a mixture of both. The java hex literal format is supported, not the shell script string literal format with hex escape characters.

So if the literal starts 0x, it must have an even number of hex digits and consist entirely of hex digits.

To send the data you require, you will need to convert the ascii characters to hex. Something like:

0x024646435231353204

I could make the serial protocol use any format we like, but it seems sensible to follow the conventions of other protocols like TCP/IP.

Posted by lawrie at Oct 07, 2013 22:16

Thanks, this command worked! But it still seams that only the first time I press the button a command is sent. I've now mapped the open relay command to one button and the relay close command to another. With this configuration I am able to once open the relay and close it once. If I press the open button again nothing happens. (And no error on console) What am I doing wrong? (The same configuration with my shell commands is working every time I hit the button)

Posted by thenetstriker at Oct 07, 2013 23:12

The problem could be that there is no reply from these commands. Again the code works like the TCP/IP protocol and waits for a reply from commands. Currently, it has no timeout and waits forever. Also as discussed earlier in this thread, it expects CRLF as the terminator of the reply. I plan to make this more flexible and add a timeout, but it might be hard to cope with the varied responses that different devices give. Do these commands have any reply?

Posted by lawrie at Oct 07, 2013 23:28

Yes they have a reply, as described in the pdf the reply has this format: <STX><ADR><COMMAND><SUBCOMMAND><ACK><CRC><EOT>
Will there be a setting in the final version where I can set that EOT marks the end of a transmission instead of CRLF?

Posted by thenetstriker at Oct 08, 2013 00:00

Yes, I could be a lot more flexible about the terminator and let you specify it in hex, so 0x04 for EOT. For commands from buttons this is not a problem as the reply is effectively ignored For sensors it is more difficult as it will be necessary to extract information from the reply. Regular expressions might be needed for that.

Perhaps I will do an interim version that just gives more flexibility with the terminator and see if that fixes your problem.

Posted by lawrie at Oct 08, 2013 07:21

Is the sourcecode of this version already published? I found nothing in the sourceforge repository.

Posted by thenetstriker at Oct 16, 2013 12:12

It is in workspace/lgriffiths/Controller_2_1_0_FM_SerialFixes

Posted by lawrie at Oct 16, 2013 12:26

Thanks for the link. I've compiled my own version and replaced the carriage return with 0x04 and that seams to work fine with my device.
Another question, I'm experiencing a lot of problems with my onewire devices with this version. (I get a lot of "N/A" readings, problems with events) Is this a known issue of this release or a problem of my device?

Edit: Maybe I just found the error. My rules had an error.

Posted by thenetstriker at Oct 16, 2013 21:00

I think I found an error in this version. I've added a custom Sensor with custom state items "0" = "0" and "1" = "1", configured an image and with custom images for the two custom states, but the image does not change in the webcontroller. (On my iPad on the same screen the image change works) I've also tried to add a label with two custom strings for the two custom states. With this settings I get even an "Unknown controller exception" on the webinterface. (On the iPad I get no error and the values are displayed correctly)

The same configuration but with the custom states set to "0" = "off" and "1" = "on" works perfectly, but I cannot use this configuration because I want to log the states using rrd. Can you please fix this problem in the next release?

Posted by thenetstriker at Oct 24, 2013 19:51

hi,
need some help with serial

I did a bunch of digging around on my own and have gotten further.

1) I had encountered an error to the effect of a " Word Length Mismatch error " with RxTx
I did some hunting around and found it was due to my running on a 64 bit system

I found some 64 bit RxTx files here http://mfizz.com/oss/rxtx-for-java

I than unziped the package and copied 3 files into openremote

RXTXcomm.jar went in controller/WEB-INF/lib
librxtxSerial.so went in lib/native
libParallel.so also went in native

after restarting and launching the webconsole I used the button I had given the command to and IT WORKED once and than crashed the controller.

As I said I have gotten further than I had before, any next steps or better ways would be appreciated
-Peter

Posted by phreak at Nov 03, 2013 02:37

Hi David,

I'm just wondering whether you are using this for LightwaveRF control, or some other serial connected device ?

FYI, I'm hoping to use OpenEnergyMonitor's RFM12PiV2 to control a number of LightwaveRF devices, and I'm assuming (Lawrie might be able to comment here) that I just load his lwrelay sketch into my RFM12Pi (hopefully directly from the Pi, using avrdude), install this latest version of OpenRemoteController code with Lawrie's serial capability, and then it should all work ?

Any hints, tips or advice gratefully received.

Hugh

Posted by scohrab at Nov 04, 2013 11:46

Hi Hugh,

My LightWaveRF library does not currently work with RFM12B radios, like the one in the RFM12Pi. It only works with the simpler RF 434Mhz transmitters and receivers that are available from Sparkfun/Cool Components or on ebay.

I have an RFM12Pi (probably version 1) but it is 868Mhz and I have only used it with the original sketch.

I have run OpenRemote on a Raspberry Pi, but I mainly run it on Windows.

It should be possible to make my library work with the RFM12B, particularly a 434Mhz version, by modifying one of the existing On-Off keying (OOK) solutions available for Jeenodes, but I have not attempted that.

You should be able to run my lwrelay sketch on an Arduino with RF434Mhz transmitters and receivers, attached by USB to the Raspberry Pi.

Lawrie

Posted by lawrie at Nov 04, 2013 12:26

Hi Lawrie,
Thanks very much for this info. Have you got any idea how much coding I would have to do ? My programming skills are very rusty, and I never learnt any C.
Alternatively, could you tell me the model of Arduino board I would be looking for. I'm able to get the OpenRemote stuff running with a 1wire board with OWFS OK, so I'm hoping to be able to just Plug-and-play.
Hugh

Posted by scohrab at Nov 05, 2013 18:12

Hi,

First of all many thanks for the serial module.
I don't have an issue getting the commands to work (ie sending commands to the device), I'm just having a very hard time getting the sensors working (ie reading back from the serial device).
I'm new with OpenRemote, so I don't know if this version 2.2 is buggy or if I'm doing something wrong (probably the latter)

Let me explain.
A very simple serial device that receives few commands, and responds to few of those.

001 sets the LED on the device off and responds with Serial.println("off");
002 sets the LED on the device on and responds with Serial.println("on");
003 does the same as 002 but no response is returned
004 does the same as 001 but no response is returned
009 increments a counter on the device no return, blinks led once
005 blinks the led and return the counter value.

In the designer, if I add only commands, and test each of them, they all work as expected, LEDs act as expected
I did use a serial monitor to check the serial traffic and everything is in order.

Problem starts if I want to add label(s) to display the returned values.
I added a sensor (type level) that sends the command 005
Then added a label associated to that senser
I expected that the sensor would start display 0 until I hit the Counter increment button (009)
at which point I would expect to see 1 displayed.

The results varied at best,
Mind you I was monitoring the serial communication so I was able to tell what was going on.
at first I saw that the sensor was being polled, ie command 005 sent to the device (perhaps at less than one per second)
but that eventually stopped, no idea why
regardless, the device was doing everything as expected, in fact, all the commands were received from an android ui as I was pressing them
The label display though, was very iffy
at times it display N/A
other times, it would display the counter value, but not consistently, quite often it would not refresh, in fact it is really hard to get it refreshed, just very rarely
Quite bizare.

I also tried to test it from the webcontroller
that one is quite flaky as well, not all commands (buttons) pressed on the Web UI were received by the device
This was never an issue from Android
I'm not sure if the controller was receiving the commands or not (any way to debug the controller to see what it is receiving)
I suspect it wasn't receiving all the commands, and think it is a webcontroller bug.
But I honestly don't care much about the webcontroller, was just merely testing it to see if it would behave differently
Android to device all commands work as expect
device to android not so much.

Any ideas on where I'm going wrong?

I even tried switches, I had zero success there reading back states.

Many thanks in advance

Posted by hrant at Jan 25, 2014 23:03

Hi!

I have been trying to get serial to work with OR on a Raspberry Pi and an Arduino, but I'm stuck with the same problem. Buttons work as they should but with switches and sliders the sensors only works sometimes.

Has anyone figured out how to get this to work properly?

Posted by mattiasl at Feb 12, 2014 08:28

Hello,

is the designer updated? i had some email commands and now they are gone, i cannot choose for email and serial protocol in a new command.
sending email via a command worked perfect before.
something changed?

greetz Rob

Posted by robnas at Jan 30, 2015 18:04

I see the serial protocol is in both staging and preview, i am a pro user, is there any ETA for when the serial protocol will make it to the Pro platform?

Posted by michaeltschmidt at Mar 01, 2015 18:58

Hi!
Does anyone know how to deploy polling interval for serial protocol?

Posted by rayon02 at Aug 29, 2015 18:35
Document generated by Confluence on Jun 05, 2016 09:30