Not getting very far but at least it is something in the sibling
processing - I just can't work out what it does in there!!
* the piostate is correctly read from the device as 0x0f (outputs off,
inputs high).
* the latch state is correctly read from this as 0x03
* writing to the pio to set PIO.B tries to send 0x02000003 instead of
0x02, the result being that neither bit gets turned on (the 2 LSBs both
high).
I've attached a trace of trying to turn on PIO.B on one device. I've added
a few extra debug lines in ow_2413.c which I've also attached.
Enjoy...
--
Robin Gilks
CALL: ow_write.c:FS_write(70) path=/3A.351601000000/PIO.B size=1 offset=0
DEBUG: ow_parseobject.c:OWQ_create(164) /3A.351601000000/PIO.B
CALL: ow_parsename.c:FS_ParsedName_anywhere(95) path=[/3A.351601000000/PIO.B]
DEBUG: ow_cache.c:Cache_Get_Device(927) Looking for device 3A 35 16 01 00 00
00 F6
DEBUG: ow_cache.c:Cache_Get_Common(1083) Search in cache sn 3A 35 16 01 00 00
00 F6 pointer=0x777518fc index=0 size=4
DEBUG: ow_cache.c:Cache_Get_Common(1099) Value found in cache. Remaining
life: 115 seconds.
DEBUG: ow_presence.c:CheckPresence(76) Found device on bus 0
OWQ OneWireQuery structure of /3A.351601000000/PIO.B
OneWireQuery size=1 offset=0, extension=1
Byte buffer OneWireQuery buffer, length=1
--000: 31
<1>
Cleanup = 0002 OneWireQuery I=1 U=1 F=2.122E-314 Y=1 D=Thu Jan 1
13:00:01 1970
--- OneWireQuery done
DEBUG: ow_write.c:FS_w_local(402) Write an aggregate element
/3A.351601000000/PIO.B
DEBUG: ow_parseobject.c:OWQ_create_separate(115) /3A.351601000000/PIO.B with
extension -2
DEBUG: ow_read.c:adjust_file_size(329) file_length=12 offset=0 size=1
DEBUG: ow_read.c:FS_r_local(391) Read an aggregate .BYTE
/3A.351601000000/PIO.B
DEBUG: ow_parseobject.c:OWQ_create_sibling(75) Path /3A.351601000000/PIO.B is
an agggregate
DEBUG: ow_parseobject.c:OWQ_create_sibling(95) Create sibling piostate from
/3A.351601000000/PIO.B as /3A.351601000000/piostate
DEBUG: ow_parseobject.c:OWQ_create_from_path(30) /3A.351601000000/piostate
CALL: ow_parsename.c:FS_ParsedName_anywhere(95)
path=[/3A.351601000000/piostate]
DEBUG: ow_cache.c:Cache_Get_Device(927) Looking for device 3A 35 16 01 00 00
00 F6
DEBUG: ow_cache.c:Cache_Get_Common(1083) Search in cache sn 3A 35 16 01 00 00
00 F6 pointer=0x777518fc index=0 size=4
DEBUG: ow_cache.c:Cache_Get_Common(1099) Value found in cache. Remaining
life: 115 seconds.
DEBUG: ow_presence.c:CheckPresence(76) Found device on bus 0
DEBUG: ow_read.c:adjust_file_size(329) file_length=12 offset=0 size=1
DEBUG: ow_cache.c:Cache_Get(850) 3A 35 16 01 00 00 00 F6 size=8
IsUncachedDir=0
DEBUG: ow_cache.c:Cache_Get_Common(1083) Search in cache sn 3A 35 16 01 00 00
00 F6 pointer=0x777400f8 index=0 size=8
DEBUG: ow_cache.c:Cache_Get_Common(1115) Value found in cache, but expired by
4 seconds.
DEBUG: ow_select.c:BUS_select(66) Selecting a path (and device)
path=/3A.351601000000/piostate SN=3A 35 16 01 00 00 00 F6 last path=00 00 00 00
00 00 00 00
DEBUG: ow_select.c:BUS_select(79) Continuing root branch
DEBUG: ow_tcp_read.c:tcp_read(64) attempt 1 bytes Time: 5.000000 seconds
DEBUG: ow_tcp_read.c:tcp_read(114) read: 1 - 0 = 1
DEBUG: ow_tcp_read.c:tcp_read(64) attempt 9 bytes Time: 5.000000 seconds
DEBUG: ow_tcp_read.c:tcp_read(114) read: 9 - 0 = 9
DEBUG: ow_transaction.c:BUS_transaction_single(84) select = 0
DEBUG: ow_tcp_read.c:tcp_read(64) attempt 1 bytes Time: 5.000000 seconds
DEBUG: ow_tcp_read.c:tcp_read(114) read: 1 - 0 = 1
DEBUG: ow_transaction.c:BUS_transaction_single(106) send = 0
DEBUG: ow_tcp_read.c:tcp_read(64) attempt 1 bytes Time: 5.000000 seconds
DEBUG: ow_tcp_read.c:tcp_read(114) read: 1 - 0 = 1
DEBUG: ow_transaction.c:BUS_transaction_single(124) readin = 0
DEBUG: ow_transaction.c:BUS_transaction_single(201) end = 0
DATA: ow_2413.c:FS_r_piostate(100) Read piostate = 0000000f
DEBUG: ow_read.c:FS_read_owq(588) Read /3A.351601000000/piostate Extension 0
Gives result 0
DEBUG: ow_cache.c:OWQ_Cache_Add(390) Adding data for /3A.351601000000/piostate
DEBUG: ow_cache.c:Cache_Add(427) 3A 35 16 01 00 00 00 F6 size=8
DEBUG: ow_cache.c:Cache_Add_Common(650) Add to cache sn 3A 35 16 01 00 00 00
F6 pointer=0x777400f8 index=0 size=8
DEBUG: ow_parsename.c:FS_ParsedName_destroy(59) /3A.351601000000/piostate
DATA: ow_2413.c:FS_r_pio(121) Read pio = 0000000f
DATA: ow_2413.c:LATCH_state(213) Latch state = 00000003
DEBUG: ow_read.c:FS_read_owq(588) Read /3A.351601000000/PIO.B Extension -2
Gives result 0
DATA: ow_2413.c:FS_w_pio(132) Write pio = 02000003
DEBUG: ow_parseobject.c:OWQ_create_sibling(75) Path /3A.351601000000/PIO.B is
an agggregate
DEBUG: ow_parseobject.c:OWQ_create_sibling(95) Create sibling piostate from
/3A.351601000000/PIO.B as /3A.351601000000/piostate
DEBUG: ow_parseobject.c:OWQ_create_from_path(30) /3A.351601000000/piostate
CALL: ow_parsename.c:FS_ParsedName_anywhere(95)
path=[/3A.351601000000/piostate]
DEBUG: ow_cache.c:Cache_Get_Device(927) Looking for device 3A 35 16 01 00 00
00 F6
DEBUG: ow_cache.c:Cache_Get_Common(1083) Search in cache sn 3A 35 16 01 00 00
00 F6 pointer=0x777518fc index=0 size=4
DEBUG: ow_cache.c:Cache_Get_Common(1099) Value found in cache. Remaining
life: 115 seconds.
DEBUG: ow_presence.c:CheckPresence(76) Found device on bus 0
DEBUG: ow_write.c:FS_w_local(387) Write a non-array element
/3A.351601000000/piostate
DATA: ow_2413.c:FS_w_piostate(110) Write piostate = 02000003
DEBUG: ow_select.c:BUS_select(66) Selecting a path (and device)
path=/3A.351601000000/piostate SN=3A 35 16 01 00 00 00 F6 last path=00 00 00 00
00 00 00 00
DEBUG: ow_select.c:BUS_select(79) Continuing root branch
DEBUG: ow_tcp_read.c:tcp_read(64) attempt 1 bytes Time: 5.000000 seconds
DEBUG: ow_tcp_read.c:tcp_read(114) read: 1 - 0 = 1
DEBUG: ow_tcp_read.c:tcp_read(64) attempt 9 bytes Time: 5.000000 seconds
DEBUG: ow_tcp_read.c:tcp_read(114) read: 9 - 0 = 9
DEBUG: ow_transaction.c:BUS_transaction_single(84) select = 0
DEBUG: ow_tcp_read.c:tcp_read(64) attempt 3 bytes Time: 5.000000 seconds
DEBUG: ow_tcp_read.c:tcp_read(114) read: 3 - 0 = 3
DEBUG: ow_transaction.c:BUS_transaction_single(106) send = 0
DEBUG: ow_tcp_read.c:tcp_read(64) attempt 1 bytes Time: 5.000000 seconds
DEBUG: ow_tcp_read.c:tcp_read(114) read: 1 - 0 = 1
DEBUG: ow_transaction.c:BUS_transaction_single(124) readin = 0
DEBUG: ow_transaction.c:BUS_transaction_single(91) compare = 0
DEBUG: ow_transaction.c:BUS_transaction_single(201) end = 0
DEBUG: ow_cache.c:Cache_Del_Common(1375) Delete from cache sn 3A 35 16 01 00
00 00 F6 in=0x777400f8 index=0
DEBUG: ow_write.c:FS_write_owq(442) Write /3A.351601000000/piostate Extension
0 Gives result 0
DEBUG: ow_parsename.c:FS_ParsedName_destroy(59) /3A.351601000000/piostate
DEBUG: ow_parseobject.c:OWQ_create_sibling(75) Path /3A.351601000000/PIO.B is
an agggregate
DEBUG: ow_parseobject.c:OWQ_create_sibling(95) Create sibling piostate from
/3A.351601000000/PIO.B as /3A.351601000000/piostate
DEBUG: ow_parseobject.c:OWQ_create_from_path(30) /3A.351601000000/piostate
CALL: ow_parsename.c:FS_ParsedName_anywhere(95)
path=[/3A.351601000000/piostate]
DEBUG: ow_cache.c:Cache_Get_Device(927) Looking for device 3A 35 16 01 00 00
00 F6
DEBUG: ow_cache.c:Cache_Get_Common(1083) Search in cache sn 3A 35 16 01 00 00
00 F6 pointer=0x777518fc index=0 size=4
DEBUG: ow_cache.c:Cache_Get_Common(1099) Value found in cache. Remaining
life: 115 seconds.
DEBUG: ow_presence.c:CheckPresence(76) Found device on bus 0
DEBUG: ow_cache.c:Cache_Del_Common(1375) Delete from cache sn 3A 35 16 01 00
00 00 F6 in=0x777400f8 index=0
DEBUG: ow_parsename.c:FS_ParsedName_destroy(59) /3A.351601000000/piostate
DEBUG: ow_write.c:FS_write_owq(442) Write /3A.351601000000/PIO.B Extension -2
Gives result 0
DEBUG: ow_write.c:FS_write_postparse(116) Successful write to
/3A.351601000000/PIO.B
DEBUG: ow_parsename.c:FS_ParsedName_destroy(59) /3A.351601000000/PIO.B
Device 3A.351601000000 port B state 01/*
$Id: ow_2413.c,v 1.56 2010/05/27 02:20:52 alfille Exp $
OWFS -- One-Wire filesystem
OWHTTPD -- One-Wire Web Server
Written 2003 Paul H Alfille
email: [email protected]
Released under the GPL
See the header file: ow.h for full attribution
1wire/iButton system from Dallas Semiconductor
*/
/* General Device File format:
This device file corresponds to a specific 1wire/iButton chip type
( or a closely related family of chips )
The connection to the larger program is through the "device" data structure,
which must be declared in the acompanying header file.
The device structure holds the
family code,
name,
number of properties,
list of property structures, called "filetype".
Each filetype structure holds the
name,
estimated length (in bytes),
aggregate structure pointer,
data format,
read function,
write funtion,
generic data pointer
The aggregate structure, is present for properties that several members
(e.g. pages of memory or entries in a temperature log. It holds:
number of elements
whether the members are lettered or numbered
whether the elements are stored together and split, or separately and joined
*/
/* Changes
7/2004 Extensive improvements based on input from Serg Oskin
*/
#include <config.h>
#include "owfs_config.h"
#include "ow_2413.h"
/* ------- Prototypes ----------- */
/* DS2413 switch */
READ_FUNCTION(FS_r_piostate);
WRITE_FUNCTION(FS_w_piostate);
READ_FUNCTION(FS_r_pio);
WRITE_FUNCTION(FS_w_pio);
READ_FUNCTION(FS_sense);
//READ_FUNCTION(FS_r_latch);
/* ------- Structures ----------- */
struct aggregate A2413 = { 2, ag_letters, ag_aggregate, };
struct filetype DS2413[] = {
F_STANDARD,
{"piostate", PROPERTY_LENGTH_UNSIGNED, NON_AGGREGATE, ft_unsigned, fc_volatile, FS_r_piostate, FS_w_piostate, INVISIBLE, NO_FILETYPE_DATA, },
{"PIO", PROPERTY_LENGTH_BITFIELD, &A2413, ft_bitfield, fc_link, FS_r_pio, FS_w_pio, VISIBLE, NO_FILETYPE_DATA,},
{"sensed", PROPERTY_LENGTH_BITFIELD, &A2413, ft_bitfield, fc_link, FS_sense, NO_WRITE_FUNCTION, VISIBLE, NO_FILETYPE_DATA,},
// {"latch", PROPERTY_LENGTH_BITFIELD, &A2413, ft_bitfield, fc_link, FS_r_latch, FS_w_pio, VISIBLE, NO_FILETYPE_DATA,},
};
DeviceEntryExtended(3A, DS2413, DEV_resume | DEV_ovdr, NO_GENERIC_READ, NO_GENERIC_WRITE);
#define _1W_PIO_ACCESS_READ 0xF5
#define _1W_PIO_ACCESS_WRITE 0x5A
#define _1W_2413_LATCH_MASK 0x0A
#define _1W_2413_CONFIRMATION 0xAA
/* ------- Functions ------------ */
/* DS2413 */
static GOOD_OR_BAD OW_write(BYTE data, const struct parsedname *pn);
static GOOD_OR_BAD OW_read(BYTE * data, const struct parsedname *pn);
static UINT SENSED_state(UINT status_bits);
static UINT LATCH_state(UINT status_bits);
static ZERO_OR_ERROR FS_r_piostate(struct one_wire_query *owq)
{
/* surrogate property
bit 0 PIOA pin state
bit 1 PIOA latch state
bit 2 PIOB pin state
bit 3 PIOB latch state
*/
BYTE piostate ;
if ( OW_read( &piostate, PN(owq) ) ) {
return -EINVAL ;
}
LEVEL_DATA("Read piostate = %08x", piostate);
OWQ_U(owq) = piostate ;
return 0 ;
}
/* write 2413 switch -- 2 values*/
static ZERO_OR_ERROR FS_w_piostate(struct one_wire_query *owq)
{
UINT pio = OWQ_U(owq) ;
LEVEL_DATA("Write piostate = %08x", pio);
return OW_write( pio, PN(owq) ) ? -EINVAL : 0 ;
}
/* 2413 switch activity latch is actual set state of PIOs, what we want in this case */
/* bites 1 and 3 */
static ZERO_OR_ERROR FS_r_pio(struct one_wire_query *owq)
{
UINT piostate = 0 ;
ZERO_OR_ERROR z_or_e = FS_r_sibling_U( &piostate, "piostate", owq ) ;
LEVEL_DATA("Read pio = %08x", piostate);
// bits 1>0 and 3->1
// complement
OWQ_U(owq) = LATCH_state( piostate ) ^ 0x03 ;
return z_or_e ;
}
/* write 2413 switch -- 2 values*/
static ZERO_OR_ERROR FS_w_pio(struct one_wire_query *owq)
{
// complement
LEVEL_DATA("Write pio = %08x", OWQ_U(owq) ^ 0x03);
ZERO_OR_ERROR ret = FS_w_sibling_U( OWQ_U(owq) ^ 0x03 , "piostate", owq );
if ( ret == 0 ) {
// Able to write, but piostate is potentially now incorrect
// since we use a different method to set pios
FS_del_sibling( "piostate", owq ) ;
return 0 ;
}
return ret ;
}
/* 2413 switch PIO sensed*/
/* bits 0 and 2 */
static ZERO_OR_ERROR FS_sense(struct one_wire_query *owq)
{
UINT piostate = 0 ;
ZERO_OR_ERROR z_or_e = FS_r_sibling_U( &piostate, "piostate", owq ) ;
// bits 0->0 and 2->1
OWQ_U(owq) = SENSED_state(piostate) ;
return z_or_e ;
}
/* read status byte */
static GOOD_OR_BAD OW_read(BYTE * data, const struct parsedname *pn)
{
BYTE cmd[] = { _1W_PIO_ACCESS_READ, };
BYTE resp[1] ;
struct transaction_log t[] = {
TRXN_START,
TRXN_WRITE1(cmd),
TRXN_READ1(resp),
TRXN_END,
};
RETURN_BAD_IF_BAD(BUS_transaction(t, pn)) ;
// High nibble the complement of low nibble?
// Fix thanks to josef_heiler
if ((resp[0] & 0x0F) != ((~resp[0] >> 4) & 0x0F)) {
return gbBAD;
}
data[0] = resp[0] & 0x0F ;
return gbGOOD;
}
/* write status byte */
/* top 6 bits are set to 1, complement then sent */
static GOOD_OR_BAD OW_write(BYTE data, const struct parsedname *pn)
{
BYTE data_masked = data | 0xFC ;
BYTE cmd[] = { _1W_PIO_ACCESS_WRITE, data_masked, ~data_masked, };
BYTE chk[1];
BYTE confirm[] = { _1W_2413_CONFIRMATION, } ;
struct transaction_log t[] = {
TRXN_START,
TRXN_WRITE3(cmd),
TRXN_READ1(chk),
TRXN_COMPARE(chk,confirm,1),
TRXN_END,
};
return BUS_transaction(t, pn) ;
}
// piostate -> sense
static UINT SENSED_state(UINT status_bits)
{
UINT ret;
ret = ((status_bits & 0x01) >> 0) | ((status_bits & 0x04) >>1);
LEVEL_DATA("Sense state = %08x", ret);
return ret;
}
// piostate -> latch
static UINT LATCH_state(UINT status_bits)
{
UINT ret;
ret = ((status_bits & 0x02) >> 1) | ((status_bits & 0x08) >>2);
LEVEL_DATA("Latch state = %08x", ret);
return ret;
}------------------------------------------------------------------------------
Flow-based real-time traffic analytics software. Cisco certified tool.
Monitor traffic, SLAs, QoS, Medianet, WAAS etc. with NetFlow Analyzer
Customize your own dashboards, set traffic alerts and generate reports.
Network behavioral analysis & security monitoring. All-in-one tool.
http://pubads.g.doubleclick.net/gampad/clk?id=126839071&iu=/4140/ostg.clktrk
_______________________________________________
Owfs-developers mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/owfs-developers