68 #define DLT_RECEIVE_TEXTBUFSIZE 10024 71 #define DLT_GLOGINFO_APID_NUM_MAX 150 72 #define DLT_GLOGINFO_DATA_MAX 800 73 #define DLT_GET_LOG_INFO_HEADER 18 74 #define DLT_INVALID_LOG_LEVEL 0xF 76 #define DLT_SERVICE_GET_LOG_INFO_OPT7 7 99 }
PACKED DltServiceGetDefaultLogLevel;
153 if (ch >=
'0' && ch <=
'9')
155 binary[pos] = (binary[pos] << 4) + (ch -
'0');
158 else if (ch >=
'A' && ch <=
'F')
160 binary[pos] = (binary[pos] << 4) + (ch -
'A' + 10);
163 else if (ch >=
'a' && ch <=
'f')
165 binary[pos] = (binary[pos] << 4) + (ch -
'a' + 10);
196 printf(
"Usage: dlt-control [options] hostname/serial_device_name\n");
197 printf(
"Send control message to DLT daemon.\n");
198 printf(
"%s \n", version);
199 printf(
"Options:\n");
200 printf(
" -v Verbose mode\n");
201 printf(
" -h Usage\n");
202 printf(
" -y Serial device mode\n");
203 printf(
" -b baudrate Serial device baudrate (Default: 115200)\n");
204 printf(
" -e ecuid Set ECU ID (Default: RECV)\n");
206 printf(
" -a id Control message application id\n");
207 printf(
" -c id Control message context id\n");
208 printf(
" -s id Control message injection service id\n");
209 printf(
" -m message Control message injection in ASCII\n");
210 printf(
" -x message Control message injection in Hex e.g. 'ad 01 24 ef'\n");
211 printf(
" -t milliseconds Timeout to terminate application (Default:1000)'\n");
212 printf(
" -l loglevel Set the log level (0=off - 6=verbose default= -1)\n");
213 printf(
" supported options:\n");
214 printf(
" -l level -a appid -c ctid\n");
215 printf(
" -l level -a abc* (set level for all ctxts of apps name starts with abc)\n");
216 printf(
" -l level -a appid (set level for all ctxts of this app)\n");
217 printf(
" -l level -c xyz* (set level for all ctxts whose name starts with xyz)\n");
218 printf(
" -l level -c ctxid (set level for the particular ctxt)\n");
219 printf(
" -l level (set level for all the registered contexts)\n");
220 printf(
" -r tracestatus Set the trace status (0=off - 1=on,255=default)\n");
221 printf(
" -d loglevel Set the default log level (0=off - 5=verbose)\n");
222 printf(
" -f tracestatus Set the default trace status (0=off - 1=on)\n");
223 printf(
" -i enable Enable timing packets (0=off - 1=on)\n");
224 printf(
" -o Store configuration\n");
225 printf(
" -g Reset to factory default\n");
226 printf(
" -j Get log info\n");
227 printf(
" -u unix port\n");
242 fprintf(stderr,
"ERROR: Could not get log info\n");
246 for (cnt = 0; cnt < g_get_loginfo.
count; cnt++)
250 printf(
"APID:%4s ", g_get_loginfo.
info[cnt].
apid);
276 int main(
int argc,
char* argv[])
306 while ((c = getopt (argc, argv,
"vhye:b:a:c:s:m:x:t:l:r:d:f:i:ogju")) != -1)
331 dltdata.
bvalue = atoi(optarg);
340 fprintf (stderr,
"Invalid appid\n");
350 fprintf (stderr,
"Invalid context id\n");
357 dltdata.
svalue = atoi(optarg);
372 dltdata.
tvalue = atoi(optarg);;
377 dltdata.
lvalue = strtol(optarg, &endptr, 10);
380 fprintf (stderr,
"invalid log level, supported log level 0-6\n");
387 dltdata.
rvalue = atoi(optarg);;
392 dltdata.
dvalue = atoi(optarg);;
397 dltdata.
fvalue = atoi(optarg);;
402 dltdata.
ivalue = atoi(optarg);;
427 if (optopt ==
'o' || optopt ==
'f')
429 fprintf (stderr,
"Option -%c requires an argument.\n", optopt);
431 else if (isprint (optopt))
433 fprintf (stderr,
"Unknown option `-%c'.\n", optopt);
437 fprintf (stderr,
"Unknown option character `\\x%x'.\n",optopt);
474 for (index = optind; index < argc; index++)
478 pr_error(
"set server ip didn't succeed\n");
482 if (g_dltclient.
servIP == 0)
485 fprintf(stderr,
"ERROR: No hostname selected\n");
493 for (index = optind; index < argc; index++)
497 pr_error(
"set serial device didn't succeed\n");
504 fprintf(stderr,
"ERROR: No serial device name specified\n");
534 fprintf(stderr,
"ERROR: Failed to read ECUId from dlt.conf \n");
545 printf(
"Send injection message:\n");
546 printf(
"AppId: %s\n",dltdata.
avalue);
547 printf(
"ConId: %s\n",dltdata.
cvalue);
548 printf(
"ServiceId: %d\n",dltdata.
svalue);
549 printf(
"Message: %s\n",dltdata.
mvalue);
558 fprintf(stderr,
"ERROR: Could not send inject message\n");
566 printf(
"Send injection message:\n");
567 printf(
"AppId: %s\n",dltdata.
avalue);
568 printf(
"ConId: %s\n",dltdata.
cvalue);
569 printf(
"ServiceId: %d\n",dltdata.
svalue);
570 printf(
"Message: %s\n",dltdata.
xvalue);
572 printf(
"Size: %d\n",size);
580 fprintf(stderr,
"ERROR: Could not send inject message\n");
589 printf(
"Set all log level:\n");
590 printf(
"Loglevel: %d\n", dltdata.
lvalue);
595 fprintf(stderr,
"ERROR: Could not send log level\n");
603 printf(
"Set log level:\n");
604 printf(
"AppId: %s\n", dltdata.
avalue);
605 printf(
"ConId: %s\n", dltdata.
cvalue);
606 printf(
"Loglevel: %d\n", dltdata.
lvalue);
614 fprintf(stderr,
"ERROR: Could not send log level\n");
621 printf(
"Set trace status:\n");
622 printf(
"AppId: %s\n",dltdata.
avalue);
623 printf(
"ConId: %s\n",dltdata.
cvalue);
624 printf(
"TraceStatus: %d\n",dltdata.
rvalue);
631 fprintf(stderr,
"ERROR: Could not send trace status\n");
634 else if(dltdata.
dvalue!=-1)
637 printf(
"Set default log level:\n");
638 printf(
"Loglevel: %d\n",dltdata.
dvalue);
642 fprintf (stderr,
"ERROR: Could not send default log level\n");
645 else if(dltdata.
rvalue!=-1)
648 printf(
"Set default trace status:\n");
649 printf(
"TraceStatus: %d\n",dltdata.
rvalue);
653 fprintf (stderr,
"ERROR: Could not send default trace status\n");
656 else if(dltdata.
ivalue!=-1)
659 printf(
"Set timing pakets:\n");
660 printf(
"Timing packets: %d\n",dltdata.
ivalue);
664 fprintf (stderr,
"ERROR: Could not send timing packets\n");
667 else if(dltdata.
oflag!=-1)
670 printf(
"Store config\n");
674 fprintf (stderr,
"ERROR: Could not send store config\n");
677 else if(dltdata.
gflag!=-1)
680 printf(
"Reset to factory default\n");
684 fprintf (stderr,
"ERROR: Could send reset to factory default\n");
687 else if (dltdata.
jvalue == 1)
690 printf(
"Get log info:\n");
697 usleep(dltdata.
tvalue*1000);
715 char number16[6]={0};
729 for (count = 0; count < (len - 1); count++)
731 number16[3] = *(rp + *rp_count + 0);
732 number16[4] = *(rp + *rp_count + 1);
733 *(wp + count) = strtol(number16, &endptr, 16);
745 if ((rp ==
NULL) || (rp_count ==
NULL))
755 num_work[3] = *(rp + *rp_count + 3);
756 num_work[4] = *(rp + *rp_count + 4);
757 num_work[5] = *(rp + *rp_count + 0);
758 num_work[6] = *(rp + *rp_count + 1);
762 return strtol(num_work, &endptr, 16);
769 if ((rp ==
NULL) || (rp_count ==
NULL))
778 num_work[2] = *(rp + *rp_count + 0);
779 num_work[3] = *(rp + *rp_count + 1);
783 return (
signed char)strtol(num_work, &endptr, 16);
790 g_get_loginfo.
count = 0;
821 char get_log_info_tag[13];
822 char service_opt_str[3];
824 if ((resp_text ==
NULL) || (service_id ==
NULL) || (service_opt ==
NULL) || (cb_result ==
NULL))
830 strncpy(get_log_info_tag,
"get_log_info", strlen(
"get_log_info"));
831 ret = memcmp((
void *)resp_text, (
void *)get_log_info_tag,
sizeof(get_log_info_tag)-1);
837 service_opt_str[0] = *(resp_text+14);
838 service_opt_str[1] = *(resp_text+15);
839 service_opt_str[2] = 0;
840 *service_opt = atoi( service_opt_str );
855 uint16_t reg_apid_count;
856 uint16_t reg_ctid_count;
857 uint16_t reg_apid_num;
858 uint16_t reg_ctid_num;
859 uint16_t reg_apid_dsc_len;
860 uint16_t reg_ctid_dsc_len;
866 if (resp_text ==
NULL)
898 loginfo_count = g_get_loginfo.
count;
902 fprintf(stderr,
"GET_LOG_INFO ERROR: APID MAX Over\n");
903 g_get_loginfo.
count = 0;
908 for (reg_apid_count = 0; reg_apid_count < reg_apid_num; reg_apid_count++)
917 fprintf(stderr,
"GET_LOG_INFO ERROR: LOG DATA MAX Over\n");
918 g_get_loginfo.
count = 0;
921 for (reg_ctid_count = 0; reg_ctid_count < reg_ctid_num; reg_ctid_count++)
937 reg_ctid_dsc = (
char *)malloc(
sizeof(
char) * reg_ctid_dsc_len + 1);
938 if (reg_ctid_dsc == 0)
940 fprintf(stderr,
"malloc failed for ctxt desc\n");
944 g_get_loginfo.
info[ loginfo_count ].
ctid_desc = reg_ctid_dsc;
952 reg_apid_dsc = (
char *)malloc(
sizeof(
char) * reg_apid_dsc_len + 1);
953 if (reg_apid_dsc == 0)
955 fprintf(stderr,
"malloc failed for apid desc\n");
959 g_get_loginfo.
info[ loginfo_count - reg_ctid_num ].
apid_desc = reg_apid_dsc;
962 g_get_loginfo.
count = loginfo_count;
997 fprintf(stderr,
"GET_LOG_INFO message_header result failed..\n");
1005 fprintf(stderr,
"GET_LOG_INFO message_payload result failed..\n");
1018 fprintf(stderr,
"GET_LOG_INFO result failed..\n");
void hexAsciiToBinary(const char *ptr, uint8_t *binary, int *size)
int dlt_receive_message_callback(DltMessage *message, void *data)
DltReturnValue dlt_client_send_timing_pakets(DltClient *client, uint8_t timingPakets)
DltReturnValue dlt_client_send_all_log_level(DltClient *client, uint8_t LogLevel)
DltStorageHeader * storageheader
void dlt_set_id(char *id, const char *text)
void dlt_client_register_message_callback(int(*registerd_callback)(DltMessage *message, void *data))
int dlt_parse_config_param(char *config_id, char **config_data)
int dlt_client_set_server_ip(DltClient *client, char *ipaddr)
#define DLT_GET_LOG_INFO_HEADER
int main(int argc, char *argv[])
#define DLT_SERVICE_ID_GET_LOG_INFO
#define DLT_GLOGINFO_APID_NUM_MAX
int dlt_client_get_log_info(DltClient *client)
DltReturnValue dlt_client_setbaudrate(DltClient *client, int baudrate)
DltReturnValue dlt_filter_init(DltFilter *filter, int verbose)
int dlt_set_loginfo_parse_service_id(char *resp_text, int *service_id, int *service_opt, char *cb_result)
int dlt_client_set_serial_device(DltClient *client, char *serial_device)
int dlt_getloginfo_make_loginfo(char *resp_text, int service_opt)
#define DLT_RECEIVE_TEXTBUFSIZE
static char * service_id[]
static char data[kDataSize]
DltReturnValue dlt_set_storageheader(DltStorageHeader *storageheader, const char *ecu)
DltReturnValue dlt_client_send_reset_to_factory_default(DltClient *client)
DltReturnValue dlt_client_init(DltClient *client, int verbose)
DltReturnValue dlt_filter_free(DltFilter *filter, int verbose)
DltReturnValue dlt_client_cleanup(DltClient *client, int verbose)
unsigned char buffer[BUFFER_SIZE]
Buffer for dlt file transfer. The size is defined by BUFFER_SIZE.
DltReturnValue dlt_client_connect(DltClient *client, int verbose)
void dlt_getloginfo_free(void)
#define pr_error(fmt,...)
#define DLT_IS_HTYP_WEID(htyp)
DltStandardHeaderExtra headerextra
DltReturnValue dlt_file_init(DltFile *file, int verbose)
DltReturnValue dlt_message_payload(DltMessage *msg, char *text, int textlength, int type, int verbose)
void dlt_getloginfo_conv_ascii_to_id(char *rp, int *rp_count, char *wp, int len)
#define DLT_INVALID_LOG_LEVEL
DltReturnValue dlt_client_send_inject_msg(DltClient *client, char *apid, char *ctid, uint32_t serviceID, uint8_t *buffer, uint32_t size)
DltReturnValue dlt_file_free(DltFile *file, int verbose)
uint16_t dlt_getloginfo_conv_ascii_to_uint16_t(char *rp, int *rp_count)
DltStandardHeader * standardheader
DltReturnValue dlt_client_send_log_level(DltClient *client, char *apid, char *ctid, uint8_t logLevel)
void dlt_get_version(char *buf, size_t size)
DltReturnValue dlt_message_header(DltMessage *msg, char *text, int textlength, int verbose)
DltReturnValue dlt_client_send_default_log_level(DltClient *client, uint8_t defaultLogLevel)
DltLoginfoDetail info[DLT_GLOGINFO_DATA_MAX]
DltReturnValue dlt_client_send_trace_status(DltClient *client, char *apid, char *ctid, uint8_t traceStatus)
void dlt_getloginfo_init(void)
DltReturnValue dlt_client_send_default_trace_status(DltClient *client, uint8_t defaultTraceStatus)
#define DLT_SERVICE_GET_LOG_INFO_OPT7
void dlt_process_get_log_info(void)
#define DLT_GLOGINFO_DATA_MAX
int16_t dlt_getloginfo_conv_ascii_to_int16_t(char *rp, int *rp_count)
DltReturnValue dlt_client_send_store_config(DltClient *client)