TCP data field: handle pure hexa

I tested a tcp/ip app in fastrack supreme
to sending and receiving data over tcp
with WIP_CEV_WRITE and WIP_CEV_READ.

First example: the message contains string:

  • in hexadecimal format:
    3031303030303030303030303030303030303030303030303230303830333138313433373131303032303730333045303238433543
    used 53 bytes in tcp packet

  • Converted to readable characters (asciicode to char):
    0100000000000000000000002008031814371100207030E028C5C

As my the first example shows the tcp packet containes the asciicodes of characters.

ascii *pData ;
  u16 length;

    length= ev->content.read.readable;
    pData=adl_memGet(length+1);

    wip_read(ev->channel, pData,length+1);
    pData[length] = '\0';
    adl_atSendResponse(ADL_AT_UNS,pData);

It correctly worked.

Secound example: message contains the following bytes:

  • in hexadecimal format:
    0100000000000000000000002008031814371100207030E028C5C
    used 27 bytes in tcp packet

  • as excpected its unable to convert to char.

How to handle the secound examples situation because that would decrease the used bytes.
I want to write out the bytes to the serial port. But the used “pData” variable cant handle this bytes (because they are not in ascii) :frowning:

I don’t understand the problem. The message is infact a sequence of chars or bytes (the difference is just a matter od signedness). Of course it is not a null-terminated string, but neither WIP nor FCM require this. So I recommend the following: Don’t append a zero to the end of the message, just send it to UART1 using the FCM functions. Read the FCM section in the ADL Guide for that.

Regards,

wismo_coder