QDataStream

  1. ‹ Older
  2. 8 weeks ago

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

  3. Norman P

    Mar 23 Pre-Release Testers, Xojo Pro Freeport, Bahamas

    @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

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

  5. Norman P

    Mar 23 Pre-Release Testers, Xojo Pro Freeport, Bahamas
    Edited 8 weeks ago

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

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

  6. Ed S

    Mar 23 Answer

    Bingo!! Thanks Norman.

  7. Norman P

    Mar 23 Pre-Release Testers, Xojo Pro Freeport, Bahamas

    @Ed S Bingo!! Thanks Norman.

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

  8. 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?

  9. Norman P

    Mar 23 Pre-Release Testers, Xojo Pro Freeport, Bahamas

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

  10. 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)?

  11. Norman P

    Mar 26 Pre-Release Testers, Xojo Pro Freeport, Bahamas
    Edited 8 weeks 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

  12. 6 weeks ago
    Edited 6 weeks 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)
    =======================================

  13. QColor definition:

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

  14. Maurizio R

    Apr 4 Pre-Release Testers, Xojo Pro

    Serializing Qt Data Types

  15. 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?

  16. Maurizio R

    Apr 4 Pre-Release Testers, Xojo Pro

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

  17. 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

  18. Maurizio R

    Apr 5 Pre-Release Testers, Xojo Pro

    Don't ask me why but try this code:

    // background color
    outputStream.WriteUInt8 (1) // RGB is Type 1
    outputStream.WriteUInt8 (255) // Alpha channel = fully opaque
    outputStream.WriteUInt8 (255)
    outputStream.WriteUInt8 (255) // Red
    outputStream.WriteUInt8 (255) 
    outputStream.WriteUInt8 (255) // Green
    outputStream.WriteUInt8 (255)
    outputStream.WriteUInt8 (255) // Blue
    outputStream.WriteUInt8 (255)
    outputStream.WriteUInt16 (0) // Pad
    
    // foreground color
    outputStream.WriteUInt8 (1) // RGB is Type 1
    outputStream.WriteUInt8 (255) // Alpha channel = fully opaque
    outputStream.WriteUInt8 (255)
    outputStream.WriteUInt8 (255) // Red
    outputStream.WriteUInt8 (255)
    outputStream.WriteUInt8 (0) // Green
    outputStream.WriteUInt8 (0)
    outputStream.WriteUInt8 (0) // Blue
    outputStream.WriteUInt8 (0)
    outputStream.WriteUInt16 (0) // Pad
  19. Here's my latest try with some help from the WSJT-X team, but instead of creating foreground and background colors it simply erases the intended text, leaving a blank white on white space.

    I'm trying to get more info from them but I seem to be a complete idiot in dealing with the source forge mailing list, so I don't know if my query is getting posted or not.

    Public Sub ChangeColors(callSign As String)
    Dim mb As New MemoryBlock (0)
    Dim outputStream As New BinaryStream (mb)
    Dim utf8 As String

    outputStream.LittleEndian = False

    outputStream.WriteUInt32 (magicNumber)
    outputStream.WriteUInt32 (2)
    outputStream.WriteUInt32 (13) ' Clear

    // Id (unique key)
    utf8 = id.ConvertEncoding (Encodings.UTF8)
    outputStream.WriteUInt32 (LenB (utf8))
    outputStream.Write (utf8)

    // callSign
    utf8 = callSign.ConvertEncoding (Encodings.UTF8)
    outputStream.WriteUInt32 (LenB (utf8))
    outputStream.Write (utf8)

    // background color
    Dim c As Color = &cff0000 ' Defaults to Alpha value 0
    outputStream.WriteUInt8 (1) ' RGB spec
    outputStream.WriteUInt16 (c.Alpha)
    outputStream.WriteUInt16 (c.Red)
    outputStream.WriteUint16 (c.Green)
    outputStream.WriteUInt16 (c.Blue)
    outputStream.WriteUInt16 (0) ' padding

    // foreground color
    c = &c0000ff ' Defaults to Alpha value 0
    outputStream.WriteUInt8 (1) ' RGB spec
    outputStream.WriteUInt16 (c.Alpha)
    outputStream.WriteUInt16 (c.Red)
    outputStream.WriteUint16 (c.Green)
    outputStream.WriteUInt16 (c.Blue)
    outputStream.WriteUInt16 (0) ' padding

    // Highlight last
    outputStream.WriteBoolean (False)

    // close the BinaryStream
    outputStream.Close

    Dim msg As new Datagram

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

    End Sub

  20. Maurizio R

    Apr 5 Pre-Release Testers, Xojo Pro
    Edited 6 weeks ago

    Ed, Qt serialize colors as I posted in my previous message.
    Alpha, Red, Green and Blue are 16 bits values not 8 bit values emitted as a 16 bits values.
    For example a full red color has the red part emitted as &hffff not &h00ff.

  21. YES!!!!

    Mille grazie, Maurizio!

or Sign Up to reply!