4 * Copyright (c) 2000 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
8 * Cherepanov Vitaliy <v.cherepanov@samsung.com>
9 * Nikita Kalyazin <:wn.kalyazin@samsung.com>
11 * Licensed under the Apache License, Version 2.0 (the "License");
12 * you may not use this file except in compliance with the License.
13 * You may obtain a copy of the License at
15 * http://www.apache.org/licenses/LICENSE-2.0
17 * Unless required by applicable law or agreed to in writing, software
18 * distributed under the License is distributed on an "AS IS" BASIS,
19 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20 * See the License for the specific language governing permissions and
21 * limitations under the License.
24 * - Samsung RnD Institute Russia
29 #include "da_protocol.h"
36 int print_sys_info(struct system_info_t * sys_info)
41 sys_info->wifi_status=0x2;
42 sys_info->bt_status=0x3;
43 sys_info->gps_status=0x4;
44 sys_info->brightness_status=0x5;
46 sys_info->camera_status=0x6;
47 sys_info->sound_status=0x7;
48 sys_info->audio_status=0x8;
49 sys_info->vibration_status=0x9;
50 sys_info->voltage_status=0x10;
52 sys_info->rssi_status=0x11;
53 sys_info->video_status=0x12;
54 sys_info->call_status=0x13;
55 sys_info->dnet_status=0x14;
56 sys_info->cpu_frequency=0x15;
58 sys_info->app_cpu_usage=0.0;
59 sys_info->cpu_load=0x17;
60 sys_info->virtual_memory=0x18;
61 sys_info->resident_memory=0x19;
62 sys_info->shared_memory=0x20;
64 sys_info->pss_memory=0x21;
65 sys_info->total_alloc_size=(uint64_t)0x22;
66 sys_info->system_memory_total=(uint64_t)0x23;
67 sys_info->system_memory_used=(uint64_t)0x24;
68 sys_info->total_used_drive=0x25;
70 sys_info->count_of_threads=0x26;
71 sys_info->thread_load=0x27;
72 sys_info->count_of_processes=0x28;
73 sys_info->process_load=0x29;
74 sys_info->disk_read_size=0x30;
76 sys_info->disk_write_size=0x31;
77 sys_info->network_send_size=0x32;
78 sys_info->network_receive_size=0x33;
87 brightness_status = 0x%X\n\
89 camera_status = 0x%X\n\
90 sound_status = 0x%X\n\
91 audio_status = 0x%X\n\
92 vibration_status = 0x%X\n\
93 voltage_status = 0x%X\n\
96 video_status = 0x%X\n\
99 cpu_frequency (pointer)= 0x%X\n\
101 app_cpu_usage = %f\n\
102 cpu_load (pointer)= 0x%X\n\
103 virtual_memory = 0x%X\n\
104 resident_memory = 0x%X\n\
105 shared_memory = 0x%X\n\
108 total_alloc_size = 0x%X\n\
109 system_memory_total = %llu\n\
110 system_memory_used = %llu\n\
111 total_used_drive = %d\n\
113 count_of_threads = %u\n\
114 thread_load (pointer)= 0x%X\n\
115 count_of_processes = %u\n\
116 process_load = 0x%X\n\
119 disk_sectors_read = 0x%X\n\
120 disk_writes = 0x%X\n\
121 disk_sectors_write = 0x%X\n\
122 network_send_size = 0x%X\n\
123 network_receive_size = 0x%X\n",
126 sys_info->wifi_status,
128 sys_info->gps_status,
129 sys_info->brightness_status,
131 sys_info->camera_status,
132 sys_info->sound_status,
133 sys_info->audio_status,
134 sys_info->vibration_status,
135 sys_info->voltage_status,
137 sys_info->rssi_status,
138 sys_info->video_status,
139 sys_info->call_status,
140 sys_info->dnet_status,
141 (unsigned int)sys_info->cpu_frequency,
143 sys_info->app_cpu_usage,
144 (unsigned int)sys_info->cpu_load,
145 sys_info->virtual_memory,
146 sys_info->resident_memory,
147 sys_info->shared_memory,
149 sys_info->pss_memory,
150 sys_info->total_alloc_size,
151 sys_info->system_memory_total,
152 sys_info->system_memory_used,
153 sys_info->total_used_drive,
155 sys_info->count_of_threads,
156 (unsigned int)sys_info->thread_load,
157 sys_info->count_of_processes,
158 (unsigned int)sys_info->process_load,
159 sys_info->disk_reads,
161 sys_info->disk_sectors_read,
162 sys_info->disk_writes,
163 sys_info->disk_sectors_write,
164 sys_info->network_send_size,
165 sys_info->network_receive_size
168 for ( i=0; i<sys_info->count_of_processes; i++)
170 LOGI_("\tpr %016X : %f\n",
171 sys_info->process_load[i].id,
172 sys_info->process_load[i].load
175 for ( i=0; i<sys_info->count_of_threads; i++)
177 LOGI_("\tth %016X : %f\n",
178 sys_info->thread_load[i].pid,
179 sys_info->thread_load[i].load
183 // FIXME CPU core num hardcoded
186 LOGI_("\tCPU load #%d : %f\n",
188 sys_info->cpu_load[i]
191 // FIXME CPU core num hardcoded
194 LOGI_("\tCPU freq #%d : %f\n",
196 sys_info->cpu_frequency[i]
199 // char *p = sys_info;
200 printBuf((char*)sys_info, sizeof(*sys_info));
205 int fill_data_msg_head (struct msg_data_t *data, uint32_t msgid,
206 uint32_t seq, uint32_t len)
210 data->seq_num = seq; // TODO fill good value
211 gettimeofday(&time, NULL);
212 data->sec = time.tv_sec;
213 data->nsec = time.tv_usec * 1000;
219 //allocate memory, need free!!!
220 struct msg_data_t *gen_message_terminate(uint32_t id)
222 uint32_t payload_len = sizeof(uint32_t);
223 struct msg_data_t *data = malloc(sizeof(*data) + payload_len);
225 fill_data_msg_head(data,NMSG_TERMINATE, 0, payload_len);
226 // TODO fill good value
232 //allocate memory, need free!!!
233 struct msg_data_t *gen_message_error(const char * err_msg)
235 int payload_len = strlen(err_msg)+1;
236 struct msg_data_t *data = malloc(sizeof(*data) + payload_len);
238 fill_data_msg_head(data, NMSG_ERROR, 0, payload_len);
245 //allocatr memory, need free!!!
246 struct msg_data_t *gen_message_event(
247 struct input_event *events,
248 uint32_t events_count,
252 uint32_t payload_len = events_count * (sizeof(id) * 4) +
253 sizeof(events_count);
254 struct msg_data_t *data = malloc(sizeof(*data) + payload_len);
255 memset(data,0,sizeof(*data) + payload_len);
258 fill_data_msg_head(data, NMSG_RECORD, 0, payload_len);
261 pack_int32(p, events_count);
263 for (i=0; i<events_count; i++){
265 pack_int32(p, (int32_t) events[i].type);
266 pack_int32(p, (int32_t) events[i].code);
267 pack_int32(p,events[i].value);
273 void inline free_msg_data(struct msg_data_t *msg)