Re: dynamicCall and QByteArray - strange characters
No, I meant the structure you would be getting if you were calling the method directly using WinAPI's COM API. I just can't say it more clearly. Or just dump the byte array to the console in ascii, see what is there and try to guess its stucture.
Re: dynamicCall and QByteArray - strange characters
Quote:
Originally Posted by
wysota
No, I meant the structure you would be getting if you were calling the method directly using WinAPI's COM API. I just can't say it more clearly. Or just dump the byte array to the console in ascii, see what is there and try to guess its stucture.
If I can try to put it a bit more clearly:
Your dynamic call returns a QByteArray with 441 elements right? So all those return types (CardID, OverWrite, idxDesignation and all those) you listed should be contained in those 441 elements.
What wysota means by structure is how those 441 elements are divided to produce the return types ie. CardID is a string of size 10, OverWrite a byte(or bit) etc... If you have that structure you can try to cast the QByteArray to that structure. Otherwise you'll need to determine the structure as wysota mentioned - by dumping to ascii and trying to figure out the type of each return type. :cool:
Re: dynamicCall and QByteArray - strange characters
Quote:
Originally Posted by
franco.amato
Hi, I don't understand a thing: I don't have to use the new operator to instantiate the objects?
That depends on the lifetime you expect the object (m_treeView in my example) to have. On the stack is fine for a short lifespan limited by scope, on the heap would be more typical. The code generated by dumpcpp connects to COM control at the time the wrapper object is constructed and doesn't care how the object came to be.
You have had success with dumpcpp creating some wrappers. The generated classes should manage marshalling COM response into qt and/or C++ structures for you make for more direct access (adjust names as needed):
Code:
#include "generated_header.h"
...
terminalLib::oTerminal *comObject;
comObject = new terminalLib::oTerminal(this);
delete comObject;
If you dig around in the generated H and CPP file you might find a definition of "ArrayList" (or it may be intended to be an opaque blob although this seems unlikely). You may also find references to a Windows help file that matches the type library.
Could you post (attach) the generated header file?
Re: dynamicCall and QByteArray - strange characters
If the QVariant returned is of type QByteArray then the COM return was a SAFEARRAY(BYTE) according to the QAxBase documentation.
You might find this useful:
http://www.roblocher.com/whitepapers/oletypes.aspx
http://msdn.microsoft.com/en-us/libr...ROT.13%29.aspx
Re: dynamicCall and QByteArray - strange characters
Quote:
Originally Posted by
ChrisW67
That depends on the lifetime you expect the object (m_treeView in my example) to have. On the stack is fine for a short lifespan limited by scope, on the heap would be more typical. The code generated by dumpcpp connects to COM control at the time the wrapper object is constructed and doesn't care how the object came to be.
You have had success with dumpcpp creating some wrappers. The generated classes should manage marshalling COM response into qt and/or C++ structures for you make for more direct access (adjust names as needed):
Code:
#include "generated_header.h"
...
terminalLib::oTerminal *comObject;
comObject = new terminalLib::oTerminal(this);
delete comObject;
If you dig around in the generated H and CPP file you might find a definition of "ArrayList" (or it may be intended to be an opaque blob although this seems unlikely). You may also find references to a Windows help file that matches the type library.
Could you post (attach) the generated header file?
Dear Chris,
for sure. Tomorrow I'll post the .h file.
Regards
Re: dynamicCall and QByteArray - strange characters
Quote:
Originally Posted by
zAAm
If I can try to put it a bit more clearly:
Your dynamic call returns a QByteArray with 441 elements right? So all those return types (CardID, OverWrite, idxDesignation and all those) you listed should be contained in those 441 elements.
What wysota means by structure is how those 441 elements are divided to produce the return types ie. CardID is a string of size 10, OverWrite a byte(or bit) etc... If you have that structure you can try to cast the QByteArray to that structure. Otherwise you'll need to determine the structure as wysota mentioned - by dumping to ascii and trying to figure out the type of each return type. :cool:
If I well understood I have to first create such structure with struct and then cast the returned value to such structure? Or I'm wrong?
Can I have some pseudo-code?
Re: dynamicCall and QByteArray - strange characters
Quote:
Originally Posted by
franco.amato
If I well understood I have to first create such structure with struct and then cast the returned value to such structure?
Did you try entering "ArrayList C++" in your favourite search engine and reading what pops up?
Re: dynamicCall and QByteArray - strange characters
Quote:
Originally Posted by
wysota
Did you try entering "ArrayList C++" in your favourite search engine and reading what pops up?
The arrayList is not the problem. The problem is the return value that's QByteArray
Re: dynamicCall and QByteArray - strange characters
Quote:
Originally Posted by
ChrisW67
Could you post (attach) the generated header file?
I tried to send the files you asked for but the forum says they are bigger than the limit.
If you have a mail address I can send them to you.
Regards
Re: dynamicCall and QByteArray - strange characters
Compress them. Then you will be able to attach them to your post. And only send the relevant file (.h).
1 Attachment(s)
Re: dynamicCall and QByteArray - strange characters
Quote:
Originally Posted by
wysota
Compress them. Then you will be able to attach them to your post. And only send the relevant file (.h).
Ok Wysota thank you.
I compressed PallyCom.h in PallyCom.zip ( 8K )
Regards
Re: dynamicCall and QByteArray - strange characters
Quote:
Originally Posted by
wysota
Compress them. Then you will be able to attach them to your post. And only send the relevant file (.h).
Wysota I saw some data calling the routine in a C# console application and I had to do a conversion byte to ascii to see something.
I think if for that that I can not see nothing in Qt. How can I convert the bytearray in ascii?
I also saw that the stream of data contains lots of '\0' and for that maybe I can not see well all characters.
Best
Re: dynamicCall and QByteArray - strange characters
Quote:
Originally Posted by
franco.amato
How can I convert the bytearray in ascii?
What did you already try to do it?
Re: dynamicCall and QByteArray - strange characters
Quote:
Originally Posted by
wysota
What did you already try to do it?
Hi,
first I have know how to access to every byte contained in the bytearray and discover how Qt manage the '\0' as in the
returned stream I have lots of such character
Re: dynamicCall and QByteArray - strange characters
Quote:
Originally Posted by
franco.amato
Hi,
first I have know how to access to every byte contained in the bytearray and discover how Qt manage the '\0' as in the
returned stream I have lots of such character
Then open the documentation of QByteArray and read it. I can tell you that Qt doesn't "manage" null bytes in any way. They are bytes like any other.
Re: dynamicCall and QByteArray - strange characters
Quote:
Originally Posted by
wysota
Then open the documentation of QByteArray and read it.
This is was I already did many times
Quote:
I can tell you that Qt doesn't "manage" null bytes in any way. They are bytes like any other.
This is the result of the routine call in a cmd line app written in C#:
Quote:
"I??\0\0xml;q=0.Franco\0\0\0\0\0\0\0\0\0Amato\0\0 \0\0\0\0\0\0\0\0\0\0\0\0AAAAAAAAAAAAAAA=0\0\n \n0987654321`E?\"UF ??\fCQ????O\"D ?\v2??(E??\n2F?D?\fH1\b\vH???\nIae?.???(?`>?/?p<?;M???????:????\"8??`:?!???PQ?\r??`'?`2 ??Q)\n??#3?????#34????\"34????\"34O???\"34O? ??\"#3D???#4D???#4D???#4D???34D???\"3DD? ??#DDE???4DTE???4UUEo??EUUUo???VffUo???ffff?? ?wwff????wwvg?\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0 \0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0 \0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0 \0\0\0\0\0\0\0\0\0"
You can see many '\0' but why debuggind with visual studio my Qt app I can not see the same string that's should contained in the QByteArray? And also I really don't understand which characteres are these: ??
I hope you can help me
Re: dynamicCall and QByteArray - strange characters
You still seem to be expecting a nice human readable string when what you are being passed is a binary data structure. The docs for the COM server say it returns an ArrayList (a .Net/C# data type of some sort) but this has to be translated to something that can be sent through the COM interface, which must remain language agnostic. The QAxBase docs imply this structure is a SAFEARRAY(BYTE). I'd hazard a guess it's a single dimensional array of VT_VARIANT entries.
In your C++ Qt application you receive a QByteArray. Use QByteArray::toHex() to dump the first 24 or 32 bytes. Then sit and try to marry the bytes to the SAFEARRAY structures described here;
http://msdn.microsoft.com/en-us/library/aa913233.aspx
Code:
typedef struct FARSTRUCT tagSAFEARRAY {
unsigned short cDims; // two bytes
unsigned short fFeatures; // two bytes
unsigned short cbElements; //two bytes
unsigned short cLocks; // two bytes
unsigned long handle; // four bytes
void HUGEP* pvData; // four bytes
SAFEARRAYBOUND rgsabound[1]; // structure below repeated if more than one dimension in array
} SAFEARRAY;
typedef struct tagSAFEARRAYBOUND {
unsigned long cElements; // four bytes
long lLbound; // four bytes
} SAFEARRAYBOUND;
Does the number of dimensions make sense? Do the array bounds make sense? If so, read here:
http://msdn.microsoft.com/en-us/library/ms221145.aspx
You might want to use your favourite search engine to look for a C++ wrapper for SAFEARRAYs.
Re: dynamicCall and QByteArray - strange characters
Quote:
Originally Posted by
franco.amato
This is was I already did many times
Then do it again and again until you find something you consider useful for writing a routine for dumping the byte array in ascii (or hex or whatever you find important). I can already tell you there is no method in QByteArray that will do the task for you - you have to come up with a proper algorithm yourself. Otherwise you won't learn anything and next time you will again ask someone for help instead of trying to solve the problem on your own first.
Re: dynamicCall and QByteArray - strange characters
Quote:
Originally Posted by
wysota
Then do it again and again until you find something you consider useful for writing a routine for dumping the byte array in ascii (or hex or whatever you find important). I can already tell you there is no method in QByteArray that will do the task for you - you have to come up with a proper algorithm yourself. Otherwise you won't learn anything and next time you will again ask someone for help instead of trying to solve the problem on your own first.
My problem is not convert byte to ascii,
my problem is understand why QByteArray doesn't contain the data as It should
Re: dynamicCall and QByteArray - strange characters
Quote:
Originally Posted by
franco.amato
my problem is understand why QByteArray doesn't contain the data as It should
How do you know it doesn't contain the data?