merge.
This commit is contained in:
commit
f413575d7f
|
|
@ -7,6 +7,7 @@ syntax: glob
|
||||||
**.o
|
**.o
|
||||||
**.o.cmd
|
**.o.cmd
|
||||||
**.swp
|
**.swp
|
||||||
|
**/.tmp_*.gcno
|
||||||
**~
|
**~
|
||||||
.tmp_versions
|
.tmp_versions
|
||||||
ChangeLog
|
ChangeLog
|
||||||
|
|
|
||||||
6
NEWS
6
NEWS
|
|
@ -27,9 +27,11 @@ Changes since 1.4.0:
|
||||||
- Added e100 driver for 2.6.29, thanks to Andre Puschmann.
|
- Added e100 driver for 2.6.29, thanks to Andre Puschmann.
|
||||||
- Added e100 driver for 2.6.31.
|
- Added e100 driver for 2.6.31.
|
||||||
* Added 8139too driver for kernels 2.6.25 (F. Pose), 2.6.26 (M. Luescher),
|
* Added 8139too driver for kernels 2.6.25 (F. Pose), 2.6.26 (M. Luescher),
|
||||||
2.6.27, 2.6.28 and 2.6.29 (M. Goetze).
|
2.6.27, 2.6.28, 2.6.29 (M. Goetze), 2.6.31 (F. Pose) and 2.6.34 (Malcolm
|
||||||
|
Lewis).
|
||||||
* Added e1000 driver for 2.6.26 (M. Luescher) and 2.6.27.
|
* Added e1000 driver for 2.6.26 (M. Luescher) and 2.6.27.
|
||||||
* Added r8169 driver for 2.6.24, 2.6.27, 2.6.28, 2.6.29 and 2.6.31.
|
* Added r8169 driver for 2.6.24, 2.6.27, 2.6.28, 2.6.29, 2.6.31 and 2.6.32
|
||||||
|
(latter thanks to Robbie K).
|
||||||
* Debug interfaces are created with the Ethernet addresses of the attached
|
* Debug interfaces are created with the Ethernet addresses of the attached
|
||||||
physical device.
|
physical device.
|
||||||
* Improved error case return codes of many functions.
|
* Improved error case return codes of many functions.
|
||||||
|
|
|
||||||
11
TODO
11
TODO
|
|
@ -13,23 +13,15 @@ Version 1.5.0:
|
||||||
* Ethernet drivers:
|
* Ethernet drivers:
|
||||||
- Fix link detection in generic driver.
|
- Fix link detection in generic driver.
|
||||||
- Add native drivers from 2.6.24 up to 2.6.31.
|
- Add native drivers from 2.6.24 up to 2.6.31.
|
||||||
* ethercat tool:
|
|
||||||
- Output error after usage.
|
|
||||||
* Fix casting away constness during expected WC calculation.
|
|
||||||
* Include SoE drive_no in ethercat tool.
|
|
||||||
|
|
||||||
Future issues:
|
Future issues:
|
||||||
|
|
||||||
* Remove allow_scanning flag.
|
* Remove allow_scanning flag.
|
||||||
* Output skipped datagrams again.
|
|
||||||
* Check for Enable SDO Complete Access flag.
|
* Check for Enable SDO Complete Access flag.
|
||||||
* Do not output 'SDO does not exist' when querying data type.
|
* Do not output 'SDO does not exist' when querying data type.
|
||||||
* Always write down PDO assignment/mapping in doubt? If not, add an interface
|
|
||||||
for enforcing this.
|
|
||||||
* Read AL status code on spontaneous state change.
|
* Read AL status code on spontaneous state change.
|
||||||
* recompile tool/CommandVersion.cpp if revision changes.
|
* recompile tool/CommandVersion.cpp if revision changes.
|
||||||
* Log SoE IDNs with real name ([SP]-x-yyyy).
|
* Log SoE IDNs with real name ([SP]-x-yyyy).
|
||||||
* Output SoE IDN configurations in 'ethercat config'.
|
|
||||||
* Only output watchdog config if not default.
|
* Only output watchdog config if not default.
|
||||||
* Implement CompleteAccess for SDO uploads.
|
* Implement CompleteAccess for SDO uploads.
|
||||||
* Output warning when send_ext() is called in illegal context.
|
* Output warning when send_ext() is called in illegal context.
|
||||||
|
|
@ -73,9 +65,12 @@ Future issues:
|
||||||
- Implement indent in 'ethercat ma'
|
- Implement indent in 'ethercat ma'
|
||||||
- Implement 0xXXXX:YY format for specifying SDOs.
|
- Implement 0xXXXX:YY format for specifying SDOs.
|
||||||
- Implement reading from stream for soe_write.
|
- Implement reading from stream for soe_write.
|
||||||
|
- Output error after usage.
|
||||||
* Simplify master fsm by introducing a common request state to handle external
|
* Simplify master fsm by introducing a common request state to handle external
|
||||||
requests (replace write_sii, sdo_request, etc).
|
requests (replace write_sii, sdo_request, etc).
|
||||||
* Remove stdio uses in userspace library?
|
* Remove stdio uses in userspace library?
|
||||||
|
* Fix casting away constness during expected WC calculation.
|
||||||
|
* Fix bus scan hang when calling ecrt_master_deactivate().
|
||||||
|
|
||||||
Smaller issues:
|
Smaller issues:
|
||||||
|
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
|
@ -59,6 +59,8 @@ noinst_HEADERS = \
|
||||||
8139too-2.6.29-orig.c \
|
8139too-2.6.29-orig.c \
|
||||||
8139too-2.6.31-ethercat.c \
|
8139too-2.6.31-ethercat.c \
|
||||||
8139too-2.6.31-orig.c \
|
8139too-2.6.31-orig.c \
|
||||||
|
8139too-2.6.34-ethercat.c \
|
||||||
|
8139too-2.6.34-orig.c \
|
||||||
e100-2.6.20-ethercat.c \
|
e100-2.6.20-ethercat.c \
|
||||||
e100-2.6.20-orig.c \
|
e100-2.6.20-orig.c \
|
||||||
e100-2.6.24-ethercat.c \
|
e100-2.6.24-ethercat.c \
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
|
@ -33,6 +33,6 @@ noinst_PROGRAMS = ec_dc_user_example
|
||||||
|
|
||||||
ec_dc_user_example_SOURCES = main.c
|
ec_dc_user_example_SOURCES = main.c
|
||||||
ec_dc_user_example_CFLAGS = -I$(top_srcdir)/include
|
ec_dc_user_example_CFLAGS = -I$(top_srcdir)/include
|
||||||
ec_dc_user_example_LDFLAGS = -L$(top_builddir)/lib/.libs -lethercat
|
ec_dc_user_example_LDFLAGS = -L$(top_builddir)/lib/.libs -lethercat -lrt
|
||||||
|
|
||||||
#------------------------------------------------------------------------------
|
#------------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
|
@ -35,6 +35,9 @@
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
#include <time.h>
|
||||||
|
#include <sys/mman.h>
|
||||||
|
#include <malloc.h>
|
||||||
|
|
||||||
/****************************************************************************/
|
/****************************************************************************/
|
||||||
|
|
||||||
|
|
@ -43,12 +46,20 @@
|
||||||
/****************************************************************************/
|
/****************************************************************************/
|
||||||
|
|
||||||
// Application parameters
|
// Application parameters
|
||||||
#define FREQUENCY 100
|
#define FREQUENCY 1000
|
||||||
#define PRIORITY 1
|
#define CLOCK_TO_USE CLOCK_REALTIME
|
||||||
|
#define MEASURE_TIMING
|
||||||
|
|
||||||
// Optional features
|
/****************************************************************************/
|
||||||
#define CONFIGURE_PDOS 1
|
|
||||||
|
|
||||||
|
#define NSEC_PER_SEC (1000000000L)
|
||||||
|
#define PERIOD_NS (NSEC_PER_SEC / FREQUENCY)
|
||||||
|
|
||||||
|
#define DIFF_NS(A, B) (((B).tv_sec - (A).tv_sec) * NSEC_PER_SEC + \
|
||||||
|
(B).tv_nsec - (A).tv_nsec)
|
||||||
|
|
||||||
|
#define TIMESPEC2NS(T) ((uint64_t) (T).tv_sec * NSEC_PER_SEC + (T).tv_nsec)
|
||||||
|
|
||||||
/****************************************************************************/
|
/****************************************************************************/
|
||||||
|
|
||||||
// EtherCAT
|
// EtherCAT
|
||||||
|
|
@ -58,10 +69,6 @@ static ec_master_state_t master_state = {};
|
||||||
static ec_domain_t *domain1 = NULL;
|
static ec_domain_t *domain1 = NULL;
|
||||||
static ec_domain_state_t domain1_state = {};
|
static ec_domain_state_t domain1_state = {};
|
||||||
|
|
||||||
// Timer
|
|
||||||
static unsigned int sig_alarms = 0;
|
|
||||||
static unsigned int user_alarms = 0;
|
|
||||||
|
|
||||||
/****************************************************************************/
|
/****************************************************************************/
|
||||||
|
|
||||||
// process data
|
// process data
|
||||||
|
|
@ -81,10 +88,26 @@ static int off_counter_in;
|
||||||
static int off_counter_out;
|
static int off_counter_out;
|
||||||
|
|
||||||
static unsigned int counter = 0;
|
static unsigned int counter = 0;
|
||||||
static unsigned int blink_counter = 0;
|
|
||||||
static unsigned int blink = 0;
|
static unsigned int blink = 0;
|
||||||
static unsigned int sync_ref_counter = 0;
|
static unsigned int sync_ref_counter = 0;
|
||||||
struct timeval app_time;
|
const struct timespec cycletime = {0, PERIOD_NS};
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
struct timespec timespec_add(struct timespec time1, struct timespec time2)
|
||||||
|
{
|
||||||
|
struct timespec result;
|
||||||
|
|
||||||
|
if ((time1.tv_nsec + time2.tv_nsec) >= NSEC_PER_SEC) {
|
||||||
|
result.tv_sec = time1.tv_sec + time2.tv_sec + 1;
|
||||||
|
result.tv_nsec = time1.tv_nsec + time2.tv_nsec - NSEC_PER_SEC;
|
||||||
|
} else {
|
||||||
|
result.tv_sec = time1.tv_sec + time2.tv_sec;
|
||||||
|
result.tv_nsec = time1.tv_nsec + time2.tv_nsec;
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
|
@ -110,7 +133,7 @@ void check_master_state(void)
|
||||||
|
|
||||||
ecrt_master_state(master, &ms);
|
ecrt_master_state(master, &ms);
|
||||||
|
|
||||||
if (ms.slaves_responding != master_state.slaves_responding)
|
if (ms.slaves_responding != master_state.slaves_responding)
|
||||||
printf("%u slave(s).\n", ms.slaves_responding);
|
printf("%u slave(s).\n", ms.slaves_responding);
|
||||||
if (ms.al_states != master_state.al_states)
|
if (ms.al_states != master_state.al_states)
|
||||||
printf("AL states: 0x%02X.\n", ms.al_states);
|
printf("AL states: 0x%02X.\n", ms.al_states);
|
||||||
|
|
@ -124,68 +147,108 @@ void check_master_state(void)
|
||||||
|
|
||||||
void cyclic_task()
|
void cyclic_task()
|
||||||
{
|
{
|
||||||
int i;
|
struct timespec wakeupTime, time;
|
||||||
|
#ifdef MEASURE_TIMING
|
||||||
|
struct timespec startTime, endTime, lastStartTime = {};
|
||||||
|
uint32_t period_ns = 0, exec_ns = 0, latency_ns = 0,
|
||||||
|
latency_min_ns = 0, latency_max_ns = 0,
|
||||||
|
period_min_ns = 0, period_max_ns = 0,
|
||||||
|
exec_min_ns = 0, exec_max_ns = 0;
|
||||||
|
#endif
|
||||||
|
|
||||||
// receive process data
|
// get current time
|
||||||
ecrt_master_receive(master);
|
clock_gettime(CLOCK_TO_USE, &wakeupTime);
|
||||||
ecrt_domain_process(domain1);
|
|
||||||
|
|
||||||
// check process data state (optional)
|
while(1) {
|
||||||
check_domain1_state();
|
wakeupTime = timespec_add(wakeupTime, cycletime);
|
||||||
|
clock_nanosleep(CLOCK_TO_USE, TIMER_ABSTIME, &wakeupTime, NULL);
|
||||||
|
|
||||||
if (counter) {
|
#ifdef MEASURE_TIMING
|
||||||
counter--;
|
clock_gettime(CLOCK_TO_USE, &startTime);
|
||||||
} else { // do this at 1 Hz
|
latency_ns = DIFF_NS(wakeupTime, startTime);
|
||||||
counter = FREQUENCY;
|
period_ns = DIFF_NS(lastStartTime, startTime);
|
||||||
|
exec_ns = DIFF_NS(lastStartTime, endTime);
|
||||||
|
lastStartTime = startTime;
|
||||||
|
|
||||||
// calculate new process data
|
if (latency_ns > latency_max_ns) {
|
||||||
blink = !blink;
|
latency_max_ns = latency_ns;
|
||||||
|
}
|
||||||
|
if (latency_ns < latency_min_ns) {
|
||||||
|
latency_min_ns = latency_ns;
|
||||||
|
}
|
||||||
|
if (period_ns > period_max_ns) {
|
||||||
|
period_max_ns = period_ns;
|
||||||
|
}
|
||||||
|
if (period_ns < period_min_ns) {
|
||||||
|
period_min_ns = period_ns;
|
||||||
|
}
|
||||||
|
if (exec_ns > exec_max_ns) {
|
||||||
|
exec_max_ns = exec_ns;
|
||||||
|
}
|
||||||
|
if (exec_ns < exec_min_ns) {
|
||||||
|
exec_min_ns = exec_ns;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
// check for master state (optional)
|
// receive process data
|
||||||
check_master_state();
|
ecrt_master_receive(master);
|
||||||
}
|
ecrt_domain_process(domain1);
|
||||||
|
|
||||||
if (blink_counter) {
|
// check process data state (optional)
|
||||||
blink_counter--;
|
check_domain1_state();
|
||||||
} else {
|
|
||||||
blink_counter = 9;
|
|
||||||
|
|
||||||
// calculate new process data
|
if (counter) {
|
||||||
blink = !blink;
|
counter--;
|
||||||
}
|
} else { // do this at 1 Hz
|
||||||
|
counter = FREQUENCY;
|
||||||
|
|
||||||
// write process data
|
// check for master state (optional)
|
||||||
EC_WRITE_U8(domain1_pd + off_dig_out, blink ? 0x66 : 0x99);
|
check_master_state();
|
||||||
EC_WRITE_U8(domain1_pd + off_counter_out, blink ? 0x00 : 0x02);
|
|
||||||
|
|
||||||
app_time.tv_usec += 1000000 / FREQUENCY;
|
#ifdef MEASURE_TIMING
|
||||||
if (app_time.tv_usec >= 1000000) {
|
// output timing stats
|
||||||
app_time.tv_usec -= 1000000;
|
printf("period %10u ... %10u\n",
|
||||||
app_time.tv_sec++;
|
period_min_ns, period_max_ns);
|
||||||
}
|
printf("exec %10u ... %10u\n",
|
||||||
ecrt_master_application_time(master, EC_TIMEVAL2NANO(app_time));
|
exec_min_ns, exec_max_ns);
|
||||||
|
printf("latency %10u ... %10u\n",
|
||||||
|
latency_min_ns, latency_max_ns);
|
||||||
|
period_max_ns = 0;
|
||||||
|
period_min_ns = 0xffffffff;
|
||||||
|
exec_max_ns = 0;
|
||||||
|
exec_min_ns = 0xffffffff;
|
||||||
|
latency_max_ns = 0;
|
||||||
|
latency_min_ns = 0xffffffff;
|
||||||
|
#endif
|
||||||
|
|
||||||
if (sync_ref_counter) {
|
// calculate new process data
|
||||||
sync_ref_counter--;
|
blink = !blink;
|
||||||
} else {
|
}
|
||||||
sync_ref_counter = 9;
|
|
||||||
ecrt_master_sync_reference_clock(master);
|
|
||||||
}
|
|
||||||
ecrt_master_sync_slave_clocks(master);
|
|
||||||
|
|
||||||
// send process data
|
// write process data
|
||||||
ecrt_domain_queue(domain1);
|
EC_WRITE_U8(domain1_pd + off_dig_out, blink ? 0x66 : 0x99);
|
||||||
ecrt_master_send(master);
|
EC_WRITE_U8(domain1_pd + off_counter_out, blink ? 0x00 : 0x02);
|
||||||
}
|
|
||||||
|
|
||||||
/****************************************************************************/
|
// write application time to master
|
||||||
|
clock_gettime(CLOCK_TO_USE, &time);
|
||||||
|
ecrt_master_application_time(master, TIMESPEC2NS(time));
|
||||||
|
|
||||||
void signal_handler(int signum) {
|
if (sync_ref_counter) {
|
||||||
switch (signum) {
|
sync_ref_counter--;
|
||||||
case SIGALRM:
|
} else {
|
||||||
sig_alarms++;
|
sync_ref_counter = 1; // sync every cycle
|
||||||
break;
|
ecrt_master_sync_reference_clock(master);
|
||||||
}
|
}
|
||||||
|
ecrt_master_sync_slave_clocks(master);
|
||||||
|
|
||||||
|
// send process data
|
||||||
|
ecrt_domain_queue(domain1);
|
||||||
|
ecrt_master_send(master);
|
||||||
|
|
||||||
|
#ifdef MEASURE_TIMING
|
||||||
|
clock_gettime(CLOCK_TO_USE, &endTime);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************/
|
/****************************************************************************/
|
||||||
|
|
@ -193,8 +256,11 @@ void signal_handler(int signum) {
|
||||||
int main(int argc, char **argv)
|
int main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
ec_slave_config_t *sc;
|
ec_slave_config_t *sc;
|
||||||
struct sigaction sa;
|
|
||||||
struct itimerval tv;
|
if (mlockall(MCL_CURRENT | MCL_FUTURE) == -1) {
|
||||||
|
perror("mlockall failed");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
master = ecrt_request_master(0);
|
master = ecrt_request_master(0);
|
||||||
if (!master)
|
if (!master)
|
||||||
|
|
@ -237,7 +303,7 @@ int main(int argc, char **argv)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
// configure SYNC signals for this slave
|
// configure SYNC signals for this slave
|
||||||
ecrt_slave_config_dc(sc, 0x0700, 10000000, 4400000, 0, 0);
|
ecrt_slave_config_dc(sc, 0x0700, PERIOD_NS, 4400000, 0, 0);
|
||||||
|
|
||||||
printf("Activating master...\n");
|
printf("Activating master...\n");
|
||||||
if (ecrt_master_activate(master))
|
if (ecrt_master_activate(master))
|
||||||
|
|
@ -247,50 +313,15 @@ int main(int argc, char **argv)
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if PRIORITY
|
|
||||||
pid_t pid = getpid();
|
pid_t pid = getpid();
|
||||||
if (setpriority(PRIO_PROCESS, pid, -19))
|
if (setpriority(PRIO_PROCESS, pid, -19))
|
||||||
fprintf(stderr, "Warning: Failed to set priority: %s\n",
|
fprintf(stderr, "Warning: Failed to set priority: %s\n",
|
||||||
strerror(errno));
|
strerror(errno));
|
||||||
#endif
|
|
||||||
|
|
||||||
sa.sa_handler = signal_handler;
|
printf("Starting cyclic function.\n");
|
||||||
sigemptyset(&sa.sa_mask);
|
cyclic_task();
|
||||||
sa.sa_flags = 0;
|
|
||||||
if (sigaction(SIGALRM, &sa, 0)) {
|
return 0;
|
||||||
fprintf(stderr, "Failed to install signal handler!\n");
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
printf("Starting timer...\n");
|
|
||||||
tv.it_interval.tv_sec = 0;
|
|
||||||
tv.it_interval.tv_usec = 1000000 / FREQUENCY;
|
|
||||||
tv.it_value.tv_sec = 0;
|
|
||||||
tv.it_value.tv_usec = 1000;
|
|
||||||
if (setitimer(ITIMER_REAL, &tv, NULL)) {
|
|
||||||
fprintf(stderr, "Failed to start timer: %s\n", strerror(errno));
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
gettimeofday(&app_time, NULL);
|
|
||||||
|
|
||||||
printf("Started.\n");
|
|
||||||
while (1) {
|
|
||||||
pause();
|
|
||||||
|
|
||||||
#if 0
|
|
||||||
struct timeval t;
|
|
||||||
gettimeofday(&t, NULL);
|
|
||||||
printf("%u.%06u\n", t.tv_sec, t.tv_usec);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
while (sig_alarms != user_alarms) {
|
|
||||||
cyclic_task();
|
|
||||||
user_alarms++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************/
|
/****************************************************************************/
|
||||||
|
|
|
||||||
|
|
@ -33,6 +33,10 @@
|
||||||
#include <linux/interrupt.h>
|
#include <linux/interrupt.h>
|
||||||
#include <linux/err.h>
|
#include <linux/err.h>
|
||||||
|
|
||||||
|
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 34)
|
||||||
|
#include <linux/slab.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27)
|
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27)
|
||||||
#include <linux/semaphore.h>
|
#include <linux/semaphore.h>
|
||||||
#else
|
#else
|
||||||
|
|
|
||||||
|
|
@ -30,6 +30,7 @@
|
||||||
#include <linux/module.h>
|
#include <linux/module.h>
|
||||||
#include <linux/err.h>
|
#include <linux/err.h>
|
||||||
#include <linux/termios.h>
|
#include <linux/termios.h>
|
||||||
|
#include <linux/slab.h>
|
||||||
|
|
||||||
#include "../../include/ecrt.h" // EtherCAT realtime interface
|
#include "../../include/ecrt.h" // EtherCAT realtime interface
|
||||||
#include "../../include/ectty.h" // EtherCAT TTY interface
|
#include "../../include/ectty.h" // EtherCAT TTY interface
|
||||||
|
|
|
||||||
|
|
@ -78,6 +78,7 @@
|
||||||
* - Added ecrt_slave_config_idn() method for storing SoE IDN configurations,
|
* - Added ecrt_slave_config_idn() method for storing SoE IDN configurations,
|
||||||
* and ecrt_master_read_idn() and ecrt_master_write_idn() to read/write IDNs
|
* and ecrt_master_read_idn() and ecrt_master_write_idn() to read/write IDNs
|
||||||
* ad-hoc via the user-space library.
|
* ad-hoc via the user-space library.
|
||||||
|
* - Added ecrt_master_reset() to initiate retrying to configure slaves.
|
||||||
*
|
*
|
||||||
* @{
|
* @{
|
||||||
*/
|
*/
|
||||||
|
|
@ -859,6 +860,17 @@ uint32_t ecrt_master_sync_monitor_process(
|
||||||
ec_master_t *master /**< EtherCAT master. */
|
ec_master_t *master /**< EtherCAT master. */
|
||||||
);
|
);
|
||||||
|
|
||||||
|
/** Retry configuring slaves.
|
||||||
|
*
|
||||||
|
* Via this method, the application can tell the master to bring all slaves to
|
||||||
|
* OP state. In general, this is not necessary, because it is automatically
|
||||||
|
* done by the master. But with special slaves, that can be reconfigured by
|
||||||
|
* the vendor during runtime, it can be useful.
|
||||||
|
*/
|
||||||
|
void ecrt_master_reset(
|
||||||
|
ec_master_t *master /**< EtherCAT master. */
|
||||||
|
);
|
||||||
|
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
* Slave configuration methods
|
* Slave configuration methods
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
|
||||||
|
|
@ -35,7 +35,7 @@ lib_LTLIBRARIES = libethercat.la
|
||||||
#------------------------------------------------------------------------------
|
#------------------------------------------------------------------------------
|
||||||
|
|
||||||
libethercat_la_LDFLAGS = -version-info 1:0:0
|
libethercat_la_LDFLAGS = -version-info 1:0:0
|
||||||
libethercat_la_CFLAGS = -I$(srcdir)/..
|
libethercat_la_CFLAGS = -I$(srcdir)/.. -fno-strict-aliasing
|
||||||
libethercat_la_SOURCES = \
|
libethercat_la_SOURCES = \
|
||||||
common.c \
|
common.c \
|
||||||
domain.c \
|
domain.c \
|
||||||
|
|
|
||||||
|
|
@ -37,6 +37,8 @@
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <sys/ioctl.h>
|
#include <sys/ioctl.h>
|
||||||
#include <sys/mman.h>
|
#include <sys/mman.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <sys/socket.h>
|
||||||
|
|
||||||
#include "master.h"
|
#include "master.h"
|
||||||
#include "master/ioctl.h"
|
#include "master/ioctl.h"
|
||||||
|
|
|
||||||
10
lib/master.c
10
lib/master.c
|
|
@ -49,6 +49,7 @@ int ecrt_master_reserve(ec_master_t *master)
|
||||||
strerror(errno));
|
strerror(errno));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
@ -571,3 +572,12 @@ uint32_t ecrt_master_sync_monitor_process(ec_master_t *master)
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
void ecrt_master_reset(ec_master_t *master)
|
||||||
|
{
|
||||||
|
if (ioctl(master->fd, EC_IOCTL_RESET, NULL) == -1) {
|
||||||
|
fprintf(stderr, "Failed to reset master: %s\n", strerror(errno));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
|
||||||
|
|
@ -1349,6 +1349,7 @@ int ec_cdev_ioctl_config(
|
||||||
data.watchdog_divider = sc->watchdog_divider;
|
data.watchdog_divider = sc->watchdog_divider;
|
||||||
data.watchdog_intervals = sc->watchdog_intervals;
|
data.watchdog_intervals = sc->watchdog_intervals;
|
||||||
data.sdo_count = ec_slave_config_sdo_count(sc);
|
data.sdo_count = ec_slave_config_sdo_count(sc);
|
||||||
|
data.idn_count = ec_slave_config_idn_count(sc);
|
||||||
data.slave_position = sc->slave ? sc->slave->ring_position : -1;
|
data.slave_position = sc->slave ? sc->slave->ring_position : -1;
|
||||||
data.dc_assign_activate = sc->dc_assign_activate;
|
data.dc_assign_activate = sc->dc_assign_activate;
|
||||||
for (i = 0; i < EC_SYNC_SIGNAL_COUNT; i++) {
|
for (i = 0; i < EC_SYNC_SIGNAL_COUNT; i++) {
|
||||||
|
|
@ -1531,6 +1532,56 @@ int ec_cdev_ioctl_config_sdo(
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
/** Get slave configuration IDN information.
|
||||||
|
*/
|
||||||
|
int ec_cdev_ioctl_config_idn(
|
||||||
|
ec_master_t *master, /**< EtherCAT master. */
|
||||||
|
unsigned long arg /**< ioctl() argument. */
|
||||||
|
)
|
||||||
|
{
|
||||||
|
ec_ioctl_config_idn_t data;
|
||||||
|
const ec_slave_config_t *sc;
|
||||||
|
const ec_soe_request_t *req;
|
||||||
|
|
||||||
|
if (copy_from_user(&data, (void __user *) arg, sizeof(data))) {
|
||||||
|
return -EFAULT;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (down_interruptible(&master->master_sem))
|
||||||
|
return -EINTR;
|
||||||
|
|
||||||
|
if (!(sc = ec_master_get_config_const(
|
||||||
|
master, data.config_index))) {
|
||||||
|
up(&master->master_sem);
|
||||||
|
EC_MASTER_ERR(master, "Slave config %u does not exist!\n",
|
||||||
|
data.config_index);
|
||||||
|
return -EINVAL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!(req = ec_slave_config_get_idn_by_pos_const(
|
||||||
|
sc, data.idn_pos))) {
|
||||||
|
up(&master->master_sem);
|
||||||
|
EC_MASTER_ERR(master, "Invalid IDN position!\n");
|
||||||
|
return -EINVAL;
|
||||||
|
}
|
||||||
|
|
||||||
|
data.drive_no = req->drive_no;
|
||||||
|
data.idn = req->idn;
|
||||||
|
data.state = req->state;
|
||||||
|
data.size = req->data_size;
|
||||||
|
memcpy(&data.data, req->data,
|
||||||
|
min((u32) data.size, (u32) EC_MAX_IDN_DATA_SIZE));
|
||||||
|
|
||||||
|
up(&master->master_sem);
|
||||||
|
|
||||||
|
if (copy_to_user((void __user *) arg, &data, sizeof(data)))
|
||||||
|
return -EFAULT;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
#ifdef EC_EOE
|
#ifdef EC_EOE
|
||||||
|
|
||||||
/** Get EoE handler information.
|
/** Get EoE handler information.
|
||||||
|
|
@ -1941,6 +1992,25 @@ int ec_cdev_ioctl_sync_mon_process(
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
/** Reset configuration.
|
||||||
|
*/
|
||||||
|
int ec_cdev_ioctl_reset(
|
||||||
|
ec_master_t *master, /**< EtherCAT master. */
|
||||||
|
unsigned long arg, /**< ioctl() argument. */
|
||||||
|
ec_cdev_priv_t *priv /**< Private data structure of file handle. */
|
||||||
|
)
|
||||||
|
{
|
||||||
|
if (unlikely(!priv->requested))
|
||||||
|
return -EPERM;
|
||||||
|
|
||||||
|
down(&master->master_sem);
|
||||||
|
ecrt_master_reset(master);
|
||||||
|
up(&master->master_sem);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
/** Configure a sync manager.
|
/** Configure a sync manager.
|
||||||
*/
|
*/
|
||||||
int ec_cdev_ioctl_sc_sync(
|
int ec_cdev_ioctl_sc_sync(
|
||||||
|
|
@ -3398,7 +3468,7 @@ int ec_cdev_ioctl_slave_soe_write(
|
||||||
|
|
||||||
data = kmalloc(ioctl.data_size, GFP_KERNEL);
|
data = kmalloc(ioctl.data_size, GFP_KERNEL);
|
||||||
if (!data) {
|
if (!data) {
|
||||||
EC_MASTER_ERR(master, "Failed to allocate %u bytes of IDN data.\n",
|
EC_MASTER_ERR(master, "Failed to allocate %zu bytes of IDN data.\n",
|
||||||
ioctl.data_size);
|
ioctl.data_size);
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
}
|
}
|
||||||
|
|
@ -3564,6 +3634,8 @@ long eccdev_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
|
||||||
return ec_cdev_ioctl_config_pdo_entry(master, arg);
|
return ec_cdev_ioctl_config_pdo_entry(master, arg);
|
||||||
case EC_IOCTL_CONFIG_SDO:
|
case EC_IOCTL_CONFIG_SDO:
|
||||||
return ec_cdev_ioctl_config_sdo(master, arg);
|
return ec_cdev_ioctl_config_sdo(master, arg);
|
||||||
|
case EC_IOCTL_CONFIG_IDN:
|
||||||
|
return ec_cdev_ioctl_config_idn(master, arg);
|
||||||
#ifdef EC_EOE
|
#ifdef EC_EOE
|
||||||
case EC_IOCTL_EOE_HANDLER:
|
case EC_IOCTL_EOE_HANDLER:
|
||||||
return ec_cdev_ioctl_eoe_handler(master, arg);
|
return ec_cdev_ioctl_eoe_handler(master, arg);
|
||||||
|
|
@ -3618,6 +3690,10 @@ long eccdev_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
|
||||||
if (!(filp->f_mode & FMODE_WRITE))
|
if (!(filp->f_mode & FMODE_WRITE))
|
||||||
return -EPERM;
|
return -EPERM;
|
||||||
return ec_cdev_ioctl_sync_mon_process(master, arg, priv);
|
return ec_cdev_ioctl_sync_mon_process(master, arg, priv);
|
||||||
|
case EC_IOCTL_RESET:
|
||||||
|
if (!(filp->f_mode & FMODE_WRITE))
|
||||||
|
return -EPERM;
|
||||||
|
return ec_cdev_ioctl_reset(master, arg, priv);
|
||||||
case EC_IOCTL_SC_SYNC:
|
case EC_IOCTL_SC_SYNC:
|
||||||
if (!(filp->f_mode & FMODE_WRITE))
|
if (!(filp->f_mode & FMODE_WRITE))
|
||||||
return -EPERM;
|
return -EPERM;
|
||||||
|
|
|
||||||
|
|
@ -39,6 +39,7 @@
|
||||||
|
|
||||||
#include <linux/list.h>
|
#include <linux/list.h>
|
||||||
#include <linux/netdevice.h>
|
#include <linux/netdevice.h>
|
||||||
|
#include <linux/semaphore.h>
|
||||||
|
|
||||||
#include "globals.h"
|
#include "globals.h"
|
||||||
#include "slave.h"
|
#include "slave.h"
|
||||||
|
|
|
||||||
|
|
@ -35,6 +35,7 @@
|
||||||
|
|
||||||
#include <linux/module.h>
|
#include <linux/module.h>
|
||||||
#include <linux/jiffies.h>
|
#include <linux/jiffies.h>
|
||||||
|
#include <linux/slab.h>
|
||||||
|
|
||||||
#include "foe_request.h"
|
#include "foe_request.h"
|
||||||
#include "foe.h"
|
#include "foe.h"
|
||||||
|
|
|
||||||
|
|
@ -42,7 +42,7 @@
|
||||||
|
|
||||||
/** Timeout while waiting for AL state change [s].
|
/** Timeout while waiting for AL state change [s].
|
||||||
*/
|
*/
|
||||||
#define EC_AL_STATE_CHANGE_TIMEOUT 2
|
#define EC_AL_STATE_CHANGE_TIMEOUT 5
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -184,7 +184,8 @@ void ec_fsm_sii_state_start_reading(
|
||||||
EC_WRITE_U16(datagram->data + 2, fsm->word_offset);
|
EC_WRITE_U16(datagram->data + 2, fsm->word_offset);
|
||||||
|
|
||||||
#ifdef SII_DEBUG
|
#ifdef SII_DEBUG
|
||||||
EC_SLAVE_DBG(slave, 0, "reading SII data:\n");
|
EC_SLAVE_DBG(fsm->slave, 0, "reading SII data, word %u:\n",
|
||||||
|
fsm->word_offset);
|
||||||
ec_print_data(datagram->data, 4);
|
ec_print_data(datagram->data, 4);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -505,8 +505,10 @@ void ec_fsm_slave_scan_state_sii_size(ec_fsm_slave_scan_t *fsm /**< slave state
|
||||||
fsm->slave->error_flag = 1;
|
fsm->slave->error_flag = 1;
|
||||||
fsm->state = ec_fsm_slave_scan_state_error;
|
fsm->state = ec_fsm_slave_scan_state_error;
|
||||||
EC_SLAVE_ERR(slave, "Failed to determine SII content size:"
|
EC_SLAVE_ERR(slave, "Failed to determine SII content size:"
|
||||||
" Reading word offset 0x%04x failed.\n", fsm->sii_offset);
|
" Reading word offset 0x%04x failed. Assuming %u words.\n",
|
||||||
return;
|
fsm->sii_offset, EC_FIRST_SII_CATEGORY_OFFSET);
|
||||||
|
slave->sii_nwords = EC_FIRST_SII_CATEGORY_OFFSET;
|
||||||
|
goto alloc_sii;
|
||||||
}
|
}
|
||||||
|
|
||||||
cat_type = EC_READ_U16(fsm->fsm_sii.value);
|
cat_type = EC_READ_U16(fsm->fsm_sii.value);
|
||||||
|
|
|
||||||
117
master/ioctl.h
117
master/ioctl.h
|
|
@ -56,7 +56,7 @@
|
||||||
*
|
*
|
||||||
* Increment this when changing the ioctl interface!
|
* Increment this when changing the ioctl interface!
|
||||||
*/
|
*/
|
||||||
#define EC_IOCTL_VERSION_MAGIC 8
|
#define EC_IOCTL_VERSION_MAGIC 11
|
||||||
|
|
||||||
// Command-line tool
|
// Command-line tool
|
||||||
#define EC_IOCTL_MODULE EC_IOR(0x00, ec_ioctl_module_t)
|
#define EC_IOCTL_MODULE EC_IOR(0x00, ec_ioctl_module_t)
|
||||||
|
|
@ -87,54 +87,56 @@
|
||||||
#define EC_IOCTL_CONFIG_PDO EC_IOWR(0x19, ec_ioctl_config_pdo_t)
|
#define EC_IOCTL_CONFIG_PDO EC_IOWR(0x19, ec_ioctl_config_pdo_t)
|
||||||
#define EC_IOCTL_CONFIG_PDO_ENTRY EC_IOWR(0x1a, ec_ioctl_config_pdo_entry_t)
|
#define EC_IOCTL_CONFIG_PDO_ENTRY EC_IOWR(0x1a, ec_ioctl_config_pdo_entry_t)
|
||||||
#define EC_IOCTL_CONFIG_SDO EC_IOWR(0x1b, ec_ioctl_config_sdo_t)
|
#define EC_IOCTL_CONFIG_SDO EC_IOWR(0x1b, ec_ioctl_config_sdo_t)
|
||||||
|
#define EC_IOCTL_CONFIG_IDN EC_IOWR(0x1c, ec_ioctl_config_idn_t)
|
||||||
#ifdef EC_EOE
|
#ifdef EC_EOE
|
||||||
#define EC_IOCTL_EOE_HANDLER EC_IOWR(0x1c, ec_ioctl_eoe_handler_t)
|
#define EC_IOCTL_EOE_HANDLER EC_IOWR(0x1d, ec_ioctl_eoe_handler_t)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Application interface
|
// Application interface
|
||||||
#define EC_IOCTL_REQUEST EC_IO(0x1d)
|
#define EC_IOCTL_REQUEST EC_IO(0x1e)
|
||||||
#define EC_IOCTL_CREATE_DOMAIN EC_IO(0x1e)
|
#define EC_IOCTL_CREATE_DOMAIN EC_IO(0x1f)
|
||||||
#define EC_IOCTL_CREATE_SLAVE_CONFIG EC_IOWR(0x1f, ec_ioctl_config_t)
|
#define EC_IOCTL_CREATE_SLAVE_CONFIG EC_IOWR(0x20, ec_ioctl_config_t)
|
||||||
#define EC_IOCTL_ACTIVATE EC_IOR(0x20, size_t)
|
#define EC_IOCTL_ACTIVATE EC_IOR(0x21, size_t)
|
||||||
#define EC_IOCTL_DEACTIVATE EC_IO(0x21)
|
#define EC_IOCTL_DEACTIVATE EC_IO(0x22)
|
||||||
#define EC_IOCTL_SEND EC_IO(0x22)
|
#define EC_IOCTL_SEND EC_IO(0x23)
|
||||||
#define EC_IOCTL_RECEIVE EC_IO(0x23)
|
#define EC_IOCTL_RECEIVE EC_IO(0x24)
|
||||||
#define EC_IOCTL_MASTER_STATE EC_IOR(0x24, ec_master_state_t)
|
#define EC_IOCTL_MASTER_STATE EC_IOR(0x25, ec_master_state_t)
|
||||||
#define EC_IOCTL_APP_TIME EC_IOW(0x25, ec_ioctl_app_time_t)
|
#define EC_IOCTL_APP_TIME EC_IOW(0x26, ec_ioctl_app_time_t)
|
||||||
#define EC_IOCTL_SYNC_REF EC_IO(0x26)
|
#define EC_IOCTL_SYNC_REF EC_IO(0x27)
|
||||||
#define EC_IOCTL_SYNC_SLAVES EC_IO(0x27)
|
#define EC_IOCTL_SYNC_SLAVES EC_IO(0x28)
|
||||||
#define EC_IOCTL_SYNC_MON_QUEUE EC_IO(0x28)
|
#define EC_IOCTL_SYNC_MON_QUEUE EC_IO(0x29)
|
||||||
#define EC_IOCTL_SYNC_MON_PROCESS EC_IOR(0x29, uint32_t)
|
#define EC_IOCTL_SYNC_MON_PROCESS EC_IOR(0x2a, uint32_t)
|
||||||
#define EC_IOCTL_SC_SYNC EC_IOW(0x2a, ec_ioctl_config_t)
|
#define EC_IOCTL_RESET EC_IO(0x2b)
|
||||||
#define EC_IOCTL_SC_WATCHDOG EC_IOW(0x2b, ec_ioctl_config_t)
|
#define EC_IOCTL_SC_SYNC EC_IOW(0x2c, ec_ioctl_config_t)
|
||||||
#define EC_IOCTL_SC_ADD_PDO EC_IOW(0x2c, ec_ioctl_config_pdo_t)
|
#define EC_IOCTL_SC_WATCHDOG EC_IOW(0x2d, ec_ioctl_config_t)
|
||||||
#define EC_IOCTL_SC_CLEAR_PDOS EC_IOW(0x2d, ec_ioctl_config_pdo_t)
|
#define EC_IOCTL_SC_ADD_PDO EC_IOW(0x2e, ec_ioctl_config_pdo_t)
|
||||||
#define EC_IOCTL_SC_ADD_ENTRY EC_IOW(0x2e, ec_ioctl_add_pdo_entry_t)
|
#define EC_IOCTL_SC_CLEAR_PDOS EC_IOW(0x2f, ec_ioctl_config_pdo_t)
|
||||||
#define EC_IOCTL_SC_CLEAR_ENTRIES EC_IOW(0x2f, ec_ioctl_config_pdo_t)
|
#define EC_IOCTL_SC_ADD_ENTRY EC_IOW(0x30, ec_ioctl_add_pdo_entry_t)
|
||||||
#define EC_IOCTL_SC_REG_PDO_ENTRY EC_IOWR(0x20, ec_ioctl_reg_pdo_entry_t)
|
#define EC_IOCTL_SC_CLEAR_ENTRIES EC_IOW(0x31, ec_ioctl_config_pdo_t)
|
||||||
#define EC_IOCTL_SC_DC EC_IOW(0x31, ec_ioctl_config_t)
|
#define EC_IOCTL_SC_REG_PDO_ENTRY EC_IOWR(0x32, ec_ioctl_reg_pdo_entry_t)
|
||||||
#define EC_IOCTL_SC_SDO EC_IOW(0x32, ec_ioctl_sc_sdo_t)
|
#define EC_IOCTL_SC_DC EC_IOW(0x33, ec_ioctl_config_t)
|
||||||
#define EC_IOCTL_SC_SDO_REQUEST EC_IOWR(0x33, ec_ioctl_sdo_request_t)
|
#define EC_IOCTL_SC_SDO EC_IOW(0x34, ec_ioctl_sc_sdo_t)
|
||||||
#define EC_IOCTL_SC_VOE EC_IOWR(0x34, ec_ioctl_voe_t)
|
#define EC_IOCTL_SC_SDO_REQUEST EC_IOWR(0x35, ec_ioctl_sdo_request_t)
|
||||||
#define EC_IOCTL_SC_STATE EC_IOWR(0x35, ec_ioctl_sc_state_t)
|
#define EC_IOCTL_SC_VOE EC_IOWR(0x36, ec_ioctl_voe_t)
|
||||||
#define EC_IOCTL_SC_IDN EC_IOW(0x36, ec_ioctl_sc_idn_t)
|
#define EC_IOCTL_SC_STATE EC_IOWR(0x37, ec_ioctl_sc_state_t)
|
||||||
#define EC_IOCTL_DOMAIN_OFFSET EC_IO(0x37)
|
#define EC_IOCTL_SC_IDN EC_IOW(0x38, ec_ioctl_sc_idn_t)
|
||||||
#define EC_IOCTL_DOMAIN_PROCESS EC_IO(0x38)
|
#define EC_IOCTL_DOMAIN_OFFSET EC_IO(0x39)
|
||||||
#define EC_IOCTL_DOMAIN_QUEUE EC_IO(0x39)
|
#define EC_IOCTL_DOMAIN_PROCESS EC_IO(0x3a)
|
||||||
#define EC_IOCTL_DOMAIN_STATE EC_IOWR(0x3a, ec_ioctl_domain_state_t)
|
#define EC_IOCTL_DOMAIN_QUEUE EC_IO(0x3b)
|
||||||
#define EC_IOCTL_SDO_REQUEST_TIMEOUT EC_IOWR(0x3b, ec_ioctl_sdo_request_t)
|
#define EC_IOCTL_DOMAIN_STATE EC_IOWR(0x3c, ec_ioctl_domain_state_t)
|
||||||
#define EC_IOCTL_SDO_REQUEST_STATE EC_IOWR(0x3c, ec_ioctl_sdo_request_t)
|
#define EC_IOCTL_SDO_REQUEST_TIMEOUT EC_IOWR(0x3d, ec_ioctl_sdo_request_t)
|
||||||
#define EC_IOCTL_SDO_REQUEST_READ EC_IOWR(0x3d, ec_ioctl_sdo_request_t)
|
#define EC_IOCTL_SDO_REQUEST_STATE EC_IOWR(0x3e, ec_ioctl_sdo_request_t)
|
||||||
#define EC_IOCTL_SDO_REQUEST_WRITE EC_IOWR(0x3e, ec_ioctl_sdo_request_t)
|
#define EC_IOCTL_SDO_REQUEST_READ EC_IOWR(0x3f, ec_ioctl_sdo_request_t)
|
||||||
#define EC_IOCTL_SDO_REQUEST_DATA EC_IOWR(0x3f, ec_ioctl_sdo_request_t)
|
#define EC_IOCTL_SDO_REQUEST_WRITE EC_IOWR(0x40, ec_ioctl_sdo_request_t)
|
||||||
#define EC_IOCTL_VOE_SEND_HEADER EC_IOW(0x40, ec_ioctl_voe_t)
|
#define EC_IOCTL_SDO_REQUEST_DATA EC_IOWR(0x41, ec_ioctl_sdo_request_t)
|
||||||
#define EC_IOCTL_VOE_REC_HEADER EC_IOWR(0x41, ec_ioctl_voe_t)
|
#define EC_IOCTL_VOE_SEND_HEADER EC_IOW(0x42, ec_ioctl_voe_t)
|
||||||
#define EC_IOCTL_VOE_READ EC_IOW(0x42, ec_ioctl_voe_t)
|
#define EC_IOCTL_VOE_REC_HEADER EC_IOWR(0x43, ec_ioctl_voe_t)
|
||||||
#define EC_IOCTL_VOE_READ_NOSYNC EC_IOW(0x43, ec_ioctl_voe_t)
|
#define EC_IOCTL_VOE_READ EC_IOW(0x44, ec_ioctl_voe_t)
|
||||||
#define EC_IOCTL_VOE_WRITE EC_IOWR(0x44, ec_ioctl_voe_t)
|
#define EC_IOCTL_VOE_READ_NOSYNC EC_IOW(0x45, ec_ioctl_voe_t)
|
||||||
#define EC_IOCTL_VOE_EXEC EC_IOWR(0x45, ec_ioctl_voe_t)
|
#define EC_IOCTL_VOE_WRITE EC_IOWR(0x46, ec_ioctl_voe_t)
|
||||||
#define EC_IOCTL_VOE_DATA EC_IOWR(0x46, ec_ioctl_voe_t)
|
#define EC_IOCTL_VOE_EXEC EC_IOWR(0x47, ec_ioctl_voe_t)
|
||||||
#define EC_IOCTL_SET_SEND_INTERVAL EC_IOW(0x47, size_t)
|
#define EC_IOCTL_VOE_DATA EC_IOWR(0x48, ec_ioctl_voe_t)
|
||||||
|
#define EC_IOCTL_SET_SEND_INTERVAL EC_IOW(0x49, size_t)
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
|
@ -420,7 +422,7 @@ typedef struct {
|
||||||
uint8_t *data;
|
uint8_t *data;
|
||||||
|
|
||||||
// outputs
|
// outputs
|
||||||
uint32_t data_size;
|
size_t data_size;
|
||||||
uint16_t error_code;
|
uint16_t error_code;
|
||||||
} ec_ioctl_slave_soe_read_t;
|
} ec_ioctl_slave_soe_read_t;
|
||||||
|
|
||||||
|
|
@ -431,7 +433,7 @@ typedef struct {
|
||||||
uint16_t slave_position;
|
uint16_t slave_position;
|
||||||
uint8_t drive_no;
|
uint8_t drive_no;
|
||||||
uint16_t idn;
|
uint16_t idn;
|
||||||
uint32_t data_size;
|
size_t data_size;
|
||||||
uint8_t *data;
|
uint8_t *data;
|
||||||
|
|
||||||
// outputs
|
// outputs
|
||||||
|
|
@ -458,6 +460,7 @@ typedef struct {
|
||||||
uint16_t watchdog_divider;
|
uint16_t watchdog_divider;
|
||||||
uint16_t watchdog_intervals;
|
uint16_t watchdog_intervals;
|
||||||
uint32_t sdo_count;
|
uint32_t sdo_count;
|
||||||
|
uint32_t idn_count;
|
||||||
int32_t slave_position;
|
int32_t slave_position;
|
||||||
uint16_t dc_assign_activate;
|
uint16_t dc_assign_activate;
|
||||||
ec_sync_signal_t dc_sync[EC_SYNC_SIGNAL_COUNT];
|
ec_sync_signal_t dc_sync[EC_SYNC_SIGNAL_COUNT];
|
||||||
|
|
@ -514,6 +517,26 @@ typedef struct {
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
/** Maximum size for displayed IDN data.
|
||||||
|
* \todo Make this dynamic.
|
||||||
|
*/
|
||||||
|
#define EC_MAX_IDN_DATA_SIZE 1024
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
// inputs
|
||||||
|
uint32_t config_index;
|
||||||
|
uint32_t idn_pos;
|
||||||
|
|
||||||
|
// outputs
|
||||||
|
uint8_t drive_no;
|
||||||
|
uint16_t idn;
|
||||||
|
ec_al_state_t state;
|
||||||
|
size_t size;
|
||||||
|
uint8_t data[EC_MAX_IDN_DATA_SIZE];
|
||||||
|
} ec_ioctl_config_idn_t;
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
#ifdef EC_EOE
|
#ifdef EC_EOE
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
|
|
||||||
|
|
@ -2501,6 +2501,19 @@ int ecrt_master_read_idn(ec_master_t *master, uint16_t slave_position,
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
void ecrt_master_reset(ec_master_t *master)
|
||||||
|
{
|
||||||
|
ec_slave_config_t *sc;
|
||||||
|
|
||||||
|
list_for_each_entry(sc, &master->configs, list) {
|
||||||
|
if (sc->slave) {
|
||||||
|
ec_slave_request_state(sc->slave, EC_SLAVE_STATE_OP);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
/** \cond */
|
/** \cond */
|
||||||
|
|
||||||
EXPORT_SYMBOL(ecrt_master_create_domain);
|
EXPORT_SYMBOL(ecrt_master_create_domain);
|
||||||
|
|
@ -2521,6 +2534,7 @@ EXPORT_SYMBOL(ecrt_master_sync_monitor_queue);
|
||||||
EXPORT_SYMBOL(ecrt_master_sync_monitor_process);
|
EXPORT_SYMBOL(ecrt_master_sync_monitor_process);
|
||||||
EXPORT_SYMBOL(ecrt_master_write_idn);
|
EXPORT_SYMBOL(ecrt_master_write_idn);
|
||||||
EXPORT_SYMBOL(ecrt_master_read_idn);
|
EXPORT_SYMBOL(ecrt_master_read_idn);
|
||||||
|
EXPORT_SYMBOL(ecrt_master_reset);
|
||||||
|
|
||||||
/** \endcond */
|
/** \endcond */
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -35,6 +35,7 @@
|
||||||
|
|
||||||
#include <linux/module.h>
|
#include <linux/module.h>
|
||||||
#include <linux/jiffies.h>
|
#include <linux/jiffies.h>
|
||||||
|
#include <linux/slab.h>
|
||||||
|
|
||||||
#include "sdo_request.h"
|
#include "sdo_request.h"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -371,6 +371,48 @@ const ec_sdo_request_t *ec_slave_config_get_sdo_by_pos_const(
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
/** Get the number of IDN configurations.
|
||||||
|
*
|
||||||
|
* \return Number of SDO configurations.
|
||||||
|
*/
|
||||||
|
unsigned int ec_slave_config_idn_count(
|
||||||
|
const ec_slave_config_t *sc /**< Slave configuration. */
|
||||||
|
)
|
||||||
|
{
|
||||||
|
const ec_soe_request_t *req;
|
||||||
|
unsigned int count = 0;
|
||||||
|
|
||||||
|
list_for_each_entry(req, &sc->soe_configs, list) {
|
||||||
|
count++;
|
||||||
|
}
|
||||||
|
|
||||||
|
return count;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
/** Finds an IDN configuration via its position in the list.
|
||||||
|
*
|
||||||
|
* Const version.
|
||||||
|
*/
|
||||||
|
const ec_soe_request_t *ec_slave_config_get_idn_by_pos_const(
|
||||||
|
const ec_slave_config_t *sc, /**< Slave configuration. */
|
||||||
|
unsigned int pos /**< Position in the list. */
|
||||||
|
)
|
||||||
|
{
|
||||||
|
const ec_soe_request_t *req;
|
||||||
|
|
||||||
|
list_for_each_entry(req, &sc->soe_configs, list) {
|
||||||
|
if (pos--)
|
||||||
|
continue;
|
||||||
|
return req;
|
||||||
|
}
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
/** Finds a VoE handler via its position in the list.
|
/** Finds a VoE handler via its position in the list.
|
||||||
*/
|
*/
|
||||||
ec_sdo_request_t *ec_slave_config_find_sdo_request(
|
ec_sdo_request_t *ec_slave_config_find_sdo_request(
|
||||||
|
|
@ -951,7 +993,8 @@ int ecrt_slave_config_idn(ec_slave_config_t *sc, uint8_t drive_no,
|
||||||
__func__, sc, drive_no, idn, state, data, size);
|
__func__, sc, drive_no, idn, state, data, size);
|
||||||
|
|
||||||
if (drive_no > 7) {
|
if (drive_no > 7) {
|
||||||
EC_CONFIG_ERR(sc, "Invalid drive number!\n");
|
EC_CONFIG_ERR(sc, "Invalid drive number %u!\n",
|
||||||
|
(unsigned int) drive_no);
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -160,6 +160,9 @@ void ec_slave_config_load_default_sync_config(ec_slave_config_t *);
|
||||||
unsigned int ec_slave_config_sdo_count(const ec_slave_config_t *);
|
unsigned int ec_slave_config_sdo_count(const ec_slave_config_t *);
|
||||||
const ec_sdo_request_t *ec_slave_config_get_sdo_by_pos_const(
|
const ec_sdo_request_t *ec_slave_config_get_sdo_by_pos_const(
|
||||||
const ec_slave_config_t *, unsigned int);
|
const ec_slave_config_t *, unsigned int);
|
||||||
|
unsigned int ec_slave_config_idn_count(const ec_slave_config_t *);
|
||||||
|
const ec_soe_request_t *ec_slave_config_get_idn_by_pos_const(
|
||||||
|
const ec_slave_config_t *, unsigned int);
|
||||||
ec_sdo_request_t *ec_slave_config_find_sdo_request(ec_slave_config_t *,
|
ec_sdo_request_t *ec_slave_config_find_sdo_request(ec_slave_config_t *,
|
||||||
unsigned int);
|
unsigned int);
|
||||||
ec_voe_handler_t *ec_slave_config_find_voe_handler(ec_slave_config_t *,
|
ec_voe_handler_t *ec_slave_config_find_voe_handler(ec_slave_config_t *,
|
||||||
|
|
|
||||||
|
|
@ -35,6 +35,7 @@
|
||||||
|
|
||||||
#include <linux/module.h>
|
#include <linux/module.h>
|
||||||
#include <linux/jiffies.h>
|
#include <linux/jiffies.h>
|
||||||
|
#include <linux/slab.h>
|
||||||
|
|
||||||
#include "soe_request.h"
|
#include "soe_request.h"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -116,7 +116,7 @@ class Command
|
||||||
bool matchesSubstr(const string &) const;
|
bool matchesSubstr(const string &) const;
|
||||||
bool matchesAbbrev(const string &) const;
|
bool matchesAbbrev(const string &) const;
|
||||||
|
|
||||||
virtual string helpString() const = 0;
|
virtual string helpString(const string &) const = 0;
|
||||||
|
|
||||||
typedef vector<string> StringVector;
|
typedef vector<string> StringVector;
|
||||||
virtual void execute(const StringVector &) = 0;
|
virtual void execute(const StringVector &) = 0;
|
||||||
|
|
|
||||||
|
|
@ -45,11 +45,11 @@ CommandAlias::CommandAlias():
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
string CommandAlias::helpString() const
|
string CommandAlias::helpString(const string &binaryBaseName) const
|
||||||
{
|
{
|
||||||
stringstream str;
|
stringstream str;
|
||||||
|
|
||||||
str << getName() << " [OPTIONS] <ALIAS>" << endl
|
str << binaryBaseName << " " << getName() << " [OPTIONS] <ALIAS>" << endl
|
||||||
<< endl
|
<< endl
|
||||||
<< getBriefDescription() << endl
|
<< getBriefDescription() << endl
|
||||||
<< endl
|
<< endl
|
||||||
|
|
|
||||||
|
|
@ -40,7 +40,7 @@ class CommandAlias:
|
||||||
public:
|
public:
|
||||||
CommandAlias();
|
CommandAlias();
|
||||||
|
|
||||||
string helpString() const;
|
string helpString(const string &) const;
|
||||||
void execute(const StringVector &);
|
void execute(const StringVector &);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
|
||||||
|
|
@ -46,11 +46,11 @@ CommandCStruct::CommandCStruct():
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
string CommandCStruct::helpString() const
|
string CommandCStruct::helpString(const string &binaryBaseName) const
|
||||||
{
|
{
|
||||||
stringstream str;
|
stringstream str;
|
||||||
|
|
||||||
str << getName() << " [OPTIONS]" << endl
|
str << binaryBaseName << " " << getName() << " [OPTIONS]" << endl
|
||||||
<< endl
|
<< endl
|
||||||
<< getBriefDescription() << endl
|
<< getBriefDescription() << endl
|
||||||
<< endl
|
<< endl
|
||||||
|
|
|
||||||
|
|
@ -40,7 +40,7 @@ class CommandCStruct:
|
||||||
public:
|
public:
|
||||||
CommandCStruct();
|
CommandCStruct();
|
||||||
|
|
||||||
string helpString() const;
|
string helpString(const string &) const;
|
||||||
void execute(const StringVector &);
|
void execute(const StringVector &);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
|
||||||
|
|
@ -47,11 +47,11 @@ CommandConfig::CommandConfig():
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
string CommandConfig::helpString() const
|
string CommandConfig::helpString(const string &binaryBaseName) const
|
||||||
{
|
{
|
||||||
stringstream str;
|
stringstream str;
|
||||||
|
|
||||||
str << getName() << " [OPTIONS]" << endl
|
str << binaryBaseName << " " << getName() << " [OPTIONS]" << endl
|
||||||
<< endl
|
<< endl
|
||||||
<< getBriefDescription() << endl
|
<< getBriefDescription() << endl
|
||||||
<< endl
|
<< endl
|
||||||
|
|
@ -153,6 +153,7 @@ void CommandConfig::showDetailedConfigs(
|
||||||
ec_ioctl_config_pdo_t pdo;
|
ec_ioctl_config_pdo_t pdo;
|
||||||
ec_ioctl_config_pdo_entry_t entry;
|
ec_ioctl_config_pdo_entry_t entry;
|
||||||
ec_ioctl_config_sdo_t sdo;
|
ec_ioctl_config_sdo_t sdo;
|
||||||
|
ec_ioctl_config_idn_t idn;
|
||||||
string indent(doIndent ? " " : "");
|
string indent(doIndent ? " " : "");
|
||||||
|
|
||||||
for (configIter = configList.begin();
|
for (configIter = configList.begin();
|
||||||
|
|
@ -259,6 +260,34 @@ void CommandConfig::showDetailedConfigs(
|
||||||
cout << indent << " None." << endl;
|
cout << indent << " None." << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cout << indent << "IDN configuration:" << endl;
|
||||||
|
if (configIter->idn_count) {
|
||||||
|
for (j = 0; j < configIter->idn_count; j++) {
|
||||||
|
m.getConfigIdn(&idn, configIter->config_index, j);
|
||||||
|
|
||||||
|
cout << indent << " Drive " << (unsigned int) idn.drive_no
|
||||||
|
<< ", " << outputIdn(idn.idn)
|
||||||
|
<< ", " << dec << idn.size << " byte" << endl;
|
||||||
|
|
||||||
|
cout << indent << " " << hex << setfill('0');
|
||||||
|
for (i = 0; i < min((uint32_t) idn.size,
|
||||||
|
(uint32_t) EC_MAX_IDN_DATA_SIZE); i++) {
|
||||||
|
cout << setw(2) << (unsigned int) idn.data[i];
|
||||||
|
if ((i + 1) % 16 == 0 && i < idn.size - 1) {
|
||||||
|
cout << endl << indent << " ";
|
||||||
|
} else {
|
||||||
|
cout << " ";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
cout << endl;
|
||||||
|
if (idn.size > EC_MAX_IDN_DATA_SIZE) {
|
||||||
|
cout << indent << " ..." << endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
cout << indent << " None." << endl;
|
||||||
|
}
|
||||||
if (configIter->dc_assign_activate) {
|
if (configIter->dc_assign_activate) {
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -34,16 +34,18 @@
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
#include "Command.h"
|
#include "Command.h"
|
||||||
|
#include "SoeCommand.h"
|
||||||
|
|
||||||
/****************************************************************************/
|
/****************************************************************************/
|
||||||
|
|
||||||
class CommandConfig:
|
class CommandConfig:
|
||||||
public Command
|
public Command,
|
||||||
|
public SoeCommand
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
CommandConfig();
|
CommandConfig();
|
||||||
|
|
||||||
string helpString() const;
|
string helpString(const string &) const;
|
||||||
void execute(const StringVector &);
|
void execute(const StringVector &);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
|
||||||
|
|
@ -44,11 +44,11 @@ CommandData::CommandData():
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
string CommandData::helpString() const
|
string CommandData::helpString(const string &binaryBaseName) const
|
||||||
{
|
{
|
||||||
stringstream str;
|
stringstream str;
|
||||||
|
|
||||||
str << getName() << " [OPTIONS]" << endl
|
str << binaryBaseName << " " << getName() << " [OPTIONS]" << endl
|
||||||
<< endl
|
<< endl
|
||||||
<< getBriefDescription() << endl
|
<< getBriefDescription() << endl
|
||||||
<< endl
|
<< endl
|
||||||
|
|
|
||||||
|
|
@ -40,7 +40,7 @@ class CommandData:
|
||||||
public:
|
public:
|
||||||
CommandData();
|
CommandData();
|
||||||
|
|
||||||
string helpString() const;
|
string helpString(const string &) const;
|
||||||
void execute(const StringVector &);
|
void execute(const StringVector &);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
|
||||||
|
|
@ -45,11 +45,11 @@ CommandDebug::CommandDebug():
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
string CommandDebug::helpString() const
|
string CommandDebug::helpString(const string &binaryBaseName) const
|
||||||
{
|
{
|
||||||
stringstream str;
|
stringstream str;
|
||||||
|
|
||||||
str << getName() << " <LEVEL>" << endl
|
str << binaryBaseName << " " << getName() << " <LEVEL>" << endl
|
||||||
<< endl
|
<< endl
|
||||||
<< getBriefDescription() << endl
|
<< getBriefDescription() << endl
|
||||||
<< endl
|
<< endl
|
||||||
|
|
|
||||||
|
|
@ -40,7 +40,7 @@ class CommandDebug:
|
||||||
public:
|
public:
|
||||||
CommandDebug();
|
CommandDebug();
|
||||||
|
|
||||||
string helpString() const;
|
string helpString(const string &) const;
|
||||||
void execute(const StringVector &);
|
void execute(const StringVector &);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -43,11 +43,11 @@ CommandDomains::CommandDomains():
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
string CommandDomains::helpString() const
|
string CommandDomains::helpString(const string &binaryBaseName) const
|
||||||
{
|
{
|
||||||
stringstream str;
|
stringstream str;
|
||||||
|
|
||||||
str << getName() << " [OPTIONS]" << endl
|
str << binaryBaseName << " " << getName() << " [OPTIONS]" << endl
|
||||||
<< endl
|
<< endl
|
||||||
<< getBriefDescription() << endl
|
<< getBriefDescription() << endl
|
||||||
<< endl
|
<< endl
|
||||||
|
|
|
||||||
|
|
@ -40,7 +40,7 @@ class CommandDomains:
|
||||||
public:
|
public:
|
||||||
CommandDomains();
|
CommandDomains();
|
||||||
|
|
||||||
string helpString() const;
|
string helpString(const string &) const;
|
||||||
void execute(const StringVector &);
|
void execute(const StringVector &);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
|
||||||
|
|
@ -43,11 +43,12 @@ CommandDownload::CommandDownload():
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
string CommandDownload::helpString() const
|
string CommandDownload::helpString(const string &binaryBaseName) const
|
||||||
{
|
{
|
||||||
stringstream str;
|
stringstream str;
|
||||||
|
|
||||||
str << getName() << " [OPTIONS] <INDEX> <SUBINDEX> <VALUE>" << endl
|
str << binaryBaseName << " " << getName()
|
||||||
|
<< " [OPTIONS] <INDEX> <SUBINDEX> <VALUE>" << endl
|
||||||
<< endl
|
<< endl
|
||||||
<< getBriefDescription() << endl
|
<< getBriefDescription() << endl
|
||||||
<< endl
|
<< endl
|
||||||
|
|
|
||||||
|
|
@ -40,7 +40,7 @@ class CommandDownload:
|
||||||
public:
|
public:
|
||||||
CommandDownload();
|
CommandDownload();
|
||||||
|
|
||||||
string helpString() const;
|
string helpString(const string &) const;
|
||||||
void execute(const StringVector &);
|
void execute(const StringVector &);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
|
||||||
|
|
@ -45,11 +45,11 @@ CommandEoe::CommandEoe():
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
string CommandEoe::helpString() const
|
string CommandEoe::helpString(const string &binaryBaseName) const
|
||||||
{
|
{
|
||||||
stringstream str;
|
stringstream str;
|
||||||
|
|
||||||
str << getName() << endl
|
str << binaryBaseName << " " << getName() << endl
|
||||||
<< endl
|
<< endl
|
||||||
<< getBriefDescription() << endl
|
<< getBriefDescription() << endl
|
||||||
<< endl
|
<< endl
|
||||||
|
|
|
||||||
|
|
@ -40,7 +40,7 @@ class CommandEoe:
|
||||||
public:
|
public:
|
||||||
CommandEoe();
|
CommandEoe();
|
||||||
|
|
||||||
string helpString() const;
|
string helpString(const string &) const;
|
||||||
void execute(const StringVector &);
|
void execute(const StringVector &);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -46,11 +46,12 @@ CommandFoeRead::CommandFoeRead():
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
string CommandFoeRead::helpString() const
|
string CommandFoeRead::helpString(const string &binaryBaseName) const
|
||||||
{
|
{
|
||||||
stringstream str;
|
stringstream str;
|
||||||
|
|
||||||
str << getName() << " [OPTIONS] <SOURCEFILE>" << endl
|
str << binaryBaseName << " " << getName()
|
||||||
|
<< " [OPTIONS] <SOURCEFILE>" << endl
|
||||||
<< endl
|
<< endl
|
||||||
<< getBriefDescription() << endl
|
<< getBriefDescription() << endl
|
||||||
<< endl
|
<< endl
|
||||||
|
|
|
||||||
|
|
@ -40,7 +40,7 @@ class CommandFoeRead:
|
||||||
public:
|
public:
|
||||||
CommandFoeRead();
|
CommandFoeRead();
|
||||||
|
|
||||||
string helpString() const;
|
string helpString(const string &) const;
|
||||||
void execute(const StringVector &);
|
void execute(const StringVector &);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -48,11 +48,12 @@ CommandFoeWrite::CommandFoeWrite():
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
string CommandFoeWrite::helpString() const
|
string CommandFoeWrite::helpString(const string &binaryBaseName) const
|
||||||
{
|
{
|
||||||
stringstream str;
|
stringstream str;
|
||||||
|
|
||||||
str << getName() << " [OPTIONS] <FILENAME>" << endl
|
str << binaryBaseName << " " << getName()
|
||||||
|
<< " [OPTIONS] <FILENAME>" << endl
|
||||||
<< endl
|
<< endl
|
||||||
<< getBriefDescription() << endl
|
<< getBriefDescription() << endl
|
||||||
<< endl
|
<< endl
|
||||||
|
|
|
||||||
|
|
@ -40,7 +40,7 @@ class CommandFoeWrite:
|
||||||
public:
|
public:
|
||||||
CommandFoeWrite();
|
CommandFoeWrite();
|
||||||
|
|
||||||
string helpString() const;
|
string helpString(const string &) const;
|
||||||
void execute(const StringVector &);
|
void execute(const StringVector &);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
|
||||||
|
|
@ -43,11 +43,11 @@ CommandGraph::CommandGraph():
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
string CommandGraph::helpString() const
|
string CommandGraph::helpString(const string &binaryBaseName) const
|
||||||
{
|
{
|
||||||
stringstream str;
|
stringstream str;
|
||||||
|
|
||||||
str << getName() << " [OPTIONS]" << endl
|
str << binaryBaseName << " " << getName() << " [OPTIONS]" << endl
|
||||||
<< endl
|
<< endl
|
||||||
<< getBriefDescription() << endl
|
<< getBriefDescription() << endl
|
||||||
<< endl
|
<< endl
|
||||||
|
|
|
||||||
|
|
@ -40,7 +40,7 @@ class CommandGraph:
|
||||||
public:
|
public:
|
||||||
CommandGraph();
|
CommandGraph();
|
||||||
|
|
||||||
string helpString() const;
|
string helpString(const string &) const;
|
||||||
void execute(const StringVector &);
|
void execute(const StringVector &);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -45,11 +45,11 @@ CommandMaster::CommandMaster():
|
||||||
|
|
||||||
/****************************************************************************/
|
/****************************************************************************/
|
||||||
|
|
||||||
string CommandMaster::helpString() const
|
string CommandMaster::helpString(const string &binaryBaseName) const
|
||||||
{
|
{
|
||||||
stringstream str;
|
stringstream str;
|
||||||
|
|
||||||
str << getName() << " [OPTIONS]" << endl
|
str << binaryBaseName << " " << getName() << " [OPTIONS]" << endl
|
||||||
<< endl
|
<< endl
|
||||||
<< getBriefDescription() << endl
|
<< getBriefDescription() << endl
|
||||||
<< endl
|
<< endl
|
||||||
|
|
|
||||||
|
|
@ -40,7 +40,7 @@ class CommandMaster:
|
||||||
public:
|
public:
|
||||||
CommandMaster();
|
CommandMaster();
|
||||||
|
|
||||||
string helpString() const;
|
string helpString(const string &) const;
|
||||||
void execute(const StringVector &);
|
void execute(const StringVector &);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
|
||||||
|
|
@ -43,11 +43,11 @@ CommandPdos::CommandPdos():
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
string CommandPdos::helpString() const
|
string CommandPdos::helpString(const string &binaryBaseName) const
|
||||||
{
|
{
|
||||||
stringstream str;
|
stringstream str;
|
||||||
|
|
||||||
str << getName() << " [OPTIONS]" << endl
|
str << binaryBaseName << " " << getName() << " [OPTIONS]" << endl
|
||||||
<< endl
|
<< endl
|
||||||
<< getBriefDescription() << endl
|
<< getBriefDescription() << endl
|
||||||
<< endl
|
<< endl
|
||||||
|
|
|
||||||
|
|
@ -40,7 +40,7 @@ class CommandPdos:
|
||||||
public:
|
public:
|
||||||
CommandPdos();
|
CommandPdos();
|
||||||
|
|
||||||
string helpString() const;
|
string helpString(const string &) const;
|
||||||
void execute(const StringVector &);
|
void execute(const StringVector &);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
|
||||||
|
|
@ -43,11 +43,12 @@ CommandRegRead::CommandRegRead():
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
string CommandRegRead::helpString() const
|
string CommandRegRead::helpString(const string &binaryBaseName) const
|
||||||
{
|
{
|
||||||
stringstream str;
|
stringstream str;
|
||||||
|
|
||||||
str << getName() << " [OPTIONS] <OFFSET> [LENGTH]" << endl
|
str << binaryBaseName << " " << getName()
|
||||||
|
<< " [OPTIONS] <OFFSET> [LENGTH]" << endl
|
||||||
<< endl
|
<< endl
|
||||||
<< getBriefDescription() << endl
|
<< getBriefDescription() << endl
|
||||||
<< endl
|
<< endl
|
||||||
|
|
|
||||||
|
|
@ -42,7 +42,7 @@ class CommandRegRead:
|
||||||
public:
|
public:
|
||||||
CommandRegRead();
|
CommandRegRead();
|
||||||
|
|
||||||
string helpString() const;
|
string helpString(const string &) const;
|
||||||
void execute(const StringVector &);
|
void execute(const StringVector &);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -45,11 +45,12 @@ CommandRegWrite::CommandRegWrite():
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
string CommandRegWrite::helpString() const
|
string CommandRegWrite::helpString(const string &binaryBaseName) const
|
||||||
{
|
{
|
||||||
stringstream str;
|
stringstream str;
|
||||||
|
|
||||||
str << getName() << " [OPTIONS] <OFFSET> <DATA>" << endl
|
str << binaryBaseName << " " << getName()
|
||||||
|
<< " [OPTIONS] <OFFSET> <DATA>" << endl
|
||||||
<< endl
|
<< endl
|
||||||
<< getBriefDescription() << endl
|
<< getBriefDescription() << endl
|
||||||
<< endl
|
<< endl
|
||||||
|
|
|
||||||
|
|
@ -42,7 +42,7 @@ class CommandRegWrite:
|
||||||
public:
|
public:
|
||||||
CommandRegWrite();
|
CommandRegWrite();
|
||||||
|
|
||||||
string helpString() const;
|
string helpString(const string &) const;
|
||||||
void execute(const StringVector &);
|
void execute(const StringVector &);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
|
||||||
|
|
@ -45,11 +45,11 @@ CommandRescan::CommandRescan():
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
string CommandRescan::helpString() const
|
string CommandRescan::helpString(const string &binaryBaseName) const
|
||||||
{
|
{
|
||||||
stringstream str;
|
stringstream str;
|
||||||
|
|
||||||
str << getName() << endl
|
str << binaryBaseName << " " << getName() << endl
|
||||||
<< endl
|
<< endl
|
||||||
<< getBriefDescription() << endl
|
<< getBriefDescription() << endl
|
||||||
<< endl
|
<< endl
|
||||||
|
|
|
||||||
|
|
@ -40,7 +40,7 @@ class CommandRescan:
|
||||||
public:
|
public:
|
||||||
CommandRescan();
|
CommandRescan();
|
||||||
|
|
||||||
string helpString() const;
|
string helpString(const string &) const;
|
||||||
void execute(const StringVector &);
|
void execute(const StringVector &);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -43,11 +43,11 @@ CommandSdos::CommandSdos():
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
string CommandSdos::helpString() const
|
string CommandSdos::helpString(const string &binaryBaseName) const
|
||||||
{
|
{
|
||||||
stringstream str;
|
stringstream str;
|
||||||
|
|
||||||
str << getName() << " [OPTIONS]" << endl
|
str << binaryBaseName << " " << getName() << " [OPTIONS]" << endl
|
||||||
<< endl
|
<< endl
|
||||||
<< getBriefDescription() << endl
|
<< getBriefDescription() << endl
|
||||||
<< endl
|
<< endl
|
||||||
|
|
|
||||||
|
|
@ -40,7 +40,7 @@ class CommandSdos:
|
||||||
public:
|
public:
|
||||||
CommandSdos();
|
CommandSdos();
|
||||||
|
|
||||||
string helpString() const;
|
string helpString(const string &) const;
|
||||||
void execute(const StringVector &);
|
void execute(const StringVector &);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
|
||||||
|
|
@ -43,11 +43,11 @@ CommandSiiRead::CommandSiiRead():
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
string CommandSiiRead::helpString() const
|
string CommandSiiRead::helpString(const string &binaryBaseName) const
|
||||||
{
|
{
|
||||||
stringstream str;
|
stringstream str;
|
||||||
|
|
||||||
str << getName() << " [OPTIONS]" << endl
|
str << binaryBaseName << " " << getName() << " [OPTIONS]" << endl
|
||||||
<< endl
|
<< endl
|
||||||
<< getBriefDescription() << endl
|
<< getBriefDescription() << endl
|
||||||
<< endl
|
<< endl
|
||||||
|
|
|
||||||
|
|
@ -40,7 +40,7 @@ class CommandSiiRead:
|
||||||
public:
|
public:
|
||||||
CommandSiiRead();
|
CommandSiiRead();
|
||||||
|
|
||||||
string helpString() const;
|
string helpString(const string &) const;
|
||||||
void execute(const StringVector &);
|
void execute(const StringVector &);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
|
||||||
|
|
@ -45,11 +45,12 @@ CommandSiiWrite::CommandSiiWrite():
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
string CommandSiiWrite::helpString() const
|
string CommandSiiWrite::helpString(const string &binaryBaseName) const
|
||||||
{
|
{
|
||||||
stringstream str;
|
stringstream str;
|
||||||
|
|
||||||
str << getName() << " [OPTIONS] <FILENAME>" << endl
|
str << binaryBaseName << " " << getName()
|
||||||
|
<< " [OPTIONS] <FILENAME>" << endl
|
||||||
<< endl
|
<< endl
|
||||||
<< getBriefDescription() << endl
|
<< getBriefDescription() << endl
|
||||||
<< endl
|
<< endl
|
||||||
|
|
|
||||||
|
|
@ -40,7 +40,7 @@ class CommandSiiWrite:
|
||||||
public:
|
public:
|
||||||
CommandSiiWrite();
|
CommandSiiWrite();
|
||||||
|
|
||||||
string helpString() const;
|
string helpString(const string &) const;
|
||||||
void execute(const StringVector &);
|
void execute(const StringVector &);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
|
||||||
|
|
@ -45,11 +45,11 @@ CommandSlaves::CommandSlaves():
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
string CommandSlaves::helpString() const
|
string CommandSlaves::helpString(const string &binaryBaseName) const
|
||||||
{
|
{
|
||||||
stringstream str;
|
stringstream str;
|
||||||
|
|
||||||
str << getName() << " [OPTIONS]" << endl
|
str << binaryBaseName << " " << getName() << " [OPTIONS]" << endl
|
||||||
<< endl
|
<< endl
|
||||||
<< getBriefDescription() << endl
|
<< getBriefDescription() << endl
|
||||||
<< endl
|
<< endl
|
||||||
|
|
|
||||||
|
|
@ -40,7 +40,7 @@ class CommandSlaves:
|
||||||
public:
|
public:
|
||||||
CommandSlaves();
|
CommandSlaves();
|
||||||
|
|
||||||
string helpString() const;
|
string helpString(const string &) const;
|
||||||
void execute(const StringVector &);
|
void execute(const StringVector &);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
|
||||||
|
|
@ -28,6 +28,7 @@
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
#include <iomanip>
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
#include "CommandSoeRead.h"
|
#include "CommandSoeRead.h"
|
||||||
|
|
@ -36,23 +37,28 @@ using namespace std;
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
CommandSoeRead::CommandSoeRead():
|
CommandSoeRead::CommandSoeRead():
|
||||||
SoeCommand("soe_read", "Read an SoE IDN from a slave.")
|
Command("soe_read", "Read an SoE IDN from a slave.")
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
string CommandSoeRead::helpString() const
|
string CommandSoeRead::helpString(const string &binaryBaseName) const
|
||||||
{
|
{
|
||||||
stringstream str;
|
stringstream str;
|
||||||
|
|
||||||
str << getName() << " [OPTIONS] <IDN>" << endl
|
str << binaryBaseName << " " << getName()
|
||||||
|
<< " [OPTIONS] <IDN>" << endl
|
||||||
|
<< binaryBaseName << " " << getName()
|
||||||
|
<< " [OPTIONS] <DRIVE> <IDN>" << endl
|
||||||
<< endl
|
<< endl
|
||||||
<< getBriefDescription() << endl
|
<< getBriefDescription() << endl
|
||||||
<< endl
|
<< endl
|
||||||
<< "This command requires a single slave to be selected." << endl
|
<< "This command requires a single slave to be selected." << endl
|
||||||
<< endl
|
<< endl
|
||||||
<< "Arguments:" << endl
|
<< "Arguments:" << endl
|
||||||
|
<< " DRIVE is the drive number (0 - 7). If omitted, 0 is assumed."
|
||||||
|
<< endl
|
||||||
<< " IDN is the IDN and must be either an unsigned" << endl
|
<< " IDN is the IDN and must be either an unsigned" << endl
|
||||||
<< " 16 bit number acc. to IEC 61800-7-204:" << endl
|
<< " 16 bit number acc. to IEC 61800-7-204:" << endl
|
||||||
<< " Bit 15: (0) Standard data, (1) Product data" << endl
|
<< " Bit 15: (0) Standard data, (1) Product data" << endl
|
||||||
|
|
@ -84,18 +90,38 @@ void CommandSoeRead::execute(const StringVector &args)
|
||||||
stringstream err;
|
stringstream err;
|
||||||
const DataType *dataType = NULL;
|
const DataType *dataType = NULL;
|
||||||
ec_ioctl_slave_soe_read_t ioctl;
|
ec_ioctl_slave_soe_read_t ioctl;
|
||||||
|
int driveArgIndex = -1, idnArgIndex = -1;
|
||||||
|
|
||||||
if (args.size() != 1) {
|
if (args.size() == 1) {
|
||||||
err << "'" << getName() << "' takes one argument!";
|
idnArgIndex = 0;
|
||||||
|
} else if (args.size() == 2) {
|
||||||
|
driveArgIndex = 0;
|
||||||
|
idnArgIndex = 1;
|
||||||
|
} else {
|
||||||
|
err << "'" << getName() << "' takes eiter 1 or 2 arguments!";
|
||||||
throwInvalidUsageException(err);
|
throwInvalidUsageException(err);
|
||||||
}
|
}
|
||||||
|
|
||||||
ioctl.drive_no = 0; // FIXME
|
if (driveArgIndex >= 0) {
|
||||||
|
stringstream str;
|
||||||
|
unsigned int number;
|
||||||
|
str << args[driveArgIndex];
|
||||||
|
str
|
||||||
|
>> resetiosflags(ios::basefield) // guess base from prefix
|
||||||
|
>> number;
|
||||||
|
if (str.fail() || number > 7) {
|
||||||
|
err << "Invalid drive number '" << args[driveArgIndex] << "'!";
|
||||||
|
throwInvalidUsageException(err);
|
||||||
|
}
|
||||||
|
ioctl.drive_no = number;
|
||||||
|
} else {
|
||||||
|
ioctl.drive_no = 0;
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
ioctl.idn = parseIdn(args[0]);
|
ioctl.idn = parseIdn(args[idnArgIndex]);
|
||||||
} catch (runtime_error &e) {
|
} catch (runtime_error &e) {
|
||||||
err << "Invalid IDN '" << args[0] << "': " << e.what();
|
err << "Invalid IDN '" << args[idnArgIndex] << "': " << e.what();
|
||||||
throwInvalidUsageException(err);
|
throwInvalidUsageException(err);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -35,12 +35,14 @@
|
||||||
/****************************************************************************/
|
/****************************************************************************/
|
||||||
|
|
||||||
class CommandSoeRead:
|
class CommandSoeRead:
|
||||||
|
public Command,
|
||||||
|
public DataTypeHandler,
|
||||||
public SoeCommand
|
public SoeCommand
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
CommandSoeRead();
|
CommandSoeRead();
|
||||||
|
|
||||||
string helpString() const;
|
string helpString(const string &) const;
|
||||||
void execute(const StringVector &);
|
void execute(const StringVector &);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -28,6 +28,7 @@
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
#include <iomanip>
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
#include "CommandSoeWrite.h"
|
#include "CommandSoeWrite.h"
|
||||||
|
|
@ -36,23 +37,28 @@ using namespace std;
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
CommandSoeWrite::CommandSoeWrite():
|
CommandSoeWrite::CommandSoeWrite():
|
||||||
SoeCommand("soe_write", "Write an SoE IDN to a slave.")
|
Command("soe_write", "Write an SoE IDN to a slave.")
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
string CommandSoeWrite::helpString() const
|
string CommandSoeWrite::helpString(const string &binaryBaseName) const
|
||||||
{
|
{
|
||||||
stringstream str;
|
stringstream str;
|
||||||
|
|
||||||
str << getName() << " [OPTIONS] <IDN> <VALUE>" << endl
|
str << binaryBaseName << " " << getName()
|
||||||
|
<< " [OPTIONS] <IDN> <VALUE>" << endl
|
||||||
|
<< binaryBaseName << " " << getName()
|
||||||
|
<< " [OPTIONS] <DRIVE> <IDN> <VALUE>" << endl
|
||||||
<< endl
|
<< endl
|
||||||
<< getBriefDescription() << endl
|
<< getBriefDescription() << endl
|
||||||
<< endl
|
<< endl
|
||||||
<< "This command requires a single slave to be selected." << endl
|
<< "This command requires a single slave to be selected." << endl
|
||||||
<< endl
|
<< endl
|
||||||
<< "Arguments:" << endl
|
<< "Arguments:" << endl
|
||||||
|
<< " DRIVE is the drive number (0 - 7). If omitted, 0 is assumed."
|
||||||
|
<< endl
|
||||||
<< " IDN is the IDN and must be either an unsigned" << endl
|
<< " IDN is the IDN and must be either an unsigned" << endl
|
||||||
<< " 16 bit number acc. to IEC 61800-7-204:" << endl
|
<< " 16 bit number acc. to IEC 61800-7-204:" << endl
|
||||||
<< " Bit 15: (0) Standard data, (1) Product data" << endl
|
<< " Bit 15: (0) Standard data, (1) Product data" << endl
|
||||||
|
|
@ -81,23 +87,45 @@ string CommandSoeWrite::helpString() const
|
||||||
|
|
||||||
void CommandSoeWrite::execute(const StringVector &args)
|
void CommandSoeWrite::execute(const StringVector &args)
|
||||||
{
|
{
|
||||||
stringstream strIdn, err;
|
stringstream err;
|
||||||
const DataType *dataType = NULL;
|
const DataType *dataType = NULL;
|
||||||
ec_ioctl_slave_soe_write_t ioctl;
|
ec_ioctl_slave_soe_write_t ioctl;
|
||||||
SlaveList slaves;
|
SlaveList slaves;
|
||||||
size_t memSize;
|
size_t memSize;
|
||||||
|
int driveArgIndex = -1, idnArgIndex = -1, valueArgIndex = -1;
|
||||||
|
|
||||||
if (args.size() != 2) {
|
if (args.size() == 2) {
|
||||||
err << "'" << getName() << "' takes 2 arguments!";
|
idnArgIndex = 0;
|
||||||
|
valueArgIndex = 1;
|
||||||
|
} else if (args.size() == 3) {
|
||||||
|
driveArgIndex = 0;
|
||||||
|
idnArgIndex = 1;
|
||||||
|
valueArgIndex = 2;
|
||||||
|
} else {
|
||||||
|
err << "'" << getName() << "' takes eiter 2 or 3 arguments!";
|
||||||
throwInvalidUsageException(err);
|
throwInvalidUsageException(err);
|
||||||
}
|
}
|
||||||
|
|
||||||
ioctl.drive_no = 0; // FIXME
|
if (driveArgIndex >= 0) {
|
||||||
|
stringstream str;
|
||||||
|
unsigned int number;
|
||||||
|
str << args[driveArgIndex];
|
||||||
|
str
|
||||||
|
>> resetiosflags(ios::basefield) // guess base from prefix
|
||||||
|
>> number;
|
||||||
|
if (str.fail() || number > 7) {
|
||||||
|
err << "Invalid drive number '" << args[driveArgIndex] << "'!";
|
||||||
|
throwInvalidUsageException(err);
|
||||||
|
}
|
||||||
|
ioctl.drive_no = number;
|
||||||
|
} else {
|
||||||
|
ioctl.drive_no = 0;
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
ioctl.idn = parseIdn(args[0]);
|
ioctl.idn = parseIdn(args[idnArgIndex]);
|
||||||
} catch (runtime_error &e) {
|
} catch (runtime_error &e) {
|
||||||
err << "Invalid IDN '" << args[0] << "': " << e.what();
|
err << "Invalid IDN '" << args[idnArgIndex] << "': " << e.what();
|
||||||
throwInvalidUsageException(err);
|
throwInvalidUsageException(err);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -123,7 +151,7 @@ void CommandSoeWrite::execute(const StringVector &args)
|
||||||
memSize = dataType->byteSize;
|
memSize = dataType->byteSize;
|
||||||
} else {
|
} else {
|
||||||
// guess string type size
|
// guess string type size
|
||||||
memSize = args[1].size() + 1;
|
memSize = args[valueArgIndex].size() + 1;
|
||||||
if (!memSize) {
|
if (!memSize) {
|
||||||
err << "Empty argument not allowed.";
|
err << "Empty argument not allowed.";
|
||||||
throwInvalidUsageException(err);
|
throwInvalidUsageException(err);
|
||||||
|
|
@ -134,13 +162,13 @@ void CommandSoeWrite::execute(const StringVector &args)
|
||||||
|
|
||||||
try {
|
try {
|
||||||
ioctl.data_size = interpretAsType(
|
ioctl.data_size = interpretAsType(
|
||||||
dataType, args[1], ioctl.data, memSize);
|
dataType, args[valueArgIndex], ioctl.data, memSize);
|
||||||
} catch (SizeException &e) {
|
} catch (SizeException &e) {
|
||||||
delete [] ioctl.data;
|
delete [] ioctl.data;
|
||||||
throwCommandException(e.what());
|
throwCommandException(e.what());
|
||||||
} catch (ios::failure &e) {
|
} catch (ios::failure &e) {
|
||||||
delete [] ioctl.data;
|
delete [] ioctl.data;
|
||||||
err << "Invalid value argument '" << args[1]
|
err << "Invalid value argument '" << args[valueArgIndex]
|
||||||
<< "' for type '" << dataType->name << "'!";
|
<< "' for type '" << dataType->name << "'!";
|
||||||
throwInvalidUsageException(err);
|
throwInvalidUsageException(err);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -35,12 +35,14 @@
|
||||||
/****************************************************************************/
|
/****************************************************************************/
|
||||||
|
|
||||||
class CommandSoeWrite:
|
class CommandSoeWrite:
|
||||||
|
public Command,
|
||||||
|
public DataTypeHandler,
|
||||||
public SoeCommand
|
public SoeCommand
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
CommandSoeWrite();
|
CommandSoeWrite();
|
||||||
|
|
||||||
string helpString() const;
|
string helpString(const string &) const;
|
||||||
void execute(const StringVector &);
|
void execute(const StringVector &);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -43,11 +43,11 @@ CommandStates::CommandStates():
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
string CommandStates::helpString() const
|
string CommandStates::helpString(const string &binaryBaseName) const
|
||||||
{
|
{
|
||||||
stringstream str;
|
stringstream str;
|
||||||
|
|
||||||
str << getName() << " [OPTIONS] <STATE>" << endl
|
str << binaryBaseName << " " << getName() << " [OPTIONS] <STATE>" << endl
|
||||||
<< endl
|
<< endl
|
||||||
<< getBriefDescription() << endl
|
<< getBriefDescription() << endl
|
||||||
<< endl
|
<< endl
|
||||||
|
|
|
||||||
|
|
@ -40,7 +40,7 @@ class CommandStates:
|
||||||
public:
|
public:
|
||||||
CommandStates();
|
CommandStates();
|
||||||
|
|
||||||
string helpString() const;
|
string helpString(const string &) const;
|
||||||
void execute(const StringVector &);
|
void execute(const StringVector &);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -43,11 +43,12 @@ CommandUpload::CommandUpload():
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
string CommandUpload::helpString() const
|
string CommandUpload::helpString(const string &binaryBaseName) const
|
||||||
{
|
{
|
||||||
stringstream str;
|
stringstream str;
|
||||||
|
|
||||||
str << getName() << " [OPTIONS] <INDEX> <SUBINDEX>" << endl
|
str << binaryBaseName << " " << getName()
|
||||||
|
<< " [OPTIONS] <INDEX> <SUBINDEX>" << endl
|
||||||
<< endl
|
<< endl
|
||||||
<< getBriefDescription() << endl
|
<< getBriefDescription() << endl
|
||||||
<< endl
|
<< endl
|
||||||
|
|
|
||||||
|
|
@ -40,7 +40,7 @@ class CommandUpload:
|
||||||
public:
|
public:
|
||||||
CommandUpload();
|
CommandUpload();
|
||||||
|
|
||||||
string helpString() const;
|
string helpString(const string &) const;
|
||||||
void execute(const StringVector &);
|
void execute(const StringVector &);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
|
||||||
|
|
@ -41,11 +41,11 @@ CommandVersion::CommandVersion():
|
||||||
|
|
||||||
/****************************************************************************/
|
/****************************************************************************/
|
||||||
|
|
||||||
string CommandVersion::helpString() const
|
string CommandVersion::helpString(const string &binaryBaseName) const
|
||||||
{
|
{
|
||||||
stringstream str;
|
stringstream str;
|
||||||
|
|
||||||
str << getName() << " [OPTIONS]" << endl
|
str << binaryBaseName << " " << getName() << " [OPTIONS]" << endl
|
||||||
<< endl
|
<< endl
|
||||||
<< getBriefDescription() << endl;
|
<< getBriefDescription() << endl;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -40,7 +40,7 @@ class CommandVersion:
|
||||||
public:
|
public:
|
||||||
CommandVersion();
|
CommandVersion();
|
||||||
|
|
||||||
string helpString() const;
|
string helpString(const string &) const;
|
||||||
void execute(const StringVector &);
|
void execute(const StringVector &);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -44,11 +44,11 @@ CommandXml::CommandXml():
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
string CommandXml::helpString() const
|
string CommandXml::helpString(const string &binaryBaseName) const
|
||||||
{
|
{
|
||||||
stringstream str;
|
stringstream str;
|
||||||
|
|
||||||
str << getName() << " [OPTIONS]" << endl
|
str << binaryBaseName << " " << getName() << " [OPTIONS]" << endl
|
||||||
<< endl
|
<< endl
|
||||||
<< getBriefDescription() << endl
|
<< getBriefDescription() << endl
|
||||||
<< endl
|
<< endl
|
||||||
|
|
|
||||||
|
|
@ -40,7 +40,7 @@ class CommandXml:
|
||||||
public:
|
public:
|
||||||
CommandXml();
|
CommandXml();
|
||||||
|
|
||||||
string helpString() const;
|
string helpString(const string &) const;
|
||||||
void execute(const StringVector &);
|
void execute(const StringVector &);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
|
||||||
|
|
@ -128,6 +128,7 @@ REV = `if test -s $(top_srcdir)/revision; then \
|
||||||
ethercat_CXXFLAGS = \
|
ethercat_CXXFLAGS = \
|
||||||
-I$(top_srcdir)/include \
|
-I$(top_srcdir)/include \
|
||||||
-I$(top_srcdir)/master \
|
-I$(top_srcdir)/master \
|
||||||
-Wall -DREV=$(REV)
|
-Wall -DREV=$(REV) \
|
||||||
|
-fno-strict-aliasing
|
||||||
|
|
||||||
#------------------------------------------------------------------------------
|
#------------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
|
@ -200,6 +200,24 @@ void MasterDevice::getConfigSdo(
|
||||||
|
|
||||||
/****************************************************************************/
|
/****************************************************************************/
|
||||||
|
|
||||||
|
void MasterDevice::getConfigIdn(
|
||||||
|
ec_ioctl_config_idn_t *data,
|
||||||
|
unsigned int index,
|
||||||
|
unsigned int pos
|
||||||
|
)
|
||||||
|
{
|
||||||
|
data->config_index = index;
|
||||||
|
data->idn_pos = pos;
|
||||||
|
|
||||||
|
if (ioctl(fd, EC_IOCTL_CONFIG_IDN, data) < 0) {
|
||||||
|
stringstream err;
|
||||||
|
err << "Failed to get slave config IDN: " << strerror(errno);
|
||||||
|
throw MasterDeviceException(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/****************************************************************************/
|
||||||
|
|
||||||
void MasterDevice::getDomain(ec_ioctl_domain_t *data, unsigned int index)
|
void MasterDevice::getDomain(ec_ioctl_domain_t *data, unsigned int index)
|
||||||
{
|
{
|
||||||
data->index = index;
|
data->index = index;
|
||||||
|
|
|
||||||
|
|
@ -116,6 +116,7 @@ class MasterDevice
|
||||||
void getConfigPdoEntry(ec_ioctl_config_pdo_entry_t *, unsigned int,
|
void getConfigPdoEntry(ec_ioctl_config_pdo_entry_t *, unsigned int,
|
||||||
uint8_t, uint16_t, uint8_t);
|
uint8_t, uint16_t, uint8_t);
|
||||||
void getConfigSdo(ec_ioctl_config_sdo_t *, unsigned int, unsigned int);
|
void getConfigSdo(ec_ioctl_config_sdo_t *, unsigned int, unsigned int);
|
||||||
|
void getConfigIdn(ec_ioctl_config_idn_t *, unsigned int, unsigned int);
|
||||||
void getDomain(ec_ioctl_domain_t *, unsigned int);
|
void getDomain(ec_ioctl_domain_t *, unsigned int);
|
||||||
void getFmmu(ec_ioctl_domain_fmmu_t *, unsigned int, unsigned int);
|
void getFmmu(ec_ioctl_domain_fmmu_t *, unsigned int, unsigned int);
|
||||||
void getData(ec_ioctl_domain_data_t *, unsigned int, unsigned int,
|
void getData(ec_ioctl_domain_data_t *, unsigned int, unsigned int,
|
||||||
|
|
|
||||||
|
|
@ -36,13 +36,6 @@ extern const ec_code_msg_t soe_error_codes[];
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
SoeCommand::SoeCommand(const string &name, const string &briefDesc):
|
|
||||||
Command(name, briefDesc)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
|
||||||
|
|
||||||
uint16_t SoeCommand::parseIdn(const string &str)
|
uint16_t SoeCommand::parseIdn(const string &str)
|
||||||
{
|
{
|
||||||
uint16_t idn = 0x0000;
|
uint16_t idn = 0x0000;
|
||||||
|
|
@ -109,6 +102,19 @@ uint16_t SoeCommand::parseIdn(const string &str)
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
string SoeCommand::outputIdn(uint16_t idn)
|
||||||
|
{
|
||||||
|
stringstream str;
|
||||||
|
|
||||||
|
str << ((idn & 0x8000) ? 'P' : 'S')
|
||||||
|
<< "-" << ((idn >> 12) & 0x07)
|
||||||
|
<< "-" << setfill('0') << setw(4) << (idn & 0x0fff);
|
||||||
|
|
||||||
|
return str.str();
|
||||||
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
/** Outputs an SoE error code.
|
/** Outputs an SoE error code.
|
||||||
*/
|
*/
|
||||||
std::string SoeCommand::errorMsg(uint16_t code)
|
std::string SoeCommand::errorMsg(uint16_t code)
|
||||||
|
|
|
||||||
|
|
@ -37,15 +37,11 @@
|
||||||
|
|
||||||
/****************************************************************************/
|
/****************************************************************************/
|
||||||
|
|
||||||
class SoeCommand:
|
class SoeCommand
|
||||||
public Command,
|
|
||||||
public DataTypeHandler
|
|
||||||
{
|
{
|
||||||
public:
|
|
||||||
SoeCommand(const string &, const string &);
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
static uint16_t parseIdn(const string &);
|
static uint16_t parseIdn(const string &);
|
||||||
|
static std::string outputIdn(uint16_t);
|
||||||
static std::string errorMsg(uint16_t);
|
static std::string errorMsg(uint16_t);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -312,7 +312,7 @@ int main(int argc, char **argv)
|
||||||
cmd->execute(commandArgs);
|
cmd->execute(commandArgs);
|
||||||
} catch (InvalidUsageException &e) {
|
} catch (InvalidUsageException &e) {
|
||||||
cerr << e.what() << endl << endl;
|
cerr << e.what() << endl << endl;
|
||||||
cerr << binaryBaseName << " " << cmd->helpString();
|
cerr << cmd->helpString(binaryBaseName);
|
||||||
retval = 1;
|
retval = 1;
|
||||||
} catch (CommandException &e) {
|
} catch (CommandException &e) {
|
||||||
cerr << e.what() << endl;
|
cerr << e.what() << endl;
|
||||||
|
|
@ -322,7 +322,7 @@ int main(int argc, char **argv)
|
||||||
retval = 1;
|
retval = 1;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
cout << binaryBaseName << " " << cmd->helpString();
|
cout << cmd->helpString(binaryBaseName);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
cerr << "Ambiguous command abbreviation! Matching:" << endl;
|
cerr << "Ambiguous command abbreviation! Matching:" << endl;
|
||||||
|
|
|
||||||
|
|
@ -43,6 +43,7 @@
|
||||||
#include <linux/version.h>
|
#include <linux/version.h>
|
||||||
#include <linux/serial.h>
|
#include <linux/serial.h>
|
||||||
#include <linux/uaccess.h>
|
#include <linux/uaccess.h>
|
||||||
|
#include <linux/slab.h>
|
||||||
|
|
||||||
#include "../master/globals.h"
|
#include "../master/globals.h"
|
||||||
#include "../include/ectty.h"
|
#include "../include/ectty.h"
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue