Page 3 of 7 FirstFirst 12345 ... LastLast
Results 41 to 60 of 121

Thread: dynamicCall and QByteArray - strange characters

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

    Default Re: dynamicCall and QByteArray - strange characters

    Quote Originally Posted by wysota View Post
    How do you know it doesn't contain the data?
    Because from a cmd line software written in C# calling the same routine with the same parameter, importing as reference such com object I can see this (debugging with visual studio):

    "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"
    And debugging the same routine but written in Qt I can not see nothing, only 4 characters.
    It show the correct size ( 441 bytes ) but I can not see its content as in the case of C#. I also did
    Qt Code:
    1. char* data = ba.data();
    2. qDebug() << content of data; //<--pseudo code
    To copy to clipboard, switch view to plain text mode 
    but I even this way I can't see the data.
    Last edited by franco.amato; 22nd April 2010 at 15:27.

  2. #42
    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: dynamicCall and QByteArray - strange characters

    Quote Originally Posted by franco.amato View Post
    And debugging the same routine but written in Qt I can not see nothing, only 4 characters.
    Look at what the C# method returns - what is the value of the 5th character? How does C interpret such characters in strings? Now if you answer yourself these questions, try to come up with how to avoid this effect using expressions C/C++ languages offer such as loops and conditionals.

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

    Default Re: dynamicCall and QByteArray - strange characters

    Quote Originally Posted by wysota View Post
    Look at what the C# method returns - what is the value of the 5th character? How does C interpret such characters in strings? Now if you answer yourself these questions, try to come up with how to avoid this effect using expressions C/C++ languages offer such as loops and conditionals.
    Wysota, for that.
    This is exactly what I asked last time...how can I manage null caracters? I know that in c/c++ is a string termination character, but I need them as are part of the raw data

  4. #44
    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: dynamicCall and QByteArray - strange characters

    Quote Originally Posted by franco.amato View Post
    This is exactly what I asked last time...how can I manage null caracters?
    Come on, man... this is a trivial programming task. How do you check if a character in an array is some special character and treat it in differently than others? What would you do if you had an array of integers and were asked to display the ones with even values on the console?

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

    Default Re: dynamicCall and QByteArray - strange characters

    Quote Originally Posted by wysota View Post
    Come on, man... this is a trivial programming task. How do you check if a character in an array is some special character and treat it in differently than others? What would you do if you had an array of integers and were asked to display the ones with even values on the console?
    Wysota you didn't understand me. I know check a character in an array.
    What I don't understand is why the debugger doesn't show me the characteres in the Qt program and yes in the C# program. Could you see the picture I sent last time?

  6. #46
    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: dynamicCall and QByteArray - strange characters

    Quote Originally Posted by franco.amato View Post
    What I don't understand is why the debugger doesn't show me the characteres in the Qt program and yes in the C# program.
    Because it doesn't treat null characters in a QByteArray in a special way and it does that with the C# data structure. That's why you need to dump the contents of the array yourself in such a way that null characters don't prevent you from seeing the whole 442 bytes of the array.

    I don't really see a reason for all this discussion. If you know how to dump the contents of the byte array then do it instead of wondering why something works here or there.

  7. #47
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: dynamicCall and QByteArray - strange characters

    It's already been mentioned back at post #37: QByteArray::toHex()
    You could equally well use QByteArray::toPercentEncoding() or roll-your-own by looping over QByteArray::size() bytes.

  8. #48
    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: dynamicCall and QByteArray - strange characters

    Quote Originally Posted by ChrisW67 View Post
    It's already been mentioned back at post #37: QByteArray::toHex()
    You could equally well use QByteArray::toPercentEncoding() or roll-your-own by looping over QByteArray::size() bytes.
    Yeah... he will surely learn something if you give him all the answers on a silver platter...
    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.


  9. #49
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: dynamicCall and QByteArray - strange characters

    Even with this offering on a platter there's still a long way to go, most of which has nothing to do with Qt.

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

    Default Re: dynamicCall and QByteArray - strange characters

    Quote Originally Posted by wysota View Post
    Yeah... he will surely learn something if you give him all the answers on a silver platter...
    How can I understand if I don't know what I have to do??
    I know that I have to first convert al ba bytes to Ascii ( I'll iterate over all bytes of the ba ).
    I don't understand why I should convert to hex or to toPercentEncoding()
    Franco Amato

  11. #51
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: dynamicCall and QByteArray - strange characters

    The bytes in the QByteArray are not a NUL terminated ASCII string although there appear to be string fragments amongst them. If it were a simple ASCII string then you'd see no gibberish when the raw data was dumped to the console. Even your C# test program doesn't think it is a straight ASCII NUL terminated string. The QByteArray contains a data structure that might be interpretable with some manual work to verify the structure. This work is going to much easier if you can see the actual values in each byte, which is why hex would be useful.

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

    Default Re: dynamicCall and QByteArray - strange characters

    Quote Originally Posted by ChrisW67 View Post
    The bytes in the QByteArray are not a NUL terminated ASCII string although there appear to be string fragments amongst them. If it were a simple ASCII string then you'd see no gibberish when the raw data was dumped to the console. Even your C# test program doesn't think it is a straight ASCII NUL terminated string. The QByteArray contains a data structure that might be interpretable with some manual work to verify the structure. This work is going to much easier if you can see the actual values in each byte, which is why hex would be useful.
    So I should implement some fomHexToAscii routine right? Sometime my poor english doen't help me.
    My problem is this: I have to get the bytearray, parse them, populate a new structure and re-write some data but for that I have to see with my eyes the meaning of some bytes as my documentation is very very poor and I have to guess where the name and surname position are, the cardId, etc...
    I hope you can understand me. The only way I can do it is to see some bytes in a human been readable way as fortunately C# does ( personally I hate C# )
    Franco Amato

  13. #53
    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: dynamicCall and QByteArray - strange characters

    Quote Originally Posted by franco.amato View Post
    How can I understand if I don't know what I have to do??
    Take a sheet of paper and a pen. At the top write down what is that you want to achieve exactly - think it terms "what I want to have" not "how I would like to do it" or "what technologies I have to use". Then try to determine the algorithm needed to achieve the goal and write it down below in a form of a numbered list. Leave some space between items. Now take some two objects and cover everything except the first point on your newly created list. Think about the problems related to solving this one step and ways to do it. Write them down as subitems of the item in the list. You can leave some space between items. Then continue with the next step and repeat the process until you reach the end of your list. Then go back and think about each of the subitems on your list and expand those that need more steps with new subitems. At the end you should have a complete list of things you need to do and the point of doing all that is to focus on one thing at a time and finding a way to solve your problem on your own. Forget about Qt, forget about C++, C#, DLLs, COM or any technology you are using. Solve the abstract task using abstract means on a piece of paper, only then think how to implement them in this or that technology. If you have a problem with any items on your list then think how to obtain the same goal using different means and replace the item with a new one.

    If you don't know why you should use toHex() or toPercentEncoding() then don't use them, think about a result that you want to obtain, then create an algorithm for it and only then look for means of implementing it. If you have problems with creating the algorithm then ask for help here or somewhere else but when you are given the answer, don't jump to the next point but rather check if you understand every aspect of things you need to do. If you have a "my method returns a FooBarThingy", ask yourself (and your favourite search engine) what "FooBarThingy" is, where it comes from, what it represents and how to use it in different technologies. Don't rush here asking "how do I use this FooBarThingy thingy...". I have already told you this a couple of times - if you don't make a leap past your current abilities, you won't learn. Ask yourself why things happen, verify your assumptions, reject them if they are wrong and find new ones until you come up with a theory that is consistent with what you observe. Then write a small application to verify your thesis.

    Geeez... this starts to look like an article... If just writing my dissertation was as easy as writing posts here...
    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.


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

    Default Re: dynamicCall and QByteArray - strange characters

    Quote Originally Posted by wysota View Post
    Take a sheet of paper and a pen. At the top write down what is that you want to achieve exactly - think it terms "what I want to have" not "how I would like to do it" or "what technologies I have to use". Then try to determine the algorithm needed to achieve the goal and write it down below in a form of a numbered list. Leave some space between items. Now take some two objects and cover everything except the first point on your newly created list. Think about the problems related to solving this one step and ways to do it. Write them down as subitems of the item in the list. You can leave some space between items. Then continue with the next step and repeat the process until you reach the end of your list. Then go back and think about each of the subitems on your list and expand those that need more steps with new subitems. At the end you should have a complete list of things you need to do and the point of doing all that is to focus on one thing at a time and finding a way to solve your problem on your own. Forget about Qt, forget about C++, C#, DLLs, COM or any technology you are using. Solve the abstract task using abstract means on a piece of paper, only then think how to implement them in this or that technology. If you have a problem with any items on your list then think how to obtain the same goal using different means and replace the item with a new one.

    If you don't know why you should use toHex() or toPercentEncoding() then don't use them, think about a result that you want to obtain, then create an algorithm for it and only then look for means of implementing it. If you have problems with creating the algorithm then ask for help here or somewhere else but when you are given the answer, don't jump to the next point but rather check if you understand every aspect of things you need to do. If you have a "my method returns a FooBarThingy", ask yourself (and your favourite search engine) what "FooBarThingy" is, where it comes from, what it represents and how to use it in different technologies. Don't rush here asking "how do I use this FooBarThingy thingy...". I have already told you this a couple of times - if you don't make a leap past your current abilities, you won't learn. Ask yourself why things happen, verify your assumptions, reject them if they are wrong and find new ones until you come up with a theory that is consistent with what you observe. Then write a small application to verify your thesis.

    Geeez... this starts to look like an article... If just writing my dissertation was as easy as writing posts here...
    I simply would to know how to read and interpret data got with ActiveQt and QByteArray ( that IIRC are Qt classes, are not classes written by me or by my sister ). It's so difficult?
    I don't need your sermon as you do everytime, you're not my father. So if I can not ask here qt-related things I don't understand why does this forum exist.

    Kind Regards
    Franco Amato

  15. #55
    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: dynamicCall and QByteArray - strange characters

    The thing is your problem is not Qt related. The role of Qt ends at the point where you get the array of bytes. Qt gave you what ActiveX returned, it is your task to interpret the result and I think this is what you fail to understand during the last 20 or so posts...

    And let's not get into what each of us does every time because we'd have to focus on your "please give me example code" posts too. I'm not going to convince you to learn ever again, don't worry. It's your decision what you do with your life.
    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.


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

    Default Re: dynamicCall and QByteArray - strange characters

    Quote Originally Posted by wysota View Post
    The thing is your problem is not Qt related. The role of Qt ends at the point where you get the array of bytes. Qt gave you what ActiveX returned, it is your task to interpret the result and I think this is what you fail to understand during the last 20 or so posts...

    And let's not get into what each of us does every time because we'd have to focus on your "please give me example code" posts too. I'm not going to convince you to learn ever again, don't worry. It's your decision what you do with your life.
    In this last post I never asked for "source code" and I didn't write "please give me example code" but I asked for pseudo-code in post #26 "Can I have some pseudo-code?".
    If for you is so hard to give some line of "pseudo code" as administrators of a programming forum or experts ( or Masters of Zen ) should do, so I didn't undersand the meaning of a programming forum, or maybe you're jealous of your knowledge. Personally when someon ask for my help in my work I'm very happy to help him as I can.
    Personally I'm an hardware designer and I don't love programming gui so for me is a big effort to come here and ask for something, do you think I'm having fun coming here and write post after post to get nothing? Is very frustrated and personally you can change my programming level to beginner or intermediate.

    Bye
    Franco Amato

  17. #57
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: dynamicCall and QByteArray - strange characters

    1. Determine what the data structure actually is. My best guess is in post #37 and its content may be a serialised C# object.
    1a. Match bytes from the byte array against candidates for the data structure and see if they make sense. A hex dump would be useful here.
    1b. If you can see recognisable bits in the data (like your name) then look at the bytes around it to see if they make any sense, e.g. is the preceding byte, short, or long value the length of the string?
    1c. Anything else that might help break the code (this is not unlike cracking weak encryption).
    2. If you match the structure and it has a name then search for a wrapper that can handle that data structure.
    3. Failing 2. write one yourself.

    You are still at step 1 and the road is rocky.

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

    Default Re: dynamicCall and QByteArray - strange characters

    Quote Originally Posted by ChrisW67 View Post
    1. Determine what the data structure actually is. My best guess is in post #37 and its content may be a serialised C# object.
    1a. Match bytes from the byte array against candidates for the data structure and see if they make sense. A hex dump would be useful here.
    1b. If you can see recognisable bits in the data (like your name) then look at the bytes around it to see if they make any sense, e.g. is the preceding byte, short, or long value the length of the string?
    1c. Anything else that might help break the code (this is not unlike cracking weak encryption).
    2. If you match the structure and it has a name then search for a wrapper that can handle that data structure.
    3. Failing 2. write one yourself.

    You are still at step 1 and the road is rocky.
    Hi ChrisW67 thank you for your time.
    I can see something readable in the c# code after a byte to ascii conversion.
    So I think I should do the same in QT
    Franco Amato

  19. #59
    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: dynamicCall and QByteArray - strange characters

    Quote Originally Posted by franco.amato View Post
    If for you is so hard to give some line of "pseudo code" as administrators of a programming forum or experts ( or Masters of Zen ) should do, so I didn't undersand the meaning of a programming forum
    Ask people around - we tend to give fishing rods, not fish here.

    or maybe you're jealous of your knowledge.
    Don't worry, I'm not. I get much satisfaction out of helping others but you and I may understand "help" differently.

    Personally when someon ask for my help in my work I'm very happy to help him as I can.
    Yeah, well... if someone does the same mistake 9 times being warned about it each and every time, he might not get warned when he tries it the 10th time.

    Personally I'm an hardware designer and I don't love programming gui so for me is a big effort to come here and ask for something, do you think I'm having fun coming here and write post after post to get nothing?
    You are not getting nothing. You are simply not getting a ready solution. Why? See my first sentence of this post. I won't even get into the topic whether you problem is even remotely related to "programming GUI".

    Is very frustrated and personally you can change my programming level to beginner or intermediate.
    I'd like to change your programming level the other way round but to be honest, you're not helping and this is what is frustrating. And it should be frustrating for you too because currently you seem to be running in circles.

    As I'm having a sleepless night again, I took some time to find links you might find helpful in your task:
    http://www.daniweb.com/forums/thread8306.html#
    http://www.roblocher.com/whitepapers/oletypes.aspx
    http://edn.embarcadero.com/article/22016
    http://stackoverflow.com/questions/1...vc-through-com
    http://www.cplusplus.com/forum/beginner/8905/
    http://msdn.microsoft.com/en-us/libr...safearray.aspx
    http://msdn.microsoft.com/en-us/libr...ROT.13%29.aspx
    http://www.devx.com/vb2themax/Tip/19167 (this one is in VB but you can see here how to navigate the array)
    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.


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

    Default Re: dynamicCall and QByteArray - strange characters

    Thank you wysota
    Franco Amato

Similar Threads

  1. Replies: 0
    Last Post: 16th April 2010, 23:21
  2. Regarding qbytearray
    By mohanakrishnan in forum Qt Programming
    Replies: 7
    Last Post: 19th November 2009, 13:38
  3. Replies: 9
    Last Post: 25th July 2009, 13:27
  4. Replies: 1
    Last Post: 28th May 2008, 16:52
  5. QByteArray in Qt3
    By joseph in forum Qt Programming
    Replies: 1
    Last Post: 6th September 2007, 06:16

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.