Closed sbjdk closed 9 years ago
@sumnerboy12 could you probably have a look at this? Thanks, Thomas E.-E.
@sbjdk I haven't used this binding for a couple of years now, so unfortunately I am not in a position to test/diagnose this. It sounds like you have figured out what the problem is however, are you able to create a pull request with your proposed changes?
Hi
I don't have a solution, but I would certainly like to contribute. Would you be available to answer some concrete questions in the process?
Thanks
/Steffen
2015-06-03 0:43 GMT+02:00 Ben Jones notifications@github.com:
@sbjdk https://github.com/sbjdk I haven't used this binding for a couple of years now, so unfortunately I am not in a position to test/diagnose this. It sounds like you have figured out what the problem is however, are you able to create a pull request with your proposed changes?
— Reply to this email directly or view it on GitHub https://github.com/openhab/openhab/issues/2679#issuecomment-108119196.
If I can help I would be more than happy to oblige.
On 03/06/2015 7:43 p.m., sbjdk wrote:
Hi
I don't have a solution, but I would certainly like to contribute. Would you be available to answer some concrete questions in the process?
Thanks
/Steffen
2015-06-03 0:43 GMT+02:00 Ben Jones notifications@github.com:
@sbjdk https://github.com/sbjdk I haven't used this binding for a couple of years now, so unfortunately I am not in a position to test/diagnose this. It sounds like you have figured out what the problem is however, are you able to create a pull request with your proposed changes?
— Reply to this email directly or view it on GitHub https://github.com/openhab/openhab/issues/2679#issuecomment-108119196.
— Reply to this email directly or view it on GitHub https://github.com/openhab/openhab/issues/2679#issuecomment-108233286.
Hi Ben
There is a method read_output() in pfio that should help us. It should return a byte with the state of all 8 output ports.
https://github.com/thomasmacpherson/piface/blob/master/python/piface/pfio.py
I then looked at exposing this from ohpiface.py using a new command and found these command/ack identifiers in the code.
WATCHDOG_CMD = 14 WATCHDOG_ACK = 15
WRITE_OUT_CMD = 1 WRITE_OUT_ACK = 2 READ_OUT_CMD = 3 READ_OUT_ACK = 4 READ_IN_CMD = 5 READ_IN_ACK = 6 DIGITAL_WRITE_CMD = 7 DIGITAL_WRITE_ACK = 8 DIGITAL_READ_CMD = 9 DIGITAL_READ_ACK = 10
Some of these are not used. Do you see any reasons why WRITE_OUT, READ_OUT and READ_IN should not be implemented. READ_OUT, of course, is what I would use from the java side.
Thanks
/Steffen
2015-06-03 9:54 GMT+02:00 Ben Jones notifications@github.com:
If I can help I would be more than happy to oblige.
On 03/06/2015 7:43 p.m., sbjdk wrote:
Hi
I don't have a solution, but I would certainly like to contribute. Would you be available to answer some concrete questions in the process?
Thanks
/Steffen
2015-06-03 0:43 GMT+02:00 Ben Jones notifications@github.com:
@sbjdk https://github.com/sbjdk I haven't used this binding for a couple of years now, so unfortunately I am not in a position to test/diagnose this. It sounds like you have figured out what the problem is however, are you able to create a pull request with your proposed changes?
— Reply to this email directly or view it on GitHub <https://github.com/openhab/openhab/issues/2679#issuecomment-108119196 .
— Reply to this email directly or view it on GitHub https://github.com/openhab/openhab/issues/2679#issuecomment-108233286.
— Reply to this email directly or view it on GitHub https://github.com/openhab/openhab/issues/2679#issuecomment-108235399.
Hi Steffen,
Just had a quick look at the ohpiface.py python script and from what I can tell it is not a simple change to do what you are asking, since the script doesn't 'know' what output pins it is responsible for. It is only configured with the list of pins to monitor.
The output pins are effectively 'late binding' - in that it is only when the script receives a write command for a given output pin, that is knows that pin is being controlled.
And because the input/output pins are numbered the same, you can't just read all output pins and publish their values back to the binding, since it will think they are the pins being monitored.
In short, the binding is pretty simple, and only really allows one-way comms with the output pins - you send commands and get an ACK that the command was received, but you can't monitor those pins.
Would probably be a welcome addition to change this, but would require a fair bit of re-working of the binding configuration in order to allow monitoring of these output pins somehow.
Sorry, thought it might be an easy fix but I am now getting recollections of looking at this when I wrote the binding and deciding it was going to be too tricky.
Ben
On 4/06/2015 9:19 a.m., sbjdk wrote:
Hi Ben
There is a method read_output() in pfio that should help us. It should return a byte with the state of all 8 output ports.
https://github.com/thomasmacpherson/piface/blob/master/python/piface/pfio.py
I then looked at exposing this from ohpiface.py using a new command and found these command/ack identifiers in the code.
WATCHDOG_CMD = 14 WATCHDOG_ACK = 15
WRITE_OUT_CMD = 1 WRITE_OUT_ACK = 2 READ_OUT_CMD = 3 READ_OUT_ACK = 4 READ_IN_CMD = 5 READ_IN_ACK = 6 DIGITAL_WRITE_CMD = 7 DIGITAL_WRITE_ACK = 8 DIGITAL_READ_CMD = 9 DIGITAL_READ_ACK = 10
Some of these are not used. Do you see any reasons why WRITE_OUT, READ_OUT and READ_IN should not be implemented. READ_OUT, of course, is what I would use from the java side.
Thanks
/Steffen
2015-06-03 9:54 GMT+02:00 Ben Jones notifications@github.com:
If I can help I would be more than happy to oblige.
On 03/06/2015 7:43 p.m., sbjdk wrote:
Hi
I don't have a solution, but I would certainly like to contribute. Would you be available to answer some concrete questions in the process?
Thanks
/Steffen
2015-06-03 0:43 GMT+02:00 Ben Jones notifications@github.com:
@sbjdk https://github.com/sbjdk I haven't used this binding for a couple of years now, so unfortunately I am not in a position to test/diagnose this. It sounds like you have figured out what the problem is however, are you able to create a pull request with your proposed changes?
— Reply to this email directly or view it on GitHub
<https://github.com/openhab/openhab/issues/2679#issuecomment-108119196 .
— Reply to this email directly or view it on GitHub
https://github.com/openhab/openhab/issues/2679#issuecomment-108233286.
— Reply to this email directly or view it on GitHub https://github.com/openhab/openhab/issues/2679#issuecomment-108235399.
— Reply to this email directly or view it on GitHub https://github.com/openhab/openhab/issues/2679#issuecomment-108618791.
Hi
I added this bit of code to ohpiface.py
elif packet.command == READ_OUT_CMD: if verbose: print "Digital read request for output pins" response = UdpPacket(READ_OUT_ACK, 0, pfio.read_output()) socket.sendto(response.for_network(), self.client_address)
Then I wrote a small Java application based on the sendCommand method from PifaceBinding. It sends READ_OUT_CMD and the byte that comes back holds the state of all 8 output pins. So far, so good.
I'm thinking that PifaceBinding could periodically issue this command. Any issues here that you can think of? I guess we would end up with calls like these:
eventPublisher.postUpdate(itemName, OnOffType.OFF); eventPublisher.postUpdate(itemName, OnOffType.ON);
/Steffen
2015-06-04 22:41 GMT+02:00 Ben Jones notifications@github.com:
Hi Steffen,
Just had a quick look at the ohpiface.py python script and from what I can tell it is not a simple change to do what you are asking, since the script doesn't 'know' what output pins it is responsible for. It is only configured with the list of pins to monitor.
The output pins are effectively 'late binding' - in that it is only when the script receives a write command for a given output pin, that is knows that pin is being controlled.
And because the input/output pins are numbered the same, you can't just read all output pins and publish their values back to the binding, since it will think they are the pins being monitored.
In short, the binding is pretty simple, and only really allows one-way comms with the output pins - you send commands and get an ACK that the command was received, but you can't monitor those pins.
Would probably be a welcome addition to change this, but would require a fair bit of re-working of the binding configuration in order to allow monitoring of these output pins somehow.
Sorry, thought it might be an easy fix but I am now getting recollections of looking at this when I wrote the binding and deciding it was going to be too tricky.
Ben
On 4/06/2015 9:19 a.m., sbjdk wrote:
Hi Ben
There is a method read_output() in pfio that should help us. It should return a byte with the state of all 8 output ports.
https://github.com/thomasmacpherson/piface/blob/master/python/piface/pfio.py
I then looked at exposing this from ohpiface.py using a new command and found these command/ack identifiers in the code.
WATCHDOG_CMD = 14 WATCHDOG_ACK = 15
WRITE_OUT_CMD = 1 WRITE_OUT_ACK = 2 READ_OUT_CMD = 3 READ_OUT_ACK = 4 READ_IN_CMD = 5 READ_IN_ACK = 6 DIGITAL_WRITE_CMD = 7 DIGITAL_WRITE_ACK = 8 DIGITAL_READ_CMD = 9 DIGITAL_READ_ACK = 10
Some of these are not used. Do you see any reasons why WRITE_OUT, READ_OUT and READ_IN should not be implemented. READ_OUT, of course, is what I would use from the java side.
Thanks
/Steffen
2015-06-03 9:54 GMT+02:00 Ben Jones notifications@github.com:
If I can help I would be more than happy to oblige.
On 03/06/2015 7:43 p.m., sbjdk wrote:
Hi
I don't have a solution, but I would certainly like to contribute. Would you be available to answer some concrete questions in the process?
Thanks
/Steffen
2015-06-03 0:43 GMT+02:00 Ben Jones notifications@github.com:
@sbjdk https://github.com/sbjdk I haven't used this binding for a couple of years now, so unfortunately I am not in a position to test/diagnose this. It sounds like you have figured out what the problem is however, are you able to create a pull request with your proposed changes?
— Reply to this email directly or view it on GitHub
<https://github.com/openhab/openhab/issues/2679#issuecomment-108119196 .
— Reply to this email directly or view it on GitHub
https://github.com/openhab/openhab/issues/2679#issuecomment-108233286.
— Reply to this email directly or view it on GitHub <https://github.com/openhab/openhab/issues/2679#issuecomment-108235399 .
— Reply to this email directly or view it on GitHub https://github.com/openhab/openhab/issues/2679#issuecomment-108618791.
— Reply to this email directly or view it on GitHub https://github.com/openhab/openhab/issues/2679#issuecomment-109043542.
Hey Steffen,
That looks promising. I would try and avoid polling the RPi (or at least make it configurable so you can disable it if required) as I try to minimise this sort of continuous polling on my network.
But sending a request at startup to get the current state would be great. And then depending on the binding config you could periodically poll for changes as well.
Great work! Ben
fixed by #2733 …
The binding confuses input pins and output pins. Follow this to reproduce:
Simple items
Messages like these should appear in the log (INFO)
When looking at the log and the UI, it becomes evident that the state of the output pins are not read correctly. All Switches are OFF - unless (as above) the input pin with the same number is CLOSED.
I suspect that the 'digital read' method should have BindingType (IN, OUT) included since both have pin numbers 0-7.
int value = sendDigitalRead(node, bindingConfig.getPinNumber());