# HG changeset patch # User Florian Pose # Date 1265362187 -3600 # Node ID 742607c464c42e6a0f5a79a8833318905ef074ac # Parent 5b04770444df38805b35ca71a9d12228137cf68a Removed tabulators. diff -r 5b04770444df -r 742607c464c4 documentation/graphs/fsm_change.dot --- a/documentation/graphs/fsm_change.dot Tue Feb 02 19:38:32 2010 +0100 +++ b/documentation/graphs/fsm_change.dot Fri Feb 05 10:29:47 2010 +0100 @@ -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"] } diff -r 5b04770444df -r 742607c464c4 documentation/graphs/fsm_master.dot --- a/documentation/graphs/fsm_master.dot Tue Feb 02 19:38:32 2010 +0100 +++ b/documentation/graphs/fsm_master.dot Fri Feb 05 10:29:47 2010 +0100 @@ -4,7 +4,7 @@ digraph master { size="7,9" center=1 - ratio=fill + ratio=fill start [fontname="Helvetica"] start -> broadcast [weight=10] diff -r 5b04770444df -r 742607c464c4 documentation/graphs/fsm_pdo_entry_conf.dot --- a/documentation/graphs/fsm_pdo_entry_conf.dot Tue Feb 02 19:38:32 2010 +0100 +++ b/documentation/graphs/fsm_pdo_entry_conf.dot Fri Feb 05 10:29:47 2010 +0100 @@ -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 } diff -r 5b04770444df -r 742607c464c4 documentation/graphs/fsm_pdo_entry_read.dot --- a/documentation/graphs/fsm_pdo_entry_read.dot Tue Feb 02 19:38:32 2010 +0100 +++ b/documentation/graphs/fsm_pdo_entry_read.dot Fri Feb 05 10:29:47 2010 +0100 @@ -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"] diff -r 5b04770444df -r 742607c464c4 documentation/graphs/fsm_pdo_read.dot --- a/documentation/graphs/fsm_pdo_read.dot Tue Feb 02 19:38:32 2010 +0100 +++ b/documentation/graphs/fsm_pdo_read.dot Fri Feb 05 10:29:47 2010 +0100 @@ -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"] } diff -r 5b04770444df -r 742607c464c4 documentation/graphs/fsm_sii.dot --- a/documentation/graphs/fsm_sii.dot Tue Feb 02 19:38:32 2010 +0100 +++ b/documentation/graphs/fsm_sii.dot Fri Feb 05 10:29:47 2010 +0100 @@ -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"] } diff -r 5b04770444df -r 742607c464c4 examples/dc_user/main.c --- a/examples/dc_user/main.c Tue Feb 02 19:38:32 2010 +0100 +++ b/examples/dc_user/main.c Fri Feb 05 10:29:47 2010 +0100 @@ -193,13 +193,13 @@ 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) diff -r 5b04770444df -r 742607c464c4 include/ecrt.h --- a/include/ecrt.h Tue Feb 02 19:38:32 2010 +0100 +++ b/include/ecrt.h Fri Feb 05 10:29:47 2010 +0100 @@ -217,7 +217,7 @@ 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 @@ * \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 @@ * */ int ecrt_master_reserve( - ec_master_t *master /**< EtherCAT master */ - ); + ec_master_t *master /**< EtherCAT master */ + ); #endif // #ifndef __KERNEL__ @@ -545,10 +545,10 @@ * \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 @@ */ 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 @@ * 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. * diff -r 5b04770444df -r 742607c464c4 lib/master.c --- a/lib/master.c Tue Feb 02 19:38:32 2010 +0100 +++ b/lib/master.c Fri Feb 05 10:29:47 2010 +0100 @@ -165,7 +165,7 @@ 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 @@ } 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_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 @@ 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 @@ 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 } diff -r 5b04770444df -r 742607c464c4 master/cdev.c --- a/master/cdev.c Tue Feb 02 19:38:32 2010 +0100 +++ b/master/cdev.c Fri Feb 05 10:29:47 2010 +0100 @@ -1684,15 +1684,16 @@ ec_cdev_priv_t *priv /**< Private data structure of file handle. */ ) { - size_t 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); + size_t 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); up(&master->master_sem); return 0; @@ -3492,10 +3493,10 @@ 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: - if (!(filp->f_mode & FMODE_WRITE)) - return -EPERM; - return ec_cdev_ioctl_set_send_interval(master,arg,priv); + case EC_IOCTL_SET_SEND_INTERVAL: + if (!(filp->f_mode & FMODE_WRITE)) + return -EPERM; + return ec_cdev_ioctl_set_send_interval(master,arg,priv); default: return -ENOTTY; } diff -r 5b04770444df -r 742607c464c4 master/fsm_master.c --- a/master/fsm_master.c Tue Feb 02 19:38:32 2010 +0100 +++ b/master/fsm_master.c Fri Feb 05 10:29:47 2010 +0100 @@ -471,14 +471,14 @@ 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); - } - - // check, if slaves have an SDO dictionary to read out. + // 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. for (slave = master->slaves; slave < master->slaves + master->slave_count; slave++) { diff -r 5b04770444df -r 742607c464c4 master/fsm_slave.c --- a/master/fsm_slave.c Tue Feb 02 19:38:32 2010 +0100 +++ b/master/fsm_slave.c Fri Feb 05 10:29:47 2010 +0100 @@ -62,9 +62,11 @@ 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_ready( - 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; + 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; } /****************************************************************************** @@ -135,10 +138,10 @@ * */ void ec_fsm_slave_state_idle( - ec_fsm_slave_t *fsm /**< Slave state machine. */ - ) -{ - // do nothing + ec_fsm_slave_t *fsm /**< Slave state machine. */ + ) +{ + // do nothing } @@ -149,18 +152,17 @@ * */ void ec_fsm_slave_state_ready( - 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; - -} - + 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; +} /*****************************************************************************/ @@ -180,25 +182,27 @@ 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 @@ // 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 @@ 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,9 +301,8 @@ wake_up(&slave->sdo_queue); fsm->sdo_request = NULL; - fsm->state = ec_fsm_slave_state_ready; -} - + fsm->state = ec_fsm_slave_state_ready; +} /*****************************************************************************/ @@ -338,6 +341,7 @@ wake_up(&slave->foe_queue); fsm->foe_request = NULL; - fsm->state = ec_fsm_slave_state_ready; -} - + fsm->state = ec_fsm_slave_state_ready; +} + +/*****************************************************************************/ diff -r 5b04770444df -r 742607c464c4 master/fsm_slave_scan.c --- a/master/fsm_slave_scan.c Tue Feb 02 19:38:32 2010 +0100 +++ b/master/fsm_slave_scan.c Fri Feb 05 10:29:47 2010 +0100 @@ -753,7 +753,7 @@ */ 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; diff -r 5b04770444df -r 742607c464c4 master/master.c --- a/master/master.c Tue Feb 02 19:38:32 2010 +0100 +++ b/master/master.c Fri Feb 05 10:29:47 2010 +0100 @@ -795,35 +795,35 @@ 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; + } +#endif + + list_add_tail(&datagram->queue, &master->external_datagram_queue); + datagram->state = EC_DATAGRAM_QUEUED; #ifdef EC_HAVE_CYCLES - datagram->cycles_sent = get_cycles(); -#endif - datagram->jiffies_sent = jiffies; - - master->fsm.idle = 0; - up(&master->io_sem); + datagram->cycles_sent = get_cycles(); +#endif + datagram->jiffies_sent = jiffies; + + master->fsm.idle = 0; + up(&master->io_sem); } /*****************************************************************************/ @@ -876,7 +876,7 @@ 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 @@ 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); - - if (master->debug_level) - EC_DBG("Idle thread running with send interval = %d us," + ec_master_set_send_interval(master, 1000000 / HZ); + + 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 @@ } 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 @@ 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 @@ } #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 @@ schedule(); } #endif - } + } if (master->debug_level) EC_DBG("Master OP thread exiting...\n"); @@ -2072,7 +2072,7 @@ } // send frames - ec_master_send_datagrams(master); + ec_master_send_datagrams(master); } /*****************************************************************************/ diff -r 5b04770444df -r 742607c464c4 master/master.h --- a/master/master.h Tue Feb 02 19:38:32 2010 +0100 +++ b/master/master.h Fri Feb 05 10:29:47 2010 +0100 @@ -155,7 +155,7 @@ 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. */ diff -r 5b04770444df -r 742607c464c4 script/ifup-eoe.sh --- a/script/ifup-eoe.sh Tue Feb 02 19:38:32 2010 +0100 +++ b/script/ifup-eoe.sh Fri Feb 05 10:29:47 2010 +0100 @@ -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 @@ # 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} diff -r 5b04770444df -r 742607c464c4 script/init.d/ethercat.in --- a/script/init.d/ethercat.in Tue Feb 02 19:38:32 2010 +0100 +++ b/script/init.d/ethercat.in Fri Feb 05 10:29:47 2010 +0100 @@ -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 @@ if [ ! -r ${ETHERCAT_CONFIG} ]; then echo ${ETHERCAT_CONFIG} not existing; if [ "${1}" = "stop" ]; then - exit 0 - else - exit 6 + exit 0 + else + exit 6 fi fi diff -r 5b04770444df -r 742607c464c4 tool/Command.cpp --- a/tool/Command.cpp Tue Feb 02 19:38:32 2010 +0100 +++ b/tool/Command.cpp Fri Feb 05 10:29:47 2010 +0100 @@ -48,49 +48,49 @@ 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::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); - } - - return list; + m.getDomain(&d, domain); + list.push_back(d); + } + + return list; } /****************************************************************************/ diff -r 5b04770444df -r 742607c464c4 tool/Command.h --- a/tool/Command.h Tue Feb 02 19:38:32 2010 +0100 +++ b/tool/Command.h Fri Feb 05 10:29:47 2010 +0100 @@ -71,7 +71,7 @@ { public: Command(const string &, const string &); - virtual ~Command(); + virtual ~Command(); const string &getName() const; const string &getBriefDescription() const; @@ -82,7 +82,7 @@ Verbose }; void setVerbosity(Verbosity); - Verbosity getVerbosity() const; + Verbosity getVerbosity() const; void setAlias(int); int getAlias() const; void setPosition(int); @@ -91,10 +91,10 @@ 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 @@ static string numericInfo(); protected: - enum {BreakAfterBytes = 16}; + enum {BreakAfterBytes = 16}; void throwInvalidUsageException(const stringstream &) const; void throwCommandException(const stringstream &) const; @@ -123,15 +123,15 @@ 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(); }; diff -r 5b04770444df -r 742607c464c4 tool/CommandCStruct.cpp --- a/tool/CommandCStruct.cpp Tue Feb 02 19:38:32 2010 +0100 +++ b/tool/CommandCStruct.cpp Fri Feb 05 10:29:47 2010 +0100 @@ -53,7 +53,7 @@ << 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 " << endl diff -r 5b04770444df -r 742607c464c4 tool/CommandConfig.cpp --- a/tool/CommandConfig.cpp Tue Feb 02 19:38:32 2010 +0100 +++ b/tool/CommandConfig.cpp Fri Feb 05 10:29:47 2010 +0100 @@ -49,28 +49,28 @@ 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 @@ << " 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 Configuration alias (see above)." << endl << " --position -p 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 @@ /** 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; diff -r 5b04770444df -r 742607c464c4 tool/CommandConfig.h --- a/tool/CommandConfig.h Tue Feb 02 19:38:32 2010 +0100 +++ b/tool/CommandConfig.h Fri Feb 05 10:29:47 2010 +0100 @@ -46,17 +46,17 @@ 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 &); }; /****************************************************************************/ diff -r 5b04770444df -r 742607c464c4 tool/CommandData.cpp --- a/tool/CommandData.cpp Tue Feb 02 19:38:32 2010 +0100 +++ b/tool/CommandData.cpp Fri Feb 05 10:29:47 2010 +0100 @@ -46,28 +46,28 @@ 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 Positive numerical domain index." << endl - << " If omitted, data of all domains" << endl - << " are output." << endl - << endl - << numericInfo(); + << endl + << "Command-specific options:" << endl + << " --domain -d 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; err << "'" << getName() << "' takes no arguments!"; @@ -75,19 +75,19 @@ } 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; diff -r 5b04770444df -r 742607c464c4 tool/CommandData.h --- a/tool/CommandData.h Tue Feb 02 19:38:32 2010 +0100 +++ b/tool/CommandData.h Fri Feb 05 10:29:47 2010 +0100 @@ -44,7 +44,7 @@ void execute(MasterDevice &, const StringVector &); protected: - void outputDomainData(MasterDevice &, const ec_ioctl_domain_t &); + void outputDomainData(MasterDevice &, const ec_ioctl_domain_t &); }; /****************************************************************************/ diff -r 5b04770444df -r 742607c464c4 tool/CommandDebug.cpp --- a/tool/CommandDebug.cpp Tue Feb 02 19:38:32 2010 +0100 +++ b/tool/CommandDebug.cpp Fri Feb 05 10:29:47 2010 +0100 @@ -46,21 +46,21 @@ { stringstream str; - str << getName() << " " << 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() << " " << 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(); } /****************************************************************************/ diff -r 5b04770444df -r 742607c464c4 tool/CommandDomains.cpp --- a/tool/CommandDomains.cpp Tue Feb 02 19:38:32 2010 +0100 +++ b/tool/CommandDomains.cpp Fri Feb 05 10:29:47 2010 +0100 @@ -46,54 +46,54 @@ { 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 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 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; err << "'" << getName() << "' takes no arguments!"; @@ -101,34 +101,34 @@ } 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; unsigned int i, j; 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) diff -r 5b04770444df -r 742607c464c4 tool/CommandDomains.h --- a/tool/CommandDomains.h Tue Feb 02 19:38:32 2010 +0100 +++ b/tool/CommandDomains.h Fri Feb 05 10:29:47 2010 +0100 @@ -44,7 +44,7 @@ void execute(MasterDevice &, const StringVector &); protected: - void showDomain(MasterDevice &, const ec_ioctl_domain_t &); + void showDomain(MasterDevice &, const ec_ioctl_domain_t &); }; /****************************************************************************/ diff -r 5b04770444df -r 742607c464c4 tool/CommandDownload.cpp --- a/tool/CommandDownload.cpp Tue Feb 02 19:38:32 2010 +0100 +++ b/tool/CommandDownload.cpp Fri Feb 05 10:29:47 2010 +0100 @@ -47,38 +47,38 @@ stringstream str; str << getName() << " [OPTIONS] " << 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 " << endl << " --position -p Slave selection. See the help of" << endl << " the 'slaves' command." << endl - << " --type -t SDO entry data type (see above)." << endl - << endl - << numericInfo(); - - return str.str(); + << " --type -t SDO entry data type (see above)." << endl + << endl + << numericInfo(); + + return str.str(); } /****************************************************************************/ @@ -235,15 +235,15 @@ 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; } diff -r 5b04770444df -r 742607c464c4 tool/CommandDownload.h --- a/tool/CommandDownload.h Tue Feb 02 19:38:32 2010 +0100 +++ b/tool/CommandDownload.h Fri Feb 05 10:29:47 2010 +0100 @@ -43,8 +43,8 @@ string helpString() const; void execute(MasterDevice &, const StringVector &); - protected: - enum {DefaultBufferSize = 1024}; + protected: + enum {DefaultBufferSize = 1024}; }; /****************************************************************************/ diff -r 5b04770444df -r 742607c464c4 tool/CommandFoeRead.cpp --- a/tool/CommandFoeRead.cpp Tue Feb 02 19:38:32 2010 +0100 +++ b/tool/CommandFoeRead.cpp Fri Feb 05 10:29:47 2010 +0100 @@ -50,25 +50,25 @@ 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 + << 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 Local target filename. If" << endl << " '-' (default), data are" << endl << " printed to stdout." << endl << " --alias -a " << endl << " --position -p 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 @@ 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 @@ } 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; } diff -r 5b04770444df -r 742607c464c4 tool/CommandFoeWrite.cpp --- a/tool/CommandFoeWrite.cpp Tue Feb 02 19:38:32 2010 +0100 +++ b/tool/CommandFoeWrite.cpp Fri Feb 05 10:29:47 2010 +0100 @@ -56,7 +56,7 @@ << 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 diff -r 5b04770444df -r 742607c464c4 tool/CommandGraph.cpp --- a/tool/CommandGraph.cpp Tue Feb 02 19:38:32 2010 +0100 +++ b/tool/CommandGraph.cpp Fri Feb 05 10:29:47 2010 +0100 @@ -119,7 +119,7 @@ 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; diff -r 5b04770444df -r 742607c464c4 tool/CommandMaster.cpp --- a/tool/CommandMaster.cpp Tue Feb 02 19:38:32 2010 +0100 +++ b/tool/CommandMaster.cpp Fri Feb 05 10:29:47 2010 +0100 @@ -48,16 +48,16 @@ { stringstream str; - str << getName() << " [OPTIONS]" << endl - << endl - << getBriefDescription() << endl - << endl - << "Command-specific options:" << endl - << " --master -m 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 of the master to use. Default: 0." + << endl << endl + << numericInfo(); - return str.str(); + return str.str(); } /****************************************************************************/ diff -r 5b04770444df -r 742607c464c4 tool/CommandPdos.cpp --- a/tool/CommandPdos.cpp Tue Feb 02 19:38:32 2010 +0100 +++ b/tool/CommandPdos.cpp Fri Feb 05 10:29:47 2010 +0100 @@ -47,43 +47,43 @@ 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 " << endl << " --position -p 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::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; diff -r 5b04770444df -r 742607c464c4 tool/CommandPdos.h --- a/tool/CommandPdos.h Tue Feb 02 19:38:32 2010 +0100 +++ b/tool/CommandPdos.h Fri Feb 05 10:29:47 2010 +0100 @@ -44,7 +44,7 @@ void execute(MasterDevice &, const StringVector &); protected: - void listSlavePdos(MasterDevice &, const ec_ioctl_slave_t &, bool); + void listSlavePdos(MasterDevice &, const ec_ioctl_slave_t &, bool); }; /****************************************************************************/ diff -r 5b04770444df -r 742607c464c4 tool/CommandRegRead.cpp --- a/tool/CommandRegRead.cpp Tue Feb 02 19:38:32 2010 +0100 +++ b/tool/CommandRegRead.cpp Fri Feb 05 10:29:47 2010 +0100 @@ -47,11 +47,11 @@ stringstream str; str << getName() << " [OPTIONS] [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 @@ << " int8, int16, int32, int64, uint8, uint16, uint32," << endl << " uint64, string, raw." << endl << endl - << "Command-specific options:" << endl + << "Command-specific options:" << endl << " --alias -a " << endl << " --position -p Slave selection. See the help of" << endl << " the 'slaves' command." << endl << " --type -t Data type (see above)." << endl - << endl - << numericInfo(); - - return str.str(); + << endl + << numericInfo(); + + return str.str(); } /****************************************************************************/ @@ -151,12 +151,12 @@ 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") { diff -r 5b04770444df -r 742607c464c4 tool/CommandRegWrite.cpp --- a/tool/CommandRegWrite.cpp Tue Feb 02 19:38:32 2010 +0100 +++ b/tool/CommandRegWrite.cpp Fri Feb 05 10:29:47 2010 +0100 @@ -53,20 +53,20 @@ << 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 " << endl << " --position -p Slave selection. See the help of" << endl @@ -101,93 +101,93 @@ 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]; - } - - 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); - } - } + 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); + + 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!"; diff -r 5b04770444df -r 742607c464c4 tool/CommandSdos.cpp --- a/tool/CommandSdos.cpp Tue Feb 02 19:38:32 2010 +0100 +++ b/tool/CommandSdos.cpp Fri Feb 05 10:29:47 2010 +0100 @@ -47,41 +47,41 @@ 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 " << endl << " --position -p 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::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; diff -r 5b04770444df -r 742607c464c4 tool/CommandSdos.h --- a/tool/CommandSdos.h Tue Feb 02 19:38:32 2010 +0100 +++ b/tool/CommandSdos.h Fri Feb 05 10:29:47 2010 +0100 @@ -44,7 +44,7 @@ void execute(MasterDevice &, const StringVector &); protected: - void listSlaveSdos(MasterDevice &, const ec_ioctl_slave_t &, bool); + void listSlaveSdos(MasterDevice &, const ec_ioctl_slave_t &, bool); }; /****************************************************************************/ diff -r 5b04770444df -r 742607c464c4 tool/CommandSiiRead.cpp --- a/tool/CommandSiiRead.cpp Tue Feb 02 19:38:32 2010 +0100 +++ b/tool/CommandSiiRead.cpp Fri Feb 05 10:29:47 2010 +0100 @@ -47,28 +47,28 @@ 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 " << endl << " --position -p Slave selection. See the help of" << endl << " the 'slaves' command." << endl - << " --verbose -v Output textual data with" << endl - << " category names." << endl - << endl - << numericInfo(); - - return str.str(); + << " --verbose -v Output textual data with" << endl + << " category names." << endl + << endl + << numericInfo(); + + return str.str(); } /****************************************************************************/ @@ -104,12 +104,12 @@ 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'); diff -r 5b04770444df -r 742607c464c4 tool/CommandSiiRead.h --- a/tool/CommandSiiRead.h Tue Feb 02 19:38:32 2010 +0100 +++ b/tool/CommandSiiRead.h Fri Feb 05 10:29:47 2010 +0100 @@ -44,12 +44,12 @@ 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); }; /****************************************************************************/ diff -r 5b04770444df -r 742607c464c4 tool/CommandSiiWrite.cpp --- a/tool/CommandSiiWrite.cpp Tue Feb 02 19:38:32 2010 +0100 +++ b/tool/CommandSiiWrite.cpp Fri Feb 05 10:29:47 2010 +0100 @@ -53,7 +53,7 @@ << 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 diff -r 5b04770444df -r 742607c464c4 tool/CommandUpload.cpp --- a/tool/CommandUpload.cpp Tue Feb 02 19:38:32 2010 +0100 +++ b/tool/CommandUpload.cpp Fri Feb 05 10:29:47 2010 +0100 @@ -51,7 +51,7 @@ << 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 @@ 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::printRawData( - const uint8_t *data, - unsigned int size - ) + const uint8_t *data, + unsigned int size + ) { cout << hex << setfill('0'); while (size--) { diff -r 5b04770444df -r 742607c464c4 tool/CommandUpload.h --- a/tool/CommandUpload.h Tue Feb 02 19:38:32 2010 +0100 +++ b/tool/CommandUpload.h Fri Feb 05 10:29:47 2010 +0100 @@ -44,7 +44,7 @@ void execute(MasterDevice &, const StringVector &); protected: - enum {DefaultBufferSize = 64 * 1024}; + enum {DefaultBufferSize = 64 * 1024}; static void printRawData(const uint8_t *, unsigned int); }; diff -r 5b04770444df -r 742607c464c4 tool/CommandVersion.cpp --- a/tool/CommandVersion.cpp Tue Feb 02 19:38:32 2010 +0100 +++ b/tool/CommandVersion.cpp Fri Feb 05 10:29:47 2010 +0100 @@ -45,11 +45,11 @@ { stringstream str; - str << getName() << " [OPTIONS]" << endl - << endl - << getBriefDescription() << endl; + str << getName() << " [OPTIONS]" << endl + << endl + << getBriefDescription() << endl; - return str.str(); + return str.str(); } /****************************************************************************/ diff -r 5b04770444df -r 742607c464c4 tool/FoeCommand.cpp --- a/tool/FoeCommand.cpp Tue Feb 02 19:38:32 2010 +0100 +++ b/tool/FoeCommand.cpp Fri Feb 05 10:29:47 2010 +0100 @@ -41,49 +41,49 @@ 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 @@ return "No rights."; case 0x0000800b: return "Program Error."; - default: - return "Unknown error code"; - } + default: + return "Unknown error code"; + } } /****************************************************************************/ diff -r 5b04770444df -r 742607c464c4 tool/FoeCommand.h --- a/tool/FoeCommand.h Tue Feb 02 19:38:32 2010 +0100 +++ b/tool/FoeCommand.h Fri Feb 05 10:29:47 2010 +0100 @@ -41,8 +41,8 @@ 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); }; /****************************************************************************/ diff -r 5b04770444df -r 742607c464c4 tool/MasterDevice.cpp --- a/tool/MasterDevice.cpp Tue Feb 02 19:38:32 2010 +0100 +++ b/tool/MasterDevice.cpp Fri Feb 05 10:29:47 2010 +0100 @@ -69,15 +69,15 @@ stringstream deviceName; if (fd == -1) { // not already open - 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); - } + 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); + } } } @@ -86,9 +86,9 @@ void MasterDevice::close() { if (fd != -1) { - ::close(fd); - fd = -1; - } + ::close(fd); + fd = -1; + } } /****************************************************************************/ @@ -427,7 +427,7 @@ stringstream err; err << "Failed to set debug level: " << strerror(errno); throw MasterDeviceException(err); - } + } } /****************************************************************************/ @@ -442,7 +442,7 @@ err << "Failed to download SDO: " << strerror(errno); throw MasterDeviceException(err); } - } + } } /****************************************************************************/ diff -r 5b04770444df -r 742607c464c4 tool/MasterDevice.h --- a/tool/MasterDevice.h Tue Feb 02 19:38:32 2010 +0100 +++ b/tool/MasterDevice.h Fri Feb 05 10:29:47 2010 +0100 @@ -83,7 +83,7 @@ ~MasterDevice(); void setIndex(unsigned int); - unsigned int getIndex() const; + unsigned int getIndex() const; enum Permissions {Read, ReadWrite}; void open(Permissions); @@ -111,11 +111,11 @@ 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 @@ inline unsigned int MasterDevice::getIndex() const { - return index; + return index; } /****************************************************************************/ diff -r 5b04770444df -r 742607c464c4 tool/main.cpp --- a/tool/main.cpp Tue Feb 02 19:38:32 2010 +0100 +++ b/tool/main.cpp Fri Feb 05 10:29:47 2010 +0100 @@ -99,7 +99,7 @@ str << "Usage: " << binaryBaseName << " [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 @@ } str << endl - << "Global options:" << endl + << "Global options:" << endl << " --master -m 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 @@ } while (c != -1); - argCount = argc - optind; + argCount = argc - optind; if (!argCount) { if (helpRequested) { @@ -250,7 +250,7 @@ << endl << usage(); exit(1); } - } + } commandName = argv[optind]; while (++optind < argc) @@ -320,7 +320,7 @@ 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 @@ retval = 1; } - return retval; + return retval; } /****************************************************************************/