OneWire ATtiny85 Slave read problem

All, need some help getting this to work please. Trying to make a OneWire slave with a tiny85. Using a Nano 3 as the master for testing purposes.

IMG_20160702_185031.jpg

Here’s the Nano/master code:

#include <OneWire.h>
OneWire  ds(4);

void setup() {
  Serial.begin(115200);
}

void sendCommand(byte* buf, byte count  ) {
  //byte cmd[count];
  buf[count] = OneWire::crc8(buf, count) % 256;
  for (byte i = 0; i <= count; i++) {
    ds.write(buf[i], 1);
  }

  for (byte i = 0; i <= count; i++) {
    Serial.print(' ');
    Serial.print(buf[i], HEX);
  }
  Serial.println();
}


void loop() {
  // put your main code here, to run repeatedly:
  byte i;
  byte present = 0;
  byte type_s;
  byte addr[12];
  byte bufcrc = 0;
  uint8_t data[64];

  if ( !ds.search(addr)) {

    ds.reset_search();
    Serial.println("No more addresses.!");
    delay(1000);
    return;
  }

  Serial.print("Found device, ROM =");
  for ( i = 0; i < 8; i++) {
    Serial.write(' ');
    Serial.print(addr[i], HEX);
  }
  Serial.println();


  if (OneWire::crc8(addr, 7) != addr[7]) {
    Serial.println("CRC is not valid!");
    return;
  }


  ds.reset();
  ds.select(addr);
  ds.write(0x01);
  //delayMicroseconds(32);
  ds.read_bytes(data, 9);
  if (OneWire::crc8(data, 8) == data[8]) {
    Serial.println(" VALID");
  }
  else {
    Serial.println(" INVALID");
  }
  for (int i = 0; i < 8; i++) {
    Serial.print(data[i], HEX);
  }
  Serial.println();


  delay(100);
}

Here is the slave/tiny85 code:

#include <OneWireSlave.h>

#define LED_PIN 3
#define ONEWIREBUS 4

OneWireSlave ds(ONEWIREBUS);

unsigned char rom[8] = {0xAA, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00};
char buf[] = {0x01, 0x23, 0x45, 0x67, 0x89, 0xAB, 0xCD, 0xEF};
byte bufcrc = 0;
char data[30];
int cur_state = 0;

void setup() {
  ds.setRom(rom);
  bufcrc = OneWireSlave::crc8(buf, sizeof(buf)) % 256;
  pinMode(LED_PIN, OUTPUT);
  digitalWrite(LED_PIN, HIGH);
  delay(500);
  digitalWrite(LED_PIN, LOW);
}

void loop() {
  ds.waitForRequest(false);
  byte c = ds.recvData(data, 30);
  if (c > 0) {
    digitalWrite(LED_PIN, HIGH);
    for (byte i = 0; i < sizeof(buf); i++ ) {
      ds.send(buf[i]);
    }
    ds.send(bufcrc);
  }
  digitalWrite(LED_PIN, LOW);
}

Here is the output. As you can see, the master can see the slave and read its ROM address. But the data that the slave sends back should read “0123456789ABCDEF” but reads all "FF"s…

Found device, ROM = AA 0 1 0 0 0 1 60
 INVALID
FFFFFFFFFFFFFFFF
No more addresses.!

Here is some output showing that if the master continues reading, the data that the slave is sending is eventually seen, sometimes, except that the leading zero is missing:

No more addresses.!
Found device, ROM = AA 0 1 0 0 0 1 60
 INVALID
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
No more addresses.!
Found device, ROM = AA 0 1 0 0 0 1 60
 INVALID
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF123456789ABCDEFDDFFFFFFFFFFFFFFFFFFFF
No more addresses.!
Found device, ROM = AA 0 1 0 0 0 1 60
 INVALID
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF123456789ABCDEFDDFFFFFFFFFFFFFFFFFFFF
No more addresses.!
Found device, ROM = AA 0 1 0 0 0 1 60
 INVALID
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
No more addresses.!
Found device, ROM = AA 0 1 0 0 0 1 60
 INVALID
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF123456789ABCDEFDDFFFFFFFFFFFFFFFFFFFF
No more addresses.!
Found device, ROM = AA 0 1 0 0 0 1 60
 INVALID
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF123456789ABCDEFDDFFFFFFFFFFFFFFFFFFFF
No more addresses.!

Can someone please give me some pointers? I must be missing some concept about how OneWire is supposed to work.

Thanks,

Paul