tool/MasterDevice.cpp
changeset 1327 4d179b06dd3c
parent 1238 02711963a059
child 1335 09c6fce1ae45
equal deleted inserted replaced
1326:ef907b0b5125 1327:4d179b06dd3c
   105     data->sync_index = sync_index;
   105     data->sync_index = sync_index;
   106     data->pdo_pos = pdo_pos;
   106     data->pdo_pos = pdo_pos;
   107 
   107 
   108     if (ioctl(fd, EC_IOCTL_CONFIG_PDO, data) < 0) {
   108     if (ioctl(fd, EC_IOCTL_CONFIG_PDO, data) < 0) {
   109         stringstream err;
   109         stringstream err;
   110         err << "Failed to get slave config Pdo: " << strerror(errno);
   110         err << "Failed to get slave config PDO: " << strerror(errno);
   111         throw MasterDeviceException(err);
   111         throw MasterDeviceException(err);
   112     }
   112     }
   113 }
   113 }
   114 
   114 
   115 /****************************************************************************/
   115 /****************************************************************************/
   127     data->pdo_pos = pdo_pos;
   127     data->pdo_pos = pdo_pos;
   128     data->entry_pos = entry_pos;
   128     data->entry_pos = entry_pos;
   129 
   129 
   130     if (ioctl(fd, EC_IOCTL_CONFIG_PDO_ENTRY, data) < 0) {
   130     if (ioctl(fd, EC_IOCTL_CONFIG_PDO_ENTRY, data) < 0) {
   131         stringstream err;
   131         stringstream err;
   132         err << "Failed to get slave config Pdo entry: " << strerror(errno);
   132         err << "Failed to get slave config PDO entry: " << strerror(errno);
   133         throw MasterDeviceException(err);
   133         throw MasterDeviceException(err);
   134     }
   134     }
   135 }
   135 }
   136 
   136 
   137 /****************************************************************************/
   137 /****************************************************************************/
   145     data->config_index = index;
   145     data->config_index = index;
   146     data->sdo_pos = sdo_pos;
   146     data->sdo_pos = sdo_pos;
   147 
   147 
   148     if (ioctl(fd, EC_IOCTL_CONFIG_SDO, data) < 0) {
   148     if (ioctl(fd, EC_IOCTL_CONFIG_SDO, data) < 0) {
   149         stringstream err;
   149         stringstream err;
   150         err << "Failed to get slave config Sdo: " << strerror(errno);
   150         err << "Failed to get slave config SDO: " << strerror(errno);
   151         throw MasterDeviceException(err);
   151         throw MasterDeviceException(err);
   152     }
   152     }
   153 }
   153 }
   154 
   154 
   155 /****************************************************************************/
   155 /****************************************************************************/
   251     pdo->sync_index = syncIndex;
   251     pdo->sync_index = syncIndex;
   252     pdo->pdo_pos = pdoPos;
   252     pdo->pdo_pos = pdoPos;
   253 
   253 
   254     if (ioctl(fd, EC_IOCTL_SLAVE_SYNC_PDO, pdo)) {
   254     if (ioctl(fd, EC_IOCTL_SLAVE_SYNC_PDO, pdo)) {
   255         stringstream err;
   255         stringstream err;
   256         err << "Failed to get Pdo: " << strerror(errno);
   256         err << "Failed to get PDO: " << strerror(errno);
   257         throw MasterDeviceException(err);
   257         throw MasterDeviceException(err);
   258     }
   258     }
   259 }
   259 }
   260 
   260 
   261 /****************************************************************************/
   261 /****************************************************************************/
   273     entry->pdo_pos = pdoPos;
   273     entry->pdo_pos = pdoPos;
   274     entry->entry_pos = entryPos;
   274     entry->entry_pos = entryPos;
   275 
   275 
   276     if (ioctl(fd, EC_IOCTL_SLAVE_SYNC_PDO_ENTRY, entry)) {
   276     if (ioctl(fd, EC_IOCTL_SLAVE_SYNC_PDO_ENTRY, entry)) {
   277         stringstream err;
   277         stringstream err;
   278         err << "Failed to get Pdo entry: " << strerror(errno);
   278         err << "Failed to get PDO entry: " << strerror(errno);
   279         throw MasterDeviceException(err);
   279         throw MasterDeviceException(err);
   280     }
   280     }
   281 }
   281 }
   282 
   282 
   283 /****************************************************************************/
   283 /****************************************************************************/
   291     sdo->slave_position = slaveIndex;
   291     sdo->slave_position = slaveIndex;
   292     sdo->sdo_position = sdoPosition;
   292     sdo->sdo_position = sdoPosition;
   293 
   293 
   294     if (ioctl(fd, EC_IOCTL_SLAVE_SDO, sdo)) {
   294     if (ioctl(fd, EC_IOCTL_SLAVE_SDO, sdo)) {
   295         stringstream err;
   295         stringstream err;
   296         err << "Failed to get Sdo: " << strerror(errno);
   296         err << "Failed to get SDO: " << strerror(errno);
   297         throw MasterDeviceException(err);
   297         throw MasterDeviceException(err);
   298     }
   298     }
   299 }
   299 }
   300 
   300 
   301 /****************************************************************************/
   301 /****************************************************************************/
   311     entry->sdo_spec = sdoSpec;
   311     entry->sdo_spec = sdoSpec;
   312     entry->sdo_entry_subindex = entrySubindex;
   312     entry->sdo_entry_subindex = entrySubindex;
   313 
   313 
   314     if (ioctl(fd, EC_IOCTL_SLAVE_SDO_ENTRY, entry)) {
   314     if (ioctl(fd, EC_IOCTL_SLAVE_SDO_ENTRY, entry)) {
   315         stringstream err;
   315         stringstream err;
   316         err << "Failed to get Sdo entry: " << strerror(errno);
   316         err << "Failed to get SDO entry: " << strerror(errno);
   317         throw MasterDeviceException(err);
   317         throw MasterDeviceException(err);
   318     }
   318     }
   319 }
   319 }
   320 
   320 
   321 /****************************************************************************/
   321 /****************************************************************************/
   388     if (ioctl(fd, EC_IOCTL_SLAVE_SDO_DOWNLOAD, data) < 0) {
   388     if (ioctl(fd, EC_IOCTL_SLAVE_SDO_DOWNLOAD, data) < 0) {
   389         stringstream err;
   389         stringstream err;
   390         if (errno == EIO && data->abort_code) {
   390         if (errno == EIO && data->abort_code) {
   391             throw MasterDeviceSdoAbortException(data->abort_code);
   391             throw MasterDeviceSdoAbortException(data->abort_code);
   392         } else {
   392         } else {
   393             err << "Failed to download Sdo: " << strerror(errno);
   393             err << "Failed to download SDO: " << strerror(errno);
   394             throw MasterDeviceException(err);
   394             throw MasterDeviceException(err);
   395         }
   395         }
   396 	}
   396 	}
   397 }
   397 }
   398 
   398 
   403     if (ioctl(fd, EC_IOCTL_SLAVE_SDO_UPLOAD, data) < 0) {
   403     if (ioctl(fd, EC_IOCTL_SLAVE_SDO_UPLOAD, data) < 0) {
   404         stringstream err;
   404         stringstream err;
   405         if (errno == EIO && data->abort_code) {
   405         if (errno == EIO && data->abort_code) {
   406             throw MasterDeviceSdoAbortException(data->abort_code);
   406             throw MasterDeviceSdoAbortException(data->abort_code);
   407         } else {
   407         } else {
   408             err << "Failed to upload Sdo: " << strerror(errno);
   408             err << "Failed to upload SDO: " << strerror(errno);
   409             throw MasterDeviceException(err);
   409             throw MasterDeviceException(err);
   410         }
   410         }
   411     }
   411     }
   412 }
   412 }
   413 
   413