Hello, There is a bug in operating on PIO.A or PIO.B.If you write to PIO.A, state of PIO.B (and vice versa) is fetched from pin state instead of latch state. This lead to loss of state of PIO.B if you write to PIO.A (and vice versa).
For example: I have pull down resistor in PIN.B, so: cat sensed.B --> 0 echo 0 >PIO.B cat latch.B --> 1 echo something >PIO.A cat latch.B --> 0
Patch attached Regards majek -- "If you want something done...do yourself!" Jean-Baptiste Emmanuel Zorg
--- ow_2413.c.org 2005-10-26 16:08:41.000000000 +0200 +++ ow_2413.c 2005-10-26 21:04:39.000000000 +0200 @@ -73,18 +73,18 @@ /* 2413 switch */ /* bits 0 and 2 */ static int FS_r_pio(unsigned int * u , const struct parsedname * pn) { - unsigned char data ; - unsigned char uu[] = { 0x03, 0x02, 0x03, 0x02, 0x01, 0x00, 0x01, 0x00, } ; - if ( OW_read(&data,pn) ) return -EINVAL ; - u[0] = uu[data&0x07] ; /* look up reversed bits */ + if ( FS_r_latch(u,pn) ) return -EINVAL ; + u[0] ^= 0x03 ; return 0 ; } /* 2413 switch PIO sensed*/ /* bits 0 and 2 */ static int FS_sense(unsigned int * u , const struct parsedname * pn) { - if ( FS_r_pio(u,pn) ) return -EINVAL ; - u[0] ^= 0x03 ; + unsigned char data ; + unsigned char uu[] = { 0x00, 0x01, 0x00, 0x01, 0x02, 0x03, 0x02, 0x03, } ; + if ( OW_read(&data,pn) ) return -EINVAL ; + u[0] = uu[data&0x07] ; return 0 ; }