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

Reverted accidential checkin.

parent 9c2da975
No related branches found
No related tags found
No related merge requests found
......@@ -21,7 +21,6 @@ Version 1.5.0:
- Check if register 0x0980 is working, to avoid clearing it when
configuring.
- Create an interface to query the System Time Difference registers.
* Remove byte-swapping functions from user space.
* EoE:
- Only execute one EoE handler per cycle.
- Replace locking callbacks.
......
......@@ -192,22 +192,6 @@ typedef struct {
/*****************************************************************************/
#ifndef __KERNEL__
/** Master information.
*
* This is used as an output parameter of ecrt_master().
*
* \see ecrt_master().
*/
typedef struct {
unsigned int slave_count; /**< Number of slaves in the bus. */
unsigned int link_up : 1; /**< \a true, if the network link is up. */
uint64_t app_time; /**< Application time. */
} ec_master_info_t;
/*****************************************************************************/
/** Slave information.
*
* This is used as an output parameter of ecrt_master_slave().
......@@ -229,8 +213,6 @@ typedef struct {
char name[EC_MAX_STRING_LENGTH]; /**< Name of the slave. */
} ec_slave_info_t;
#endif // #ifndef __KERNEL__
/*****************************************************************************/
/** Domain working counter interpretation.
......@@ -392,52 +374,6 @@ void ecrt_release_master(
ec_master_t *master /**< EtherCAT master */
);
#ifndef __KERNEL__
/** Opens an EtherCAT master for userspace access.
*
* This function has to be the first function an application has to call to
* use EtherCAT. The function takes the index of the master as its argument.
* The first master has index 0, the n-th master has index n - 1. The number
* of masters has to be specified when loading the master module.
*
* \return Pointer to the opened master, otherwise \a NULL.
*/
ec_master_t *ecrt_open_master(
unsigned int master_index /**< Index of the master to request. */
);
/** Reserves an EtherCAT master for realtime operation.
*
* Before an application can use PDO/domain registration functions or SDO
* request functions on the master, it has to reserve one for exclusive use.
*
* \return 0 in case of success, else < 0
*
*/
int ecrt_reserve_master(
ec_master_t *master /**< EtherCAT master */
);
/** Obtains master information.
*
* No memory is allocated on the heap in
* this function.
*
* \attention The pointer to this structure must point to a valid variable.
*
* \return 0 in case of success, else < 0
*/
int ecrt_master(
ec_master_t *master, /**< EtherCAT master */
ec_master_info_t *master_info /**< Structure that will output the
information */
);
#endif // #ifndef __KERNEL__
/******************************************************************************
* Master methods
*****************************************************************************/
......@@ -532,7 +468,7 @@ int ecrt_master_slave(
information */
);
#endif /* #ifndef __KERNEL__ */
#endif /* ifndef __KERNEL__ */
/** Finishes the configuration phase and prepares for cyclic operation.
*
......@@ -667,7 +603,7 @@ int ecrt_slave_sdo_upload(
uint32_t *abort_code /**< Abort code of the SDO upload. */
);
#endif /* #ifndef __KERNEL__ */
#endif /* ifndef __KERNEL__ */
/******************************************************************************
* Slave configuration methods
......
......@@ -50,48 +50,40 @@ unsigned int ecrt_version_magic(void)
/*****************************************************************************/
ec_master_t *ecrt_request_master(unsigned int master_index)
{
ec_master_t *master = ecrt_open_master(master_index);
if (master) {
if (ecrt_master_reserve(master) < 0) {
close(master->fd);
free(master);
master = 0;
}
}
return master;
}
/*****************************************************************************/
#define MAX_PATH_LEN 64
ec_master_t *ecrt_open_master(unsigned int master_index)
ec_master_t *ecrt_request_master(unsigned int master_index)
{
char path[MAX_PATH_LEN];
ec_master_t *master;
char path[MAX_PATH_LEN];
ec_master_t *master;
master = malloc(sizeof(ec_master_t));
if (!master) {
fprintf(stderr, "Failed to allocate memory.\n");
return 0;
}
master = malloc(sizeof(ec_master_t));
if (!master) {
fprintf(stderr, "Failed to allocate memory.\n");
return 0;
}
master->process_data = NULL;
master->process_data_size = 0;
master->process_data = NULL;
master->process_data_size = 0;
snprintf(path, MAX_PATH_LEN - 1, "/dev/EtherCAT%u", master_index);
snprintf(path, MAX_PATH_LEN - 1, "/dev/EtherCAT%u", master_index);
master->fd = open(path, O_RDWR);
if (master->fd == -1) {
fprintf(stderr, "Failed to open %s: %s\n", path, strerror(errno));
free(master);
return 0;
}
master->fd = open(path, O_RDWR);
if (master->fd == -1) {
fprintf(stderr, "Failed to open %s: %s\n", path, strerror(errno));
free(master);
return 0;
}
return master;
if (ioctl(master->fd, EC_IOCTL_REQUEST, NULL) == -1) {
fprintf(stderr, "Failed to request master %u: %s\n",
master_index, strerror(errno));
close(master->fd);
free(master);
return 0;
}
return master;
}
/*****************************************************************************/
......
......@@ -42,17 +42,6 @@
/*****************************************************************************/
int ecrt_master_reserve(ec_master_t *master)
{
if (ioctl(master->fd, EC_IOCTL_REQUEST, NULL) == -1) {
fprintf(stderr, "Failed to reserve master: %s\n",
strerror(errno));
return -1;
}
}
/*****************************************************************************/
ec_domain_t *ecrt_master_create_domain(ec_master_t *master)
{
ec_domain_t *domain;
......@@ -112,25 +101,6 @@ ec_slave_config_t *ecrt_master_slave_config(ec_master_t *master,
return sc;
}
/*****************************************************************************/
int ecrt_master(ec_master_t* master,
ec_master_info_t *master_info)
{
ec_ioctl_master_t data;
if (ioctl(master->fd, EC_IOCTL_MASTER, &data) < 0) {
fprintf(stderr, "Failed to get master info: %s\n",
strerror(errno));
return -1;
}
master_info->slave_count = data.slave_count;
master_info->link_up = data.devices[0].link_state;
master_info->app_time = data.app_time;
return 0;
}
/*****************************************************************************/
int ecrt_master_slave(ec_master_t *master, uint16_t position,
......
......@@ -1105,7 +1105,7 @@ void ec_fsm_coe_down_start(ec_fsm_coe_t *fsm /**< finite state machine */)
if (slave->master->debug_level) {
EC_DBG("Expedited download request:\n");
ec_print_data(data, 10 + request->data_size);
ec_print_data(data, 10);
}
}
else { // request->data_size > 4, use normal transfer type
......@@ -1662,7 +1662,7 @@ void ec_fsm_coe_up_response(ec_fsm_coe_t *fsm /**< finite state machine */)
data_size, fsm->complete_size);
data = ec_slave_mbox_prepare_send(slave, datagram,
0x03, 10);
0x03, 3);
if (IS_ERR(data)) {
fsm->state = ec_fsm_coe_error;
return;
......@@ -1674,7 +1674,7 @@ void ec_fsm_coe_up_response(ec_fsm_coe_t *fsm /**< finite state machine */)
if (master->debug_level) {
EC_DBG("Upload segment request:\n");
ec_print_data(data, 10);
ec_print_data(data, 3);
}
fsm->retries = EC_FSM_RETRIES;
......@@ -1876,7 +1876,7 @@ void ec_fsm_coe_up_seg_response(ec_fsm_coe_t *fsm /**< finite state machine */)
last_segment = EC_READ_U8(data + 2) & 0x01;
seg_size = (EC_READ_U8(data + 2) & 0xE) >> 1;
if (rec_size > 10) {
data_size = rec_size - 3; // Header of segment upload is smaller then normal upload
data_size = rec_size - 10;
} else { // == 10
/* seg_size contains the number of trailing bytes to ignore. */
data_size = rec_size - seg_size;
......@@ -1890,13 +1890,13 @@ void ec_fsm_coe_up_seg_response(ec_fsm_coe_t *fsm /**< finite state machine */)
return;
}
memcpy(request->data + request->data_size, data + 3, data_size);
memcpy(request->data + request->data_size, data + 10, data_size);
request->data_size += data_size;
if (!last_segment) {
fsm->toggle = !fsm->toggle;
data = ec_slave_mbox_prepare_send(slave, datagram, 0x03, 10);
data = ec_slave_mbox_prepare_send(slave, datagram, 0x03, 3);
if (IS_ERR(data)) {
fsm->state = ec_fsm_coe_error;
return;
......@@ -1908,7 +1908,7 @@ void ec_fsm_coe_up_seg_response(ec_fsm_coe_t *fsm /**< finite state machine */)
if (master->debug_level) {
EC_DBG("Upload segment request:\n");
ec_print_data(data, 10);
ec_print_data(data, 3);
}
fsm->retries = EC_FSM_RETRIES;
......
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