/* With this service it is possible to retrieve one or more values of a control unit. This can be information of all kinds and of different lengths such as Partnumber or the software version. Dynamic values such as the current state of the sensor can be queried. Each value is associated to a Data Identifier (DID) between 0 and 65535. */
static int handle_read_data_by_identifier(struct upgrade_uds_t *self_p, int length)
/* With this service it is possible to retrieve one or more values of a control unit. This can be information of all kinds and of different lengths such as Partnumber or the software version. Dynamic values such as the current state of the sensor can be queried. Each value is associated to a Data Identifier (DID) between 0 and 65535. */
static int handle_read_data_by_identifier(struct upgrade_uds_t *self_p, int length)
{
    uint16_t did;
    int res;
    if (length < 2) {
        ignore_and_write_negative_response(self_p,
                                           length,
                                           READ_DATA_BY_IDENTIFIER,
                                           INCORRECT_MESSAGE_LENGTH_OR_INVALID_FORMAT);
        return (-1);
    }
    chan_read(self_p->chin_p, &did, sizeof(did));
    did = ntohs(did);
    length -= 2;
    switch (did) {
    case DID_VERSION:
        res = handle_read_data_by_identifier_version(self_p);
        break;
    case DID_SYSTEM_TIME:
        res = handle_read_data_by_identifier_system_time(self_p);
        break;
    default:
        ignore_and_write_negative_response(self_p,
                                           length,
                                           READ_DATA_BY_IDENTIFIER,
                                           SERVICE_NOT_SUPPORTED);
        res = -1;
        break;
    }
    return (res);
}