Results 1 to 11 of 11

Thread: Problem calling a routine with dynamicCall

  1. #1
    Join Date
    Nov 2007
    Location
    Italy
    Posts
    692
    Thanks
    59
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Problem calling a routine with dynamicCall

    Hi,
    I'm trying to use a com object. I have a problem with a routine named RegUserData.
    The documentation says this about the RegUserData's parameters:

    CardID(string/10)
    OverWrite(0: no overwrite. If ID is already registered, return with result 06.,1: overwrite.)
    idxDesignation
    idxDepartment
    FirstName(string /15)
    LastName(string /15)
    idxGroup (integer/0~255)
    Status(1: Activate, 0: Deactivate)
    WorkMode(0:finger+pass ,1:finger,2ass,3:finger or pass,4:Only Crad,5:Only from external Reader,6:Matching on Mifare card)
    WorkTimeStart()
    WorkTimeEnd()
    EmployeeID
    RegisterMode( Finger =1, Password = 2, Finger and Password = 3, Card=4, Max=4)
    CheckExpire
    ExpireDateStart
    ExpireDateEnd
    Password(string/10)
    NF(Number of fingerprint data per user Max. 2)
    TemplateSize
    FingerData (byte,User Fingerprint data total size depends on the number of fingerprints registered per user)
    You can says that the FingerData param is at the last position.
    Instead when I try to call the routine with dynamicCall the doc generated with dumpcpp says that the FingerData param is at the second position so:

    Qt Code:
    1. /*
    2.   Method RegUserData
    3.   */
    4. inline bool RegUserData(const QString& CardID, QVariantList FingerData, bool OverWrite, int idxDesignation, int
    5. idxDepartment, const QString& FirstName, const QString& LastName, int idxGroup, bool Status, int WorkMode,
    6. const QString& WorkTimeStart, const QString& WorkTimeEnd, const QString& EmployeeID, int RegisterMode, bool
    7. CheckExpire, const QDateTime& ExpireDateStart, const QDateTime& ExpireDateEnd, const QString& Password, int NF,
    8. int TemplateSize);
    To copy to clipboard, switch view to plain text mode 

    You can see the FingerPrint data at second position.
    I would know why does dumpcpp invert the order of the parameters?

    Best Regards
    Franco Amato

  2. #2
    Join Date
    Nov 2007
    Location
    Italy
    Posts
    692
    Thanks
    59
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Problem calling a routine with dynamicCall

    Meanwhile I called the routine with the order specified by dumpcpp and I get error with the parameter 1.
    Doc says that I have to pass a QString so:
    Qt Code:
    1. bool RegUserData(QString CardID, QVariantList FingerData, bool OverWrite = 0, int idxDesignation = 0, int idxDepartment = 0, QString FirstName = 0, QString LastName = 0, int idxGroup = 0, bool Status = 0, int WorkMode = 0, QString WorkTimeStart = 0, QString WorkTimeEnd = 0, QString EmployeeID = 0, int RegisterMode = 0, bool CheckExpire = 0, QDateTime ExpireDateStart = 0, QDateTime ExpireDateEnd = 0, QString Password = 0, int NF = 0, int TemplateSize = 0);
    To copy to clipboard, switch view to plain text mode 

    so I wrote this code:

    Qt Code:
    1. //cardId
    2. QString cardId = QString::number( user->cardId(), 10 ); // cardId is a QString for example "1234567890"
    3.  
    4. //fp data
    5. QVariantList fingerData;
    6. int templatesize = (int)(user->templateSize());
    7. char* fpPtr = user->fpdata();
    8. for(int i = 0; i < templatesize; i++)
    9. {
    10. QVariant v = *(fpPtr+i);
    11. fingerData.append(v);
    12. }
    13.  
    14. paramList.append(cardId);//CardID
    15. paramList.append(fingerData);//FingerData
    16.  
    17. bool result = m_axobj->dynamicCall("RegUserData(QString CardID, QVariantList FingerData, \
    18. bool OverWrite = 0, int idxDesignation = 0, \
    19. int idxDepartment = 0, QString FirstName = 0, \
    20. QString LastName = 0, int idxGroup = 0, \
    21. bool Status = 0, int WorkMode = 0, \
    22. QString WorkTimeStart = 0, QString WorkTimeEnd = 0, \
    23. QString EmployeeID = 0, int RegisterMode = 0, \
    24. bool CheckExpire = 0, QDateTime ExpireDateStart = 0, \
    25. QDateTime ExpireDateEnd = 0, QString Password = 0, \
    26. int NF = 0, int TemplateSize = 0)", paramList).toBool();
    To copy to clipboard, switch view to plain text mode 

    And I get the error:
    QAxBase: Error calling IDispatch member Type mismatch in parameter 1.
    Seems it doesn't like the QString CardID, but the documentation says that I have to pass the first param as a QString as I'm doing.
    Where I'm wrong?

    Best Regards,
    Franco
    Franco Amato

  3. #3
    Join Date
    Nov 2007
    Location
    Italy
    Posts
    692
    Thanks
    59
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Problem calling a routine with dynamicCall

    I also tried to call the routine directly so:

    Qt Code:
    1. using namespace PallyCOM;
    2. m_terminal = new PallyCOM::oTerminal(this);
    3. m_terminal->setControl("{1AF66B3E-B0D5-4108-80B5-13E429298140}");
    To copy to clipboard, switch view to plain text mode 

    and in the routine I call:

    Qt Code:
    1. bool Device::registerNewUser(UserData* user)
    2. {
    3. QList<QVariant> paramList;
    4.  
    5. //cardId
    6. QString cardId = QString::number( user->cardId(), 10 );
    7.  
    8. //fp data
    9. QVariantList fingerData;
    10. int templatesize = (int)(user->templateSize());
    11. char* fpPtr = user->fpdata();
    12. for(int i = 0; i < templatesize; i++)
    13. {
    14. QVariant v = *(fpPtr+i);
    15. fingerData.append(v);
    16. }
    17.  
    18. m_terminal->RegUserData(cardId , fingerData, false );// I call one of the overloaded routines
    19.  
    20. }
    To copy to clipboard, switch view to plain text mode 

    In this case the prototype is this ( created by dumpcpp )
    Qt Code:
    1. inline bool RegUserData(const QString& CardID, QVariantList FingerData, bool OverWrite);
    To copy to clipboard, switch view to plain text mode 

    so I also tried to change this line:

    Qt Code:
    1. //cardId
    2. QString cardId = QString::number( user->cardId(), 10 );
    To copy to clipboard, switch view to plain text mode 
    to this:
    Qt Code:
    1. const QString& cardId = QString::number( user->cardId(), 10 );
    To copy to clipboard, switch view to plain text mode 

    to match the parameters needed by the RegUserData but I always get the same error at run-time.
    Franco Amato

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Problem calling a routine with dynamicCall

    What is the type of paramList? Are you sure the first argument to dynamicCall() should contain all the argument names and default values?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  5. #5
    Join Date
    Nov 2007
    Location
    Italy
    Posts
    692
    Thanks
    59
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Problem calling a routine with dynamicCall

    Quote Originally Posted by wysota View Post
    What is the type of paramList? Are you sure the first argument to dynamicCall() should contain all the argument names and default values?
    Wysota hi,
    how can I check the type of paramList? And how can I check if the first argument to dynamicCall() should contain all the argument names and default values as you asked?
    This is what the generateDocumentation produced:

    Qt Code:
    1. bool result = m_axobj->dynamicCall("RegUserData(QString CardID, QVariantList FingerData, \
    2. bool OverWrite = 0, int idxDesignation = 0, \
    3. int idxDepartment = 0, QString FirstName = 0, \
    4. QString LastName = 0, int idxGroup = 0, \
    5. bool Status = 0, int WorkMode = 0, \
    6. QString WorkTimeStart = 0, QString WorkTimeEnd = 0, \
    7. QString EmployeeID = 0, int RegisterMode = 0, \
    8. bool CheckExpire = 0, QDateTime ExpireDateStart = 0, \
    9. QDateTime ExpireDateEnd = 0, QString Password = 0, \
    10. int NF = 0, int TemplateSize = 0)", paramList).toBool();
    To copy to clipboard, switch view to plain text mode 

    Best Regards,
    Franco Amato

  6. #6
    Join Date
    Apr 2010
    Posts
    769
    Thanks
    1
    Thanked 94 Times in 86 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: Problem calling a routine with dynamicCall

    how can I check the type of paramList? And how can I check if the first argument to dynamicCall() should contain all the argument names and default values
    Kind of a wild thought, but maybe you could read the documentation?

    Or, if you're using some sort of introspection, maybe you could accept what it tells you and use those arguments and order?

  7. #7
    Join Date
    Nov 2007
    Location
    Italy
    Posts
    692
    Thanks
    59
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Problem calling a routine with dynamicCall

    Quote Originally Posted by SixDegrees View Post
    Kind of a wild thought, but maybe you could read the documentation?

    Or, if you're using some sort of introspection, maybe you could accept what it tells you and use those arguments and order?
    I used those arguments and order. I gave a QString as 1 argument as it asked for and it gave to me such error "Type mismatch in parameter 1"
    Franco Amato

  8. #8
    Join Date
    Nov 2007
    Location
    Italy
    Posts
    692
    Thanks
    59
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Problem calling a routine with dynamicCall

    Quote Originally Posted by wysota View Post
    What is the type of paramList? Are you sure the first argument to dynamicCall() should contain all the argument names and default values?
    Wysota sorry,
    I didn't understand you well yestarday. paramList is of type QVariantList.

    Best,
    Franco Amato

  9. #9
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Problem calling a routine with dynamicCall

    Remember that in C++ indexing usually starts at 0 so "1" probably means the second argument.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  10. #10
    Join Date
    Nov 2007
    Location
    Italy
    Posts
    692
    Thanks
    59
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Problem calling a routine with dynamicCall

    Quote Originally Posted by wysota View Post
    Remember that in C++ indexing usually starts at 0 so "1" probably means the second argument.
    Hi in that case the second argument is a QVariantList as shown here:

    Qt Code:
    1. bool result = m_axobj->dynamicCall("RegUserData(QString CardID, \
    2. QVariantList FingerData, \ <--second param
    3. bool OverWrite = 0, int idxDesignation = 0, \
    4. int idxDepartment = 0, QString FirstName = 0, \
    5. QString LastName = 0, int idxGroup = 0, \
    6. bool Status = 0, int WorkMode = 0, \
    7. QString WorkTimeStart = 0, QString WorkTimeEnd = 0, \
    8. QString EmployeeID = 0, int RegisterMode = 0, \
    9. bool CheckExpire = 0, QDateTime ExpireDateStart = 0, \
    10. QDateTime ExpireDateEnd = 0, QString Password = 0, \
    11. int NF = 0, int TemplateSize = 0)", paramList).toBool();
    To copy to clipboard, switch view to plain text mode 

    FingerData is an array of chars so to convert it in QVariantList I used this code:

    Qt Code:
    1. //fp data
    2. QVariantList fingerData; // the second param
    3. int templatesize = (int)(user->templateSize()); //template size = 352
    4. //I get the pointer to the char array containing the finger print data
    5. char* fpPtr = user->fpdata(); //( char array[templatesize] )
    6. for(int i = 0; i < templatesize; i++)
    7. {
    8. QVariant v = *(fpPtr+i); // I convert every element of the char array to a QVariant
    9. fingerData.append(v); // and I add it to the QVarianlList
    10. }
    To copy to clipboard, switch view to plain text mode 

    I don't know another way to convert a char array to a QVariantList, but maybe this is not the correct way.
    Franco Amato

  11. #11
    Join Date
    Nov 2007
    Location
    Italy
    Posts
    692
    Thanks
    59
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Problem calling a routine with dynamicCall

    I changed the code to convert a char array to a QVariantList so:
    Qt Code:
    1. //fp data
    2. QVariantList fingerData;
    3. char* fpPtr = user->fpdata(); //I get the ptr to the char array
    4. QVariant v(fpPtr); I create a QVariant
    5. fingerData.append(v); //and add it to a QVariantList
    To copy to clipboard, switch view to plain text mode 

    But I still get the error type mismatch in parameter 1
    and more: my char array has 352 elements instead with this code the fingerData has only 225 elements.
    Some elements are missing but I don't know where.

    I have no idea idea of where I'm wrong.
    Can anyone help me?
    Franco Amato

Similar Threads

  1. dynamicCall and QByteArray - strange characters
    By franco.amato in forum Qt Programming
    Replies: 120
    Last Post: 28th April 2010, 21:11
  2. Replies: 0
    Last Post: 16th April 2010, 23:21
  3. Problems with ACtiveQT in calling a routine
    By franco.amato in forum Qt Programming
    Replies: 0
    Last Post: 15th April 2010, 01:00
  4. Wierd behaviour in a slot routine
    By koenig in forum Newbie
    Replies: 7
    Last Post: 29th January 2010, 07:27
  5. Replies: 1
    Last Post: 28th May 2008, 16:52

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.