This article describes how to debug a data parsing script on premises, and troubleshoot problems if IoT Platform fails to parse data by using the script.

Debug a script on premises

You can check whether a data parsing script is valid in IoT Platform. However, you cannot debug the script in IoT Platform. We recommend that you write and debug a script on premises, and then copy the script to the online editor in the IoT Platform console.

The following sample script is used for on-premises debugging. For more information about sample scripts, see Example for parsing TSL data. Specify the parameters as required when you use the script.

//Test Demo
function Test()
    var rawdata_report_prop = new Buffer([
        0x00, //The fixed command header. 0 indicates property data submission.
        0x00, 0x22, 0x33, 0x44, //The ID of the request.
        0x12, 0x32, //The value of the prop_int16 parameter. This value is a two-byte Int16 value.
        0x01, //The value of the prop_bool parameter. This value is a one-byte Boolean value.
        0x3f, 0xa0, 0x00, 0x00 //The value of the prop_float parameter. This value is a four-byte Float value.
    var setString = new String('{"method":"","id":"12345","version":"1.0","params":{"prop_float":123.452, "prop_int16":333, "prop_bool":1}}');

Troubleshoot online parsing problems

After a device is connected to IoT Platform and submits property data, you can view the data in the IoT Platform console if a data parsing script works properly. Find the required device in the device list and click View to go to the Device Details page. On this page, choose TSL Data > Status.

If the device has submitted data but the data is not displayed, choose Maintenance > Device Log > Cloud run log to view the logs and troubleshoot the problem.

You can perform the following steps to troubleshoot the problem:

  1. Select a product, enter the DeviceName, and then click Search. Select TSL Report from the Workload Type drop-down list to query logs.
  2. View the log entry that include payloads and parsed data.
  3. Check the error code. For more information about error codes, see IoT Platform logs.
  4. Check the script and submitted device data based on the error code.

The following errors may occur:

  • The script does not exist.

    The error code 6200 is displayed in the log entry. For more information about the description of error codes, see IoT Platform logs. The error code 6200 indicates that the script does not exist. Check whether the script has been submitted to the console.

  • The Alink method does not exist.

    The error code 6450 is displayed in the log entry. This error code indicates that the method parameter in the Alink data does not exist. For more information, see IoT Platform logs. The method parameter is missing after the custom formatted data or pass-through data is parsed to the standard Alink data.

    The following log entry shows the error message:
    17:54:19.064, A7B02C60646B4D2E8744F7AA7C3D9567, upstream-error - bizType=OTHER_MESSAGE,params={"params":{}},result=code:6450,message:alink method not exist,...
    The error message alink method not exist indicates that the method parameter does not exist in the Alink data. This error occurs if the definition of the method parameter is invalid in the data parsing script. You must modify the script.