On 17.11.2015 15:12, Jan Kandziora wrote: > >> > >> > NB: while we're looking at the DS2409 code ... OWCH: >> > >> > /* 2409 switch -- branch status -- note that bit value is reversed */ >> > static ZERO_OR_ERROR FS_r_branch(struct one_wire_query *owq) >> > { >> > BYTE data = 0 ; >> > >> > OWQ_U(owq) = (((data) & 0x01) | ((data >> 1) & 0x02)) ^ 0x03; >> > return GB_to_Z_OR_E(OW_r_control(&data, PN(owq))) ; >> > } >> > >> > Wouldn't it make slightly more sense to *first* read data and *then* set >> > the return value? :-P >> > > Wait, wait. What do you object here exactly? > > I admit that I had problems with this code myself. However …
* set data to zero * set output value to 3 ('data' is zero) * read 'data' from bus * … but don't use it in any way. Disassembly of the code demonstrates that the value 3 is set. (I admit that I double-checked despite the evidence.) 0000000000000140 <FS_r_branch>: 140: 48 83 ec 18 sub $0x18,%rsp 144: 48 8d 77 18 lea 0x18(%rdi),%rsi 148: c7 87 b0 30 00 00 03 movl $0x3,0x30b0(%rdi) -- -- Matthias Urlichs ------------------------------------------------------------------------------ _______________________________________________ Owfs-developers mailing list Owfs-developers@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/owfs-developers