No ACK before Reset

Discussion about Z-Uno product. Visit http://z-uno.z-wave.me for more details.
dawiinci
Posts: 46
Joined: 14 Oct 2017 10:54

Re: No ACK before Reset

Post by dawiinci » 09 Dec 2017 11:50

It didn't work as expected. I can send commands which are executed but if I read the status I don't get anything. basically I get "-1".

Any ideas?

dawiinci
Posts: 46
Joined: 14 Oct 2017 10:54

Re: No ACK before Reset

Post by dawiinci » 01 Jan 2018 20:30

Something is still wrong.

Here's the updated code which should work. However wether I connect the Autonomer or not I always get -1. Even if I set a delay between clearing and reading I get the value almost immediately. It looks like as if the Z-Uno just ignores the delay(5000) completely.

Any help is appreciated.

Code: Select all

// V1.6

ZUNO_SETUP_SLEEPING_MODE(ZUNO_SLEEPING_MODE_SLEEPING);

ZUNO_SETUP_CHANNELS(
  ZUNO_SENSOR_MULTILEVEL(ZUNO_SENSOR_MULTILEVEL_TYPE_GENERAL_PURPOSE_VALUE, SENSOR_MULTILEVEL_SCALE_PERCENTAGE_VALUE, SENSOR_MULTILEVEL_SIZE_TWO_BYTES, SENSOR_MULTILEVEL_PRECISION_ZERO_DECIMALS, getterStatus),
  ZUNO_SWITCH_BINARY(getterNull, setterAutomower));

uint8_t requestStatusAutomower[5] = { 0x0F, 0x01, 0xF1, 0x00, 0x00 };
uint8_t autoAutomower[5] = { 0x0F, 0x81, 0x2C, 0x00, 0x01 };
uint8_t chargeAutomower[5] = { 0x0F, 0x81, 0x2C, 0x00, 0x03 };
uint8_t statusAutomower[5] = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };
uint8_t commandAutomower[5] = { 0x0F, 0x01, 0xF1, 0x00, 0x00 };

int statusInt;

void SerialWriteBuf(uint8_t *buffer, size_t size)
{
  while (size != 0) {
    Serial1.write((uint8_t) * buffer);
    buffer++;
    size--;
  }
}

void setup() {
  Serial1.begin(9600);
}

void loop() {
}

int getterStatus(void) {
  memcpy(commandAutomower, requestStatusAutomower, sizeof(commandAutomower));

  while (Serial1.available())
    Serial1.read(); //clear buffer

  SerialWriteBuf(commandAutomower, sizeof(commandAutomower));
  delay(5000);
  Serial1.readBytes(statusAutomower, 5);

  statusInt = statusAutomower[4] << 8 | statusAutomower[3]; // Last two bytes inverted!
  return statusInt; // ID according to list (-1 is no RS-232)
}

int getterNull(void) {
  // no status, switch only triggers
  return 0;
}

void setterAutomower(byte value) {
  if (value == 1) {
    //switch on, Automower AUTO
    memcpy(commandAutomower, autoAutomower, sizeof(commandAutomower));
    SerialWriteBuf(commandAutomower, sizeof(commandAutomower)); //Serial1.write(commandAutomower, 5);
  }
  else {
    //switch off, Automower HOME (charge)
    memcpy(commandAutomower, chargeAutomower, sizeof(commandAutomower));
    SerialWriteBuf(commandAutomower, sizeof(commandAutomower));
  }
}

petergebruers
Posts: 170
Joined: 26 Jul 2015 17:29

Re: No ACK before Reset

Post by petergebruers » 01 Jan 2018 20:51

Are you sure you get valid data on the right pins? -1 sounds as if the pin is not connected, or the other device does not send any data (idle = vcc).

If you do not have scope or a logic analyzer, here is something you could try. Remove the mower and connect serial rx to tx. Each time you send data, you should be able to receive that same data...

dawiinci
Posts: 46
Joined: 14 Oct 2017 10:54

Re: No ACK before Reset

Post by dawiinci » 02 Jan 2018 13:43

Good point I tested it and it works like you said.

So what could be wrong with Serial, because it worked with AltSoftSerial:
viewtopic.php?f=3427&t=25584

Also if I use the delay the response is always immediate, I figured out this is by design... Maybe the mower needs more time. But how could I do this.

I only want to get the values by polling, but I want the values instantly. So putting the code in loop isn't very efficient.

dawiinci
Posts: 46
Joined: 14 Oct 2017 10:54

Re: No ACK before Reset

Post by dawiinci » 02 Jan 2018 14:34

Update: it works as soon as I put the stuff in loop and add delays. Seems like this is the only way of doing it.

However, I am a bit concerned about requesting the status every two seconds from the mower (service port). Is this concern making sense?

petergebruers
Posts: 170
Joined: 26 Jul 2015 17:29

Re: No ACK before Reset

Post by petergebruers » 02 Jan 2018 20:45

Sounds like you have made some progress. I am not at home to try something with your code, maybe I can do this tomorrow.

It is hard to tell what tx-rx does to your particular device, but it is a very good question. When I test sensors, I limit data transmission to save (battery) power. This is one possible effect. I think a BME280 can self heat by about 0.5 degrees when polled at maximum speed versus once every second. So these are two real world examples of possible side effects.

dawiinci
Posts: 46
Joined: 14 Oct 2017 10:54

Re: No ACK before Reset

Post by dawiinci » 03 Jan 2018 13:47

Thanks for your insights. Despite the battery, do you think there is wear on the electronics of the mower or not? This was my main concern.

Post Reply