[etherlab-dev] [Patch] Simple support for EK1101

Dave Page dave.page at gleeble.com
Wed Jan 8 03:39:31 CET 2014


Hi,

     Here is a patch to use the ID switch setting of the EK1101 instead 
of the nominal alias register, when '--enable-regalias' is specified to 
configure. An objection to this patch is the hard-coding of the vendor 
and product code. A whitelist approach would probably be better.

         - Dave Page


diff -r 51ad16e57f8f master/fsm_slave_scan.c
--- a/master/fsm_slave_scan.c   Tue Dec 10 10:43:13 2013 +0100
+++ b/master/fsm_slave_scan.c   Tue Jan 07 21:37:20 2014 -0500
@@ -816,9 +816,13 @@
      ec_datagram_t *datagram = fsm->datagram;
      ec_slave_t *slave = fsm->slave;

+    // choose switch register when slave is EK1101
+    uint16_t reg_addr = slave->sii.vendor_id == 0x2 &&
+        slave->sii.product_code == 0x044d2c52 ? 0x1000 : 0x0012;
+
      // read alias from register
      EC_SLAVE_DBG(slave, 1, "Reading alias from register.\n");
-    ec_datagram_fprd(datagram, slave->station_address, 0x0012, 2);
+    ec_datagram_fprd(datagram, slave->station_address, reg_addr, 2);
      ec_datagram_zero(datagram);
      fsm->retries = EC_FSM_RETRIES;
      fsm->state = ec_fsm_slave_scan_state_regalias;

-------------- next part --------------
A non-text attachment was scrubbed...
Name: dave_page.vcf
Type: text/x-vcard
Size: 313 bytes
Desc: not available
URL: <http://lists.etherlab.org/pipermail/etherlab-dev/attachments/20140108/591b0992/attachment.vcf>


More information about the etherlab-dev mailing list