This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

CC3220SF-LAUNCHXL: Convert Binary data to understandable format, plot and save as file using Javascript and HTML

Part Number: CC3220SF-LAUNCHXL
Other Parts Discussed in Thread: CC3220SF

I am using CC3220SF_launchpad an HTTP server to get the data from the field.

Ex. current sensor

Uint16_t sensorData[64]={645,745,842,931,1011,1080,1138,1185,1222,1250,1270,1283,1290,1290,1283,1269,1247,1220,1188,1152,1114,1077,1041,1006,973,941,908,874,835,793,747,697,645,594,544,498,456,417,382,350,318,285,250,214,176,139,103,71,43,22,8,1,1,8,21,41,69,106,153,211,280,360,449,546}

I am trying to send these data directly as the response of the request as below–

int32_t dataGetCallback(uint8_t requestIdx, uint8_t *argcCallback, uint8_t **argvCallback, SlNetAppRequest_t *netAppRequest)
{
    char *pPayload;
    uint16_t metadataLen;
    int32_t retVal;

    metadataLen = prepareGetMetadata(0, 128, HttpContentTypeList_ApplicationOctecStream);
    sl_NetAppSend (netAppRequest->Handle, metadataLen, gMetadataBuffer, (SL_NETAPP_REQUEST_RESPONSE_FLAGS_CONTINUATION | SL_NETAPP_REQUEST_RESPONSE_FLAGS_METADATA));
    
    pPayload = (char *)&sensorData;
    sl_NetAppSend (netAppRequest->Handle,128,(unsigned char*)pPayload, 0); /* mark as last segment */


    return 0;
}

 

(above sample is at server in c program)

Data received as the response of ajax call (javascript) is then stored in an variable at the HTTP Client (Any Desktop or Laptop). When I see the response body the data are as below which I am not able to interpret --

I want to plot these data in web browser and also save in a file as comma (,) separated integer values. Can anyone suggest how to convert/process these data to get the integer format array and save in javascript and HTML?

  • Hello,

    This question doesnt really seem to be related to the cc3220 and doesnt really fit in this forum as it is more of a javascript/html problem in regards to plotting. But the problem seems to be that your payload is pointing to a uint16 array thus the data is read incorrectly as unsigned char which is 8 bits and its being interpreted (from your picture) very incorrectly. Unfortunately this forum is more for debugging devices and software, than data conversions.

    Kind regards,

    Rogelio