yeah if thats from the debugger then the data your seeing is the debugger writing it in hex just so you can read it
in the memory block its raw bytes
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.
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
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
OK perhaps there are 2 32 bit floatsā¦ just in case, how do you turn a 64 bit float into a xojo number?
same trick as the memoryblock one before for an integer
just read at a specific offset
see http://documentation.xojo.com/api/language/me.htmlmoryBlock
Bingo!! Thanks Norman.
Woohoo BINGO !!! ā¦ whats the prize ?
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?
Old enough to know who they are
Young enough to not have watched them
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)?
[quote=430494:@Ed Stokes]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[/quote]
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
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)
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?
Correct.
See the QColor doc for the value of the 5 int16 values.
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