Discussion:
DIG_Transfer returns error -10003 when passed mapped view of file
(too old to reply)
Buffning
2006-08-11 17:10:10 UTC
Permalink
I'm using a 6533 PCMCIA card and i'm trying to use memory mapping to
improve the performance.  DIG_DB_Transfer returns an error of
invalid numeric parameter, when I pass it a mapped view of a file
(portion of code shown below).  If I pass Transfer a normal
character array and save that array in memory location, the error
disappears and the data gets mapped to the harddrive, but this would
seem to slow down the process significantly.  Why doesn't
DIG_DB_Transfer accept this call?
-----
memorylocation = (char*) MapViewOfFile(hmemmap, FILE_MAP_WRITE, 0, numberofbuffersmapped*ulPtsTfr*2, ulPtsTfr*2);
iStatus = DIG_DB_Transfer(iDevice, iGroup, (short*) memorylocation, ulPtsTfr);
               
Buffning
2006-08-14 21:10:14 UTC
Permalink
I have absolutely no idea what WINE is.  Looking online it looks
like a way to run windows on Unix.  I'm not using that as far as I
can tell.  I'm running on windows XP using microsoft XP and
running microsoft SDK and programming in c++.  the functions i
specifically posted were under the kernel32 library.  Mapping a
view of the file, theoretically, should just return a pointer to an
area of the harddrive inside of a created file so that I can put things
directly onto the disk as opposed to passing through RAM, which I was
hoping would cut down on memory transfers and speed up the
process. 

Thanks,
Mark
Buffning
2006-08-15 18:10:12 UTC
Permalink
I attached the entire program below.  The problem seems to be in
the line of the DB_Transfer function though because if I uncomment the
char* memtowrite and pass memtowrite in place of memorylocation, the
code works fine (albeit too slowly for my needs since I then have to
transfer from memtowrite into memory.)




void main(void)
{
    cout << "This program should display out
information as to what it is taking \n in and where in the program it
currently is so that \n we can check to see where the program is
failing.\n" << endl;
// handle file I/O and get location to store data
    char filename[32];
    short *memorylocation;
    ofstream outputfile;

    u32 numberofbuffersmapped=0, numberofbuffersinfile=13000;
    const u32 buffersize = 800;  // sets up size of
buffer, must be divisible by 16 so that whole number of bytes can be
drawn from it

    HANDLE hfile, hmemmap;
    DWORD lasterror;

    LPCWSTR temp = MultiCharToUniChar((char*) &"hello.txt");
    hfile = CreateFile(temp, GENERIC_WRITE | GENERIC_READ, FILE_SHARE_WRITE, NULL, CREATE_ALWAYS, 0, NULL);
    delete[] temp;
    lasterror = GetLastError();
    if ( hfile == INVALID_HANDLE_VALUE )
         printf( "Cannot open file because %d \n", lasterror);
    
    hmemmap = CreateFileMapping(hfile, NULL, PAGE_READWRITE, 0, numberofbuffersinfile*buffersize, NULL);
    lasterror = GetLastError();
    if ( hmemmap == INVALID_HANDLE_VALUE )
         printf( "Cannot open mememap because %d \n", lasterror);

    
//initiate variables to be used in card interface
    const i16 itimetowaitbeforeending = 6; // in seconds
    i16 iStatus = 0;
    i16 iRetVal = 0;
    const i16 iDevice = 1;
    const i16 iGroup = 1;
    const i16 iGroupSize = 2;
    const i16 iPort = 0;
    const i16 iDir = 0;
    const i16 iProtocol = 0;
    const i16 iEdge = 0;
    const i16 ireqPol = 1;
    const i16 iackPol = 0;
    const i16 iackDelayTime =0;
    const i16 iPgConfig = 1;
    const i16 iReqSource = 1;
    const i16 iPgTB = -3; 
    const i16 iReqInt = 10;
    const i16 iExtGate = 0;
    const i16 iDBModeON = 1;
    const i16 iDBModeOFF = 0;
    const i16 iOldDataStop = 1;
    static i16 piBuffer[buffersize]={0};
    const u32 ulPtsTfr = buffersize/2;
    const i16 iPartialTransfer = 0;
    const i16 iIgnoreWarning = 0;    //1 to ignore warning,
    const i32 lTimeout = 180;
    const i16 iYieldON = 1;
    u32 PointsRemaining     = 0;
    u32 lastpointsremaining = buffersize*numberofbuffersinfile;
//    char *memtowrite;
//    memtowrite = new char [buffersize];

// set up time to find when timeout occurs to stop program
    clock_t start = clock();
    clock_t end = clock();

    iStatus = DIG_Block_Clear(iDevice, iGroup);
    
    iStatus = Timeout_Config(iDevice, lTimeout);  // set to 10 seconds
    iRetVal = NIDAQErrorHandler(iStatus, "Timeout_Config", iIgnoreWarning);

    /* Configure group of ports as input, with
Buffning
2006-08-19 18:10:08 UTC
Permalink
I've checked mapviewoffile and it seems to be working.  it lets me
use it and the data i store in it gets written to the file like it
should.  I haven't checked to see if it returns an odd address
that would misalign the 2 byte shorts that are to be stored in
it. 

Thanks for the help
Mark

Loading...