neuoy / OneWireArduinoSlave

An arduino library to communicate using the Dallas one-wire protocol, where the Arduino takes the role of a slave. Entirely implemented using interrupts, you can perform other tasks while communication is handled in background.
58 stars 19 forks source link

Enumeration and scratchpad fail, Linux master #15

Open mgritz opened 7 years ago

mgritz commented 7 years ago

Have you ever tried to run this against a raspberrypi or anything else running Linux's w1 driver?

I tested your example sketch in a setup consisting of an 328P-based Arduino Nano, standard logic-level-shifter and a Pi as the master. No other sensors are present.

The Pi seems to be unable to enumerate devices (w1_gpio, w1_therm and wire kernel modules loaded). While the Pi enumerates your driver catches bus reset correctly and calls back with error event immediately after, I am unsure where exactly. A bit of debugging shows that the state machine bounces back and forth between DS_WaitingCommand and DS_WaitingReset.

As a workaround I tried to disable enumeration on the Pi and to add client 28-0000000002 manually instead. This gives me the device descriptors to read the scratchpad manually with the w1 driver assuming there is only the one registered client present on the bus.

Doing so, my logic analyzer tells me the bus actually carries

This is tried ten times before the driver throws in the towel returning

pi@homeguard:/sys/bus/w1/devices/w1_bus_master1 $ cat 28-000000000002/w1_slave
ff ff ff ff ff ff ff ff ff : crc=c9 NO
00 00 00 00 00 00 00 00 00 t=-62
pi@homeguard:/sys/bus/w1/devices/w1_bus_master1 $

for the scratchpad contents and resigning with CRC failure.

Any ideas? It's possibly just me doing nonsense here but I'm starting to get the impression I might have kicked up a bug.