Help converting data for TCP Socket request


I am trying to read sensor data from Tinkerforge Himidity Bricklet in my Xojo Desktop App.

There is a pretty good Documentation, about how I can do this by a TCP/IP request.

The following example shows how to call the get_humidity function of a Humidity Bricklet with UID "b1Q" (Base58) or 33688 (integer). The corresponding request packet has
    UID 33688 as uint32 (0x98 0x83 0x00 0x00),
    Packet length 8 as uint8 (0x08),
    Function ID 1 as uint8 (0x01),
    Sequence number 1 and response expected 1 as uint8 (0x18) and
    Flags 0 as uint8 (0x00).

and an empty payload. Its hex dump looks like this:

0000   98 83 00 00 08 01 18 00                          .. ......

So till now, I can connect to the Brick by TCP socket and get a first response of the attached SensorUIDs.
I have the SensorUnitID as integer and the FunctionID as well as integer.

How can I create and send such a request (98 83 00 00 08 01 18 00) ?
Whitch functions can convert the IntegerUID to 0x98 0x83 0x00 0x00 ?

May someone can give me a hint in which direction I have to search?

Thanks in advance


tcpsocket.write takes a “string” - which is kind of a misnomer in some ways
“Strings” can be treated as a bunch of bytes (its just the way “strings” are)

what you might do is create a memoryblock that is the right size (in this case 8 byte)

then put in the values you want using the memoryblock functions

then write the memoryblock like

tcpsocket.write( mb )

as memoryblocks have this nice characteristic that they will convert themselves to a “string” that is just a bunch of bytes

something like

dim mb as new memoryblock(8)
mb.littleendian = false
mb.Int32(0) = 33688
mb.Uint8(4)  = 8
mb.Uint8(5) = 1
mb.Uint8(6) = &h18
mb.Unit8(7) = 0

 tcp.write( mb )

@Norman Palardy : Thanks, that helped me a lot.