Skip to content

question about codes #48

@CUgroup

Description

@CUgroup

Greetings, Dr.jaeger. This is a student at CU.
At present, we've finished connecting TS w/ CAN.
I changed two places of your code in order to fit TS codes in CCS to support C2000, can you please check are these changes necessary or not?

  1. In ‘src’ folder of 'TS library', for every files, i.e., TS.c, TSbin.c, TS_txt.c, there are code sentence as:

for (unsigned int i = 0; i < n; i++)

It has an error in CCS, because Version of C/C++ GCC support in CCS is not advanced.
Correct it as:

unsigned int i; for (i = 0; i < n; i++)

Do you want to change your code as above? Because it can get a wider usage, e.g. it can support other C standards, and it is easy to change.

  1. In ‘src’ folder, in 'thingset.c', one structure 'ts_get_object_by_id' is defined as:

///
struct ts_data_object *ts_get_object_by_id (struct ts_context *ts, ts_object_id_t id)
{
unsigned int i = 0;

for (i = 0; i < ts->num_objects; i++) {
    if (ts->data_objects[i].id == id) {
        return &(ts->data_objects[i]);
    }
}

return NULL;
}
///

Afterwards,

endpoint = ts_get_object_by_id(ts, id);

W/out this change, 'response' = 0, because return of function is always 0, endpoint=0.

Delete ‘return NULL’, correct it as:

///
struct ts_data_object *ts_get_object_by_id(struct ts_context *ts, ts_object_id_t id)
{
unsigned int i = 0;

for (i = 0; i < ts->num_objects; i++) {
    if (ts->data_objects[i].id == id) {
        return &(ts->data_objects[i]);
    }
} 

///

afterwards, endpoint can be correct and can get correct 'response' as e.g. in TS website.

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions