Skip to content
Snippets Groups Projects
Commit 094cf215 authored by Florian Pose's avatar Florian Pose
Browse files

Rahmen jetzt zustandslos.

parent 55a6c7dc
No related branches found
No related tags found
No related merge requests found
...@@ -59,7 +59,7 @@ int EtherCAT_rt_canopen_sdo_write(ec_slave_t *slave, /**< EtherCAT-Slave */ ...@@ -59,7 +59,7 @@ int EtherCAT_rt_canopen_sdo_write(ec_slave_t *slave, /**< EtherCAT-Slave */
ec_frame_init_npwr(&frame, master, slave->station_address, ec_frame_init_npwr(&frame, master, slave->station_address,
0x1800, 0xF6, data); 0x1800, 0xF6, data);
if (unlikely(ec_frame_send_receive(&frame) < 0)) { if (unlikely(ec_frame_send_receive(&frame))) {
EC_ERR("Mailbox sending failed on slave %i!\n", slave->ring_position); EC_ERR("Mailbox sending failed on slave %i!\n", slave->ring_position);
return -1; return -1;
} }
......
...@@ -311,12 +311,7 @@ int EtherCAT_rt_domain_xio(ec_domain_t *domain /**< Dom ...@@ -311,12 +311,7 @@ int EtherCAT_rt_domain_xio(ec_domain_t *domain /**< Dom
} }
if (unlikely(ec_frame_receive(frame) < 0)) { if (unlikely(ec_frame_receive(frame) < 0)) {
EC_ERR("Receive error!\n"); EC_ERR("Receiving process data failed!\n");
return -1;
}
if (unlikely(frame->state != ec_frame_received)) {
EC_WARN("Process data command not received!\n");
return -1; return -1;
} }
......
...@@ -19,7 +19,6 @@ ...@@ -19,7 +19,6 @@
#define EC_FUNC_HEADER \ #define EC_FUNC_HEADER \
frame->master = master; \ frame->master = master; \
frame->state = ec_frame_ready; \
frame->index = 0; \ frame->index = 0; \
frame->working_counter = 0; frame->working_counter = 0;
...@@ -258,10 +257,6 @@ int ec_frame_send(ec_frame_t *frame /**< Rahmen zum Senden */) ...@@ -258,10 +257,6 @@ int ec_frame_send(ec_frame_t *frame /**< Rahmen zum Senden */)
EC_DBG("ec_frame_send\n"); EC_DBG("ec_frame_send\n");
} }
if (unlikely(frame->state != ec_frame_ready)) {
EC_WARN("Frame not in \"ready\" state!\n");
}
command_size = frame->data_length + EC_COMMAND_HEADER_SIZE command_size = frame->data_length + EC_COMMAND_HEADER_SIZE
+ EC_COMMAND_FOOTER_SIZE; + EC_COMMAND_FOOTER_SIZE;
frame_size = command_size + EC_FRAME_HEADER_SIZE; frame_size = command_size + EC_FRAME_HEADER_SIZE;
...@@ -284,8 +279,6 @@ int ec_frame_send(ec_frame_t *frame /**< Rahmen zum Senden */) ...@@ -284,8 +279,6 @@ int ec_frame_send(ec_frame_t *frame /**< Rahmen zum Senden */)
EC_DBG("Sending command index 0x%X\n", frame->index); EC_DBG("Sending command index 0x%X\n", frame->index);
} }
frame->state = ec_frame_sent;
// Zeiger auf Socket-Buffer holen // Zeiger auf Socket-Buffer holen
data = ec_device_prepare(&frame->master->device); data = ec_device_prepare(&frame->master->device);
...@@ -336,11 +329,6 @@ int ec_frame_receive(ec_frame_t *frame /**< Gesendeter Rahmen */) ...@@ -336,11 +329,6 @@ int ec_frame_receive(ec_frame_t *frame /**< Gesendeter Rahmen */)
uint8_t command_type, command_index; uint8_t command_type, command_index;
ec_device_t *device; ec_device_t *device;
if (unlikely(frame->state != ec_frame_sent)) {
EC_ERR("Frame was not sent!\n");
return -1;
}
device = &frame->master->device; device = &frame->master->device;
if (!(received_length = ec_device_received(device))) return -1; if (!(received_length = ec_device_received(device))) return -1;
...@@ -388,8 +376,6 @@ int ec_frame_receive(ec_frame_t *frame /**< Gesendeter Rahmen */) ...@@ -388,8 +376,6 @@ int ec_frame_receive(ec_frame_t *frame /**< Gesendeter Rahmen */)
return -1; return -1;
} }
frame->state = ec_frame_received;
// Empfangene Daten in Kommandodatenspeicher kopieren // Empfangene Daten in Kommandodatenspeicher kopieren
memcpy(frame->data, data, data_length); memcpy(frame->data, data, data_length);
data += data_length; data += data_length;
......
...@@ -16,23 +16,6 @@ ...@@ -16,23 +16,6 @@
/*****************************************************************************/ /*****************************************************************************/
#define EC_MAX_DATA_SIZE (EC_MAX_FRAME_SIZE - EC_FRAME_HEADER_SIZE \
- EC_COMMAND_HEADER_SIZE \
- EC_COMMAND_FOOTER_SIZE)
/*****************************************************************************/
/**
Status eines EtherCAT-Rahmens.
*/
typedef enum {
ec_frame_ready, ec_frame_sent, ec_frame_received
}
ec_frame_state_t;
/*****************************************************************************/
/** /**
EtherCAT-Rahmen-Typ EtherCAT-Rahmen-Typ
*/ */
...@@ -44,9 +27,9 @@ typedef enum ...@@ -44,9 +27,9 @@ typedef enum
ec_frame_type_apwr = 0x02, /**< Auto-increment physical write */ ec_frame_type_apwr = 0x02, /**< Auto-increment physical write */
ec_frame_type_nprd = 0x04, /**< Node-addressed physical read */ ec_frame_type_nprd = 0x04, /**< Node-addressed physical read */
ec_frame_type_npwr = 0x05, /**< Node-addressed physical write */ ec_frame_type_npwr = 0x05, /**< Node-addressed physical write */
ec_frame_type_brd = 0x07, /**< Broadcast read */ ec_frame_type_brd = 0x07, /**< Broadcast read */
ec_frame_type_bwr = 0x08, /**< Broadcast write */ ec_frame_type_bwr = 0x08, /**< Broadcast write */
ec_frame_type_lrw = 0x0C /**< Logical read/write */ ec_frame_type_lrw = 0x0C /**< Logical read/write */
} }
ec_frame_type_t; ec_frame_type_t;
...@@ -90,7 +73,6 @@ typedef struct ...@@ -90,7 +73,6 @@ typedef struct
ec_address_t address; /**< Adresse des/der Empfnger */ ec_address_t address; /**< Adresse des/der Empfnger */
unsigned int data_length; /**< Lnge der zu sendenden und/oder empfangenen unsigned int data_length; /**< Lnge der zu sendenden und/oder empfangenen
Daten */ Daten */
ec_frame_state_t state; /**< Zustand des Kommandos */
uint8_t index; /**< Kommando-Index, mit dem der Frame gesendet wurde uint8_t index; /**< Kommando-Index, mit dem der Frame gesendet wurde
(wird vom Master beim Senden gesetzt). */ (wird vom Master beim Senden gesetzt). */
uint16_t working_counter; /**< Working-Counter */ uint16_t working_counter; /**< Working-Counter */
......
...@@ -24,6 +24,11 @@ ...@@ -24,6 +24,11 @@
#define EC_FMMU_SIZE 16 /**< Gre einer FMMU-Konfigurationsseite */ #define EC_FMMU_SIZE 16 /**< Gre einer FMMU-Konfigurationsseite */
#define EC_MAX_FMMUS 16 /**< Maximale Anzahl FMMUs pro Slave */ #define EC_MAX_FMMUS 16 /**< Maximale Anzahl FMMUs pro Slave */
#define EC_MAX_DATA_SIZE (EC_MAX_FRAME_SIZE \
- EC_FRAME_HEADER_SIZE \
- EC_COMMAND_HEADER_SIZE \
- EC_COMMAND_FOOTER_SIZE) /**< Maximale Datengre */
#define EC_MASTER_MAX_DOMAINS 10 /**< Maximale Anzahl Domnen eines Masters */ #define EC_MASTER_MAX_DOMAINS 10 /**< Maximale Anzahl Domnen eines Masters */
#ifndef NULL #ifndef NULL
......
...@@ -164,24 +164,23 @@ int ec_scan_for_slaves(ec_master_t *master /**< EtherCAT-Master */) ...@@ -164,24 +164,23 @@ int ec_scan_for_slaves(ec_master_t *master /**< EtherCAT-Master */)
unsigned int i; unsigned int i;
unsigned char data[2]; unsigned char data[2];
if (master->slaves || master->slave_count) if (master->slaves || master->slave_count) {
EC_WARN("Slave scan already done!\n"); EC_ERR("Slave scan already done!\n");
ec_master_clear_slaves(master); return -1;
}
// Determine number of slaves on bus // Determine number of slaves on bus
ec_frame_init_brd(&frame, master, 0x0000, 4); ec_frame_init_brd(&frame, master, 0x0000, 4);
if (unlikely(ec_frame_send_receive(&frame) < 0)) return -1; if (unlikely(ec_frame_send_receive(&frame))) return -1;
master->slave_count = frame.working_counter; master->slave_count = frame.working_counter;
EC_INFO("Found %i slaves on bus.\n", master->slave_count); EC_INFO("Found %i slaves on bus.\n", master->slave_count);
if (!master->slave_count) return 0; if (!master->slave_count) return 0;
if (!(master->slaves = (ec_slave_t *) kmalloc(master->slave_count if (!(master->slaves = (ec_slave_t *) kmalloc(master->slave_count
* sizeof(ec_slave_t), * sizeof(ec_slave_t),
GFP_KERNEL))) { GFP_KERNEL))) {
EC_ERR("Could not allocate memory for bus slaves!\n"); EC_ERR("Could not allocate memory for slaves!\n");
return -1; return -1;
} }
...@@ -204,7 +203,7 @@ int ec_scan_for_slaves(ec_master_t *master /**< EtherCAT-Master */) ...@@ -204,7 +203,7 @@ int ec_scan_for_slaves(ec_master_t *master /**< EtherCAT-Master */)
ec_frame_init_apwr(&frame, master, slave->ring_position, 0x0010, ec_frame_init_apwr(&frame, master, slave->ring_position, 0x0010,
sizeof(uint16_t), data); sizeof(uint16_t), data);
if (unlikely(ec_frame_send_receive(&frame) < 0)) { if (unlikely(ec_frame_send_receive(&frame))) {
EC_ERR("Writing station address failed on slave %i!\n", i); EC_ERR("Writing station address failed on slave %i!\n", i);
return -1; return -1;
} }
...@@ -486,7 +485,7 @@ int EtherCAT_rt_master_activate(ec_master_t *master /**< EtherCAT-Master */) ...@@ -486,7 +485,7 @@ int EtherCAT_rt_master_activate(ec_master_t *master /**< EtherCAT-Master */)
memset(data, 0x00, EC_FMMU_SIZE * slave->base_fmmu_count); memset(data, 0x00, EC_FMMU_SIZE * slave->base_fmmu_count);
ec_frame_init_npwr(&frame, master, slave->station_address, 0x0600, ec_frame_init_npwr(&frame, master, slave->station_address, 0x0600,
EC_FMMU_SIZE * slave->base_fmmu_count, data); EC_FMMU_SIZE * slave->base_fmmu_count, data);
if (unlikely(ec_frame_send_receive(&frame) < 0)) { if (unlikely(ec_frame_send_receive(&frame))) {
EC_ERR("Resetting FMMUs failed on slave %i!\n", EC_ERR("Resetting FMMUs failed on slave %i!\n",
slave->ring_position); slave->ring_position);
return -1; return -1;
...@@ -498,7 +497,7 @@ int EtherCAT_rt_master_activate(ec_master_t *master /**< EtherCAT-Master */) ...@@ -498,7 +497,7 @@ int EtherCAT_rt_master_activate(ec_master_t *master /**< EtherCAT-Master */)
memset(data, 0x00, EC_SYNC_SIZE * slave->base_sync_count); memset(data, 0x00, EC_SYNC_SIZE * slave->base_sync_count);
ec_frame_init_npwr(&frame, master, slave->station_address, 0x0800, ec_frame_init_npwr(&frame, master, slave->station_address, 0x0800,
EC_SYNC_SIZE * slave->base_sync_count, data); EC_SYNC_SIZE * slave->base_sync_count, data);
if (unlikely(ec_frame_send_receive(&frame) < 0)) { if (unlikely(ec_frame_send_receive(&frame))) {
EC_ERR("Resetting sync managers failed on slave %i!\n", EC_ERR("Resetting sync managers failed on slave %i!\n",
slave->ring_position); slave->ring_position);
return -1; return -1;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment