Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. GPIB in QT

GPIB in QT

Scheduled Pinned Locked Moved General and Desktop
26 Posts 6 Posters 16.7k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • I Offline
    I Offline
    Ivan1120
    wrote on last edited by
    #1

    Hi everyone:
    Does anyone have experiences about using GPIB in QT? If I want to implement it, is it possible?? I need to build communication between device and computer through "NI GPIB-USB-HS". Can someone give me some directions?? Thanks.

    Information of "NI GPIB-USB-HS" is following:

    http://sine.ni.com/nips/cds/view/p/lang/en/nid/201586

    1 Reply Last reply
    0
    • C Offline
      C Offline
      ChrisW67
      wrote on last edited by
      #2

      Qt has no facilities for USB manipulation.

      Your C++ compiler will allow you to link to the manufacturer provided Windows or Linux shared library. Consult the manufacturer's documentation for the API.

      1 Reply Last reply
      0
      • I Offline
        I Offline
        Ivan1120
        wrote on last edited by
        #3

        I have already found the API I need and implemented in VS2008 using C# before, but when I tried following step in QT:

        [Project name]->click right button of mouse->Add Library->choose External library

        It can only choose .lib file, but the API manufacturer provided is .dll file.Furthermore, it's for .net framework, can it work on QT??

        1 Reply Last reply
        0
        • jazzycamelJ Offline
          jazzycamelJ Offline
          jazzycamel
          wrote on last edited by
          #4

          One of the quickest ways to use a DLL on windows is simply to load the library with "LoadLibrary":http://msdn.microsoft.com/en-us/library/windows/desktop/ms684175.aspx and then use "GetProcAddress":http://msdn.microsoft.com/en-us/library/windows/desktop/ms683212.aspx to get a handle to each of the methods you wish to use. I've done this with homemade and 3rd party DLL's alike. Also, loading a module this way should also load any of its required dependencies (such .NET elements).

          Hope this helps ;o)

          For the avoidance of doubt:

          1. All my code samples (C++ or Python) are tested before posting
          2. As of 23/03/20, my Python code is formatted to PEP-8 standards using black from the PSF (https://github.com/psf/black)
          1 Reply Last reply
          0
          • I Offline
            I Offline
            Ivan1120
            wrote on last edited by
            #5

            Thanks, I will try.But someone told me .dll from .net can't work on native C or C++, like QT.

            1 Reply Last reply
            0
            • C Offline
              C Offline
              ChrisW67
              wrote on last edited by
              #6

              Qt is a library. It has nothing at all to do with whether your compiler tool chain can link to another library of any sort.

              From the "driver readme":http://download.ni.com/support/softlib//gpib/Windows/3.1.1/ReadMe.html:

              The following table lists the programming languages and Microsoft Visual Studio versions supported by NI-488.2.
              Programming Language Visual Studio Versions Supported by NI-488.2
              Unmanaged C/C++ 6.0[1][2], 2003[2], 2005, 2008, 2010, and 2012

              It would seem that you should no issue with any MSVC compiler/linker

              1 Reply Last reply
              0
              • I Offline
                I Offline
                Ivan1120
                wrote on last edited by
                #7

                Thanks. I have some question about you mentioned, Is MSVC compiler different with Unmanaged C/C++6.0, 2003.. etc, I have no idea into MSVC compiler, does it work on QT only !?Actually, I found some information yesterday in the following link:

                http://forums.ni.com/t5/Instrument-Control-GPIB-Serial/Access-ni4882-dll-with-Qt-and-MinGW/td-p/1985471

                But I can't do same thing as this forum said, I didn't know some tool I could find somewhere. It's a big challenge for me in my work.

                1 Reply Last reply
                0
                • C Offline
                  C Offline
                  ChrisW67
                  wrote on last edited by
                  #8

                  MSVC = Microsoft Visual C++, the compiler included in most versions of the Windows SDK and Visual Studio. If you have Visual Studio for .Net work then chances are you have Microsoft's C++ compiler already (i.e. CL.exe). The compiler is not part of Qt.

                  Unmanaged code means "not .Net" code. There should be a matching set of include files, *.lib file(s), and *.dll file(s) provided by the manufacturer.

                  If you are using MSVC as your compiler then you should have nothing special to do to use the supplied library files with your application.

                  If you are using MinGW as your C++ compiler and the manufacturer library has C-style bindings (seems to be the case) then you should have nothing special to do use it with this tool chain.

                  1 Reply Last reply
                  0
                  • I Offline
                    I Offline
                    Ivan1120
                    wrote on last edited by
                    #9

                    My compiler is MSCV, Microsoft Visual C++ Compiler 9.0(x86).The .dll comes from the manufacturer is built by .net.I can get them from their website, so they are matched, right? If they are matched. how could I use them in QT ?? I knew method of using "QLibrary", but I want is a whole class in the .dll, not function.By the way, total functions I need are included in class, so I should using the class, aren't !? Thanks for your answer in advance.

                    1 Reply Last reply
                    0
                    • D Offline
                      D Offline
                      dbzhang800
                      wrote on last edited by
                      #10

                      No, the managed .dll can not be accessed by native C++ code directly!

                      --
                      BTW,

                      If you really want to call managed .dll from native c++ code in the furture, you can ref: http://support.microsoft.com/kb/828736

                      1 Reply Last reply
                      0
                      • I Offline
                        I Offline
                        Ivan1120
                        wrote on last edited by
                        #11

                        Is native C++ code as same as unmanaged code !?

                        1 Reply Last reply
                        0
                        • D Offline
                          D Offline
                          dbzhang800
                          wrote on last edited by
                          #12

                          Yes, native code is compiled to work directly with the OS, which is not managed by the CLR (Common Language Runtime).

                          1 Reply Last reply
                          0
                          • I Offline
                            I Offline
                            Ivan1120
                            wrote on last edited by
                            #13

                            http://en.wikipedia.org/wiki/Managed_code
                            Look above link, C++ also can be manage code, so C++ can be managed code(C++ in .net) and unmanaged code(Native C++), right !? It depends on which environment developer to use.

                            1 Reply Last reply
                            0
                            • D Offline
                              D Offline
                              dbzhang800
                              wrote on last edited by
                              #14

                              [quote author="Ivan1120" date="1374561273"]http://en.wikipedia.org/wiki/Managed_code
                              Look above link, C++ also can be manage code, so C++ can be managed code(C++ in .net) and unmanaged code(Native C++), right !? It depends on which environment developer to use. [/quote]

                              Yes, it is depending the options you passed to the msvc c++ compiler. take a simple c++ application for example:

                              @
                              #include <iostream>

                              int main()
                              {
                              std::cout<<"Hello From MSVC"<<std::endl;
                              return 0;
                              }
                              @

                              It can be compiled as native code

                              @
                              cl a.cpp
                              @

                              or compiled as managed code

                              @
                              cl /clr a.cpp
                              @

                              But in Qt world, only native C++ code make sense at present.


                              BTW, you should use the native c/c++ api provided by your device manipulater

                              1 Reply Last reply
                              0
                              • I Offline
                                I Offline
                                Ivan1120
                                wrote on last edited by
                                #15

                                I have one more question, I tried the direction you gave me from below link:

                                http://support.microsoft.com/kb/828736

                                In the article, the step 9 of "Call the Managed DLL from Native C++ Code",
                                @// Initialize COM.
                                HRESULT hr = CoInitialize(NULL);

                                // Create the interface pointer.
                                ICalculatorPtr pICalc(__uuidof(ManagedClass));

                                long lResult = 0;

                                // Call the Add method.
                                pICalc->Add(5, 10, &lResult);

                                wprintf(L"The result is %d", lResult);

                                // Uninitialize COM.
                                CoUninitialize();
                                return 0;@
                                What is "ICalculatorPtr"?? The .dll I built from above link, ICalculator is interface, my question is if I want to use .dll from device manufacturer provided, their .dll file should be written from interface ??

                                1 Reply Last reply
                                0
                                • I Offline
                                  I Offline
                                  Ivan1120
                                  wrote on last edited by
                                  #16

                                  Does anybody know!?

                                  1 Reply Last reply
                                  0
                                  • JKSHJ Offline
                                    JKSHJ Offline
                                    JKSH
                                    Moderators
                                    wrote on last edited by
                                    #17

                                    Try http://social.msdn.microsoft.com/Forums/vstudio/en-US/217608ea-e499-458a-af36-2dcffd36b323/microsoft-howto-does-not-work-how-to-call-a-managed-dll-from-native-visual-c-code-in-visual

                                    Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

                                    1 Reply Last reply
                                    0
                                    • I Offline
                                      I Offline
                                      Ivan1120
                                      wrote on last edited by
                                      #18

                                      Thanks, my code can work well.But I want to know what is “ICalculatorPtr”, I didn't see any definition of it. Because if I use this method in the future, this would be a important issue. Thanks in advance.

                                      1 Reply Last reply
                                      0
                                      • JKSHJ Offline
                                        JKSHJ Offline
                                        JKSH
                                        Moderators
                                        wrote on last edited by
                                        #19

                                        I've never seen it myself, sorry. Try asking at a Microsoft forum, since it's from Microsoft API.

                                        Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

                                        1 Reply Last reply
                                        0
                                        • I Offline
                                          I Offline
                                          Ivan1120
                                          wrote on last edited by
                                          #20

                                          Thank you:)). If I can't get answer here, maybe I'll go to ask in Microsoft forum.Does any body know what is “ICalculatorPtr” and how does it generate??

                                          1 Reply Last reply
                                          0

                                          • Login

                                          • Login or register to search.
                                          • First post
                                            Last post
                                          0
                                          • Categories
                                          • Recent
                                          • Tags
                                          • Popular
                                          • Users
                                          • Groups
                                          • Search
                                          • Get Qt Extensions
                                          • Unsolved