opened
basvdijk
username_0
Are there any plans to create a `setmode` function in order to configure the RFXcom for the protocols to listen to?

http://docs.openhab.org/addons/bindings/rfxcom1/readme.html for example describes a `setMode` function with a hex value e.g. `0D000000035300000C2F00000000`.
Feature request for setmode option
issue
created
basvdijk
username_0
I figured by reading the source how I might be able to use the `enable` function. However the program hangs on sending the code to the rfxcom.

Any thoughts?

```
configuredEnabledProtocols = ['AC', 'BYRONSX', 'LIGHTING4', 'OREGON', 'RUBICSON', 'X10'];

let enabledProtocolArray = [];

configuredEnabledProtocols.forEach(function (protocol) {
    enabledProtocolArray.push(rfxcom.protocols[protocol]);
}, this);

console.log(enabledProtocolArray);
// echoes: 
// [ { bit: 4, msg: 5 },
//   { bit: 32, msg: 3 },
//   { bit: 8, msg: 3 },
//   { bit: 32, msg: 5 },
//   { bit: 2, msg: 3 },
//   { bit: 1, msg: 5 } ]

rfxtrx.enable(enabledProtocolArray, function onDone(response) {
    console.log(response);
});
```
comment
created
maxwellhadley
username_1
I've tried duplicating your issue, and I get an abnormal exit as soon as the code tries to write the message to the serialport:

    const rfxcom = require('rfxcom');

    const rfxtrx = new rfxcom.RfxCom("/dev/tty.usbserial-A1R1A6A", {debug: true}); 

    rfxtrx.initialise(function () {
        console.log("Device initialised");
        rfxtrx.enable([rfxcom.protocols.LIGHTING4,
                        rfxcom.protocols.OREGON,
                        rfxcom.protocols.AC,
                        rfxcom.protocols.ARC,
                        rfxcom.protocols.X10]);
    });

with the message:

    Process finished with exit code 134 (interrupted by signal 6: SIGABRT)

I don't know what is going on here - I'll have to investigate in more depth
comment
created
maxwellhadley
username_1
OK so I was sending the command too early, before everything was initialised. Now I can see it going into an infinite loop, re-initialising the device every time. Looks like a bug in the `statusHandler()` logic
comment
created
basvdijk
username_0
@username_1 Thanks for looking into this That explains why my applications was hanging. Any thoughts on how this could be fixed? Btw your example would be a nice one for the documentation about the `enable` function :)
comment
created
maxwellhadley
username_1
I have found a problem with the initialisation logic. The callback supplied to the `initialise()` function was being called before the device was properly initialised. The logic for this is complicated because the actual sequence of commands and responses required changed from firmware release 433_81/181/234 02-01-2015 and onwards, and I try to cope with both. I think this bug also explains why the software goes into an infinite loop, or at least my fix for it stops the loop from happening. What firmware version are you using?

Please can you run a test for me? Run the following code, which should provoke the infinite loop, and post the console output (for at least a couple of loop iterations)

    const rfxcom = require('rfxcom');
    const rfxtrx = new rfxcom.RfxCom("/dev/tty.usbserial-A1R1A6A", {debug: true});
    rfxtrx.on("status", function (evt) {console.log(evt)});

    rfxtrx.initialise(function () {
        console.log("Device initialised");
        setTimeout( function () {
            rfxtrx.enable([rfxcom.protocols.LIGHTING4,
                rfxcom.protocols.OREGON,
                rfxcom.protocols.AC,
                rfxcom.protocols.ARC,
                rfxcom.protocols.X10])
        }, 2000);
    });

Obviously you will need to use the correct device path for your system, and the exact set of protocols enabled doesn't matter, so just use what you are happy with
comment
created
basvdijk
username_0
Here is the output. I must say I haven't updated my firmware for at least a year...

```
[rfxcom] on /dev/ttyUSB-RFX433 - Sent    : 0D,00,00,00,00,00,00,00,00,00,00,00,00,00
[rfxcom] on /dev/ttyUSB-RFX433 - Sent    : 0D,00,00,01,02,00,00,00,00,00,00,00,00,00
[rfxcom] on /dev/ttyUSB-RFX433 - Received: 14,01,00,01,02,53,01,2A,00,24,00,01,02,1C,03,52,46,58,43,4F,4D
{ subtype: 0,
  seqnbr: 1,
  cmnd: 2,
  receiverType: '433.92MHz transceiver',
  hardwareVersion: '1.2',
  firmwareVersion: 1001,
  firmwareType: 'Ext',
  enabledProtocols: [ 'RUBICSON', 'LIGHTING4', 'BYRONSX', 'AC', 'OREGON' ] }
[rfxcom] on /dev/ttyUSB-RFX433 - Sent    : 0D,00,00,02,07,00,00,00,00,00,00,00,00,00
Device initialised
[rfxcom] on /dev/ttyUSB-RFX433 - Received: 14,01,07,02,07,43,6F,70,79,72,69,67,68,74,20,52,46,58,43,4F,4D
[rfxcom] on /dev/ttyUSB-RFX433 - Copyright RFXCOM
[rfxcom] on /dev/ttyUSB-RFX433 - Started command message queue
[rfxcom] on /dev/ttyUSB-RFX433 - Sent    : 0D,00,00,03,03,53,00,08,00,27,00,00,00,00
[rfxcom] on /dev/ttyUSB-RFX433 - Received: 14,01,00,03,03,53,01,08,00,27,00,01,02,1C,03,52,46,58,43,4F,4D
{ subtype: 0,
  seqnbr: 3,
  cmnd: 3,
  receiverType: '433.92MHz transceiver',
  hardwareVersion: '1.2',
  firmwareVersion: 1001,
  firmwareType: 'Ext',
  enabledProtocols: [ 'LIGHTING4', 'X10', 'ARC', 'AC', 'OREGON' ] }
[rfxcom] on /dev/ttyUSB-RFX433 - Sent    : 0D,00,00,04,07,00,00,00,00,00,00,00,00,00
Device initialised
[rfxcom] on /dev/ttyUSB-RFX433 - Received: 14,01,07,04,07,43,6F,70,79,72,69,67,68,74,20,52,46,58,43,4F,4D
[rfxcom] on /dev/ttyUSB-RFX433 - Copyright RFXCOM
[rfxcom] on /dev/ttyUSB-RFX433 - Started command message queue
[rfxcom] on /dev/ttyUSB-RFX433 - Sent    : 0D,00,00,05,03,53,00,08,00,27,00,00,00,00
[rfxcom] on /dev/ttyUSB-RFX433 - Received: 14,01,00,05,03,53,01,08,00,27,00,01,02,1C,03,52,46,58,43,4F,4D
{ subtype: 0,
  seqnbr: 5,
  cmnd: 3,
  receiverType: '433.92MHz transceiver',
  hardwareVersion: '1.2',
  firmwareVersion: 1001,
  firmwareType: 'Ext',
  enabledProtocols: [ 'LIGHTING4', 'X10', 'ARC', 'AC', 'OREGON' ] }
[rfxcom] on /dev/ttyUSB-RFX433 - Sent    : 0D,00,00,06,07,00,00,00,00,00,00,00,00,00
Device initialised
[rfxcom] on /dev/ttyUSB-RFX433 - Received: 14,01,07,06,07,43,6F,70,79,72,69,67,68,74,20,52,46,58,43,4F,4D
[rfxcom] on /dev/ttyUSB-RFX433 - Copyright RFXCOM
[rfxcom] on /dev/ttyUSB-RFX433 - Started command message queue
[rfxcom] on /dev/ttyUSB-RFX433 - Sent    : 0D,00,00,07,03,53,00,08,00,27,00,00,00,00
[rfxcom] on /dev/ttyUSB-RFX433 - Received: 14,01,00,07,03,53,01,08,00,27,00,01,02,1C,03,52,46,58,43,4F,4D
{ subtype: 0,
  seqnbr: 7,
  cmnd: 3,
  receiverType: '433.92MHz transceiver',
  hardwareVersion: '1.2',
  firmwareVersion: 1001,
  firmwareType: 'Ext',
  enabledProtocols: [ 'LIGHTING4', 'X10', 'ARC', 'AC', 'OREGON' ] }
[rfxcom] on /dev/ttyUSB-RFX433 - Sent    : 0D,00,00,08,07,00,00,00,00,00,00,00,00,00
Device initialised
[rfxcom] on /dev/ttyUSB-RFX433 - Received: 14,01,07,08,07,43,6F,70,79,72,69,67,68,74,20,52,46,58,43,4F,4D
[rfxcom] on /dev/ttyUSB-RFX433 - Copyright RFXCOM
[rfxcom] on /dev/ttyUSB-RFX433 - Started command message queue
[rfxcom] on /dev/ttyUSB-RFX433 - Sent    : 0D,00,00,09,03,53,00,08,00,27,00,00,00,00
[rfxcom] on /dev/ttyUSB-RFX433 - Received: 14,01,00,09,03,53,01,08,00,27,00,01,02,1C,03,52,46,58,43,4F,4D
{ subtype: 0,
  seqnbr: 9,
  cmnd: 3,
  receiverType: '433.92MHz transceiver',
  hardwareVersion: '1.2',
  firmwareVersion: 1001,
  firmwareType: 'Ext',
  enabledProtocols: [ 'LIGHTING4', 'X10', 'ARC', 'AC', 'OREGON' ] }
[rfxcom] on /dev/ttyUSB-RFX433 - Sent    : 0D,00,00,0A,07,00,00,00,00,00,00,00,00,00
Device initialised
[rfxcom] on /dev/ttyUSB-RFX433 - Received: 14,01,07,0A,07,43,6F,70,79,72,69,67,68,74,20,52,46,58,43,4F,4D
[rfxcom] on /dev/ttyUSB-RFX433 - Copyright RFXCOM
[rfxcom] on /dev/ttyUSB-RFX433 - Started command message queue
[rfxcom] on /dev/ttyUSB-RFX433 - Sent    : 0D,00,00,0B,03,53,00,08,00,27,00,00,00,00
[rfxcom] on /dev/ttyUSB-RFX433 - Received: 14,01,00,0B,03,53,01,08,00,27,00,01,02,1C,03,52,46,58,43,4F,4D
{ subtype: 0,
  seqnbr: 11,
  cmnd: 3,
  receiverType: '433.92MHz transceiver',
  hardwareVersion: '1.2',
  firmwareVersion: 1001,
  firmwareType: 'Ext',
  enabledProtocols: [ 'LIGHTING4', 'X10', 'ARC', 'AC', 'OREGON' ] }
[rfxcom] on /dev/ttyUSB-RFX433 - Sent    : 0D,00,00,0C,07,00,00,00,00,00,00,00,00,00
Device initialised
[rfxcom] on /dev/ttyUSB-RFX433 - Received: 14,01,07,0C,07,43,6F,70,79,72,69,67,68,74,20,52,46,58,43,4F,4D
[rfxcom] on /dev/ttyUSB-RFX433 - Copyright RFXCOM
[rfxcom] on /dev/ttyUSB-RFX433 - Started command message queue
```
comment
created
basvdijk
username_0
Just want let you known that I've just upgraded to the latest firmware 1020 but the issue still remains.
comment
created
maxwellhadley
username_1
I've just published 0.16.1 to npm which fixes the initialisation bug, and also makes `enable()` use the transmit queue for consistency with all the other public methods. I'm not 100% this will fix your issue, but `enable()` is now working fine for me here. I'm using a RFXtrx433E with firmware version 1017.
comment
created
basvdijk
username_0
@username_1 Great! I've tested it and now it works. Thanks! Are there any plans to going to support firmware updates?
comment
closed
maxwellhadley
username_1
issue
created
maxwellhadley
username_1
Yes: I'm now quite far progressed along the road toward a 1.0.0 release - see #61 

Thanks for spotting this problem & letting me know about it!
comment