SDO-Schnittstelle verbessert.
--- a/include/ecrt.h Tue Mar 28 17:40:57 2006 +0000
+++ b/include/ecrt.h Wed Mar 29 10:30:13 2006 +0000
@@ -50,34 +50,21 @@
// Master methods
ec_domain_t *ecrt_master_create_domain(ec_master_t *master);
+
int ecrt_master_activate(ec_master_t *master);
void ecrt_master_deactivate(ec_master_t *master);
+
int ecrt_master_fetch_sdo_lists(ec_master_t *master);
+
void ecrt_master_sync_io(ec_master_t *master);
void ecrt_master_async_send(ec_master_t *master);
void ecrt_master_async_receive(ec_master_t *master);
void ecrt_master_prepare_async_io(ec_master_t *master);
+
void ecrt_master_debug(ec_master_t *master, int level);
void ecrt_master_print(const ec_master_t *master);
-int ecrt_master_sdo_exp_write(ec_master_t *master,
- const char *slave_addr,
- uint16_t sdo_index,
- uint8_t sdo_subindex,
- uint32_t value,
- size_t size);
-int ecrt_master_sdo_exp_read(ec_master_t *master,
- const char *slave_addr,
- uint16_t sdo_index,
- uint8_t sdo_subindex,
- uint32_t *value);
-int ecrt_master_sdo_read(ec_master_t *master,
- const char *slave_addr,
- uint16_t sdo_index,
- uint8_t sdo_subindex,
- uint8_t *data,
- size_t *size);
-int ecrt_master_write_slave_alias(ec_master_t *master,
- const char *slave_address, uint16_t alias);
+
+ec_slave_t *ecrt_master_get_slave(const ec_master_t *, const char *);
/*****************************************************************************/
// Domain Methods
@@ -86,12 +73,12 @@
const char *address,
const char *vendor_name,
const char *product_name,
- void **data_ptr,
- const char *field_name,
+ void **data_ptr, const char *field_name,
unsigned int field_index,
unsigned int field_count);
int ecrt_domain_register_field_list(ec_domain_t *domain,
ec_field_init_t *fields);
+
void ecrt_domain_queue(ec_domain_t *domain);
void ecrt_domain_process(ec_domain_t *domain);
int ecrt_domain_state(ec_domain_t *domain);
@@ -99,20 +86,22 @@
/*****************************************************************************/
// Slave Methods
-int ecrt_slave_sdo_exp_write(ec_slave_t *slave,
- uint16_t sdo_index,
- uint8_t sdo_subindex,
- uint32_t value,
- size_t size);
-int ecrt_slave_sdo_exp_read(ec_slave_t *slave,
- uint16_t sdo_index,
- uint8_t sdo_subindex,
- uint32_t *value);
-int ecrt_slave_sdo_read(ec_slave_t *slave,
- uint16_t sdo_index,
- uint8_t sdo_subindex,
- uint8_t *data,
- size_t *size);
+int ecrt_slave_sdo_read_exp8(ec_slave_t *slave, uint16_t sdo_index,
+ uint8_t sdo_subindex, uint8_t *value);
+int ecrt_slave_sdo_read_exp16(ec_slave_t *slave, uint16_t sdo_index,
+ uint8_t sdo_subindex, uint16_t *value);
+int ecrt_slave_sdo_read_exp32(ec_slave_t *slave, uint16_t sdo_index,
+ uint8_t sdo_subindex, uint32_t *value);
+int ecrt_slave_sdo_write_exp8(ec_slave_t *slave, uint16_t sdo_index,
+ uint8_t sdo_subindex, uint8_t value);
+int ecrt_slave_sdo_write_exp16(ec_slave_t *slave, uint16_t sdo_index,
+ uint8_t sdo_subindex, uint16_t value);
+int ecrt_slave_sdo_write_exp32(ec_slave_t *slave, uint16_t sdo_index,
+ uint8_t sdo_subindex, uint32_t value);
+int ecrt_slave_sdo_read(ec_slave_t *slave, uint16_t sdo_index,
+ uint8_t sdo_subindex, uint8_t *data, size_t *size);
+
+int ecrt_slave_write_alias(ec_slave_t *slave, uint16_t alias);
/*****************************************************************************/
// Bitwise read/write macros
--- a/master/canopen.c Tue Mar 28 17:40:57 2006 +0000
+++ b/master/canopen.c Wed Mar 29 10:30:13 2006 +0000
@@ -16,6 +16,11 @@
/*****************************************************************************/
+void ec_canopen_abort_msg(uint32_t);
+int ec_slave_fetch_sdo_descriptions(ec_slave_t *);
+
+/*****************************************************************************/
+
/**
SDO Abort Code Messages
*/
@@ -29,40 +34,35 @@
const ec_sdo_abort_message_t sdo_abort_messages[];
-void ec_canopen_abort_msg(uint32_t);
-int ec_slave_fetch_sdo_descriptions(ec_slave_t *);
-
-/*****************************************************************************/
-
-/**
- Schreibt ein CANopen-SDO (service data object), expedited.
- */
-
-int ecrt_slave_sdo_exp_write(ec_slave_t *slave, /**< EtherCAT-Slave */
- uint16_t sdo_index, /**< SDO-Index */
- uint8_t sdo_subindex, /**< SDO-Subindex */
- uint32_t value, /**< Neuer Wert */
- size_t size /**< Größe des Datenfeldes */
- )
+/*****************************************************************************/
+
+/**
+ Beschreibt ein CANopen-SDO eines Slaves im Expedited-Modus.
+ \return 0 wenn alles ok, < 0 bei Fehler
+ */
+
+int ec_slave_sdo_write_exp(ec_slave_t *slave, /**< EtherCAT-Slave */
+ uint16_t sdo_index, /**< SDO-Index */
+ uint8_t sdo_subindex, /**< SDO-Subindex */
+ const uint8_t *sdo_data, /**< Neuer Wert */
+ size_t size
+ )
{
uint8_t data[0x0A];
- unsigned int i;
size_t rec_size;
if (size == 0 || size > 4) {
- EC_ERR("Invalid SDO data size: %i!\n", size);
- return -1;
- }
-
- EC_WRITE_U16(data, 0x02 << 12); // Number (0), Service (SDO request)
- EC_WRITE_U8 (data + 2, 0x23 | ((4 - size) << 2)); // Spec., exp., init.
+ EC_ERR("Invalid data size!\n");
+ return -1;
+ }
+
+ EC_WRITE_U16(data, 0x2000); // SDO request
+ EC_WRITE_U8 (data + 2, 0x23 | (4 - size) << 2); // expedited, size specif.
EC_WRITE_U16(data + 3, sdo_index);
EC_WRITE_U8 (data + 5, sdo_subindex);
- for (i = 0; i < size; i++) {
- EC_WRITE_U8(data + 6 + i, value & 0xFF);
- value >>= 8;
- }
+ memcpy(data + 6, sdo_data, size);
+ if (size < 4) memset(data + 6 + size, 0x00, 4 - size);
// Mailox senden und empfangen
if (ec_slave_mailbox_send(slave, 0x03, data, 0x0A)) return -1;
@@ -71,9 +71,9 @@
if (ec_slave_mailbox_receive(slave, 0x03, data, &rec_size)) return -1;
if (EC_READ_U16(data) >> 12 == 0x02 && // SDO request
- EC_READ_U8 (data + 2) >> 5 == 0x04) { // Abort SDO transf. req.
- EC_ERR("SDO download of 0x%04X:%X (value %X, size %X) aborted on slave"
- " %i.\n", sdo_index, sdo_subindex, value, size,
+ EC_READ_U8 (data + 2) >> 5 == 0x04) { // Abort SDO transfer request
+ EC_ERR("SDO download of 0x%04X:%X (%i bytes) aborted on!"
+ " slave %i.\n", sdo_index, sdo_subindex, size,
slave->ring_position);
ec_canopen_abort_msg(EC_READ_U32(data + 6));
return -1;
@@ -95,20 +95,21 @@
/*****************************************************************************/
/**
- Liest ein CANopen-SDO (service data object), expedited.
- */
-
-int ecrt_slave_sdo_exp_read(ec_slave_t *slave, /**< EtherCAT-Slave */
- uint16_t sdo_index, /**< SDO-Index */
- uint8_t sdo_subindex, /**< SDO-Subindex */
- uint32_t *value /**< Speicher für gel. Wert */
- )
+ Liest 32-Bit eines CANopen-SDOs im Expedited-Modus aus einem Slave.
+ \return 0 wenn alles ok, < 0 bei Fehler
+ */
+
+int ec_slave_sdo_read_exp(ec_slave_t *slave, /**< EtherCAT-Slave */
+ uint16_t sdo_index, /**< SDO-Index */
+ uint8_t sdo_subindex, /**< SDO-Subindex */
+ uint8_t *target /**< Speicher für 4 Bytes */
+ )
{
uint8_t data[0x20];
size_t rec_size;
- EC_WRITE_U16(data, 0x2000); // Number (0), Service = SDO request
- EC_WRITE_U8 (data + 2, 0x1 << 1 | 0x2 << 5); // Expedited upload request
+ EC_WRITE_U16(data, 0x2000); // SDO request
+ EC_WRITE_U8 (data + 2, 0x42); // Upload request, expedited
EC_WRITE_U16(data + 3, sdo_index);
EC_WRITE_U8 (data + 5, sdo_subindex);
@@ -134,14 +135,15 @@
return -1;
}
- *value = EC_READ_U32(data + 6);
- return 0;
-}
-
-/*****************************************************************************/
-
-/**
- Liest ein CANopen-SDO (service data object).
+ memcpy(target, data + 6, 4);
+ return 0;
+}
+
+/*****************************************************************************/
+
+/**
+ Liest ein CANopen-SDO aus einem Slave.
+ \return 0 wenn alles ok, < 0 bei Fehler
*/
int ecrt_slave_sdo_read(ec_slave_t *slave, /**< EtherCAT-Slave */
@@ -155,7 +157,7 @@
size_t rec_size, data_size;
uint32_t complete_size;
- EC_WRITE_U16(data, 0x2000); // Number (0), Service = SDO request
+ EC_WRITE_U16(data, 0x2000); // SDO request
EC_WRITE_U8 (data + 2, 0x2 << 5); // Initiate upload request
EC_WRITE_U16(data + 3, sdo_index);
EC_WRITE_U8 (data + 5, sdo_subindex);
@@ -209,88 +211,7 @@
/*****************************************************************************/
/**
- Schreibt ein CANopen-SDO (Angabe des Masters und der Adresse), expedited.
-
- Siehe ecrt_slave_sdo_exp_write()
-
- \return 0 wenn alles ok, < 0 bei Fehler
- */
-
-int ecrt_master_sdo_exp_write(ec_master_t *master,
- /**< EtherCAT-Master */
- const char *addr,
- /**< Addresse, siehe ec_master_slave_address() */
- uint16_t index,
- /**< SDO-Index */
- uint8_t subindex,
- /**< SDO-Subindex */
- uint32_t value,
- /**< Neuer Wert */
- size_t size
- /**< Größe des Datenfeldes */
- )
-{
- ec_slave_t *slave;
- if (!(slave = ec_master_slave_address(master, addr))) return -1;
- return ecrt_slave_sdo_exp_write(slave, index, subindex, value, size);
-}
-
-/*****************************************************************************/
-
-/**
- Liest ein CANopen-SDO (Angabe des Masters und der Adresse), expedited.
-
- Siehe ecrt_slave_sdo_exp_read()
-
- \return 0 wenn alles ok, < 0 bei Fehler
- */
-
-int ecrt_master_sdo_exp_read(ec_master_t *master,
- /**< EtherCAT-Slave */
- const char *addr,
- /**< Addresse, siehe ec_master_slave_address() */
- uint16_t index,
- /**< SDO-Index */
- uint8_t subindex,
- /**< SDO-Subindex */
- uint32_t *value
- /**< Speicher für gel. Wert */
- )
-{
- ec_slave_t *slave;
- if (!(slave = ec_master_slave_address(master, addr))) return -1;
- return ecrt_slave_sdo_exp_read(slave, index, subindex, value);
-}
-
-/*****************************************************************************/
-
-/**
- Liest ein CANopen-SDO (Angabe des Masters und der Adresse), expedited.
-
- Siehe ecrt_slave_sdo_exp_read()
-
- \return 0 wenn alles ok, < 0 bei Fehler
- */
-
-int ecrt_master_sdo_read(ec_master_t *master, /**< EtherCAT-Master */
- const char *addr, /**< Addresse, siehe
- ec_master_slave_address() */
- uint16_t sdo_index, /**< SDO-Index */
- uint8_t sdo_subindex, /**< SDO-Subindex */
- uint8_t *target, /**< Speicher für gel. Wert */
- size_t *size /**< Größe des Speichers */
- )
-{
- ec_slave_t *slave;
- if (!(slave = ec_master_slave_address(master, addr))) return -1;
- return ecrt_slave_sdo_read(slave, sdo_index, sdo_subindex, target, size);
-}
-
-/*****************************************************************************/
-
-/**
Holt das Object-Dictionary aus dem Slave.
-
\return 0, wenn alles ok, sonst < 0
*/
@@ -302,10 +223,10 @@
ec_sdo_t *sdo;
uint16_t sdo_index;
- EC_WRITE_U16(data, 0x8000); // Number (0), Service = SDO information
+ EC_WRITE_U16(data, 0x8000); // SDO information
EC_WRITE_U8 (data + 2, 0x01); // Get OD List Request
- EC_WRITE_U8 (data + 3, 0x00); // res.
- EC_WRITE_U16(data + 4, 0x0000); // fragments left
+ EC_WRITE_U8 (data + 3, 0x00);
+ EC_WRITE_U16(data + 4, 0x0000);
EC_WRITE_U16(data + 6, 0x0001); // Deliver all SDOs!
if (ec_slave_mailbox_send(slave, 0x03, data, 8)) return -1;
@@ -370,11 +291,12 @@
ec_sdo_t *sdo;
list_for_each_entry(sdo, &slave->sdo_dictionary, list) {
- EC_WRITE_U16(data, 0x8000); // Number (0), Service = SDO inform.
+ EC_WRITE_U16(data, 0x8000); // SDO information
EC_WRITE_U8 (data + 2, 0x03); // Get object description request
- EC_WRITE_U8 (data + 3, 0x00); // res.
- EC_WRITE_U16(data + 4, 0x0000); // fragments left
+ EC_WRITE_U8 (data + 3, 0x00);
+ EC_WRITE_U16(data + 4, 0x0000);
EC_WRITE_U16(data + 6, sdo->index); // SDO index
+
if (ec_slave_mailbox_send(slave, 0x03, data, 8)) return -1;
rec_size = 0xF0;
@@ -489,13 +411,129 @@
};
/*****************************************************************************/
-
-EXPORT_SYMBOL(ecrt_slave_sdo_exp_write);
-EXPORT_SYMBOL(ecrt_slave_sdo_exp_read);
+// Echtzeitschnittstelle
+
+/*****************************************************************************/
+
+/**
+ Liest ein 8-Bit CANopen-SDO im Expedited-Modus aus einem Slave.
+ Siehe ec_slave_sdo_read_exp()
+ \return 0 wenn alles ok, < 0 bei Fehler
+ */
+
+int ecrt_slave_sdo_read_exp8(ec_slave_t *slave, /**< EtherCAT-Slave */
+ uint16_t sdo_index, /**< SDO-Index */
+ uint8_t sdo_subindex, /**< SDO-Subindex */
+ uint8_t *target /**< Speicher für gel. Wert */
+ )
+{
+ uint8_t data[4];
+ if (ec_slave_sdo_read_exp(slave, sdo_index, sdo_subindex, data)) return -1;
+ *target = EC_READ_U8(data);
+ return 0;
+}
+
+/*****************************************************************************/
+
+/**
+ Liest ein 16-Bit CANopen-SDO im Expedited-Modus aus einem Slave.
+ Siehe ec_slave_sdo_read_exp()
+ \return 0 wenn alles ok, < 0 bei Fehler
+ */
+
+int ecrt_slave_sdo_read_exp16(ec_slave_t *slave, /**< EtherCAT-Slave */
+ uint16_t sdo_index, /**< SDO-Index */
+ uint8_t sdo_subindex, /**< SDO-Subindex */
+ uint16_t *target /**< Speicher für gel. Wert */
+ )
+{
+ uint8_t data[4];
+ if (ec_slave_sdo_read_exp(slave, sdo_index, sdo_subindex, data)) return -1;
+ *target = EC_READ_U16(data);
+ return 0;
+}
+
+/*****************************************************************************/
+
+/**
+ Liest ein 32-Bit CANopen-SDO im Expedited-Modus aus einem Slave.
+ Siehe ec_slave_sdo_read_exp()
+ \return 0 wenn alles ok, < 0 bei Fehler
+ */
+
+int ecrt_slave_sdo_read_exp32(ec_slave_t *slave, /**< EtherCAT-Slave */
+ uint16_t sdo_index, /**< SDO-Index */
+ uint8_t sdo_subindex, /**< SDO-Subindex */
+ uint32_t *target /**< Speicher für gel. Wert */
+ )
+{
+ uint8_t data[4];
+ if (ec_slave_sdo_read_exp(slave, sdo_index, sdo_subindex, data)) return -1;
+ *target = EC_READ_U32(data);
+ return 0;
+}
+
+/*****************************************************************************/
+
+/**
+ Beschreibt ein 8-Bit CANopen-SDO eines Slaves im Expedited-Modus.
+ \return 0 wenn alles ok, < 0 bei Fehler
+ */
+
+int ecrt_slave_sdo_write_exp8(ec_slave_t *slave, /**< EtherCAT-Slave */
+ uint16_t sdo_index, /**< SDO-Index */
+ uint8_t sdo_subindex, /**< SDO-Subindex */
+ uint8_t value /**< Neuer Wert */
+ )
+{
+ return ec_slave_sdo_write_exp(slave, sdo_index, sdo_subindex, &value, 1);
+}
+
+/*****************************************************************************/
+
+/**
+ Beschreibt ein 16-Bit CANopen-SDO eines Slaves im Expedited-Modus.
+ \return 0 wenn alles ok, < 0 bei Fehler
+ */
+
+int ecrt_slave_sdo_write_exp16(ec_slave_t *slave, /**< EtherCAT-Slave */
+ uint16_t sdo_index, /**< SDO-Index */
+ uint8_t sdo_subindex, /**< SDO-Subindex */
+ uint16_t value /**< Neuer Wert */
+ )
+{
+ uint8_t data[2];
+ EC_WRITE_U16(data, value);
+ return ec_slave_sdo_write_exp(slave, sdo_index, sdo_subindex, data, 2);
+}
+
+/*****************************************************************************/
+
+/**
+ Beschreibt ein 32-Bit CANopen-SDO eines Slaves im Expedited-Modus.
+ \return 0 wenn alles ok, < 0 bei Fehler
+ */
+
+int ecrt_slave_sdo_write_exp32(ec_slave_t *slave, /**< EtherCAT-Slave */
+ uint16_t sdo_index, /**< SDO-Index */
+ uint8_t sdo_subindex, /**< SDO-Subindex */
+ uint32_t value /**< Neuer Wert */
+ )
+{
+ uint8_t data[4];
+ EC_WRITE_U32(data, value);
+ return ec_slave_sdo_write_exp(slave, sdo_index, sdo_subindex, data, 4);
+}
+
+/*****************************************************************************/
+
+EXPORT_SYMBOL(ecrt_slave_sdo_read_exp8);
+EXPORT_SYMBOL(ecrt_slave_sdo_read_exp16);
+EXPORT_SYMBOL(ecrt_slave_sdo_read_exp32);
+EXPORT_SYMBOL(ecrt_slave_sdo_write_exp8);
+EXPORT_SYMBOL(ecrt_slave_sdo_write_exp16);
+EXPORT_SYMBOL(ecrt_slave_sdo_write_exp32);
EXPORT_SYMBOL(ecrt_slave_sdo_read);
-EXPORT_SYMBOL(ecrt_master_sdo_exp_write);
-EXPORT_SYMBOL(ecrt_master_sdo_exp_read);
-EXPORT_SYMBOL(ecrt_master_sdo_read);
/*****************************************************************************/
--- a/master/domain.c Tue Mar 28 17:40:57 2006 +0000
+++ b/master/domain.c Wed Mar 29 10:30:13 2006 +0000
@@ -230,7 +230,7 @@
/**< Domäne */
const char *address,
/**< ASCII-Addresse des Slaves,
- siehe ec_master_slave_address() */
+ siehe ecrt_master_get_slave() */
const char *vendor_name,
/**< Herstellername */
const char *product_name,
@@ -259,7 +259,7 @@
master = domain->master;
// Adresse übersetzen
- if (!(slave = ec_master_slave_address(master, address))) return NULL;
+ if (!(slave = ecrt_master_get_slave(master, address))) return NULL;
if (!(type = slave->type)) {
EC_ERR("Slave \"%s\" (position %i) has unknown type!\n", address,
--- a/master/master.c Tue Mar 28 17:40:57 2006 +0000
+++ b/master/master.c Wed Mar 29 10:30:13 2006 +0000
@@ -539,11 +539,9 @@
\return Zeiger auf Slave bei Erfolg, sonst NULL
*/
-ec_slave_t *ec_master_slave_address(const ec_master_t *master,
- /**< EtherCAT-Master */
- const char *address
- /**< Address-String */
- )
+ec_slave_t *ecrt_master_get_slave(const ec_master_t *master, /**< Master */
+ const char *address /**< Address-String */
+ )
{
unsigned long first, second;
char *remainder, *remainder2;
@@ -1185,29 +1183,6 @@
/*****************************************************************************/
-/**
- Schreibt den "Configured station alias".
-
- \return 0, wenn alles ok, sonst < 0
-*/
-
-int ecrt_master_write_slave_alias(ec_master_t *master,
- /** EtherCAT-Master */
- const char *slave_address,
- /** Slave-Adresse,
- siehe ec_master_slave_address() */
- uint16_t alias
- /** Neuer Alias */
- )
-{
- ec_slave_t *slave;
- if (!(slave = ec_master_slave_address(master, slave_address)))
- return -1;
- return ec_slave_sii_write16(slave, 0x0004, alias);
-}
-
-/*****************************************************************************/
-
EXPORT_SYMBOL(ecrt_master_create_domain);
EXPORT_SYMBOL(ecrt_master_activate);
EXPORT_SYMBOL(ecrt_master_deactivate);
@@ -1218,7 +1193,7 @@
EXPORT_SYMBOL(ecrt_master_async_receive);
EXPORT_SYMBOL(ecrt_master_debug);
EXPORT_SYMBOL(ecrt_master_print);
-EXPORT_SYMBOL(ecrt_master_write_slave_alias);
+EXPORT_SYMBOL(ecrt_master_get_slave);
/*****************************************************************************/
--- a/master/master.h Tue Mar 28 17:40:57 2006 +0000
+++ b/master/master.h Wed Mar 29 10:30:13 2006 +0000
@@ -76,7 +76,6 @@
// Slave management
int ec_master_bus_scan(ec_master_t *);
-ec_slave_t *ec_master_slave_address(const ec_master_t *, const char *);
// Misc
void ec_master_debug(const ec_master_t *);
--- a/master/slave.c Tue Mar 28 17:40:57 2006 +0000
+++ b/master/slave.c Wed Mar 29 10:30:13 2006 +0000
@@ -1163,6 +1163,24 @@
/*****************************************************************************/
+/**
+ Schreibt den "Configured station alias".
+ \return 0, wenn alles ok, sonst < 0
+*/
+
+int ecrt_slave_write_alias(ec_slave_t *slave, /** EtherCAT-Slave */
+ uint16_t alias /** Neuer Alias */
+ )
+{
+ return ec_slave_sii_write16(slave, 0x0004, alias);
+}
+
+/*****************************************************************************/
+
+EXPORT_SYMBOL(ecrt_slave_write_alias);
+
+/*****************************************************************************/
+
/* Emacs-Konfiguration
;;; Local Variables: ***
;;; c-basic-offset:4 ***
--- a/mini/mini.c Tue Mar 28 17:40:57 2006 +0000
+++ b/mini/mini.c Wed Mar 29 10:30:13 2006 +0000
@@ -130,15 +130,20 @@
//ecrt_master_debug(master, 2);
#if 0
- if (ecrt_master_sdo_write(master, "1", 0x4061, 1, 0, 1) ||
- ecrt_master_sdo_write(master, "1", 0x4061, 2, 1, 1) ||
- ecrt_master_sdo_write(master, "1", 0x4061, 3, 1, 1) ||
- ecrt_master_sdo_write(master, "1", 0x4066, 0, 0, 1) ||
- ecrt_master_sdo_write(master, "1", 0x4067, 0, 4, 1) ||
- ecrt_master_sdo_write(master, "1", 0x4068, 0, 0, 1) ||
- ecrt_master_sdo_write(master, "1", 0x4069, 0, 25, 1) ||
- ecrt_master_sdo_write(master, "1", 0x406A, 0, 25, 1) ||
- ecrt_master_sdo_write(master, "1", 0x406B, 0, 50, 1)) {
+ if (!(slave = ecrt_master_get_slave(master, "5"))) {
+ printk(KERN_ERR "Failed to get slave 5!\n");
+ goto out_deactivate;
+ }
+
+ if (ecrt_slave_sdo_write_exp8(slave, 0x4061, 1, 0) ||
+ ecrt_slave_sdo_write_exp8(slave, 0x4061, 2, 1) ||
+ ecrt_slave_sdo_write_exp8(slave, 0x4061, 3, 1) ||
+ ecrt_slave_sdo_write_exp8(slave, 0x4066, 0, 0) ||
+ ecrt_slave_sdo_write_exp8(slave, 0x4067, 0, 4) ||
+ ecrt_slave_sdo_write_exp8(slave, 0x4068, 0, 0) ||
+ ecrt_slave_sdo_write_exp8(slave, 0x4069, 0, 25) ||
+ ecrt_slave_sdo_write_exp8(slave, 0x406A, 0, 25) ||
+ ecrt_slave_sdo_write_exp8(slave, 0x406B, 0, 50)) {
printk(KERN_ERR "Failed to configure SSI slave!\n");
goto out_deactivate;
}
@@ -148,7 +153,7 @@
#if 0
printk(KERN_INFO "Writing alias...\n");
- if (ecrt_master_write_slave_alias(master, "0", 0xBEEF)) {
+ if (ecrt_slave_sdo_write_exp16(slave, 0xBEEF)) {
printk(KERN_ERR "Failed to write alias!\n");
goto out_deactivate;
}
--- a/rt/msr_module.c Tue Mar 28 17:40:57 2006 +0000
+++ b/rt/msr_module.c Wed Mar 29 10:30:13 2006 +0000
@@ -186,6 +186,7 @@
struct ipipe_domain_attr attr; //ipipe
uint8_t string[10];
size_t size;
+ ec_slave_t *slave;
// Als allererstes die RT-Lib initialisieren
if (msr_rtlib_init(1, MSR_ABTASTFREQUENZ, 10, &msr_globals_register) < 0) {
@@ -231,31 +232,41 @@
ecrt_master_print(master);
#ifdef BLOCK1
+ if (!(slave = ecrt_master_get_slave(master, "1"))) {
+ printk(KERN_ERR "Failed to get slave 1!\n");
+ goto out_deactivate;
+ }
+
size = 10;
- if (ecrt_master_sdo_read(master, "1", 0x100A, 0, string, &size)) {
+ if (ecrt_slave_sdo_read(slave, 0x100A, 0, string, &size)) {
printk(KERN_ERR "Could not read SSI version!\n");
goto out_deactivate;
}
string[size] = 0;
printk(KERN_INFO "Software-version 1: %s\n", string);
+ if (!(slave = ecrt_master_get_slave(master, "5"))) {
+ printk(KERN_ERR "Failed to get slave 5!\n");
+ goto out_deactivate;
+ }
+
size = 10;
- if (ecrt_master_sdo_read(master, "5", 0x100A, 0, string, &size)) {
+ if (ecrt_slave_sdo_read(slave, 0x100A, 0, string, &size)) {
printk(KERN_ERR "Could not read SSI version!\n");
goto out_deactivate;
}
string[size] = 0;
printk(KERN_INFO "Software-version 5: %s\n", string);
- if (ecrt_master_sdo_exp_write(master, "5", 0x4061, 1, 0, 1) ||
- ecrt_master_sdo_exp_write(master, "5", 0x4061, 2, 1, 1) ||
- ecrt_master_sdo_exp_write(master, "5", 0x4061, 3, 1, 1) ||
- ecrt_master_sdo_exp_write(master, "5", 0x4066, 0, 0, 1) ||
- ecrt_master_sdo_exp_write(master, "5", 0x4067, 0, 4, 1) ||
- ecrt_master_sdo_exp_write(master, "5", 0x4068, 0, 0, 1) ||
- ecrt_master_sdo_exp_write(master, "5", 0x4069, 0, 25, 1) ||
- ecrt_master_sdo_exp_write(master, "5", 0x406A, 0, 25, 1) ||
- ecrt_master_sdo_exp_write(master, "5", 0x406B, 0, 50, 1)) {
+ if (ecrt_slave_sdo_write_exp8(slave, 0x4061, 1, 0) ||
+ ecrt_slave_sdo_write_exp8(slave, 0x4061, 2, 1) ||
+ ecrt_slave_sdo_write_exp8(slave, 0x4061, 3, 1) ||
+ ecrt_slave_sdo_write_exp8(slave, 0x4066, 0, 0) ||
+ ecrt_slave_sdo_write_exp8(slave, 0x4067, 0, 4) ||
+ ecrt_slave_sdo_write_exp8(slave, 0x4068, 0, 0) ||
+ ecrt_slave_sdo_write_exp8(slave, 0x4069, 0, 25) ||
+ ecrt_slave_sdo_write_exp8(slave, 0x406A, 0, 25) ||
+ ecrt_slave_sdo_write_exp8(slave, 0x406B, 0, 50)) {
printk(KERN_ERR "Failed to configure SSI slave!\n");
goto out_deactivate;
}
--- a/todo.txt Tue Mar 28 17:40:57 2006 +0000
+++ b/todo.txt Wed Mar 29 10:30:13 2006 +0000
@@ -10,9 +10,9 @@
- Konfiguration Inkrementalgeberklemme
- SSI-Klemme
- SysFS-Interface implementieren
-- SDO Dictionary der Slaves auslesen und im SysFS darstellen
- DLL-Link-States auslesen und Topologie berechnen
- Ethernet over EtherCAT (EoE)
- eepro100-Kartentreiber
+- Master mit eigener State-Machine -> run()
- Installationsanleitung / Dokumentation
- Userspace-Tool zum Konfigurieren und visualisieren