From 44ba1bdec6529bc1d6293328121880a3f0623840 Mon Sep 17 00:00:00 2001 From: Florian Pose Date: Tue, 10 Jun 2008 09:05:54 +0000 Subject: [PATCH] Open device with correct permissions immediately. --- tools/Master.cpp | 12 +++--------- tools/Master.h | 1 - 2 files changed, 3 insertions(+), 10 deletions(-) diff --git a/tools/Master.cpp b/tools/Master.cpp index 6bcb2cc7..2bae6fd0 100644 --- a/tools/Master.cpp +++ b/tools/Master.cpp @@ -100,7 +100,6 @@ Master::Master() { index = 0; fd = -1; - currentPermissions = Read; } /****************************************************************************/ @@ -416,7 +415,7 @@ void Master::sdoDownload( ec_ioctl_sdo_entry_t entry; unsigned int entryByteSize; - open(Read); + open(ReadWrite); try { getSdoEntry(&entry, slavePosition, @@ -869,11 +868,7 @@ void Master::open(Permissions perm) stringstream deviceName; if (fd != -1) { // already open - if (currentPermissions < perm) { // more permissions required - close(); - } else { - return; - } + return; } deviceName << "/dev/EtherCAT" << index; @@ -885,8 +880,6 @@ void Master::open(Permissions perm) << strerror(errno); throw MasterException(err.str()); } - - currentPermissions = perm; } /****************************************************************************/ @@ -897,6 +890,7 @@ void Master::close() return; ::close(fd); + fd = -1; } /*****************************************************************************/ diff --git a/tools/Master.h b/tools/Master.h index 3b8bd2f8..817581e0 100644 --- a/tools/Master.h +++ b/tools/Master.h @@ -93,7 +93,6 @@ class Master unsigned int index; int fd; - Permissions currentPermissions; }; /****************************************************************************/