Am 05.07.2013 23:12, schrieb Jan Kandziora:
> Hi,
> 
> [...]
>
Attached is a related patch to modules/owlib/src/c/ow_2409.c which adds
to nodes "auxselect" and "mainselect". Writing something to these nodes
selects the aux/main branch of a DS2409 without any meddling of the
automatic branch selection mechanism.

Using these two nodes and addressing the chips in the main directory
makes it possible to circumvent the automatic branch selection
completely and do it in the user application.


Hmm, if we could make a (by-bus) switch for the other patch - not
enabled by default, this could be merged to the mainline.


Kind regards

        Jan

Index: module/owlib/src/c/ow_2409.c
===================================================================
RCS file: /cvsroot/owfs/owfs/module/owlib/src/c/ow_2409.c,v
retrieving revision 1.48
diff -u -r1.48 ow_2409.c
--- module/owlib/src/c/ow_2409.c	7 Apr 2012 17:45:51 -0000	1.48
+++ module/owlib/src/c/ow_2409.c	5 Jul 2013 22:11:25 -0000
@@ -47,6 +47,8 @@
 /* DS2409 switch */
 WRITE_FUNCTION(FS_discharge);
 WRITE_FUNCTION(FS_clearevent);
+WRITE_FUNCTION(FS_auxselect);
+WRITE_FUNCTION(FS_mainselect);
 READ_FUNCTION(FS_r_control);
 WRITE_FUNCTION(FS_w_control);
 READ_FUNCTION(FS_r_sensed);
@@ -60,6 +62,8 @@
 	F_STANDARD,
 	{"discharge", PROPERTY_LENGTH_YESNO, NON_AGGREGATE, ft_yesno, fc_stable, NO_READ_FUNCTION, FS_discharge, VISIBLE, NO_FILETYPE_DATA, },
 	{"clearevent", PROPERTY_LENGTH_YESNO, NON_AGGREGATE, ft_yesno, fc_stable, NO_READ_FUNCTION, FS_clearevent, VISIBLE, NO_FILETYPE_DATA, },
+	{"auxselect", PROPERTY_LENGTH_YESNO, NON_AGGREGATE, ft_yesno, fc_stable, NO_READ_FUNCTION, FS_auxselect, VISIBLE, NO_FILETYPE_DATA, },
+	{"mainselect", PROPERTY_LENGTH_YESNO, NON_AGGREGATE, ft_yesno, fc_stable, NO_READ_FUNCTION, FS_mainselect, VISIBLE, NO_FILETYPE_DATA, },
 	{"control", PROPERTY_LENGTH_UNSIGNED, NON_AGGREGATE, ft_unsigned, fc_stable, FS_r_control, FS_w_control, VISIBLE, NO_FILETYPE_DATA, },
 	{"sensed", PROPERTY_LENGTH_BITFIELD, &A2409, ft_bitfield, fc_volatile, FS_r_sensed, NO_WRITE_FUNCTION, VISIBLE, NO_FILETYPE_DATA, },
 	{"branch", PROPERTY_LENGTH_BITFIELD, &A2409, ft_bitfield, fc_volatile, FS_r_branch, NO_WRITE_FUNCTION, VISIBLE, NO_FILETYPE_DATA, },
@@ -78,6 +82,8 @@
 static GOOD_OR_BAD OW_discharge(const struct parsedname *pn);
 static GOOD_OR_BAD OW_clearevent(const struct parsedname *pn);
 static GOOD_OR_BAD OW_w_control(const UINT data, const struct parsedname *pn);
+static GOOD_OR_BAD OW_auxselect(const struct parsedname *pn);
+static GOOD_OR_BAD OW_mainselect(const struct parsedname *pn);
 
 #define _1W_STATUS_READ_WRITE  0x5A
 #define _1W_ALL_LINES_OFF      0x66
@@ -105,6 +111,22 @@
 	return 0;
 }
 
+static ZERO_OR_ERROR FS_auxselect(struct one_wire_query *owq)
+{
+	if ((OWQ_Y(owq)!=0) && BAD( OW_auxselect(PN(owq)) ) ) {
+		return -EINVAL;
+	}
+	return 0;
+}
+
+static ZERO_OR_ERROR FS_mainselect(struct one_wire_query *owq)
+{
+	if ((OWQ_Y(owq)!=0) && BAD( OW_mainselect(PN(owq)) ) ) {
+		return -EINVAL;
+	}
+	return 0;
+}
+
 /* 2409 switch -- branch pin voltage */
 static ZERO_OR_ERROR FS_r_sensed(struct one_wire_query *owq)
 {
@@ -198,6 +220,42 @@
 	 return BUS_transaction(t, pn) ;
 }
 
+static GOOD_OR_BAD OW_auxselect(const struct parsedname *pn)
+{
+	BYTE c[] = { _1W_SMART_ON_AUX, 0xff, };
+	BYTE info[2];
+ 	struct transaction_log t[] = {
+		TRXN_START,
+		TRXN_WRITE2(c),
+		TRXN_READ2(info),
+		TRXN_END,
+	};
+
+	// Could certainly couple this with next transaction
+	RETURN_BAD_IF_BAD(BUS_transaction(t, pn)) ;
+
+	/* Check that Info corresponds */
+	return info[1] == c[0] ? gbGOOD : gbBAD;
+}
+
+static GOOD_OR_BAD OW_mainselect(const struct parsedname *pn)
+{
+	BYTE c[] = { _1W_SMART_ON_MAIN, 0xff, };
+	BYTE info[2];
+ 	struct transaction_log t[] = {
+		TRXN_START,
+		TRXN_WRITE2(c),
+		TRXN_READ2(info),
+		TRXN_END,
+	};
+
+	// Could certainly couple this with next transaction
+	RETURN_BAD_IF_BAD(BUS_transaction(t, pn)) ;
+
+	/* Check that Info corresponds */
+	return info[1] == c[0] ? gbGOOD : gbBAD;
+}
+
 static GOOD_OR_BAD OW_w_control(const UINT data, const struct parsedname *pn)
 {
 	const BYTE d[] = { 0x20, 0xA0, 0x00, 0x40, };
------------------------------------------------------------------------------
This SF.net email is sponsored by Windows:

Build for Windows Store.

http://p.sf.net/sfu/windows-dev2dev
_______________________________________________
Owfs-developers mailing list
Owfs-developers@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/owfs-developers

Reply via email to