Qt Programming: Serial Port Communication Module / Plugin

First, let me explain what I'm trying to do:

  • I use Qt to create an application mainly based on webkit. This application extracts content from the Internet and presents it to the user in the usual way.

  • My application needs to transmit multiple serial port devices, such as a printer, IC card reader.

  • These serial port devices have different models, so they have a different communication protocol.

  • I want to share my application with serial port devices reporting part, so that I can only update the Communcation part without updating the entire application.

Do I need to write a plugin / webkit Qt plugin or some other way to do this? Any suggestions are welcome!

thank

+3
source share
5 answers

AFAIK Qt already provides a plugin mechanism.

Note the QLibrary class and examples there.

+3
source

For the qextserialport serial port part

0
source

dll/dynamic library, TARGET = lib CONFIG + = dll qmake.

0

PluginManager ++.

2+- , , .

, , . 40 + , .

[DLL- ++-] , , .

// ..

, , , , .

( -, Java):

/* This is the basic plugin header file that every plugin DLL has to include

   Use your compilers pragmas/keywords to export the entire class from the DLL
   In Microsoft land the keywords are _declspec( dllexport ) to export the class
   from the base DLL and __declspec( dllimport ) to import the class into other
   code.  I'm using the MS keywords here because I don't remember how this is done
   in other compilers. :)
*/

#if BUILDING_BASE_PLUGIN
/* You're compiling the DLL that exports the Plugin Base
#define BASE_DLL_EXPORT declspec( dllexport )
#else
/* You're compiling code that uses the plugin base
#define BASE_DLL_EXPORT declspec( dllimport )
#endif

class DLL_EXPORT SerialPortPluginBase
{
public:
    enum SerialPortPluginError{ SUCCESS = 0, ERROR_1, ERROR_2, ERROR_ETC };

    virtual SerialPortPluginError Open( /*Parameters*/ ) = 0;
    virtual SerialPortPluginError Read( /*Parameters*/ ) = 0;
    virtual SerialPortPluginError Write( /*Parameters*/ ) = 0;
    virtual SerialPortPluginError Close( /*Parameters*/ ) = 0;
    static std::string pluginName = "SerialPortPluginBase";
    static int version;
};

, , / DLL (. ).

DLL/SO.

. .

, .:)

0

Source: https://habr.com/ru/post/1779916/


All Articles