LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Programming NI PCI 1588

I a working with two NI PCI 1588 NIC cards and need a lot of help getting them up and running.  So far I have installed the cards and need help writing a program for the cards.  I am using MSVS C++ 2005.  I have found the NI-Sync API Reference Help and have been trying to put something together to communicate with my cards but to no avail.  I am getting lots of errors related to the inputs involved in these function calls.  It has been a while since I have used C++.  Is there a help file for all of the visa types that are used in the ni-sync function calls? 

If anyone can get me started on the right foot it would be greatly apprectiated.
0 Kudos
Message 1 of 21
(5,149 Views)
Hey HNelson,
 
Have you had a chance to analyze the CVI examples. They're C Style, and may be able to help you get a starting point. You can find them at Start->Programs->National Instruments->NI-Sync->Examples->CVI Examples.
 
Regards,
 
Nick D.
 

Message Edited by Nick D on 08-01-2007 08:29 AM

0 Kudos
Message 2 of 21
(5,127 Views)
Yes, I have taken a look in the example folders however I cannot find one that relates to the PCI 1588 card.  All of the examples discuss different cards if im not mistaken.  The closest thing I have found and tried utilizing is this thread:

http://forums.ni.com/ni/board/message?board.id=180&message.id=22931&query.id=148547#M22931

I have walked through the code using the NI-Sync API Reference guide and understand the processes that he/she is going through however I cannot seem to duplicate the code.  I have tried the following:

----------------------------------------------------------

#include "stdafx.h"
#include <iostream>
#include "conio.h"
#include "nisync.h"
#include "visa.h"
#include "visatype.h"
#include "vpptype.h"
#include "visaext.h"
#include <string>
using namespace std;

int main()    {

    ViStatus status;
    ViChar emsg;
    ViSession myVi;

    status = niSync_init("PXI3::4::INSTR", VI_TRUE, VI_TRUE, &myVi);
    if (status) // error or warning
    {
        niSync_error_message (myVi, status, emsg);
        printf("niSync_init did not succeed: %s\n", emsg);
    }
    else
    {
        cout << endl << endl <<"Press any key to terminate program: ";
        _getch();
    }
    return 0;
}

----------------------------------------------------------

When I try to compile this i recieve the errors:

c:\documents and settings\hnelson\my documents\visual studio 2005\projects\1588 test\1588 test\1588 test.cpp(24) : error C2664: 'niSync_error_message' : cannot convert parameter 3 from 'ViChar' to 'ViChar []'
        Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast

This is my first time using VC++.  I am trying to start small talking to the card and then build from there.  I am slowely remembering C++ programming but I am not sure how to fix the error without knowing the ViChar variable type.

0 Kudos
Message 3 of 21
(5,122 Views)
I think the ViSession myVi; needs to be ViSession *myVi;
0 Kudos
Message 4 of 21
(5,133 Views)
I thought it would have something to do with pointers/arrays too but no luck.  By changing "ViSession myVi;" to "ViSession *myVi;" the following two errors appear:

c:\documents and settings\hnelson\my documents\visual studio 2005\projects\1588 test\1588 test\1588 test.cpp(21) : error C2664: 'niSync_init' : cannot convert parameter 4 from 'ViSession **__w64 ' to 'ViSession *'
        Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
c:\documents and settings\hnelson\my documents\visual studio 2005\projects\1588 test\1588 test\1588 test.cpp(24) : error C2664: 'niSync_error_message' : cannot convert parameter 1 from 'ViSession *' to 'ViSession'
        There is no context in which this conversion is possible



0 Kudos
Message 5 of 21
(5,127 Views)

Your:

    ViChar emsg;

needs to be:

    ViChar emsg [256];   // Or however big a string you are expecting...


otherwise there is no space allocated for a message, just a single character.

JR

0 Kudos
Message 6 of 21
(5,111 Views)
Okay, I have changed emsg as well so I currently have the following:

#include "stdafx.h"
#include <iostream>
#include "conio.h"
#include "nisync.h"
#include "visa.h"
#include "visatype.h"
#include "vpptype.h"
#include "visaext.h"
#include <string>
using namespace std;

int main()    {

    ViStatus status;
    ViChar emsg [256];
    ViSession *myVi;

    status = niSync_init("PXI3::4::INSTR", VI_TRUE, VI_TRUE, &myVi);
    if (status) // error or warning
    {
        niSync_error_message (myVi, status, emsg);
        printf("niSync_init did not succeed: %s\n", emsg);
    }
    else
    {
        cout << endl << endl <<"Press any key to terminate program: ";
        _getch();
    }
    return 0;
}


I still get the same two errors described above.


Is there any help file similar to the NI-Sync API Reference but for the Visa Libraries?
0 Kudos
Message 7 of 21
(5,109 Views)

I'm afraid Joshua's tip is incorrect. Put myVi back to how you had it to start with and all should be well.

JR

0 Kudos
Message 8 of 21
(5,106 Views)
after changing myVi back I get the following errors:

1588 Test.obj : error LNK2019: unresolved external symbol _niSync_error_message@12 referenced in function _main
1588 Test.obj : error LNK2019: unresolved external symbol _niSync_init@16 referenced in function _main

0 Kudos
Message 9 of 21
(5,104 Views)

So it now compiles OK but you get link errors. I'm not that familiar with the VC++ environment but I would guess that you need to include the correct .lib file somewhere in the Linker options.

JR

0 Kudos
Message 10 of 21
(5,101 Views)