QDataStream

  1. ‹ Older
  2. 9 months ago

    Norman P

    21 Mar 2019 Pre-Release Testers, Xojo Pro Outside Innisfail

    yeah if thats from the debugger then the data your seeing is the debugger writing it in hex just so you can read it :P
    in the memory block its raw bytes

  3. Norman...

    Many many thanks... I have re-written the code and it is now working as I hoped.

    Your help and patience very much appreciated.

  4. I still have another question...

    I need to convert this Qt Data Type

    float 32-bit floating point number using the standard IEEE 754 format

    into a double.

    Here is a sample value as hex:

    3F D3 33 33 40 00 00 00

  5. Maurizio R

    23 Mar 2019 Pre-Release Testers, Xojo Pro

    A 32 bit float is named Single in Xojo.

  6. I'm concerned that 3F D3 33 33 40 00 00 00 (from the data stream) seems to be a 64 bit number.

  7. Norman P

    23 Mar 2019 Pre-Release Testers, Xojo Pro Outside Innisfail

    @Ed S I'm concerned that 3F D3 33 33 40 00 00 00 (from the data stream) seems to be a 64 bit number.

    3F D3 33 33 40 00 00 00 is more than 32 bits for sure

    3F D3 33 33 would be 32 bits
    40 00 00 00 would be 32 bits as well

  8. OK perhaps there are 2 32 bit floats... just in case, how do you turn a 64 bit float into a xojo number?

  9. Norman P

    23 Mar 2019 Pre-Release Testers, Xojo Pro Outside Innisfail
    Edited 9 months ago

    same trick as the memoryblock one before for an integer
    just read at a specific offset

    see http://docs.xojo.com/MemoryBlock

  10. 8 months ago

    Ed S

    23 Mar 2019 Answer

    Bingo!! Thanks Norman.

  11. Norman P

    23 Mar 2019 Pre-Release Testers, Xojo Pro Outside Innisfail

    @Ed S Bingo!! Thanks Norman.

    Woohoo BINGO !!! .. whats the prize ? :P

  12. Bingo bango bongo, I don't want to leave the Congo. Oh no, no, no!
    Bingo bango bongo, I'm so happy in the jungle, I refuse to go.

    Danny Kaye and the Andrews Sisters:
    https://www.youtube.com/watch?v=ugW2INtnl84

    Are you old enough to remember?

  13. Norman P

    23 Mar 2019 Pre-Release Testers, Xojo Pro Outside Innisfail

    Old enough to know who they are
    Young enough to not have watched them :)

  14. I'm back...

    I have mastered the receipt and decoding of messages from the UDP server.

    Now I need a bit of advice concerning encoding and sending messages to it.

    As noted above, the format spec is at https://sourceforge.net/p/wsjt/wsjtx/ci/master/tree/NetworkMessage.hpp

    My understanding is that I can send a message to the server using something like this:
    UdPSocket1.Write( kGroupAddress, clearMessage)

    I have tried formatting the clearMessage thus:
    clearMessage = "ADBCCBDA 00000002 00000003 01"

    This appears to be wrong as the server does not respond as expected.

    With reference to the spec above, the message should have the following info:

    Header format:

    (1) 32-bit unsigned integer magic number 0xadbccbda
    (2) 32-bit unsigned integer schema number

    * Payload format:
    Clear
    (3) Out/In 3 quint32
    (4) Id (unique key) utf8
    (5) Window quint8 (In only)

    which translates to

    (1) ADBCCBDA (magic number)
    (2) 00000002 (schema number)
    (3) 00000003 (desired function: Clear )
    (4) 01 (unique ID: clear the "Rx Frequency" window)
    (1) ** unnecessary as message is outbound **

    My question:

    How do I encode this message for the server and use it with UdPSocket1.Write( serverAddress, serverMessage)?

  15. Norman P

    26 Mar 2019 Pre-Release Testers, Xojo Pro Outside Innisfail
    Edited 8 months ago

    @Ed S I have tried formatting the clearMessage thus:
    clearMessage = "ADBCCBDA 00000002 00000003 01"

    This appears to be wrong as the server does not respond as expected.

    With reference to the spec above, the message should have the following info:

    Header format:

    (1) 32-bit unsigned integer magic number 0xadbccbda
    (2) 32-bit unsigned integer schema number

    if you put a break point right after where you set "clear message" and look in the debugger you will see your bytes are not correct
    OK now for the "why not"
    The first letter in your message is A - its BYTE numerical value is not "a" its dec 65 (hex 41)
    In order to get the correct magic value you need to do something like

    clearMessage = ChrB(&hAD) + ChrB(&hBC) + ChrB(&hCB) + ChrB(&hDA)

    this crafts 4 bytes with the values AD, BC, CB, DA - and disregards any encoding etc

    the second part again needs to be a 4 byte value - the string you have crafted is many more bytes than this
    and a similar tactic is required

    clearmessage = clearmessage  + chrb(&h00) + chrb(&h00)  + chrb(&h00)  + chrb(&h02)

    and so on

    Note that in this case "string" is not textual data
    Its just a convenient container for a pile of BYTES

  16. Edited 8 months ago

    Hello....

    I'm back with a new question concerning QDataStream.

    I have had good luck with my project and it is doing most of what I want. Anyone working with WSJT-X and Xojo should feel free to contact me as I am happy to share what I've learned.

    However, I still have one more question.

    I need to understand how to structure a QColor variable for UDP transmission.

    Here is the final code for sending a message to the WSJT-X instance:

    ======================================
    Method: Clear ( what2clear As Uint8 )

    Dim mb As New MemoryBlock (0)
    Dim outputStream As New BinaryStream (mb)

    outputStream.LittleEndian = False
    outputStream.WriteUInt32 (magicNumber)
    outputStream.WriteUInt32 (2)
    outputStream.WriteUInt32 (3) ' Clear

    //outputStream.WriteUInt32 (&hffffffff) ' Null id string
    Dim utf8 As String = id.ConvertEncoding (Encodings.UTF8)
    outputStream.WriteUInt32 (LenB (utf8))
    outputStream.Write (utf8)

    outputStream.WriteUInt8 (what2clear) ' Clear a window
    outputStream.Close

    Dim msg As new Datagram

    msg.Address = WSJTX_IP
    msg.Port = WSJTX_Port
    msg.Data = mb
    WSJTX_Socket.Write (msg)
    =======================================

  17. QColor definition:

    https://doc.qt.io/Qt-5/qcolor.html

  18. Maurizio R

    4 Apr 2019 Pre-Release Testers, Xojo Pro

    Serializing Qt Data Types

  19. I think I see....

    I need to send 1 qint8 followed by 5 quint16s...

    something like this:

    outputStream.WriteUInt8 ( value )
    outputStream.WriteUInt16 ( value )
    outputStream.WriteUInt16 ( value )
    outputStream.WriteUInt16 ( value )
    outputStream.WriteUInt16 ( value )
    outputStream.WriteUInt16 ( value )

    is that correct?

  20. Maurizio R

    4 Apr 2019 Pre-Release Testers, Xojo Pro

    Correct.
    See the QColor doc for the value of the 5 int16 values.

  21. I'm afraid I still need help

    I'm getting white on white!

    Here's my code:

    // background color
    outputStream.WriteUInt8 (1) // RGB is Type 1
    outputStream.WriteUInt16 (255) // Alpha channel = fully opaque
    outputStream.WriteUInt16 (255) // Red
    outputStream.WriteUInt16 (255) // Green
    outputStream.WriteUInt16 (255) // Blue
    outputStream.WriteUInt16 (255) // Pad

    // foreground color
    outputStream.WriteUInt8 (1) // RGB is Type 1
    outputStream.WriteUInt16 (255) // Alpha channel = fully opaque
    outputStream.WriteUInt16 (255) // Red
    outputStream.WriteUInt16 (0) // Green
    outputStream.WriteUInt16 (0) // Blue
    outputStream.WriteUInt16 (0) // Pad

  22. Newer ›

or Sign Up to reply!