129,6 → 129,7 |
if (ioctl(dev->nFileNo, PCIVME_INIT_HARDWARE, &init) < 0) |
{ |
dev->nLastError = errno; |
printf("initHardware:err=%d %s\n" , errno, strerror(errno) ); |
return errno; |
} |
|
147,6 → 148,7 |
if (ioctl(dev->nFileNo, PCIVME_DEINIT_HARDWARE, &deinit) < 0) |
{ |
dev->nLastError = errno; |
printf("deInitHardware:err=%d %s\n" , errno, strerror(errno) ); |
return errno; |
} |
|
165,10 → 167,11 |
return errno; |
|
dev->nFileNo = open(cszDeviceName, O_RDWR); |
|
printf("VMEopen: dev->nFileNo %d size=%d %s\n" , dev->nFileNo,sizeof(*dev), cszDeviceName ); |
if (dev->nFileNo == -1) |
{ |
error = errno; |
printf("VMEopen:err=%d %s\n" , error, strerror(error) ); |
free(dev); |
return error; |
} |
177,7 → 180,7 |
*pnHandle = (int)dev; |
|
error = initHardware(dev); |
if (error) |
if (error) |
return error; |
|
dev->nLastError = 0; |
205,6 → 208,7 |
if (ioctl(dev->nFileNo, PCIVME_SET_ACCESS_PARA, &access_command) < 0) |
{ |
dev->nLastError = errno; |
printf("setAccessProperties:err=%d %s\n" , errno, strerror(errno) ); |
return errno; |
} |
|
220,18 → 224,31 |
size_t count = (size_t)(ulElementCount * ubAccessWidth); |
ssize_t result; |
int error; |
long pos; |
|
printf("VMEread: AW 0x%0x 0x%0x , AM 0x%0x \n", dev->cAccessWidth, ubAccessWidth, dev->cAddressModifier); |
if (dev->cAccessWidth != ubAccessWidth) |
{ |
if ((error = setAccessProperties(nHandle, dev->cAddressModifier, ubAccessWidth))) |
return error; |
} |
pos = lseek(dev->nFileNo, ulAddress, SEEK_SET); |
|
if ( pos < 0){ |
printf("VMEread: pos=0x%08lx dev->nFileNo=%d ADDR=0x%08lx %s\n",pos, dev->nFileNo, ulAddress, strerror(errno)); |
switch (errno){ |
case EBADF:printf("errno =EBADF\n");break; |
case EINVAL:printf("errno =EINVAL\n");break; |
case EOVERFLOW:printf("errno =EOVERFLOW\n");break; |
case ESPIPE:printf("errno =ESPIPE\n");break; |
case ENXIO:printf("errno =ENXIO\n");break; |
} |
//return errno; |
} |
|
if (lseek(dev->nFileNo, ulAddress, SEEK_SET) < 0) |
return errno; |
|
|
result = read(dev->nFileNo, pvBuffer, count); |
|
printf("VMEread: read %d dev->nFileNo=%d err=%d %s\n",count, dev->nFileNo, errno, strerror(errno)); |
if (result != count) |
{ |
if (result < 0) |
252,7 → 269,9 |
size_t count = (size_t)(ulElementCount * ubAccessWidth); |
ssize_t result; |
int error; |
long pos; |
|
printf("VMEwrite: AW 0x%0x 0x%0x , AM 0x%0x \n", dev->cAccessWidth, ubAccessWidth, dev->cAddressModifier); |
if (dev->cAccessWidth != ubAccessWidth) |
{ |
if ((error = setAccessProperties(nHandle, dev->cAddressModifier, ubAccessWidth))) |
259,16 → 278,26 |
return error; |
} |
|
if (lseek(dev->nFileNo, ulAddress, SEEK_SET) < 0) |
return errno; |
|
pos = lseek(dev->nFileNo, ulAddress, SEEK_SET); |
if (pos < 0){ |
printf("VMEwrite: pos=0x%08lx dev->nFileNo=%d ADDR=0x%08lx %s\n",pos, dev->nFileNo, ulAddress, strerror(errno)); |
switch (errno){ |
case EBADF:printf("errno =EBADF\n");break; |
case EINVAL:printf("errno =EINVAL\n");break; |
case EOVERFLOW:printf("errno =EOVERFLOW\n");break; |
case ESPIPE:printf("errno =ESPIPE\n");break; |
case ENXIO:printf("errno =ENXIO\n");break; |
} |
//return errno; |
} |
result = write(dev->nFileNo, pvBuffer, count); |
|
printf("VMEwrite: write %d dev->nFileNo=%d err=%d %s\n",count, dev->nFileNo,errno, strerror(errno)); |
if (result != count) |
{ |
if (result < 0) |
{ |
dev->nLastError = errno; |
|
return errno; |
} |
else |