Removed tabulators.
This commit is contained in:
parent
0f104bbc83
commit
a144042657
|
|
@ -3,32 +3,32 @@
|
|||
|
||||
digraph change {
|
||||
|
||||
start [fontname="Helvetica"]
|
||||
start -> check [weight=5]
|
||||
start [fontname="Helvetica"]
|
||||
start -> check [weight=5]
|
||||
|
||||
check [fontname="Helvetica"]
|
||||
check -> status [weight=5]
|
||||
check -> error [fontname="Helvetica", label="Response\ntimeout"]
|
||||
check [fontname="Helvetica"]
|
||||
check -> status [weight=5]
|
||||
check -> error [fontname="Helvetica", label="Response\ntimeout"]
|
||||
|
||||
status [fontname="Helvetica"]
|
||||
status -> end [fontname="Helvetica", label="Success", weight=5]
|
||||
status -> code [fontname="Helvetica", label="Refuse", weight=5]
|
||||
status -> error [fontname="Helvetica", label="Change\ntimeout"]
|
||||
status [fontname="Helvetica"]
|
||||
status -> end [fontname="Helvetica", label="Success", weight=5]
|
||||
status -> code [fontname="Helvetica", label="Refuse", weight=5]
|
||||
status -> error [fontname="Helvetica", label="Change\ntimeout"]
|
||||
|
||||
code [fontname="Helvetica"]
|
||||
code -> ack [weight=2]
|
||||
code [fontname="Helvetica"]
|
||||
code -> ack [weight=2]
|
||||
|
||||
start_ack [fontname="Helvetica"]
|
||||
start_ack -> ack [fontname="Helvetica", label="Ack only"]
|
||||
start_ack [fontname="Helvetica"]
|
||||
start_ack -> ack [fontname="Helvetica", label="Ack only"]
|
||||
|
||||
ack [fontname="Helvetica"]
|
||||
ack -> check_ack [weight=2]
|
||||
ack [fontname="Helvetica"]
|
||||
ack -> check_ack [weight=2]
|
||||
|
||||
check_ack [fontname="Helvetica"]
|
||||
check_ack -> end [fontname="Helvetica", label="Ack only"]
|
||||
check_ack -> error [weight=2]
|
||||
check_ack [fontname="Helvetica"]
|
||||
check_ack -> end [fontname="Helvetica", label="Ack only"]
|
||||
check_ack -> error [weight=2]
|
||||
|
||||
end [fontname="Helvetica"]
|
||||
end [fontname="Helvetica"]
|
||||
|
||||
error [fontname="Helvetica"]
|
||||
error [fontname="Helvetica"]
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
digraph master {
|
||||
size="7,9"
|
||||
center=1
|
||||
ratio=fill
|
||||
ratio=fill
|
||||
|
||||
start [fontname="Helvetica"]
|
||||
start -> broadcast [weight=10]
|
||||
|
|
|
|||
|
|
@ -3,23 +3,23 @@
|
|||
|
||||
digraph pdo_entry_conf {
|
||||
|
||||
start [fontname="Helvetica"]
|
||||
start [fontname="Helvetica"]
|
||||
start -> zero_entry_count [weight=10]
|
||||
|
||||
zero_entry_count [fontname="Helvetica"]
|
||||
zero_entry_count [fontname="Helvetica"]
|
||||
zero_entry_count -> end [fontname="Helvetica",label="No Entries"]
|
||||
zero_entry_count -> action_map [fontname="Helvetica",label="Add first entry", weight=10]
|
||||
|
||||
action_map [shape=point,label=""]
|
||||
action_map -> map_entry [weight=10]
|
||||
action_map -> map_entry [weight=10]
|
||||
|
||||
map_entry [fontname="Helvetica"]
|
||||
map_entry [fontname="Helvetica"]
|
||||
map_entry -> action_map [fontname="Helvetica",label="Next entry"]
|
||||
map_entry -> set_entry_count [fontname="Helvetica",label="No more Entries", weight=10]
|
||||
|
||||
set_entry_count [fontname="Helvetica"]
|
||||
set_entry_count [fontname="Helvetica"]
|
||||
set_entry_count -> end [weight=10]
|
||||
|
||||
end [fontname="Helvetica"]
|
||||
end
|
||||
end [fontname="Helvetica"]
|
||||
end
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,17 +3,17 @@
|
|||
|
||||
digraph pdo_entry_read {
|
||||
|
||||
start [fontname="Helvetica"]
|
||||
start [fontname="Helvetica"]
|
||||
start -> count [weight=5]
|
||||
|
||||
count [fontname="Helvetica"]
|
||||
count -> action_next [weight=5]
|
||||
count [fontname="Helvetica"]
|
||||
count -> action_next [weight=5]
|
||||
|
||||
action_next [shape=point,label=""]
|
||||
action_next -> pdo_entry [fontname="Helvetica", label="Next entry", weight=5]
|
||||
action_next -> end [fontname="Helvetica", label="No more entries"]
|
||||
action_next -> end [fontname="Helvetica", label="No more entries"]
|
||||
|
||||
pdo_entry [fontname="Helvetica"]
|
||||
pdo_entry [fontname="Helvetica"]
|
||||
pdo_entry -> action_next
|
||||
|
||||
end [fontname="Helvetica"]
|
||||
|
|
|
|||
|
|
@ -3,25 +3,25 @@
|
|||
|
||||
digraph pdo_read {
|
||||
|
||||
start [fontname="Helvetica"]
|
||||
start [fontname="Helvetica"]
|
||||
start -> action_next_sync [fontname="Helvetica", label="First SM", weight=5]
|
||||
|
||||
action_next_sync [shape=point,label=""]
|
||||
action_next_sync -> pdo_count [weight=5]
|
||||
action_next_sync -> end
|
||||
|
||||
pdo_count [fontname="Helvetica"]
|
||||
pdo_count [fontname="Helvetica"]
|
||||
pdo_count -> action_next_pdo [weight=5]
|
||||
|
||||
action_next_pdo [shape=point,label=""]
|
||||
action_next_pdo -> pdo [fontname="Helvetica", label="Next PDO", weight=5]
|
||||
action_next_pdo -> action_next_sync [fontname="Helvetica", label="No more PDOs"]
|
||||
action_next_pdo -> action_next_sync [fontname="Helvetica", label="No more PDOs"]
|
||||
|
||||
pdo [fontname="Helvetica"]
|
||||
pdo [fontname="Helvetica"]
|
||||
pdo -> pdo_entries [weight=5]
|
||||
|
||||
pdo_entries [fontname="Helvetica"]
|
||||
pdo_entries [fontname="Helvetica"]
|
||||
pdo_entries -> action_next_pdo
|
||||
|
||||
end [fontname="Helvetica"]
|
||||
end [fontname="Helvetica"]
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,31 +3,31 @@
|
|||
|
||||
digraph sii {
|
||||
|
||||
start_reading [fontname="Helvetica"]
|
||||
start_reading -> read_check [weight=5]
|
||||
start_reading [fontname="Helvetica"]
|
||||
start_reading -> read_check [weight=5]
|
||||
|
||||
read_check [fontname="Helvetica"]
|
||||
read_check -> error
|
||||
read_check -> read_fetch [weight=5]
|
||||
read_check [fontname="Helvetica"]
|
||||
read_check -> error
|
||||
read_check -> read_fetch [weight=5]
|
||||
|
||||
read_fetch [fontname="Helvetica"]
|
||||
read_fetch -> error
|
||||
read_fetch -> end [weight=5]
|
||||
read_fetch -> read_fetch
|
||||
read_fetch [fontname="Helvetica"]
|
||||
read_fetch -> error
|
||||
read_fetch -> end [weight=5]
|
||||
read_fetch -> read_fetch
|
||||
|
||||
start_writing [fontname="Helvetica"]
|
||||
start_writing -> write_check [weight=5]
|
||||
start_writing [fontname="Helvetica"]
|
||||
start_writing -> write_check [weight=5]
|
||||
|
||||
write_check [fontname="Helvetica"]
|
||||
write_check -> error
|
||||
write_check -> write_check2 [weight=5]
|
||||
write_check [fontname="Helvetica"]
|
||||
write_check -> error
|
||||
write_check -> write_check2 [weight=5]
|
||||
|
||||
write_check2 [fontname="Helvetica"]
|
||||
write_check2 -> error
|
||||
write_check2 -> end [weight=5]
|
||||
write_check2 -> write_check2
|
||||
write_check2 [fontname="Helvetica"]
|
||||
write_check2 -> error
|
||||
write_check2 -> end [weight=5]
|
||||
write_check2 -> write_check2
|
||||
|
||||
end [fontname="Helvetica"]
|
||||
end [fontname="Helvetica"]
|
||||
|
||||
error [fontname="Helvetica"]
|
||||
error [fontname="Helvetica"]
|
||||
}
|
||||
|
|
|
|||
|
|
@ -193,13 +193,13 @@ void signal_handler(int signum) {
|
|||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
ec_slave_config_t *sc;
|
||||
ec_slave_config_t *sc;
|
||||
struct sigaction sa;
|
||||
struct itimerval tv;
|
||||
|
||||
master = ecrt_request_master(0);
|
||||
if (!master)
|
||||
return -1;
|
||||
if (!master)
|
||||
return -1;
|
||||
|
||||
domain1 = ecrt_master_create_domain(master);
|
||||
if (!domain1)
|
||||
|
|
|
|||
|
|
@ -217,7 +217,7 @@ typedef struct {
|
|||
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. */
|
||||
uint8_t scan_busy; /**< \a true, while the master is scanning the bus */
|
||||
uint8_t scan_busy; /**< \a true, while the master is scanning the bus */
|
||||
uint64_t app_time; /**< Application time. */
|
||||
} ec_master_info_t;
|
||||
|
||||
|
|
@ -426,8 +426,8 @@ ec_master_t *ecrt_request_master(
|
|||
* \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. */
|
||||
);
|
||||
unsigned int master_index /**< Index of the master to request. */
|
||||
);
|
||||
|
||||
#endif // #ifndef __KERNEL__
|
||||
|
||||
|
|
@ -455,8 +455,8 @@ void ecrt_release_master(
|
|||
*
|
||||
*/
|
||||
int ecrt_master_reserve(
|
||||
ec_master_t *master /**< EtherCAT master */
|
||||
);
|
||||
ec_master_t *master /**< EtherCAT master */
|
||||
);
|
||||
|
||||
#endif // #ifndef __KERNEL__
|
||||
|
||||
|
|
@ -545,10 +545,10 @@ ec_slave_config_t *ecrt_master_slave_config(
|
|||
* \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 */
|
||||
);
|
||||
ec_master_t *master, /**< EtherCAT master */
|
||||
ec_master_info_t *master_info /**< Structure that will output the
|
||||
information */
|
||||
);
|
||||
|
||||
/** Obtains slave information.
|
||||
*
|
||||
|
|
@ -700,7 +700,7 @@ void ecrt_master_deactivate(
|
|||
*/
|
||||
int ecrt_master_set_send_interval(
|
||||
ec_master_t *master, /**< EtherCAT master. */
|
||||
size_t send_interval /**< Send interval in us */
|
||||
size_t send_interval /**< Send interval in us */
|
||||
);
|
||||
|
||||
/** Sends all datagrams in the queue.
|
||||
|
|
@ -1001,13 +1001,13 @@ int ecrt_slave_config_reg_pdo_entry(
|
|||
* if the slave shall be operated without distributed clocks (default).
|
||||
*/
|
||||
void ecrt_slave_config_dc(
|
||||
ec_slave_config_t *sc, /**< Slave configuration. */
|
||||
ec_slave_config_t *sc, /**< Slave configuration. */
|
||||
uint16_t assign_activate, /**< AssignActivate word. */
|
||||
uint32_t sync0_cycle, /**< SYNC0 cycle time [ns]. */
|
||||
uint32_t sync0_shift, /**< SYNC0 shift time [ns]. */
|
||||
uint32_t sync0_shift, /**< SYNC0 shift time [ns]. */
|
||||
uint32_t sync1_cycle, /**< SYNC1 cycle time [ns]. */
|
||||
uint32_t sync1_shift /**< SYNC1 shift time [ns]. */
|
||||
);
|
||||
uint32_t sync1_shift /**< SYNC1 shift time [ns]. */
|
||||
);
|
||||
|
||||
/** Add an SDO configuration.
|
||||
*
|
||||
|
|
|
|||
14
lib/master.c
14
lib/master.c
|
|
@ -165,7 +165,7 @@ int ecrt_master_get_slave(ec_master_t *master, uint16_t slave_position,
|
|||
int ecrt_master_get_sync_manager(ec_master_t *master, uint16_t slave_position,
|
||||
uint8_t sync_index, ec_sync_info_t *sync)
|
||||
{
|
||||
ec_ioctl_slave_sync_t data;
|
||||
ec_ioctl_slave_sync_t data;
|
||||
|
||||
if (sync_index >= EC_MAX_SYNC_MANAGERS)
|
||||
return -ENOENT;
|
||||
|
|
@ -181,7 +181,7 @@ int ecrt_master_get_sync_manager(ec_master_t *master, uint16_t slave_position,
|
|||
}
|
||||
|
||||
sync->index = sync_index;
|
||||
sync->dir = EC_READ_BIT(&data.control_register, 2) ?
|
||||
sync->dir = EC_READ_BIT(&data.control_register, 2) ?
|
||||
EC_DIR_OUTPUT : EC_DIR_INPUT;
|
||||
sync->n_pdos = data.pdo_count;
|
||||
sync->pdos = NULL;
|
||||
|
|
@ -196,7 +196,7 @@ int ecrt_master_get_sync_manager(ec_master_t *master, uint16_t slave_position,
|
|||
int ecrt_master_get_pdo(ec_master_t *master, uint16_t slave_position,
|
||||
uint8_t sync_index, uint16_t pos, ec_pdo_info_t *pdo)
|
||||
{
|
||||
ec_ioctl_slave_sync_pdo_t data;
|
||||
ec_ioctl_slave_sync_pdo_t data;
|
||||
|
||||
if (sync_index >= EC_MAX_SYNC_MANAGERS)
|
||||
return -ENOENT;
|
||||
|
|
@ -225,7 +225,7 @@ int ecrt_master_get_pdo_entry(ec_master_t *master, uint16_t slave_position,
|
|||
uint8_t sync_index, uint16_t pdo_pos, uint16_t entry_pos,
|
||||
ec_pdo_entry_info_t *entry)
|
||||
{
|
||||
ec_ioctl_slave_sync_pdo_entry_t data;
|
||||
ec_ioctl_slave_sync_pdo_entry_t data;
|
||||
|
||||
if (sync_index >= EC_MAX_SYNC_MANAGERS)
|
||||
return -ENOENT;
|
||||
|
|
@ -349,9 +349,9 @@ void ecrt_master_deactivate(ec_master_t *master)
|
|||
|
||||
int ecrt_master_set_send_interval(ec_master_t *master,size_t send_interval_us)
|
||||
{
|
||||
if (ioctl(master->fd, EC_IOCTL_SET_SEND_INTERVAL,
|
||||
&send_interval_us) == -1) {
|
||||
fprintf(stderr, "Failed to set send interval: %s\n",
|
||||
if (ioctl(master->fd, EC_IOCTL_SET_SEND_INTERVAL,
|
||||
&send_interval_us) == -1) {
|
||||
fprintf(stderr, "Failed to set send interval: %s\n",
|
||||
strerror(errno));
|
||||
return -1; // FIXME
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1684,15 +1684,16 @@ int ec_cdev_ioctl_set_send_interval(
|
|||
ec_cdev_priv_t *priv /**< Private data structure of file handle. */
|
||||
)
|
||||
{
|
||||
size_t send_interval;
|
||||
size_t send_interval;
|
||||
|
||||
if (copy_from_user(&send_interval, (void __user *) arg, sizeof(send_interval))) {
|
||||
if (copy_from_user(&send_interval, (void __user *) arg,
|
||||
sizeof(send_interval))) {
|
||||
return -EFAULT;
|
||||
}
|
||||
|
||||
if (down_interruptible(&master->master_sem))
|
||||
return -EINTR;
|
||||
ec_master_set_send_interval(master,send_interval);
|
||||
ec_master_set_send_interval(master,send_interval);
|
||||
up(&master->master_sem);
|
||||
|
||||
return 0;
|
||||
|
|
@ -3492,10 +3493,10 @@ long eccdev_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
|
|||
return ec_cdev_ioctl_voe_exec(master, arg, priv);
|
||||
case EC_IOCTL_VOE_DATA:
|
||||
return ec_cdev_ioctl_voe_data(master, arg, priv);
|
||||
case EC_IOCTL_SET_SEND_INTERVAL:
|
||||
case EC_IOCTL_SET_SEND_INTERVAL:
|
||||
if (!(filp->f_mode & FMODE_WRITE))
|
||||
return -EPERM;
|
||||
return ec_cdev_ioctl_set_send_interval(master,arg,priv);
|
||||
return ec_cdev_ioctl_set_send_interval(master,arg,priv);
|
||||
default:
|
||||
return -ENOTTY;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -471,14 +471,14 @@ void ec_fsm_master_action_idle(
|
|||
if (ec_fsm_master_action_process_sdo(fsm))
|
||||
return;
|
||||
|
||||
// enable processing of SDO/FOE requests
|
||||
for (slave = master->slaves;
|
||||
slave < master->slaves + master->slave_count;
|
||||
slave++) {
|
||||
ec_fsm_slave_ready(&slave->fsm);
|
||||
}
|
||||
// enable processing of SDO/FOE requests
|
||||
for (slave = master->slaves;
|
||||
slave < master->slaves + master->slave_count;
|
||||
slave++) {
|
||||
ec_fsm_slave_ready(&slave->fsm);
|
||||
}
|
||||
|
||||
// check, if slaves have an SDO dictionary to read out.
|
||||
// check, if slaves have an SDO dictionary to read out.
|
||||
for (slave = master->slaves;
|
||||
slave < master->slaves + master->slave_count;
|
||||
slave++) {
|
||||
|
|
|
|||
|
|
@ -62,9 +62,11 @@ void ec_fsm_slave_init(
|
|||
fsm->slave = slave;
|
||||
fsm->datagram = datagram;
|
||||
fsm->datagram->data_size = 0;
|
||||
if (slave->master->debug_level)
|
||||
EC_DBG("init fsm for slave %u...\n",slave->ring_position);
|
||||
fsm->state = ec_fsm_slave_state_idle;
|
||||
|
||||
if (slave->master->debug_level)
|
||||
EC_DBG("Init FSM for slave %u...\n", slave->ring_position);
|
||||
|
||||
fsm->state = ec_fsm_slave_state_idle;
|
||||
|
||||
// init sub-state-machines
|
||||
ec_fsm_coe_init(&fsm->fsm_coe, fsm->datagram);
|
||||
|
|
@ -112,16 +114,17 @@ void ec_fsm_slave_exec(
|
|||
*
|
||||
*/
|
||||
void ec_fsm_slave_ready(
|
||||
ec_fsm_slave_t *fsm /**< Slave state machine. */
|
||||
)
|
||||
ec_fsm_slave_t *fsm /**< Slave state machine. */
|
||||
)
|
||||
{
|
||||
if (fsm->state == ec_fsm_slave_state_idle) {
|
||||
if (fsm->slave->master->debug_level) {
|
||||
EC_DBG("Slave %u ready for SDO/FOE.\n",fsm->slave->ring_position);
|
||||
}
|
||||
fsm->state = ec_fsm_slave_state_ready;
|
||||
}
|
||||
return;
|
||||
if (fsm->state == ec_fsm_slave_state_idle) {
|
||||
if (fsm->slave->master->debug_level) {
|
||||
EC_DBG("Slave %u ready for SDO/FOE.\n",
|
||||
fsm->slave->ring_position);
|
||||
}
|
||||
fsm->state = ec_fsm_slave_state_ready;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
|
|
@ -135,10 +138,10 @@ void ec_fsm_slave_ready(
|
|||
*
|
||||
*/
|
||||
void ec_fsm_slave_state_idle(
|
||||
ec_fsm_slave_t *fsm /**< Slave state machine. */
|
||||
ec_fsm_slave_t *fsm /**< Slave state machine. */
|
||||
)
|
||||
{
|
||||
// do nothing
|
||||
// do nothing
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -149,19 +152,18 @@ void ec_fsm_slave_state_idle(
|
|||
*
|
||||
*/
|
||||
void ec_fsm_slave_state_ready(
|
||||
ec_fsm_slave_t *fsm /**< Slave state machine. */
|
||||
)
|
||||
ec_fsm_slave_t *fsm /**< Slave state machine. */
|
||||
)
|
||||
{
|
||||
// Check for pending external SDO requests
|
||||
if (ec_fsm_slave_action_process_sdo(fsm))
|
||||
return;
|
||||
// Check for pending FOE requests
|
||||
if (ec_fsm_slave_action_process_foe(fsm))
|
||||
return;
|
||||
// Check for pending external SDO requests
|
||||
if (ec_fsm_slave_action_process_sdo(fsm))
|
||||
return;
|
||||
|
||||
// Check for pending FOE requests
|
||||
if (ec_fsm_slave_action_process_foe(fsm))
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
/** Check for pending SDO requests and process one.
|
||||
|
|
@ -180,25 +182,27 @@ int ec_fsm_slave_action_process_sdo(
|
|||
list_for_each_entry_safe(request, next, &slave->slave_sdo_requests, list) {
|
||||
|
||||
list_del_init(&request->list); // dequeue
|
||||
if (slave->current_state & EC_SLAVE_STATE_ACK_ERR) {
|
||||
EC_WARN("Aborting SDO request, slave %u has ERROR.\n",
|
||||
slave->ring_position);
|
||||
request->req.state = EC_INT_REQUEST_FAILURE;
|
||||
wake_up(&slave->sdo_queue);
|
||||
fsm->sdo_request = NULL;
|
||||
fsm->state = ec_fsm_slave_state_idle;
|
||||
return 0;
|
||||
}
|
||||
if (slave->current_state == EC_SLAVE_STATE_INIT) {
|
||||
EC_WARN("Aborting SDO request, slave %u is in INIT.\n",
|
||||
slave->ring_position);
|
||||
request->req.state = EC_INT_REQUEST_FAILURE;
|
||||
wake_up(&slave->sdo_queue);
|
||||
fsm->sdo_request = NULL;
|
||||
fsm->state = ec_fsm_slave_state_idle;
|
||||
return 0;
|
||||
}
|
||||
request->req.state = EC_INT_REQUEST_BUSY;
|
||||
if (slave->current_state & EC_SLAVE_STATE_ACK_ERR) {
|
||||
EC_WARN("Aborting SDO request, slave %u has ERROR.\n",
|
||||
slave->ring_position);
|
||||
request->req.state = EC_INT_REQUEST_FAILURE;
|
||||
wake_up(&slave->sdo_queue);
|
||||
fsm->sdo_request = NULL;
|
||||
fsm->state = ec_fsm_slave_state_idle;
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (slave->current_state == EC_SLAVE_STATE_INIT) {
|
||||
EC_WARN("Aborting SDO request, slave %u is in INIT.\n",
|
||||
slave->ring_position);
|
||||
request->req.state = EC_INT_REQUEST_FAILURE;
|
||||
wake_up(&slave->sdo_queue);
|
||||
fsm->sdo_request = NULL;
|
||||
fsm->state = ec_fsm_slave_state_idle;
|
||||
return 0;
|
||||
}
|
||||
|
||||
request->req.state = EC_INT_REQUEST_BUSY;
|
||||
|
||||
// Found pending SDO request. Execute it!
|
||||
if (master->debug_level)
|
||||
|
|
@ -233,20 +237,20 @@ int ec_fsm_slave_action_process_foe(
|
|||
|
||||
// search the first request to be processed
|
||||
list_for_each_entry_safe(request, next, &slave->foe_requests, list) {
|
||||
if (slave->current_state & EC_SLAVE_STATE_ACK_ERR) {
|
||||
EC_WARN("Aborting FOE request, slave %u has ERROR.\n",
|
||||
slave->ring_position);
|
||||
request->req.state = EC_INT_REQUEST_FAILURE;
|
||||
wake_up(&slave->sdo_queue);
|
||||
fsm->sdo_request = NULL;
|
||||
fsm->state = ec_fsm_slave_state_idle;
|
||||
return 0;
|
||||
}
|
||||
list_del_init(&request->list); // dequeue
|
||||
if (slave->current_state & EC_SLAVE_STATE_ACK_ERR) {
|
||||
EC_WARN("Aborting FOE request, slave %u has ERROR.\n",
|
||||
slave->ring_position);
|
||||
request->req.state = EC_INT_REQUEST_FAILURE;
|
||||
wake_up(&slave->sdo_queue);
|
||||
fsm->sdo_request = NULL;
|
||||
fsm->state = ec_fsm_slave_state_idle;
|
||||
return 0;
|
||||
}
|
||||
list_del_init(&request->list); // dequeue
|
||||
request->req.state = EC_INT_REQUEST_BUSY;
|
||||
|
||||
if (master->debug_level)
|
||||
EC_DBG("Processing FOE request for slave %u.\n",
|
||||
EC_DBG("Processing FOE request for slave %u.\n",
|
||||
slave->ring_position);
|
||||
|
||||
fsm->foe_request = &request->req;
|
||||
|
|
@ -282,9 +286,9 @@ void ec_fsm_slave_state_sdo_request(
|
|||
EC_DBG("Failed to process SDO request for slave %u.\n",
|
||||
fsm->slave->ring_position);
|
||||
request->state = EC_INT_REQUEST_FAILURE;
|
||||
wake_up(&slave->sdo_queue);
|
||||
fsm->sdo_request = NULL;
|
||||
fsm->state = ec_fsm_slave_state_idle;
|
||||
wake_up(&slave->sdo_queue);
|
||||
fsm->sdo_request = NULL;
|
||||
fsm->state = ec_fsm_slave_state_idle;
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -297,10 +301,9 @@ void ec_fsm_slave_state_sdo_request(
|
|||
wake_up(&slave->sdo_queue);
|
||||
|
||||
fsm->sdo_request = NULL;
|
||||
fsm->state = ec_fsm_slave_state_ready;
|
||||
fsm->state = ec_fsm_slave_state_ready;
|
||||
}
|
||||
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
/** Slave state: FOE REQUEST.
|
||||
|
|
@ -338,6 +341,7 @@ void ec_fsm_slave_state_foe_request(
|
|||
wake_up(&slave->foe_queue);
|
||||
|
||||
fsm->foe_request = NULL;
|
||||
fsm->state = ec_fsm_slave_state_ready;
|
||||
fsm->state = ec_fsm_slave_state_ready;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
|
|
|||
|
|
@ -753,7 +753,7 @@ void ec_fsm_slave_scan_enter_regalias(
|
|||
*/
|
||||
void ec_fsm_slave_scan_state_regalias(
|
||||
ec_fsm_slave_scan_t *fsm /**< slave state machine */
|
||||
)
|
||||
)
|
||||
{
|
||||
ec_datagram_t *datagram = fsm->datagram;
|
||||
ec_slave_t *slave = fsm->slave;
|
||||
|
|
|
|||
|
|
@ -795,35 +795,35 @@ void ec_master_queue_external_datagram(
|
|||
ec_datagram_t *datagram /**< datagram */
|
||||
)
|
||||
{
|
||||
ec_datagram_t *queued_datagram;
|
||||
ec_datagram_t *queued_datagram;
|
||||
|
||||
down(&master->io_sem);
|
||||
|
||||
// check, if the datagram is already queued
|
||||
list_for_each_entry(queued_datagram, &master->external_datagram_queue,
|
||||
// check, if the datagram is already queued
|
||||
list_for_each_entry(queued_datagram, &master->external_datagram_queue,
|
||||
queue) {
|
||||
if (queued_datagram == datagram) {
|
||||
datagram->state = EC_DATAGRAM_QUEUED;
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (queued_datagram == datagram) {
|
||||
datagram->state = EC_DATAGRAM_QUEUED;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
#if DEBUG_INJECT
|
||||
if (master->debug_level) {
|
||||
EC_DBG("Requesting external datagram %p size=%u\n",
|
||||
if (master->debug_level) {
|
||||
EC_DBG("Requesting external datagram %p size=%u\n",
|
||||
datagram, datagram->data_size);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
list_add_tail(&datagram->queue, &master->external_datagram_queue);
|
||||
datagram->state = EC_DATAGRAM_QUEUED;
|
||||
list_add_tail(&datagram->queue, &master->external_datagram_queue);
|
||||
datagram->state = EC_DATAGRAM_QUEUED;
|
||||
#ifdef EC_HAVE_CYCLES
|
||||
datagram->cycles_sent = get_cycles();
|
||||
datagram->cycles_sent = get_cycles();
|
||||
#endif
|
||||
datagram->jiffies_sent = jiffies;
|
||||
datagram->jiffies_sent = jiffies;
|
||||
|
||||
master->fsm.idle = 0;
|
||||
up(&master->io_sem);
|
||||
master->fsm.idle = 0;
|
||||
up(&master->io_sem);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
|
@ -876,7 +876,7 @@ void ec_master_queue_datagram_ext(
|
|||
void ec_master_send_datagrams(ec_master_t *master /**< EtherCAT master */)
|
||||
{
|
||||
ec_datagram_t *datagram, *next;
|
||||
size_t datagram_size;
|
||||
size_t datagram_size;
|
||||
uint8_t *frame_data, *cur_data;
|
||||
void *follows_word;
|
||||
#ifdef EC_HAVE_CYCLES
|
||||
|
|
@ -1222,13 +1222,13 @@ static int ec_master_idle_thread(void *priv_data)
|
|||
ec_master_t *master = (ec_master_t *) priv_data;
|
||||
ec_slave_t *slave = NULL;
|
||||
int fsm_exec;
|
||||
size_t sent_bytes;
|
||||
size_t sent_bytes;
|
||||
|
||||
// send interval in IDLE phase
|
||||
ec_master_set_send_interval(master, 1000000 / HZ);
|
||||
ec_master_set_send_interval(master, 1000000 / HZ);
|
||||
|
||||
if (master->debug_level)
|
||||
EC_DBG("Idle thread running with send interval = %d us,"
|
||||
if (master->debug_level)
|
||||
EC_DBG("Idle thread running with send interval = %d us,"
|
||||
" max data size=%d\n", master->send_interval,
|
||||
master->max_queue_size);
|
||||
|
||||
|
|
@ -1259,20 +1259,20 @@ static int ec_master_idle_thread(void *priv_data)
|
|||
}
|
||||
ec_master_inject_external_datagrams(master);
|
||||
ecrt_master_send(master);
|
||||
sent_bytes = master->main_device.tx_skb[
|
||||
sent_bytes = master->main_device.tx_skb[
|
||||
master->main_device.tx_ring_index]->len;
|
||||
up(&master->io_sem);
|
||||
|
||||
if (ec_fsm_master_idle(&master->fsm)) {
|
||||
if (ec_fsm_master_idle(&master->fsm)) {
|
||||
#ifdef EC_USE_HRTIMER
|
||||
ec_master_nanosleep(master->send_interval * 1000);
|
||||
ec_master_nanosleep(master->send_interval * 1000);
|
||||
#else
|
||||
set_current_state(TASK_INTERRUPTIBLE);
|
||||
schedule_timeout(1);
|
||||
#endif
|
||||
} else {
|
||||
#ifdef EC_USE_HRTIMER
|
||||
ec_master_nanosleep(sent_bytes * EC_BYTE_TRANSMISSION_TIME_NS);
|
||||
ec_master_nanosleep(sent_bytes * EC_BYTE_TRANSMISSION_TIME_NS);
|
||||
#else
|
||||
schedule();
|
||||
#endif
|
||||
|
|
@ -1296,7 +1296,7 @@ static int ec_master_operation_thread(void *priv_data)
|
|||
int fsm_exec;
|
||||
|
||||
if (master->debug_level)
|
||||
EC_DBG("Operation thread running with fsm interval = %d us,"
|
||||
EC_DBG("Operation thread running with fsm interval = %d us,"
|
||||
" max data size=%d\n",
|
||||
master->send_interval,
|
||||
master->max_queue_size);
|
||||
|
|
@ -1326,8 +1326,8 @@ static int ec_master_operation_thread(void *priv_data)
|
|||
}
|
||||
|
||||
#ifdef EC_USE_HRTIMER
|
||||
// the op thread should not work faster than the sending RT thread
|
||||
ec_master_nanosleep(master->send_interval * 1000);
|
||||
// the op thread should not work faster than the sending RT thread
|
||||
ec_master_nanosleep(master->send_interval * 1000);
|
||||
#else
|
||||
if (ec_fsm_master_idle(&master->fsm)) {
|
||||
set_current_state(TASK_INTERRUPTIBLE);
|
||||
|
|
@ -1337,7 +1337,7 @@ static int ec_master_operation_thread(void *priv_data)
|
|||
schedule();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
if (master->debug_level)
|
||||
EC_DBG("Master OP thread exiting...\n");
|
||||
|
|
@ -2072,7 +2072,7 @@ void ecrt_master_send(ec_master_t *master)
|
|||
}
|
||||
|
||||
// send frames
|
||||
ec_master_send_datagrams(master);
|
||||
ec_master_send_datagrams(master);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
|
|
|||
|
|
@ -155,7 +155,7 @@ struct ec_master {
|
|||
ext_datagram_queue. */
|
||||
|
||||
struct list_head external_datagram_queue; /**< External Datagram queue. */
|
||||
size_t send_interval; /* interval between calls to ecrt_master_send */
|
||||
size_t send_interval; /* interval between calls to ecrt_master_send */
|
||||
size_t max_queue_size; /** max. size of datagram queue */
|
||||
struct list_head domains; /**< List of domains. */
|
||||
|
||||
|
|
|
|||
|
|
@ -27,6 +27,8 @@
|
|||
# technology and brand is only permitted in compliance with the industrial
|
||||
# property and similar rights of Beckhoff Automation GmbH.
|
||||
#
|
||||
# vim: expandtab
|
||||
#
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
# this ifup.d script adds special network interfaces to a network bridge
|
||||
|
|
@ -47,8 +49,8 @@ fi
|
|||
|
||||
# does the EoE bridge already exist?
|
||||
if ! ${BRCTL} show | grep -q "^${BRNAME}"; then
|
||||
${LOGGER} Creating ${BRNAME}
|
||||
${BRCTL} addbr ${BRNAME} # create it
|
||||
${LOGGER} Creating ${BRNAME}
|
||||
${BRCTL} addbr ${BRNAME} # create it
|
||||
fi
|
||||
|
||||
${LOGGER} Adding ${IFNAME} to ${BRNAME}
|
||||
|
|
|
|||
|
|
@ -29,6 +29,8 @@
|
|||
# technology and brand is only permitted in compliance with the industrial
|
||||
# property and similar rights of Beckhoff Automation GmbH.
|
||||
#
|
||||
# vim: expandtab
|
||||
#
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
### BEGIN INIT INFO
|
||||
|
|
@ -58,9 +60,9 @@ ETHERCAT_CONFIG=/etc/sysconfig/ethercat
|
|||
if [ ! -r ${ETHERCAT_CONFIG} ]; then
|
||||
echo ${ETHERCAT_CONFIG} not existing;
|
||||
if [ "${1}" = "stop" ]; then
|
||||
exit 0
|
||||
exit 0
|
||||
else
|
||||
exit 6
|
||||
exit 6
|
||||
fi
|
||||
fi
|
||||
|
||||
|
|
|
|||
|
|
@ -48,49 +48,49 @@ Command::~Command()
|
|||
|
||||
void Command::setVerbosity(Verbosity v)
|
||||
{
|
||||
verbosity = v;
|
||||
verbosity = v;
|
||||
};
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
void Command::setAlias(int a)
|
||||
{
|
||||
alias = a;
|
||||
alias = a;
|
||||
};
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
void Command::setPosition(int p)
|
||||
{
|
||||
position = p;
|
||||
position = p;
|
||||
};
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
void Command::setDomain(int d)
|
||||
{
|
||||
domain = d;
|
||||
domain = d;
|
||||
};
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
void Command::setDataType(const string &t)
|
||||
{
|
||||
dataType = t;
|
||||
dataType = t;
|
||||
};
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
void Command::setForce(bool f)
|
||||
{
|
||||
force = f;
|
||||
force = f;
|
||||
};
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
void Command::setOutputFile(const string &f)
|
||||
{
|
||||
outputFile = f;
|
||||
outputFile = f;
|
||||
};
|
||||
|
||||
/****************************************************************************/
|
||||
|
|
@ -279,25 +279,25 @@ Command::ConfigList Command::selectedConfigs(MasterDevice &m)
|
|||
|
||||
Command::DomainList Command::selectedDomains(MasterDevice &m)
|
||||
{
|
||||
ec_ioctl_domain_t d;
|
||||
DomainList list;
|
||||
ec_ioctl_domain_t d;
|
||||
DomainList list;
|
||||
|
||||
if (domain == -1) {
|
||||
ec_ioctl_master_t master;
|
||||
ec_ioctl_master_t master;
|
||||
unsigned int i;
|
||||
|
||||
m.getMaster(&master);
|
||||
|
||||
for (i = 0; i < master.domain_count; i++) {
|
||||
m.getDomain(&d, i);
|
||||
list.push_back(d);
|
||||
m.getDomain(&d, i);
|
||||
list.push_back(d);
|
||||
}
|
||||
} else {
|
||||
m.getDomain(&d, domain);
|
||||
list.push_back(d);
|
||||
m.getDomain(&d, domain);
|
||||
list.push_back(d);
|
||||
}
|
||||
|
||||
return list;
|
||||
return list;
|
||||
}
|
||||
|
||||
/****************************************************************************/
|
||||
|
|
|
|||
|
|
@ -71,7 +71,7 @@ class Command
|
|||
{
|
||||
public:
|
||||
Command(const string &, const string &);
|
||||
virtual ~Command();
|
||||
virtual ~Command();
|
||||
|
||||
const string &getName() const;
|
||||
const string &getBriefDescription() const;
|
||||
|
|
@ -82,7 +82,7 @@ class Command
|
|||
Verbose
|
||||
};
|
||||
void setVerbosity(Verbosity);
|
||||
Verbosity getVerbosity() const;
|
||||
Verbosity getVerbosity() const;
|
||||
void setAlias(int);
|
||||
int getAlias() const;
|
||||
void setPosition(int);
|
||||
|
|
@ -91,10 +91,10 @@ class Command
|
|||
int getDomain() const;
|
||||
void setDataType(const string &);
|
||||
const string &getDataType() const;
|
||||
void setForce(bool);
|
||||
bool getForce() const;
|
||||
void setOutputFile(const string &);
|
||||
const string &getOutputFile() const;
|
||||
void setForce(bool);
|
||||
bool getForce() const;
|
||||
void setOutputFile(const string &);
|
||||
const string &getOutputFile() const;
|
||||
|
||||
bool matchesSubstr(const string &) const;
|
||||
bool matchesAbbrev(const string &) const;
|
||||
|
|
@ -107,7 +107,7 @@ class Command
|
|||
static string numericInfo();
|
||||
|
||||
protected:
|
||||
enum {BreakAfterBytes = 16};
|
||||
enum {BreakAfterBytes = 16};
|
||||
|
||||
void throwInvalidUsageException(const stringstream &) const;
|
||||
void throwCommandException(const stringstream &) const;
|
||||
|
|
@ -123,15 +123,15 @@ class Command
|
|||
static string alStateString(uint8_t);
|
||||
|
||||
private:
|
||||
string name;
|
||||
string name;
|
||||
string briefDesc;
|
||||
Verbosity verbosity;
|
||||
int alias;
|
||||
int position;
|
||||
int domain;
|
||||
string dataType;
|
||||
bool force;
|
||||
string outputFile;
|
||||
int domain;
|
||||
string dataType;
|
||||
bool force;
|
||||
string outputFile;
|
||||
|
||||
Command();
|
||||
};
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@ string CommandCStruct::helpString() const
|
|||
<< endl
|
||||
<< "The output C code can be used directly with the" << endl
|
||||
<< "ecrt_slave_config_pdos() function of the application" << endl
|
||||
<< "interface." << endl
|
||||
<< "interface." << endl
|
||||
<< endl
|
||||
<< "Command-specific options:" << endl
|
||||
<< " --alias -a <alias>" << endl
|
||||
|
|
|
|||
|
|
@ -49,28 +49,28 @@ string CommandConfig::helpString() const
|
|||
stringstream str;
|
||||
|
||||
str << getName() << " [OPTIONS]" << endl
|
||||
<< endl
|
||||
<< getBriefDescription() << endl
|
||||
<< endl
|
||||
<< "Without the --verbose option, slave configurations are" << endl
|
||||
<< "output one-per-line. Example:" << endl
|
||||
<< endl
|
||||
<< "1001:0 0x0000003b/0x02010000 3 OP" << endl
|
||||
<< "| | | |" << endl
|
||||
<< "| | | \\- Application-layer" << endl
|
||||
<< "| | | state of the attached" << endl
|
||||
<< "| | | slave, or '-', if no" << endl
|
||||
<< "| | | slave is attached." << endl
|
||||
<< "| | \\- Absolute decimal ring" << endl
|
||||
<< "| | position of the attached" << endl
|
||||
<< "| | slave, or '-' if none" << endl
|
||||
<< "| | attached." << endl
|
||||
<< "| \\- Expected vendor ID and product code (both" << endl
|
||||
<< "| hexadecimal)." << endl
|
||||
<< "\\- Alias address and relative position (both decimal)." << endl
|
||||
<< endl
|
||||
<< "With the --verbose option given, the configured PDOs and" << endl
|
||||
<< "SDOs are output in addition." << endl
|
||||
<< endl
|
||||
<< getBriefDescription() << endl
|
||||
<< endl
|
||||
<< "Without the --verbose option, slave configurations are" << endl
|
||||
<< "output one-per-line. Example:" << endl
|
||||
<< endl
|
||||
<< "1001:0 0x0000003b/0x02010000 3 OP" << endl
|
||||
<< "| | | |" << endl
|
||||
<< "| | | \\- Application-layer" << endl
|
||||
<< "| | | state of the attached" << endl
|
||||
<< "| | | slave, or '-', if no" << endl
|
||||
<< "| | | slave is attached." << endl
|
||||
<< "| | \\- Absolute decimal ring" << endl
|
||||
<< "| | position of the attached" << endl
|
||||
<< "| | slave, or '-' if none" << endl
|
||||
<< "| | attached." << endl
|
||||
<< "| \\- Expected vendor ID and product code (both" << endl
|
||||
<< "| hexadecimal)." << endl
|
||||
<< "\\- Alias address and relative position (both decimal)." << endl
|
||||
<< endl
|
||||
<< "With the --verbose option given, the configured PDOs and" << endl
|
||||
<< "SDOs are output in addition." << endl
|
||||
<< endl
|
||||
<< "Configuration selection:" << endl
|
||||
<< " Slave configurations can be selected with" << endl
|
||||
|
|
@ -86,15 +86,15 @@ string CommandConfig::helpString() const
|
|||
<< " 4) If both the --alias and the --position option are" << endl
|
||||
<< " given, the selection can match a single" << endl
|
||||
<< " configuration, that is displayed, if it exists." << endl
|
||||
<< endl
|
||||
<< "Command-specific options:" << endl
|
||||
<< endl
|
||||
<< "Command-specific options:" << endl
|
||||
<< " --alias -a <alias> Configuration alias (see above)." << endl
|
||||
<< " --position -p <pos> Relative position (see above)." << endl
|
||||
<< " --verbose -v Show detailed configurations." << endl
|
||||
<< " --verbose -v Show detailed configurations." << endl
|
||||
<< endl
|
||||
<< numericInfo();
|
||||
|
||||
return str.str();
|
||||
return str.str();
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
|
@ -126,9 +126,9 @@ void CommandConfig::execute(MasterDevice &m, const StringVector &args)
|
|||
/** Lists the complete bus configuration.
|
||||
*/
|
||||
void CommandConfig::showDetailedConfigs(
|
||||
MasterDevice &m,
|
||||
const ConfigList &configList
|
||||
)
|
||||
MasterDevice &m,
|
||||
const ConfigList &configList
|
||||
)
|
||||
{
|
||||
ConfigList::const_iterator configIter;
|
||||
unsigned int i, j, k, l;
|
||||
|
|
|
|||
|
|
@ -46,17 +46,17 @@ class CommandConfig:
|
|||
string helpString() const;
|
||||
void execute(MasterDevice &, const StringVector &);
|
||||
|
||||
protected:
|
||||
struct Info {
|
||||
string alias;
|
||||
string pos;
|
||||
string ident;
|
||||
string slavePos;
|
||||
string state;
|
||||
};
|
||||
protected:
|
||||
struct Info {
|
||||
string alias;
|
||||
string pos;
|
||||
string ident;
|
||||
string slavePos;
|
||||
string state;
|
||||
};
|
||||
|
||||
void showDetailedConfigs(MasterDevice &, const ConfigList &);
|
||||
void listConfigs(MasterDevice &m, const ConfigList &);
|
||||
void showDetailedConfigs(MasterDevice &, const ConfigList &);
|
||||
void listConfigs(MasterDevice &m, const ConfigList &);
|
||||
};
|
||||
|
||||
/****************************************************************************/
|
||||
|
|
|
|||
|
|
@ -46,27 +46,27 @@ string CommandData::helpString() const
|
|||
stringstream str;
|
||||
|
||||
str << getName() << " [OPTIONS]" << endl
|
||||
<< endl
|
||||
<< getBriefDescription() << endl
|
||||
<< endl
|
||||
<< getBriefDescription() << endl
|
||||
<< endl
|
||||
<< "Data of multiple domains are concatenated." << endl
|
||||
<< endl
|
||||
<< "Command-specific options:" << endl
|
||||
<< " --domain -d <index> Positive numerical domain index." << endl
|
||||
<< " If omitted, data of all domains" << endl
|
||||
<< " are output." << endl
|
||||
<< endl
|
||||
<< numericInfo();
|
||||
<< endl
|
||||
<< "Command-specific options:" << endl
|
||||
<< " --domain -d <index> Positive numerical domain index." << endl
|
||||
<< " If omitted, data of all domains" << endl
|
||||
<< " are output." << endl
|
||||
<< endl
|
||||
<< numericInfo();
|
||||
|
||||
return str.str();
|
||||
return str.str();
|
||||
}
|
||||
|
||||
/****************************************************************************/
|
||||
|
||||
void CommandData::execute(MasterDevice &m, const StringVector &args)
|
||||
{
|
||||
DomainList domains;
|
||||
DomainList::const_iterator di;
|
||||
DomainList domains;
|
||||
DomainList::const_iterator di;
|
||||
|
||||
if (args.size()) {
|
||||
stringstream err;
|
||||
|
|
@ -75,19 +75,19 @@ void CommandData::execute(MasterDevice &m, const StringVector &args)
|
|||
}
|
||||
|
||||
m.open(MasterDevice::Read);
|
||||
domains = selectedDomains(m);
|
||||
domains = selectedDomains(m);
|
||||
|
||||
for (di = domains.begin(); di != domains.end(); di++) {
|
||||
outputDomainData(m, *di);
|
||||
}
|
||||
for (di = domains.begin(); di != domains.end(); di++) {
|
||||
outputDomainData(m, *di);
|
||||
}
|
||||
}
|
||||
|
||||
/****************************************************************************/
|
||||
|
||||
void CommandData::outputDomainData(
|
||||
MasterDevice &m,
|
||||
const ec_ioctl_domain_t &domain
|
||||
)
|
||||
MasterDevice &m,
|
||||
const ec_ioctl_domain_t &domain
|
||||
)
|
||||
{
|
||||
ec_ioctl_domain_data_t data;
|
||||
unsigned char *processData;
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ class CommandData:
|
|||
void execute(MasterDevice &, const StringVector &);
|
||||
|
||||
protected:
|
||||
void outputDomainData(MasterDevice &, const ec_ioctl_domain_t &);
|
||||
void outputDomainData(MasterDevice &, const ec_ioctl_domain_t &);
|
||||
};
|
||||
|
||||
/****************************************************************************/
|
||||
|
|
|
|||
|
|
@ -46,21 +46,21 @@ string CommandDebug::helpString() const
|
|||
{
|
||||
stringstream str;
|
||||
|
||||
str << getName() << " <LEVEL>" << endl
|
||||
<< endl
|
||||
<< getBriefDescription() << endl
|
||||
<< endl
|
||||
<< "Debug messages are printed to syslog." << endl
|
||||
<< endl
|
||||
<< "Arguments:" << endl
|
||||
<< " LEVEL can have one of the following values:" << endl
|
||||
<< " 0 for no debugging output," << endl
|
||||
<< " 1 for some debug messages, or" << endl
|
||||
<< " 2 for printing all frame contents (use with caution!)."
|
||||
<< endl << endl
|
||||
<< numericInfo();
|
||||
str << getName() << " <LEVEL>" << endl
|
||||
<< endl
|
||||
<< getBriefDescription() << endl
|
||||
<< endl
|
||||
<< "Debug messages are printed to syslog." << endl
|
||||
<< endl
|
||||
<< "Arguments:" << endl
|
||||
<< " LEVEL can have one of the following values:" << endl
|
||||
<< " 0 for no debugging output," << endl
|
||||
<< " 1 for some debug messages, or" << endl
|
||||
<< " 2 for printing all frame contents (use with caution!)."
|
||||
<< endl << endl
|
||||
<< numericInfo();
|
||||
|
||||
return str.str();
|
||||
return str.str();
|
||||
}
|
||||
|
||||
/****************************************************************************/
|
||||
|
|
|
|||
|
|
@ -46,53 +46,53 @@ string CommandDomains::helpString() const
|
|||
{
|
||||
stringstream str;
|
||||
|
||||
str << getName() << " [OPTIONS]" << endl
|
||||
<< endl
|
||||
<< getBriefDescription() << endl
|
||||
str << getName() << " [OPTIONS]" << endl
|
||||
<< endl
|
||||
<< "Without the --verbose option, the domains are displayed" << endl
|
||||
<< getBriefDescription() << endl
|
||||
<< endl
|
||||
<< "Without the --verbose option, the domains are displayed" << endl
|
||||
<< "one-per-line. Example:" << endl
|
||||
<< endl
|
||||
<< "Domain0: LogBaseAddr 0x00000000, Size 6, WorkingCounter 0/1"
|
||||
<< endl << endl
|
||||
<< "The domain's base address for the logical datagram" << endl
|
||||
<< "(LRD/LWR/LRW) is displayed followed by the domain's" << endl
|
||||
<< "process data size in byte. The last values are the current" << endl
|
||||
<< "datagram working counter sum and the expected working" << endl
|
||||
<< "counter sum. If the values are equal, all PDOs were" << endl
|
||||
<< endl
|
||||
<< "Domain0: LogBaseAddr 0x00000000, Size 6, WorkingCounter 0/1"
|
||||
<< endl << endl
|
||||
<< "The domain's base address for the logical datagram" << endl
|
||||
<< "(LRD/LWR/LRW) is displayed followed by the domain's" << endl
|
||||
<< "process data size in byte. The last values are the current" << endl
|
||||
<< "datagram working counter sum and the expected working" << endl
|
||||
<< "counter sum. If the values are equal, all PDOs were" << endl
|
||||
<< "exchanged during the last cycle." << endl
|
||||
<< endl
|
||||
<< "If the --verbose option is given, the participating slave" << endl
|
||||
<< "configurations/FMMUs and the current process data are" << endl
|
||||
<< "additionally displayed:" << endl
|
||||
<< endl
|
||||
<< "Domain1: LogBaseAddr 0x00000006, Size 6, WorkingCounter 0/1"
|
||||
<< endl
|
||||
<< " SlaveConfig 1001:0, SM3 ( Input), LogAddr 0x00000006, Size 6"
|
||||
<< endl
|
||||
<< " 0x00 0x00 0x00 0x00 0x00 0x00" << endl
|
||||
<< endl
|
||||
<< "The process data are displayed as hexadecimal bytes." << endl
|
||||
<< endl
|
||||
<< "Command-specific options:" << endl
|
||||
<< " --domain -d <index> Positive numerical domain index." << endl
|
||||
<< " If ommitted, all domains are" << endl
|
||||
<< "If the --verbose option is given, the participating slave" << endl
|
||||
<< "configurations/FMMUs and the current process data are" << endl
|
||||
<< "additionally displayed:" << endl
|
||||
<< endl
|
||||
<< "Domain1: LogBaseAddr 0x00000006, Size 6, WorkingCounter 0/1"
|
||||
<< endl
|
||||
<< " SlaveConfig 1001:0, SM3 ( Input), LogAddr 0x00000006, Size 6"
|
||||
<< endl
|
||||
<< " 0x00 0x00 0x00 0x00 0x00 0x00" << endl
|
||||
<< endl
|
||||
<< "The process data are displayed as hexadecimal bytes." << endl
|
||||
<< endl
|
||||
<< "Command-specific options:" << endl
|
||||
<< " --domain -d <index> Positive numerical domain index." << endl
|
||||
<< " If ommitted, all domains are" << endl
|
||||
<< " displayed." << endl
|
||||
<< endl
|
||||
<< " --verbose -v Show FMMUs and process data" << endl
|
||||
<< " in addition." << endl
|
||||
<< endl
|
||||
<< numericInfo();
|
||||
<< endl
|
||||
<< " --verbose -v Show FMMUs and process data" << endl
|
||||
<< " in addition." << endl
|
||||
<< endl
|
||||
<< numericInfo();
|
||||
|
||||
return str.str();
|
||||
return str.str();
|
||||
}
|
||||
|
||||
/****************************************************************************/
|
||||
|
||||
void CommandDomains::execute(MasterDevice &m, const StringVector &args)
|
||||
{
|
||||
DomainList domains;
|
||||
DomainList::const_iterator di;
|
||||
DomainList domains;
|
||||
DomainList::const_iterator di;
|
||||
|
||||
if (args.size()) {
|
||||
stringstream err;
|
||||
|
|
@ -101,19 +101,19 @@ void CommandDomains::execute(MasterDevice &m, const StringVector &args)
|
|||
}
|
||||
|
||||
m.open(MasterDevice::Read);
|
||||
domains = selectedDomains(m);
|
||||
domains = selectedDomains(m);
|
||||
|
||||
for (di = domains.begin(); di != domains.end(); di++) {
|
||||
showDomain(m, *di);
|
||||
}
|
||||
for (di = domains.begin(); di != domains.end(); di++) {
|
||||
showDomain(m, *di);
|
||||
}
|
||||
}
|
||||
|
||||
/****************************************************************************/
|
||||
|
||||
void CommandDomains::showDomain(
|
||||
MasterDevice &m,
|
||||
const ec_ioctl_domain_t &domain
|
||||
)
|
||||
MasterDevice &m,
|
||||
const ec_ioctl_domain_t &domain
|
||||
)
|
||||
{
|
||||
unsigned char *processData;
|
||||
ec_ioctl_domain_data_t data;
|
||||
|
|
@ -121,14 +121,14 @@ void CommandDomains::showDomain(
|
|||
ec_ioctl_domain_fmmu_t fmmu;
|
||||
unsigned int dataOffset;
|
||||
|
||||
cout << "Domain" << dec << domain.index << ":"
|
||||
<< " LogBaseAddr 0x"
|
||||
<< hex << setfill('0')
|
||||
cout << "Domain" << dec << domain.index << ":"
|
||||
<< " LogBaseAddr 0x"
|
||||
<< hex << setfill('0')
|
||||
<< setw(8) << domain.logical_base_address
|
||||
<< ", Size " << dec << setfill(' ')
|
||||
<< ", Size " << dec << setfill(' ')
|
||||
<< setw(3) << domain.data_size
|
||||
<< ", WorkingCounter "
|
||||
<< domain.working_counter << "/"
|
||||
<< ", WorkingCounter "
|
||||
<< domain.working_counter << "/"
|
||||
<< domain.expected_working_counter << endl;
|
||||
|
||||
if (!domain.data_size || getVerbosity() != Verbose)
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ class CommandDomains:
|
|||
void execute(MasterDevice &, const StringVector &);
|
||||
|
||||
protected:
|
||||
void showDomain(MasterDevice &, const ec_ioctl_domain_t &);
|
||||
void showDomain(MasterDevice &, const ec_ioctl_domain_t &);
|
||||
};
|
||||
|
||||
/****************************************************************************/
|
||||
|
|
|
|||
|
|
@ -47,38 +47,38 @@ string CommandDownload::helpString() const
|
|||
stringstream str;
|
||||
|
||||
str << getName() << " [OPTIONS] <INDEX> <SUBINDEX> <VALUE>" << endl
|
||||
<< endl
|
||||
<< getBriefDescription() << endl
|
||||
<< endl
|
||||
<< getBriefDescription() << endl
|
||||
<< endl
|
||||
<< "This command requires a single slave to be selected." << endl
|
||||
<< endl
|
||||
<< "The data type of the SDO entry is taken from the SDO" << endl
|
||||
<< "dictionary by default. It can be overridden with the" << endl
|
||||
<< "--type option. If the slave does not support the SDO" << endl
|
||||
<< "information service or the SDO is not in the dictionary," << endl
|
||||
<< "the --type option is mandatory." << endl
|
||||
<< endl
|
||||
<< "These are the valid SDO entry data types:" << endl
|
||||
<< " int8, int16, int32, uint8, uint16, uint32, string," << endl
|
||||
<< endl
|
||||
<< "The data type of the SDO entry is taken from the SDO" << endl
|
||||
<< "dictionary by default. It can be overridden with the" << endl
|
||||
<< "--type option. If the slave does not support the SDO" << endl
|
||||
<< "information service or the SDO is not in the dictionary," << endl
|
||||
<< "the --type option is mandatory." << endl
|
||||
<< endl
|
||||
<< "These are the valid SDO entry data types:" << endl
|
||||
<< " int8, int16, int32, uint8, uint16, uint32, string," << endl
|
||||
<< " octet_string." << endl
|
||||
<< endl
|
||||
<< "Arguments:" << endl
|
||||
<< " INDEX is the SDO index and must be an unsigned" << endl
|
||||
<< " 16 bit number." << endl
|
||||
<< " SUBINDEX is the SDO entry subindex and must be an" << endl
|
||||
<< " unsigned 8 bit number." << endl
|
||||
<< " VALUE is the value to download and must correspond" << endl
|
||||
<< " to the SDO entry datatype (see above)." << endl
|
||||
<< endl
|
||||
<< "Command-specific options:" << endl
|
||||
<< endl
|
||||
<< "Arguments:" << endl
|
||||
<< " INDEX is the SDO index and must be an unsigned" << endl
|
||||
<< " 16 bit number." << endl
|
||||
<< " SUBINDEX is the SDO entry subindex and must be an" << endl
|
||||
<< " unsigned 8 bit number." << endl
|
||||
<< " VALUE is the value to download and must correspond" << endl
|
||||
<< " to the SDO entry datatype (see above)." << endl
|
||||
<< endl
|
||||
<< "Command-specific options:" << endl
|
||||
<< " --alias -a <alias>" << endl
|
||||
<< " --position -p <pos> Slave selection. See the help of" << endl
|
||||
<< " the 'slaves' command." << endl
|
||||
<< " --type -t <type> SDO entry data type (see above)." << endl
|
||||
<< endl
|
||||
<< numericInfo();
|
||||
<< " --type -t <type> SDO entry data type (see above)." << endl
|
||||
<< endl
|
||||
<< numericInfo();
|
||||
|
||||
return str.str();
|
||||
return str.str();
|
||||
}
|
||||
|
||||
/****************************************************************************/
|
||||
|
|
@ -235,15 +235,15 @@ void CommandDownload::execute(MasterDevice &m, const StringVector &args)
|
|||
throwInvalidUsageException(err);
|
||||
}
|
||||
|
||||
try {
|
||||
try {
|
||||
m.sdoDownload(&data);
|
||||
} catch (MasterDeviceSdoAbortException &e) {
|
||||
} catch (MasterDeviceSdoAbortException &e) {
|
||||
delete [] data.data;
|
||||
err << "SDO transfer aborted with code 0x"
|
||||
<< setfill('0') << hex << setw(8) << e.abortCode
|
||||
<< ": " << abortText(e.abortCode);
|
||||
throwCommandException(err);
|
||||
} catch(MasterDeviceException &e) {
|
||||
} catch(MasterDeviceException &e) {
|
||||
delete [] data.data;
|
||||
throw e;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -43,8 +43,8 @@ class CommandDownload:
|
|||
string helpString() const;
|
||||
void execute(MasterDevice &, const StringVector &);
|
||||
|
||||
protected:
|
||||
enum {DefaultBufferSize = 1024};
|
||||
protected:
|
||||
enum {DefaultBufferSize = 1024};
|
||||
};
|
||||
|
||||
/****************************************************************************/
|
||||
|
|
|
|||
|
|
@ -50,25 +50,25 @@ string CommandFoeRead::helpString() const
|
|||
stringstream str;
|
||||
|
||||
str << getName() << " [OPTIONS] <SOURCEFILE>" << endl
|
||||
<< endl
|
||||
<< getBriefDescription() << endl
|
||||
<< endl
|
||||
<< endl
|
||||
<< getBriefDescription() << endl
|
||||
<< endl
|
||||
<< "This command requires a single slave to be selected." << endl
|
||||
<< endl
|
||||
<< endl
|
||||
<< "Arguments:" << endl
|
||||
<< " SOURCEFILE is the name of the source file on the slave." << endl
|
||||
<< endl
|
||||
<< "Command-specific options:" << endl
|
||||
<< "Command-specific options:" << endl
|
||||
<< " --output-file -o <file> Local target filename. If" << endl
|
||||
<< " '-' (default), data are" << endl
|
||||
<< " printed to stdout." << endl
|
||||
<< " --alias -a <alias> " << endl
|
||||
<< " --position -p <pos> Slave selection. See the help" << endl
|
||||
<< " of the 'slaves' command." << endl
|
||||
<< endl
|
||||
<< numericInfo();
|
||||
<< endl
|
||||
<< numericInfo();
|
||||
|
||||
return str.str();
|
||||
return str.str();
|
||||
}
|
||||
|
||||
/****************************************************************************/
|
||||
|
|
@ -104,9 +104,9 @@ void CommandFoeRead::execute(MasterDevice &m, const StringVector &args)
|
|||
|
||||
strncpy(data.file_name, args[0].c_str(), sizeof(data.file_name));
|
||||
|
||||
try {
|
||||
m.readFoe(&data);
|
||||
} catch (MasterDeviceException &e) {
|
||||
try {
|
||||
m.readFoe(&data);
|
||||
} catch (MasterDeviceException &e) {
|
||||
delete [] data.buffer;
|
||||
if (data.result) {
|
||||
if (data.result == FOE_OPCODE_ERROR) {
|
||||
|
|
@ -121,13 +121,13 @@ void CommandFoeRead::execute(MasterDevice &m, const StringVector &args)
|
|||
} else {
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// TODO --output-file
|
||||
for (i = 0; i < data.data_size; i++) {
|
||||
uint8_t *w = data.buffer + i;
|
||||
cout << *(uint8_t *) w ;
|
||||
}
|
||||
for (i = 0; i < data.data_size; i++) {
|
||||
uint8_t *w = data.buffer + i;
|
||||
cout << *(uint8_t *) w ;
|
||||
}
|
||||
|
||||
delete [] data.buffer;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -56,7 +56,7 @@ string CommandFoeWrite::helpString() const
|
|||
<< getBriefDescription() << endl
|
||||
<< endl
|
||||
<< "This command requires a single slave to be selected." << endl
|
||||
<< endl
|
||||
<< endl
|
||||
<< "Arguments:" << endl
|
||||
<< " FILENAME can either be a path to a file, or '-'. In" << endl
|
||||
<< " the latter case, data are read from stdin and" << endl
|
||||
|
|
|
|||
|
|
@ -119,7 +119,7 @@ void CommandGraph::execute(MasterDevice &m, const StringVector &args)
|
|||
cout << endl;
|
||||
|
||||
for (si = slaves.begin(); si != slaves.end(); si++) {
|
||||
cout << " slave" << si->position << " [shape=\"box\""
|
||||
cout << " slave" << si->position << " [shape=\"box\""
|
||||
<< ",label=\"" << si->position;
|
||||
if (string(si->order).size())
|
||||
cout << "\\n" << si->order;
|
||||
|
|
|
|||
|
|
@ -48,16 +48,16 @@ string CommandMaster::helpString() const
|
|||
{
|
||||
stringstream str;
|
||||
|
||||
str << getName() << " [OPTIONS]" << endl
|
||||
<< endl
|
||||
<< getBriefDescription() << endl
|
||||
<< endl
|
||||
<< "Command-specific options:" << endl
|
||||
<< " --master -m <index> Index of the master to use. Default: 0."
|
||||
<< endl << endl
|
||||
<< numericInfo();
|
||||
str << getName() << " [OPTIONS]" << endl
|
||||
<< endl
|
||||
<< getBriefDescription() << endl
|
||||
<< endl
|
||||
<< "Command-specific options:" << endl
|
||||
<< " --master -m <index> Index of the master to use. Default: 0."
|
||||
<< endl << endl
|
||||
<< numericInfo();
|
||||
|
||||
return str.str();
|
||||
return str.str();
|
||||
}
|
||||
|
||||
/****************************************************************************/
|
||||
|
|
|
|||
|
|
@ -47,43 +47,43 @@ string CommandPdos::helpString() const
|
|||
stringstream str;
|
||||
|
||||
str << getName() << " [OPTIONS]" << endl
|
||||
<< endl
|
||||
<< getBriefDescription() << endl
|
||||
<< endl
|
||||
<< "The information is displayed in three layers, which are" << endl
|
||||
<< "indented accordingly:" << endl
|
||||
<< endl
|
||||
<< "1) Sync managers - Contains the sync manager information" << endl
|
||||
<< " from the SII: Index, physical start address, default" << endl
|
||||
<< " size, control register and enable word. Example:" << endl
|
||||
<< endl
|
||||
<< " SM3: PhysAddr 0x1100, DefaultSize 0, ControlRegister 0x20, "
|
||||
<< "Enable 1" << endl
|
||||
<< endl
|
||||
<< "2) Assigned PDOs - PDO direction, hexadecimal index and" << endl
|
||||
<< " the PDO name, if avaliable. Note that a 'Tx' and 'Rx'" << endl
|
||||
<< getBriefDescription() << endl
|
||||
<< endl
|
||||
<< "The information is displayed in three layers, which are" << endl
|
||||
<< "indented accordingly:" << endl
|
||||
<< endl
|
||||
<< "1) Sync managers - Contains the sync manager information" << endl
|
||||
<< " from the SII: Index, physical start address, default" << endl
|
||||
<< " size, control register and enable word. Example:" << endl
|
||||
<< endl
|
||||
<< " SM3: PhysAddr 0x1100, DefaultSize 0, ControlRegister 0x20, "
|
||||
<< "Enable 1" << endl
|
||||
<< endl
|
||||
<< "2) Assigned PDOs - PDO direction, hexadecimal index and" << endl
|
||||
<< " the PDO name, if avaliable. Note that a 'Tx' and 'Rx'" << endl
|
||||
<< " are seen from the slave's point of view. Example:" << endl
|
||||
<< endl
|
||||
<< " TxPDO 0x1a00 \"Channel1\"" << endl
|
||||
<< endl
|
||||
<< "3) Mapped PDO entries - PDO entry index and subindex (both" << endl
|
||||
<< " hexadecimal), the length in bit and the description, if" << endl
|
||||
<< " available. Example:" << endl
|
||||
<< endl
|
||||
<< " PDO entry 0x3101:01, 8 bit, \"Status\"" << endl
|
||||
<< endl
|
||||
<< "Note, that the displayed PDO assignment and PDO mapping" << endl
|
||||
<< "information can either originate from the SII or from the" << endl
|
||||
<< "CoE communication area." << endl
|
||||
<< endl
|
||||
<< "Command-specific options:" << endl
|
||||
<< endl
|
||||
<< " TxPDO 0x1a00 \"Channel1\"" << endl
|
||||
<< endl
|
||||
<< "3) Mapped PDO entries - PDO entry index and subindex (both" << endl
|
||||
<< " hexadecimal), the length in bit and the description, if" << endl
|
||||
<< " available. Example:" << endl
|
||||
<< endl
|
||||
<< " PDO entry 0x3101:01, 8 bit, \"Status\"" << endl
|
||||
<< endl
|
||||
<< "Note, that the displayed PDO assignment and PDO mapping" << endl
|
||||
<< "information can either originate from the SII or from the" << endl
|
||||
<< "CoE communication area." << endl
|
||||
<< endl
|
||||
<< "Command-specific options:" << endl
|
||||
<< " --alias -a <alias>" << endl
|
||||
<< " --position -p <pos> Slave selection. See the help of" << endl
|
||||
<< " the 'slaves' command." << endl
|
||||
<< endl
|
||||
<< numericInfo();
|
||||
<< endl
|
||||
<< numericInfo();
|
||||
|
||||
return str.str();
|
||||
return str.str();
|
||||
}
|
||||
|
||||
/****************************************************************************/
|
||||
|
|
@ -112,10 +112,10 @@ void CommandPdos::execute(MasterDevice &m, const StringVector &args)
|
|||
/****************************************************************************/
|
||||
|
||||
void CommandPdos::listSlavePdos(
|
||||
MasterDevice &m,
|
||||
MasterDevice &m,
|
||||
const ec_ioctl_slave_t &slave,
|
||||
bool showHeader
|
||||
)
|
||||
bool showHeader
|
||||
)
|
||||
{
|
||||
ec_ioctl_slave_sync_t sync;
|
||||
ec_ioctl_slave_sync_pdo_t pdo;
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ class CommandPdos:
|
|||
void execute(MasterDevice &, const StringVector &);
|
||||
|
||||
protected:
|
||||
void listSlavePdos(MasterDevice &, const ec_ioctl_slave_t &, bool);
|
||||
void listSlavePdos(MasterDevice &, const ec_ioctl_slave_t &, bool);
|
||||
};
|
||||
|
||||
/****************************************************************************/
|
||||
|
|
|
|||
|
|
@ -47,11 +47,11 @@ string CommandRegRead::helpString() const
|
|||
stringstream str;
|
||||
|
||||
str << getName() << " [OPTIONS] <OFFSET> [LENGTH]" << endl
|
||||
<< endl
|
||||
<< getBriefDescription() << endl
|
||||
<< endl
|
||||
<< endl
|
||||
<< getBriefDescription() << endl
|
||||
<< endl
|
||||
<< "This command requires a single slave to be selected." << endl
|
||||
<< endl
|
||||
<< endl
|
||||
<< "Arguments:" << endl
|
||||
<< " OFFSET is the register address. Must" << endl
|
||||
<< " be an unsigned 16 bit number." << endl
|
||||
|
|
@ -65,15 +65,15 @@ string CommandRegRead::helpString() const
|
|||
<< " int8, int16, int32, int64, uint8, uint16, uint32," << endl
|
||||
<< " uint64, string, raw." << endl
|
||||
<< endl
|
||||
<< "Command-specific options:" << endl
|
||||
<< "Command-specific options:" << endl
|
||||
<< " --alias -a <alias>" << endl
|
||||
<< " --position -p <pos> Slave selection. See the help of" << endl
|
||||
<< " the 'slaves' command." << endl
|
||||
<< " --type -t <type> Data type (see above)." << endl
|
||||
<< endl
|
||||
<< numericInfo();
|
||||
<< endl
|
||||
<< numericInfo();
|
||||
|
||||
return str.str();
|
||||
return str.str();
|
||||
}
|
||||
|
||||
/****************************************************************************/
|
||||
|
|
@ -151,12 +151,12 @@ void CommandRegRead::execute(MasterDevice &m, const StringVector &args)
|
|||
|
||||
data.data = new uint8_t[data.length];
|
||||
|
||||
try {
|
||||
m.readReg(&data);
|
||||
} catch (MasterDeviceException &e) {
|
||||
try {
|
||||
m.readReg(&data);
|
||||
} catch (MasterDeviceException &e) {
|
||||
delete [] data.data;
|
||||
throw e;
|
||||
}
|
||||
throw e;
|
||||
}
|
||||
|
||||
cout << setfill('0');
|
||||
if (!dataType || string(dataType->name) == "string") {
|
||||
|
|
|
|||
|
|
@ -53,20 +53,20 @@ string CommandRegWrite::helpString() const
|
|||
<< getBriefDescription() << endl
|
||||
<< endl
|
||||
<< "This command requires a single slave to be selected." << endl
|
||||
<< endl
|
||||
<< endl
|
||||
<< "Arguments:" << endl
|
||||
<< " OFFSET is the register address to write to." << endl
|
||||
<< " DATA depends on whether a datatype was specified" << endl
|
||||
<< " with the --type option: If not, DATA must be" << endl
|
||||
<< " either a path to a file with data to write," << endl
|
||||
<< " or '-', which means, that data are read from" << endl
|
||||
<< " stdin. If a datatype was specified, VALUE is" << endl
|
||||
<< " interpreted respective to the given type." << endl
|
||||
<< " with the --type option: If not, DATA must be" << endl
|
||||
<< " either a path to a file with data to write," << endl
|
||||
<< " or '-', which means, that data are read from" << endl
|
||||
<< " stdin. If a datatype was specified, VALUE is" << endl
|
||||
<< " interpreted respective to the given type." << endl
|
||||
<< endl
|
||||
<< "These are the valid data types:" << endl
|
||||
<< " int8, int16, int32, int64, uint8, uint16, uint32," << endl
|
||||
<< " uint64, string." << endl
|
||||
<< endl
|
||||
<< endl
|
||||
<< "Command-specific options:" << endl
|
||||
<< " --alias -a <alias>" << endl
|
||||
<< " --position -p <pos> Slave selection. See the help of" << endl
|
||||
|
|
@ -101,93 +101,93 @@ void CommandRegWrite::execute(MasterDevice &m, const StringVector &args)
|
|||
throwInvalidUsageException(err);
|
||||
}
|
||||
|
||||
if (getDataType().empty()) {
|
||||
if (args[1] == "-") {
|
||||
loadRegData(&data, cin);
|
||||
} else {
|
||||
file.open(args[1].c_str(), ifstream::in | ifstream::binary);
|
||||
if (file.fail()) {
|
||||
err << "Failed to open '" << args[1] << "'!";
|
||||
throwCommandException(err);
|
||||
}
|
||||
loadRegData(&data, file);
|
||||
file.close();
|
||||
}
|
||||
} else {
|
||||
stringstream strValue;
|
||||
const DataType *dataType = findDataType(getDataType());
|
||||
if (getDataType().empty()) {
|
||||
if (args[1] == "-") {
|
||||
loadRegData(&data, cin);
|
||||
} else {
|
||||
file.open(args[1].c_str(), ifstream::in | ifstream::binary);
|
||||
if (file.fail()) {
|
||||
err << "Failed to open '" << args[1] << "'!";
|
||||
throwCommandException(err);
|
||||
}
|
||||
loadRegData(&data, file);
|
||||
file.close();
|
||||
}
|
||||
} else {
|
||||
stringstream strValue;
|
||||
const DataType *dataType = findDataType(getDataType());
|
||||
|
||||
if (!dataType) {
|
||||
err << "Invalid data type '" << getDataType() << "'!";
|
||||
throwInvalidUsageException(err);
|
||||
}
|
||||
|
||||
if (dataType->byteSize) {
|
||||
data.length = dataType->byteSize;
|
||||
data.data = new uint8_t[data.length];
|
||||
}
|
||||
if (dataType->byteSize) {
|
||||
data.length = dataType->byteSize;
|
||||
data.data = new uint8_t[data.length];
|
||||
}
|
||||
|
||||
strValue << args[1];
|
||||
strValue >> resetiosflags(ios::basefield); // guess base from prefix
|
||||
strValue.exceptions(ios::failbit);
|
||||
strValue << args[1];
|
||||
strValue >> resetiosflags(ios::basefield); // guess base from prefix
|
||||
strValue.exceptions(ios::failbit);
|
||||
|
||||
try {
|
||||
if (string(dataType->name) == "int8") {
|
||||
int16_t val; // uint8_t is interpreted as char
|
||||
strValue >> val;
|
||||
if (val > 127 || val < -128)
|
||||
throw ios::failure("Value out of range");
|
||||
*data.data = (int8_t) val;
|
||||
} else if (string(dataType->name) == "int16") {
|
||||
int16_t val;
|
||||
strValue >> val;
|
||||
*(int16_t *) data.data = cpu_to_le16(val);
|
||||
} else if (string(dataType->name) == "int32") {
|
||||
int32_t val;
|
||||
strValue >> val;
|
||||
*(int32_t *) data.data = cpu_to_le32(val);
|
||||
} else if (string(dataType->name) == "int64") {
|
||||
int64_t val;
|
||||
strValue >> val;
|
||||
*(int64_t *) data.data = cpu_to_le64(val);
|
||||
} else if (string(dataType->name) == "uint8") {
|
||||
uint16_t val; // uint8_t is interpreted as char
|
||||
strValue >> val;
|
||||
if (val > 0xff)
|
||||
throw ios::failure("Value out of range");
|
||||
*data.data = (uint8_t) val;
|
||||
} else if (string(dataType->name) == "uint16") {
|
||||
uint16_t val;
|
||||
strValue >> val;
|
||||
*(uint16_t *) data.data = cpu_to_le16(val);
|
||||
} else if (string(dataType->name) == "uint32") {
|
||||
uint32_t val;
|
||||
strValue >> val;
|
||||
*(uint32_t *) data.data = cpu_to_le32(val);
|
||||
} else if (string(dataType->name) == "uint64") {
|
||||
uint64_t val;
|
||||
strValue >> val;
|
||||
*(uint64_t *) data.data = cpu_to_le64(val);
|
||||
} else if (string(dataType->name) == "string" ||
|
||||
string(dataType->name) == "octet_string") {
|
||||
data.length = strValue.str().size();
|
||||
if (!data.length) {
|
||||
err << "Zero-size string now allowed!";
|
||||
throwCommandException(err);
|
||||
}
|
||||
data.data = new uint8_t[data.length];
|
||||
strValue >> (char *) data.data;
|
||||
} else {
|
||||
err << "Invalid data type " << dataType->name;
|
||||
throwCommandException(err);
|
||||
}
|
||||
} catch (ios::failure &e) {
|
||||
delete [] data.data;
|
||||
err << "Invalid value argument '" << args[1]
|
||||
<< "' for type '" << dataType->name << "'!";
|
||||
throwInvalidUsageException(err);
|
||||
}
|
||||
}
|
||||
try {
|
||||
if (string(dataType->name) == "int8") {
|
||||
int16_t val; // uint8_t is interpreted as char
|
||||
strValue >> val;
|
||||
if (val > 127 || val < -128)
|
||||
throw ios::failure("Value out of range");
|
||||
*data.data = (int8_t) val;
|
||||
} else if (string(dataType->name) == "int16") {
|
||||
int16_t val;
|
||||
strValue >> val;
|
||||
*(int16_t *) data.data = cpu_to_le16(val);
|
||||
} else if (string(dataType->name) == "int32") {
|
||||
int32_t val;
|
||||
strValue >> val;
|
||||
*(int32_t *) data.data = cpu_to_le32(val);
|
||||
} else if (string(dataType->name) == "int64") {
|
||||
int64_t val;
|
||||
strValue >> val;
|
||||
*(int64_t *) data.data = cpu_to_le64(val);
|
||||
} else if (string(dataType->name) == "uint8") {
|
||||
uint16_t val; // uint8_t is interpreted as char
|
||||
strValue >> val;
|
||||
if (val > 0xff)
|
||||
throw ios::failure("Value out of range");
|
||||
*data.data = (uint8_t) val;
|
||||
} else if (string(dataType->name) == "uint16") {
|
||||
uint16_t val;
|
||||
strValue >> val;
|
||||
*(uint16_t *) data.data = cpu_to_le16(val);
|
||||
} else if (string(dataType->name) == "uint32") {
|
||||
uint32_t val;
|
||||
strValue >> val;
|
||||
*(uint32_t *) data.data = cpu_to_le32(val);
|
||||
} else if (string(dataType->name) == "uint64") {
|
||||
uint64_t val;
|
||||
strValue >> val;
|
||||
*(uint64_t *) data.data = cpu_to_le64(val);
|
||||
} else if (string(dataType->name) == "string" ||
|
||||
string(dataType->name) == "octet_string") {
|
||||
data.length = strValue.str().size();
|
||||
if (!data.length) {
|
||||
err << "Zero-size string now allowed!";
|
||||
throwCommandException(err);
|
||||
}
|
||||
data.data = new uint8_t[data.length];
|
||||
strValue >> (char *) data.data;
|
||||
} else {
|
||||
err << "Invalid data type " << dataType->name;
|
||||
throwCommandException(err);
|
||||
}
|
||||
} catch (ios::failure &e) {
|
||||
delete [] data.data;
|
||||
err << "Invalid value argument '" << args[1]
|
||||
<< "' for type '" << dataType->name << "'!";
|
||||
throwInvalidUsageException(err);
|
||||
}
|
||||
}
|
||||
|
||||
if ((uint32_t) data.offset + data.length > 0xffff) {
|
||||
err << "Offset and length exceeding 64k!";
|
||||
|
|
|
|||
|
|
@ -47,41 +47,41 @@ string CommandSdos::helpString() const
|
|||
stringstream str;
|
||||
|
||||
str << getName() << " [OPTIONS]" << endl
|
||||
<< endl
|
||||
<< getBriefDescription() << endl
|
||||
<< endl
|
||||
<< "SDO dictionary information is displayed in two layers," << endl
|
||||
<< "which are indented accordingly:" << endl
|
||||
<< endl
|
||||
<< "1) SDOs - Hexadecimal SDO index and the name. Example:" << endl
|
||||
<< endl
|
||||
<< " SDO 0x1018, \"Identity object\"" << endl
|
||||
<< endl
|
||||
<< "2) SDO entries - SDO index and SDO entry subindex (both" << endl
|
||||
<< " hexadecimal) followed by the access rights (see" << endl
|
||||
<< endl
|
||||
<< getBriefDescription() << endl
|
||||
<< endl
|
||||
<< "SDO dictionary information is displayed in two layers," << endl
|
||||
<< "which are indented accordingly:" << endl
|
||||
<< endl
|
||||
<< "1) SDOs - Hexadecimal SDO index and the name. Example:" << endl
|
||||
<< endl
|
||||
<< " SDO 0x1018, \"Identity object\"" << endl
|
||||
<< endl
|
||||
<< "2) SDO entries - SDO index and SDO entry subindex (both" << endl
|
||||
<< " hexadecimal) followed by the access rights (see" << endl
|
||||
<< " below), the data type, the length in bit, and the" << endl
|
||||
<< " description. Example:" << endl
|
||||
<< endl
|
||||
<< " 0x1018:01, rwrwrw, uint32, 32 bit, \"Vendor id\"" << endl
|
||||
<< endl
|
||||
<< endl
|
||||
<< " 0x1018:01, rwrwrw, uint32, 32 bit, \"Vendor id\"" << endl
|
||||
<< endl
|
||||
<< "The access rights are specified for the AL states PREOP," << endl
|
||||
<< "SAFEOP and OP. An 'r' means, that the entry is readable" << endl
|
||||
<< "in the corresponding state, an 'w' means writable," << endl
|
||||
<< "respectively. If a right is not granted, a dash '-' is" << endl
|
||||
<< "shown." << endl
|
||||
<< endl
|
||||
<< "If the --quiet option is given, only the SDOs are output."
|
||||
<< endl << endl
|
||||
<< "Command-specific options:" << endl
|
||||
<< "If the --quiet option is given, only the SDOs are output."
|
||||
<< endl << endl
|
||||
<< "Command-specific options:" << endl
|
||||
<< " --alias -a <alias>" << endl
|
||||
<< " --position -p <pos> Slave selection. See the help of" << endl
|
||||
<< " the 'slaves' command." << endl
|
||||
<< " --quiet -q Only output SDOs (without the" << endl
|
||||
<< " SDO entries)." << endl
|
||||
<< endl
|
||||
<< numericInfo();
|
||||
<< " --quiet -q Only output SDOs (without the" << endl
|
||||
<< " SDO entries)." << endl
|
||||
<< endl
|
||||
<< numericInfo();
|
||||
|
||||
return str.str();
|
||||
return str.str();
|
||||
}
|
||||
|
||||
/****************************************************************************/
|
||||
|
|
@ -110,10 +110,10 @@ void CommandSdos::execute(MasterDevice &m, const StringVector &args)
|
|||
/****************************************************************************/
|
||||
|
||||
void CommandSdos::listSlaveSdos(
|
||||
MasterDevice &m,
|
||||
MasterDevice &m,
|
||||
const ec_ioctl_slave_t &slave,
|
||||
bool showHeader
|
||||
)
|
||||
bool showHeader
|
||||
)
|
||||
{
|
||||
ec_ioctl_slave_sdo_t sdo;
|
||||
ec_ioctl_slave_sdo_entry_t entry;
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ class CommandSdos:
|
|||
void execute(MasterDevice &, const StringVector &);
|
||||
|
||||
protected:
|
||||
void listSlaveSdos(MasterDevice &, const ec_ioctl_slave_t &, bool);
|
||||
void listSlaveSdos(MasterDevice &, const ec_ioctl_slave_t &, bool);
|
||||
};
|
||||
|
||||
/****************************************************************************/
|
||||
|
|
|
|||
|
|
@ -47,28 +47,28 @@ string CommandSiiRead::helpString() const
|
|||
stringstream str;
|
||||
|
||||
str << getName() << " [OPTIONS]" << endl
|
||||
<< endl
|
||||
<< getBriefDescription() << endl
|
||||
<< endl
|
||||
<< endl
|
||||
<< getBriefDescription() << endl
|
||||
<< endl
|
||||
<< "This command requires a single slave to be selected." << endl
|
||||
<< endl
|
||||
<< "Without the --verbose option, binary SII contents are" << endl
|
||||
<< "output." << endl
|
||||
<< endl
|
||||
<< "With the --verbose option given, a textual representation" << endl
|
||||
<< "of the data is output, that is separated by SII category" << endl
|
||||
<< "names." << endl
|
||||
<< endl
|
||||
<< "Command-specific options:" << endl
|
||||
<< endl
|
||||
<< "Without the --verbose option, binary SII contents are" << endl
|
||||
<< "output." << endl
|
||||
<< endl
|
||||
<< "With the --verbose option given, a textual representation" << endl
|
||||
<< "of the data is output, that is separated by SII category" << endl
|
||||
<< "names." << endl
|
||||
<< endl
|
||||
<< "Command-specific options:" << endl
|
||||
<< " --alias -a <alias>" << endl
|
||||
<< " --position -p <pos> Slave selection. See the help of" << endl
|
||||
<< " the 'slaves' command." << endl
|
||||
<< " --verbose -v Output textual data with" << endl
|
||||
<< " category names." << endl
|
||||
<< endl
|
||||
<< numericInfo();
|
||||
<< " --verbose -v Output textual data with" << endl
|
||||
<< " category names." << endl
|
||||
<< endl
|
||||
<< numericInfo();
|
||||
|
||||
return str.str();
|
||||
return str.str();
|
||||
}
|
||||
|
||||
/****************************************************************************/
|
||||
|
|
@ -104,12 +104,12 @@ void CommandSiiRead::execute(MasterDevice &m, const StringVector &args)
|
|||
data.nwords = slave->sii_nwords;
|
||||
data.words = new uint16_t[data.nwords];
|
||||
|
||||
try {
|
||||
m.readSii(&data);
|
||||
} catch (MasterDeviceException &e) {
|
||||
try {
|
||||
m.readSii(&data);
|
||||
} catch (MasterDeviceException &e) {
|
||||
delete [] data.words;
|
||||
throw e;
|
||||
}
|
||||
throw e;
|
||||
}
|
||||
|
||||
if (getVerbosity() == Verbose) {
|
||||
cout << "SII Area:" << hex << setfill('0');
|
||||
|
|
|
|||
|
|
@ -44,12 +44,12 @@ class CommandSiiRead:
|
|||
void execute(MasterDevice &, const StringVector &);
|
||||
|
||||
protected:
|
||||
struct CategoryName {
|
||||
uint16_t type;
|
||||
const char *name;
|
||||
};
|
||||
static const CategoryName categoryNames[];
|
||||
static const char *getCategoryName(uint16_t);
|
||||
struct CategoryName {
|
||||
uint16_t type;
|
||||
const char *name;
|
||||
};
|
||||
static const CategoryName categoryNames[];
|
||||
static const char *getCategoryName(uint16_t);
|
||||
};
|
||||
|
||||
/****************************************************************************/
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@ string CommandSiiWrite::helpString() const
|
|||
<< getBriefDescription() << endl
|
||||
<< endl
|
||||
<< "This command requires a single slave to be selected." << endl
|
||||
<< endl
|
||||
<< endl
|
||||
<< "The file contents are checked for validity and integrity." << endl
|
||||
<< "These checks can be overridden with the --force option." << endl
|
||||
<< endl
|
||||
|
|
|
|||
|
|
@ -51,7 +51,7 @@ string CommandUpload::helpString() const
|
|||
<< getBriefDescription() << endl
|
||||
<< endl
|
||||
<< "This command requires a single slave to be selected." << endl
|
||||
<< endl
|
||||
<< endl
|
||||
<< "The data type of the SDO entry is taken from the SDO" << endl
|
||||
<< "dictionary by default. It can be overridden with the" << endl
|
||||
<< "--type option. If the slave does not support the SDO" << endl
|
||||
|
|
@ -152,15 +152,15 @@ void CommandUpload::execute(MasterDevice &m, const StringVector &args)
|
|||
|
||||
data.target = new uint8_t[data.target_size + 1];
|
||||
|
||||
try {
|
||||
m.sdoUpload(&data);
|
||||
} catch (MasterDeviceSdoAbortException &e) {
|
||||
try {
|
||||
m.sdoUpload(&data);
|
||||
} catch (MasterDeviceSdoAbortException &e) {
|
||||
delete [] data.target;
|
||||
err << "SDO transfer aborted with code 0x"
|
||||
<< setfill('0') << hex << setw(8) << e.abortCode
|
||||
<< ": " << abortText(e.abortCode);
|
||||
throwCommandException(err);
|
||||
} catch (MasterDeviceException &e) {
|
||||
} catch (MasterDeviceException &e) {
|
||||
delete [] data.target;
|
||||
throw e;
|
||||
}
|
||||
|
|
@ -237,9 +237,9 @@ void CommandUpload::execute(MasterDevice &m, const StringVector &args)
|
|||
/****************************************************************************/
|
||||
|
||||
void CommandUpload::printRawData(
|
||||
const uint8_t *data,
|
||||
unsigned int size
|
||||
)
|
||||
const uint8_t *data,
|
||||
unsigned int size
|
||||
)
|
||||
{
|
||||
cout << hex << setfill('0');
|
||||
while (size--) {
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ class CommandUpload:
|
|||
void execute(MasterDevice &, const StringVector &);
|
||||
|
||||
protected:
|
||||
enum {DefaultBufferSize = 64 * 1024};
|
||||
enum {DefaultBufferSize = 64 * 1024};
|
||||
|
||||
static void printRawData(const uint8_t *, unsigned int);
|
||||
};
|
||||
|
|
|
|||
|
|
@ -45,11 +45,11 @@ string CommandVersion::helpString() const
|
|||
{
|
||||
stringstream str;
|
||||
|
||||
str << getName() << " [OPTIONS]" << endl
|
||||
<< endl
|
||||
<< getBriefDescription() << endl;
|
||||
str << getName() << " [OPTIONS]" << endl
|
||||
<< endl
|
||||
<< getBriefDescription() << endl;
|
||||
|
||||
return str.str();
|
||||
return str.str();
|
||||
}
|
||||
|
||||
/****************************************************************************/
|
||||
|
|
|
|||
|
|
@ -41,49 +41,49 @@ FoeCommand::FoeCommand(const string &name, const string &briefDesc):
|
|||
|
||||
std::string FoeCommand::resultText(int result)
|
||||
{
|
||||
switch (result) {
|
||||
case FOE_BUSY:
|
||||
return "FOE_BUSY";
|
||||
case FOE_READY:
|
||||
return "FOE_READY";
|
||||
case FOE_IDLE:
|
||||
return "FOE_IDLE";
|
||||
case FOE_WC_ERROR:
|
||||
return "FOE_WC_ERROR";
|
||||
case FOE_RECEIVE_ERROR:
|
||||
return "FOE_RECEIVE_ERROR";
|
||||
case FOE_PROT_ERROR:
|
||||
return "FOE_PROT_ERROR";
|
||||
case FOE_NODATA_ERROR:
|
||||
return "FOE_NODATA_ERROR";
|
||||
case FOE_PACKETNO_ERROR:
|
||||
return "FOE_PACKETNO_ERROR";
|
||||
case FOE_OPCODE_ERROR:
|
||||
return "FOE_OPCODE_ERROR";
|
||||
case FOE_TIMEOUT_ERROR:
|
||||
return "FOE_TIMEOUT_ERROR";
|
||||
case FOE_SEND_RX_DATA_ERROR:
|
||||
return "FOE_SEND_RX_DATA_ERROR";
|
||||
case FOE_RX_DATA_ACK_ERROR:
|
||||
return "FOE_RX_DATA_ACK_ERROR";
|
||||
case FOE_ACK_ERROR:
|
||||
return "FOE_ACK_ERROR";
|
||||
case FOE_MBOX_FETCH_ERROR:
|
||||
return "FOE_MBOX_FETCH_ERROR";
|
||||
case FOE_READ_NODATA_ERROR:
|
||||
return "FOE_READ_NODATA_ERROR";
|
||||
case FOE_MBOX_PROT_ERROR:
|
||||
return "FOE_MBOX_PROT_ERROR";
|
||||
default:
|
||||
return "???";
|
||||
}
|
||||
switch (result) {
|
||||
case FOE_BUSY:
|
||||
return "FOE_BUSY";
|
||||
case FOE_READY:
|
||||
return "FOE_READY";
|
||||
case FOE_IDLE:
|
||||
return "FOE_IDLE";
|
||||
case FOE_WC_ERROR:
|
||||
return "FOE_WC_ERROR";
|
||||
case FOE_RECEIVE_ERROR:
|
||||
return "FOE_RECEIVE_ERROR";
|
||||
case FOE_PROT_ERROR:
|
||||
return "FOE_PROT_ERROR";
|
||||
case FOE_NODATA_ERROR:
|
||||
return "FOE_NODATA_ERROR";
|
||||
case FOE_PACKETNO_ERROR:
|
||||
return "FOE_PACKETNO_ERROR";
|
||||
case FOE_OPCODE_ERROR:
|
||||
return "FOE_OPCODE_ERROR";
|
||||
case FOE_TIMEOUT_ERROR:
|
||||
return "FOE_TIMEOUT_ERROR";
|
||||
case FOE_SEND_RX_DATA_ERROR:
|
||||
return "FOE_SEND_RX_DATA_ERROR";
|
||||
case FOE_RX_DATA_ACK_ERROR:
|
||||
return "FOE_RX_DATA_ACK_ERROR";
|
||||
case FOE_ACK_ERROR:
|
||||
return "FOE_ACK_ERROR";
|
||||
case FOE_MBOX_FETCH_ERROR:
|
||||
return "FOE_MBOX_FETCH_ERROR";
|
||||
case FOE_READ_NODATA_ERROR:
|
||||
return "FOE_READ_NODATA_ERROR";
|
||||
case FOE_MBOX_PROT_ERROR:
|
||||
return "FOE_MBOX_PROT_ERROR";
|
||||
default:
|
||||
return "???";
|
||||
}
|
||||
}
|
||||
|
||||
/****************************************************************************/
|
||||
|
||||
std::string FoeCommand::errorText(int errorCode)
|
||||
{
|
||||
switch (errorCode) {
|
||||
switch (errorCode) {
|
||||
case 0x00008001:
|
||||
return "Not found.";
|
||||
case 0x00008002:
|
||||
|
|
@ -106,9 +106,9 @@ std::string FoeCommand::errorText(int errorCode)
|
|||
return "No rights.";
|
||||
case 0x0000800b:
|
||||
return "Program Error.";
|
||||
default:
|
||||
return "Unknown error code";
|
||||
}
|
||||
default:
|
||||
return "Unknown error code";
|
||||
}
|
||||
}
|
||||
|
||||
/****************************************************************************/
|
||||
|
|
|
|||
|
|
@ -41,8 +41,8 @@ class FoeCommand:
|
|||
FoeCommand(const string &, const string &);
|
||||
|
||||
protected:
|
||||
static std::string resultText(int);
|
||||
static std::string errorText(int);
|
||||
static std::string resultText(int);
|
||||
static std::string errorText(int);
|
||||
};
|
||||
|
||||
/****************************************************************************/
|
||||
|
|
|
|||
|
|
@ -69,15 +69,15 @@ void MasterDevice::open(Permissions perm)
|
|||
stringstream deviceName;
|
||||
|
||||
if (fd == -1) { // not already open
|
||||
deviceName << "/dev/EtherCAT" << index;
|
||||
deviceName << "/dev/EtherCAT" << index;
|
||||
|
||||
if ((fd = ::open(deviceName.str().c_str(),
|
||||
perm == ReadWrite ? O_RDWR : O_RDONLY)) == -1) {
|
||||
stringstream err;
|
||||
err << "Failed to open master device " << deviceName.str() << ": "
|
||||
<< strerror(errno);
|
||||
throw MasterDeviceException(err);
|
||||
}
|
||||
if ((fd = ::open(deviceName.str().c_str(),
|
||||
perm == ReadWrite ? O_RDWR : O_RDONLY)) == -1) {
|
||||
stringstream err;
|
||||
err << "Failed to open master device " << deviceName.str() << ": "
|
||||
<< strerror(errno);
|
||||
throw MasterDeviceException(err);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -86,9 +86,9 @@ void MasterDevice::open(Permissions perm)
|
|||
void MasterDevice::close()
|
||||
{
|
||||
if (fd != -1) {
|
||||
::close(fd);
|
||||
fd = -1;
|
||||
}
|
||||
::close(fd);
|
||||
fd = -1;
|
||||
}
|
||||
}
|
||||
|
||||
/****************************************************************************/
|
||||
|
|
@ -427,7 +427,7 @@ void MasterDevice::setDebug(unsigned int debugLevel)
|
|||
stringstream err;
|
||||
err << "Failed to set debug level: " << strerror(errno);
|
||||
throw MasterDeviceException(err);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/****************************************************************************/
|
||||
|
|
@ -442,7 +442,7 @@ void MasterDevice::sdoDownload(ec_ioctl_slave_sdo_download_t *data)
|
|||
err << "Failed to download SDO: " << strerror(errno);
|
||||
throw MasterDeviceException(err);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/****************************************************************************/
|
||||
|
|
|
|||
|
|
@ -83,7 +83,7 @@ class MasterDevice
|
|||
~MasterDevice();
|
||||
|
||||
void setIndex(unsigned int);
|
||||
unsigned int getIndex() const;
|
||||
unsigned int getIndex() const;
|
||||
|
||||
enum Permissions {Read, ReadWrite};
|
||||
void open(Permissions);
|
||||
|
|
@ -111,11 +111,11 @@ class MasterDevice
|
|||
void writeSii(ec_ioctl_slave_sii_t *);
|
||||
void readReg(ec_ioctl_slave_reg_t *);
|
||||
void writeReg(ec_ioctl_slave_reg_t *);
|
||||
void setDebug(unsigned int);
|
||||
void sdoDownload(ec_ioctl_slave_sdo_download_t *);
|
||||
void sdoUpload(ec_ioctl_slave_sdo_upload_t *);
|
||||
void requestState(uint16_t, uint8_t);
|
||||
void readFoe(ec_ioctl_slave_foe_t *);
|
||||
void setDebug(unsigned int);
|
||||
void sdoDownload(ec_ioctl_slave_sdo_download_t *);
|
||||
void sdoUpload(ec_ioctl_slave_sdo_upload_t *);
|
||||
void requestState(uint16_t, uint8_t);
|
||||
void readFoe(ec_ioctl_slave_foe_t *);
|
||||
void writeFoe(ec_ioctl_slave_foe_t *);
|
||||
#ifdef EC_EOE
|
||||
void getEoeHandler(ec_ioctl_eoe_handler_t *, uint16_t);
|
||||
|
|
@ -130,7 +130,7 @@ class MasterDevice
|
|||
|
||||
inline unsigned int MasterDevice::getIndex() const
|
||||
{
|
||||
return index;
|
||||
return index;
|
||||
}
|
||||
|
||||
/****************************************************************************/
|
||||
|
|
|
|||
|
|
@ -99,7 +99,7 @@ string usage()
|
|||
|
||||
str << "Usage: " << binaryBaseName << " <COMMAND> [OPTIONS] [ARGUMENTS]"
|
||||
<< endl << endl
|
||||
<< "Commands (can be abbreviated):" << endl;
|
||||
<< "Commands (can be abbreviated):" << endl;
|
||||
|
||||
str << left;
|
||||
for (ci = commandList.begin(); ci != commandList.end(); ci++) {
|
||||
|
|
@ -108,9 +108,9 @@ string usage()
|
|||
}
|
||||
|
||||
str << endl
|
||||
<< "Global options:" << endl
|
||||
<< "Global options:" << endl
|
||||
<< " --master -m <master> Index of the master to use. Default: 0."
|
||||
<< endl
|
||||
<< endl
|
||||
<< " --force -f Force a command." << endl
|
||||
<< " --quiet -q Output less information." << endl
|
||||
<< " --verbose -v Output more information." << endl
|
||||
|
|
@ -239,7 +239,7 @@ void getOptions(int argc, char **argv)
|
|||
}
|
||||
while (c != -1);
|
||||
|
||||
argCount = argc - optind;
|
||||
argCount = argc - optind;
|
||||
|
||||
if (!argCount) {
|
||||
if (helpRequested) {
|
||||
|
|
@ -250,7 +250,7 @@ void getOptions(int argc, char **argv)
|
|||
<< endl << usage();
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
commandName = argv[optind];
|
||||
while (++optind < argc)
|
||||
|
|
@ -320,7 +320,7 @@ int main(int argc, char **argv)
|
|||
commandList.push_back(new CommandVersion());
|
||||
commandList.push_back(new CommandXml());
|
||||
|
||||
getOptions(argc, argv);
|
||||
getOptions(argc, argv);
|
||||
|
||||
matchingCommands = getMatchingCommands(commandName);
|
||||
masterDev.setIndex(masterIndex);
|
||||
|
|
@ -368,7 +368,7 @@ int main(int argc, char **argv)
|
|||
retval = 1;
|
||||
}
|
||||
|
||||
return retval;
|
||||
return retval;
|
||||
}
|
||||
|
||||
/****************************************************************************/
|
||||
|
|
|
|||
Loading…
Reference in New Issue