master/slave.c
changeset 238 b4960499098f
parent 199 04ecf40fc2e9
child 246 0bf7c769de06
equal deleted inserted replaced
237:7b3126cf6dab 238:b4960499098f
    37 #include "master.h"
    37 #include "master.h"
    38 
    38 
    39 /*****************************************************************************/
    39 /*****************************************************************************/
    40 
    40 
    41 int ec_slave_fetch_categories(ec_slave_t *);
    41 int ec_slave_fetch_categories(ec_slave_t *);
    42 int ec_slave_fetch_strings(ec_slave_t *, const uint8_t *);
       
    43 int ec_slave_fetch_general(ec_slave_t *, const uint8_t *);
       
    44 int ec_slave_fetch_sync(ec_slave_t *, const uint8_t *, size_t);
       
    45 int ec_slave_fetch_pdo(ec_slave_t *, const uint8_t *, size_t, ec_pdo_type_t);
       
    46 int ec_slave_locate_string(ec_slave_t *, unsigned int, char **);
       
    47 ssize_t ec_show_slave_attribute(struct kobject *, struct attribute *, char *);
    42 ssize_t ec_show_slave_attribute(struct kobject *, struct attribute *, char *);
    48 
    43 
    49 /*****************************************************************************/
    44 /*****************************************************************************/
    50 
    45 
    51 /** \cond */
    46 /** \cond */
    53 EC_SYSFS_READ_ATTR(ring_position);
    48 EC_SYSFS_READ_ATTR(ring_position);
    54 EC_SYSFS_READ_ATTR(coupler_address);
    49 EC_SYSFS_READ_ATTR(coupler_address);
    55 EC_SYSFS_READ_ATTR(vendor_name);
    50 EC_SYSFS_READ_ATTR(vendor_name);
    56 EC_SYSFS_READ_ATTR(product_name);
    51 EC_SYSFS_READ_ATTR(product_name);
    57 EC_SYSFS_READ_ATTR(product_desc);
    52 EC_SYSFS_READ_ATTR(product_desc);
       
    53 EC_SYSFS_READ_ATTR(sii_desc);
    58 EC_SYSFS_READ_ATTR(type);
    54 EC_SYSFS_READ_ATTR(type);
    59 
    55 
    60 static struct attribute *def_attrs[] = {
    56 static struct attribute *def_attrs[] = {
    61     &attr_ring_position,
    57     &attr_ring_position,
    62     &attr_coupler_address,
    58     &attr_coupler_address,
    63     &attr_vendor_name,
    59     &attr_vendor_name,
    64     &attr_product_name,
    60     &attr_product_name,
    65     &attr_product_desc,
    61     &attr_product_desc,
       
    62     &attr_sii_desc,
    66     &attr_type,
    63     &attr_type,
    67     NULL,
    64     NULL,
    68 };
    65 };
    69 
    66 
    70 static struct sysfs_ops sysfs_ops = {
    67 static struct sysfs_ops sysfs_ops = {
   490 /*****************************************************************************/
   487 /*****************************************************************************/
   491 
   488 
   492 /**
   489 /**
   493    Fetches data from slave's EEPROM.
   490    Fetches data from slave's EEPROM.
   494    \return 0 in case of success, else < 0
   491    \return 0 in case of success, else < 0
       
   492    \todo memory allocation
   495 */
   493 */
   496 
   494 
   497 int ec_slave_fetch_categories(ec_slave_t *slave /**< EtherCAT slave */)
   495 int ec_slave_fetch_categories(ec_slave_t *slave /**< EtherCAT slave */)
   498 {
   496 {
   499     uint16_t word_offset, cat_type, word_count;
   497     uint16_t word_offset, cat_type, word_count;
  1207 /*****************************************************************************/
  1205 /*****************************************************************************/
  1208 
  1206 
  1209 /**
  1207 /**
  1210    Formats attribute data for SysFS read access.
  1208    Formats attribute data for SysFS read access.
  1211    \return number of bytes to read
  1209    \return number of bytes to read
  1212    \ingroup RealTimeInterface
       
  1213 */
  1210 */
  1214 
  1211 
  1215 ssize_t ec_show_slave_attribute(struct kobject *kobj, /**< slave's kobject */
  1212 ssize_t ec_show_slave_attribute(struct kobject *kobj, /**< slave's kobject */
  1216                                 struct attribute *attr, /**< attribute */
  1213                                 struct attribute *attr, /**< attribute */
  1217                                 char *buffer /**< memory to store data */
  1214                                 char *buffer /**< memory to store data */
  1235             return sprintf(buffer, "%s\n", slave->type->product_name);
  1232             return sprintf(buffer, "%s\n", slave->type->product_name);
  1236     }
  1233     }
  1237     else if (attr == &attr_product_desc) {
  1234     else if (attr == &attr_product_desc) {
  1238         if (slave->type)
  1235         if (slave->type)
  1239             return sprintf(buffer, "%s\n", slave->type->description);
  1236             return sprintf(buffer, "%s\n", slave->type->description);
       
  1237     }
       
  1238     else if (attr == &attr_sii_desc) {
       
  1239         if (slave->eeprom_desc)
       
  1240             return sprintf(buffer, "%s\n", slave->eeprom_desc);
  1240     }
  1241     }
  1241     else if (attr == &attr_type) {
  1242     else if (attr == &attr_type) {
  1242         if (slave->type) {
  1243         if (slave->type) {
  1243             if (slave->type->special == EC_TYPE_BUS_COUPLER)
  1244             if (slave->type->special == EC_TYPE_BUS_COUPLER)
  1244                 return sprintf(buffer, "coupler\n");
  1245                 return sprintf(buffer, "coupler\n");