Page 4 of 7 FirstFirst ... 23456 ... LastLast
Results 61 to 80 of 121

Thread: dynamicCall and QByteArray - strange characters

  1. #61
    Join Date
    Nov 2007
    Location
    Italy
    Posts
    693
    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 I got the data structure from the constructor.
    There still is something I don't understand. Why I need to convert to hex? I did it and noticed tha the size is changed. It's twice respect the original bytearray:

    Qt Code:
    1. ba = m_axobj->dynamicCall("GetUserData(QString)", "1234567890" ).toByteArray(); //<-- size 441
    2. QByteArray baHex = ba.toHex(); //<-- size 882
    To copy to clipboard, switch view to plain text mode 
    Franco Amato

  2. #62
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,360
    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

    You were supposed to print it on the screen to see what is inside. Though I still think an ascii dump would be better if the structure holds mostly character-based content.
    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.


  3. #63
    Join Date
    Nov 2007
    Location
    Italy
    Posts
    693
    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
    You were supposed to print it on the screen to see what is inside. Though I still think an ascii dump would be better if the structure holds mostly character-based content.
    I'll write a byte-to-ascii converter.
    The structure contains both character-based content (as name and surname) and not character-based ( as finger print data )
    Meanwhile my final goal is to parse the byte array and pack another structure to write back to another finger print terminal
    Franco Amato

  4. #64
    Join Date
    Nov 2007
    Location
    Italy
    Posts
    693
    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 franco.amato View Post
    I'll write a byte-to-ascii converter.
    The structure contains both character-based content (as name and surname) and not character-based ( as finger print data )
    Meanwhile my final goal is to parse the byte array and pack another structure to write back to another finger print terminal
    Hi,
    how could I do for example to read the first 4 bytes of the bytearray data and convert them to an integer?
    I have to copy with the memcpy?
    Franco Amato

  5. #65
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,360
    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

    It depends on the byte order of the architecture but memcpy will work too.
    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.


  6. #66
    Join Date
    Nov 2007
    Location
    Italy
    Posts
    693
    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
    It depends on the byte order of the architecture.
    Hi wysota, could you do more specific?
    I would convert the first 4 bytes of the bytearray in a number, the cardId in my case that it's a number of maximum 10 digits and that I can represent with 4 bytes.
    I tried this

    Qt Code:
    1. ba = m_axobj->dynamicCall("GetUserData(QString)", "1234567890" ).toByteArray();
    2. QByteArray cardId = ba.left(4); //now cardId contains the first 4 bytes of ba
    3. qint32 v = qFromBigEndian( (const uchar*)cardId.constData() );
    To copy to clipboard, switch view to plain text mode 

    without success.
    Where I'm wrong?
    Last edited by franco.amato; 23rd April 2010 at 22:30.
    Franco Amato

  7. #67
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,360
    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
    Hi wysota, could you do more specific?
    It depends whether the architecture is big-endian or little-endian.

    Qt Code:
    1. int size = ba.size();
    2. QByteArray cardId = ba.left(4); //now cardId contains the first 4 bytes of ba
    3. qint32 v = qFromBigEndian( (const uchar*)cardId.constData() );
    To copy to clipboard, switch view to plain text mode 

    without success.
    Maybe your machine is little-endian.
    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.


  8. #68
    Join Date
    Nov 2007
    Location
    Italy
    Posts
    693
    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
    It depends whether the architecture is big-endian or little-endian.


    Maybe your machine is little-endian.
    wysota, the problem is in compilation. Compiler says I cannot convert from 'const unsigned char *' to 'qint32'

    so I changed
    Qt Code:
    1. qint32 v = qFromBigEndian( (const uchar*)cardId.constData() );
    To copy to clipboard, switch view to plain text mode 

    to
    Qt Code:
    1. qint32 v = qFromBigEndian( (const uchar*)(cardId.constData()) );
    To copy to clipboard, switch view to plain text mode 

    for the operator precedence but nothing change.
    I still get such error. This sounds strange as the documentation says
    T qFromBigEndian ( const uchar * src )where T can be a qint32
    Franco Amato

  9. #69
    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

    Why I need to convert to hex? I did it and noticed that the size is changed.
    Google Hexadecimal. Seriously. If you printed each byte out in decimal you'd expect the size to be different... hex is just another human readable format that's longer than what it represents.

    There were clearly a good number of non-printable characters in the 441 byte data block. Just looking at the gibberish printed doesn't concretely tell you that the printed sequence "I??" is actually a series of bytes with decimal values: 49, 63, 2, 20 (example only). The "?" characters might be the result of a byte matching the ASCII for "?" (first one) or a byte that matches nothing the machine can print so it substitutes a "?" (the second). Dumping the bytes as a series of decimal or hexadecimal values allows you to see the actual values of the bytes. Hex was easier because there's already method to do that.

    I agree with Wysota that straight character dump is also needed.

    how could I do for example to read the first 4 bytes of the bytearray data and convert them to an integer?
    Think about how four bytes are arranged into a 32-bit integer. Extract the four bytes and combine them. Also think about what order the four bytes may be in the data stream versus what order they may be in your 32-bit integer. Search for "Endianness". You could also try casting a pointer to the byte array's data block but that has downsides.

  10. #70
    Join Date
    Nov 2007
    Location
    Italy
    Posts
    693
    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
    I agree with Wysota that straight character dump is also needed.
    what does mean?

    Think about how four bytes are arranged into a 32-bit integer. Extract the four bytes and combine them. Also think about what order the four bytes may be in the data stream versus what order they may be in your 32-bit integer. Search for "Endianness". You could also try casting a pointer to the byte array's data block but that has downsides.
    I extracted and copied first 4 bytes to a new bytearray and tried to convert to a number. See post above with the code I wrote but I get a compiler error that I don't understand
    Franco Amato

  11. #71
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,360
    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 does mean?
    Please read the whole thread again and Google for every term you are not sure you understand. We have already discussed this and at the end at least I came to an impression that you implied you knew how to print the contents of the byte array in ascii. I suggest you do it now and post here the output you get as for now you are only chasing ghosts.

    I extracted and copied first 4 bytes to a new bytearray and tried to convert to a number. See post above with the code I wrote but I get a compiler error that I don't understand
    The compiler says you can't cast a non-mutable pointer to a charater to 32 bit signed integer. Even if you managed to do that, I doubt you would be using the value you wanted to use, especially if your machine is 64bit. It'd be best if you checked whether qFromBigEndian() actually does what you expect it to. Moreover it seems you are using Intel based Windows machine so I can hardly believe some driver would return some internal number in big-endian encoding.
    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.


  12. #72
    Join Date
    Nov 2007
    Location
    Italy
    Posts
    693
    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
    Please read the whole thread again and Google for every term you are not sure you understand. We have already discussed this and at the end at least I came to an impression that you implied you knew how to print the contents of the byte array in ascii. I suggest you do it now and post here the output you get as for now you are only chasing ghosts.


    The compiler says you can't cast a non-mutable pointer to a charater to 32 bit signed integer. Even if you managed to do that, I doubt you would be using the value you wanted to use, especially if your machine is 64bit. It'd be best if you checked whether qFromBigEndian() actually does what you expect it to. Moreover it seems you are using Intel based Windows machine so I can hardly believe some driver would return some internal number in big-endian encoding.
    Hi wysota yes my machine is little endian ( Intel ).
    Meanwhile I'm trying to store the first 4 bytes (32 bits) into an integer to check the value. I should get the number 1234567890 that can be stored with 4 bytes,
    but seems an impossible task for me
    Franco Amato

  13. #73
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,360
    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

    I will not post any more posts in this thread until I see the hexadecimal and ascii dump (or something that at least remotely looks like one) of the byte array contents you get from the COM method.
    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. #74
    Join Date
    Nov 2007
    Location
    Italy
    Posts
    693
    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
    I will not post any more posts in this thread until I see the hexadecimal and ascii dump (or something that at least remotely looks like one) of the byte array contents you get from the COM method.
    here the hexadecimal dump

    499602d20000686f72697a6174694672616e636f0000000000 00000000416d61746f00000000000000000000010103000000 00323232323232323232323232323232632003010a04150a04 1530393837363534333231010160451710138d22554620c210 a90c144351aa861983c04f06224420a90b3204909f062845d1 a30a32468044850c4831080b1548f1b2890a496165882e89d1 9e0628cb603e862fcd703c893b4dc098a01dcdf09e883acec0 9598220f0138881e8f603a88210fe095831b50519e0d159081 04602791603288189251290affff1123333ffffffff0112333 34ffffffe011223334fffffde0112233344fffdee011223334 4fffeee01122233344ffeee01112233444ffeeee0112233444 ffddee0112233444ffddde0112333444ffcdde0122334444ff ccdd0123444445ffcccd0134445445ffbbcc02345555456fbb cc02455555556fabbbe4566666556faaaaa6666666667faaaa 977777666687f99998777776678f0000000000000000000000 00000000000000000000000000000000000000000000000000 00000000000000000000000000000000000000000000000000 00000000000000000000000000000000
    Franco Amato

  15. #75
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,360
    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

    And ascii?
    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. #76
    Join Date
    Nov 2007
    Location
    Italy
    Posts
    693
    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
    And ascii?
    "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"
    from the C# code
    Franco Amato

  17. #77
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,360
    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

    I don't want C# code. How do you know ActiveX returns data packaged in the same way to C++ and C#?

    Anyway I can tell you the first four bytes in your blob are not a number. Unless you are expecting a huge value there... like 47335830
    Last edited by wysota; 23rd April 2010 at 23:49.
    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.


  18. #78
    Join Date
    Nov 2007
    Location
    Italy
    Posts
    693
    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
    I don't want C# code. How do you know ActiveX returns data packaged in the same way to C++ and C#?

    Anyway I can tell you the first four bytes in your blob are not a number. Unless you are expecting a huge value there... like 47335830
    yes I'm expecting 1234567890
    Franco Amato

  19. #79
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,360
    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

    In that case it's there as big endian.
    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. #80
    Join Date
    Nov 2007
    Location
    Italy
    Posts
    693
    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
    In that case it's there as big endian.
    I didn't understand.
    You found the value 1234567890 in the first 4 bytes??? Really?
    If yes please help me to extract and show it as I'm becoming crazy.
    Meanwhile the big endian you mentioned has sense has the stream come from a fingerprint reader that's not based on
    intel cpu.
    Last edited by franco.amato; 24th April 2010 at 00:14.
    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.