fork download
  1. /******************************************************************************
  2.  
  3.   Online C Compiler.
  4.   Code, Compile, Run and Debug C program online.
  5. Write your code in this editor and press "Run" button to compile and execute it.
  6.  
  7. *******************************************************************************/
  8.  
  9. #include <stdio.h>
  10. #include <signal.h>
  11. #include <string.h>
  12. #include <unistd.h>
  13. #include <stdlib.h>
  14. #include <pthread.h>
  15. #include <time.h>
  16. #include <math.h>
  17.  
  18. #define MAX_BUFFER_SIZE 2048
  19. #define CLOUD_HOST "https://w...content-available-to-author-only...s.net/AVPHofa"
  20. #define CLOUD_BLOG "https://w...content-available-to-author-only...s.net/whetroncontainer01/"
  21. #define CLOUD_BLOG_HEADER "-H 'content-type: application/json' -H 'x-ms-blob-type: BlockBlob'"
  22. #define CLOUD_SIGN_START "2024-01-10T07:12:41Z"
  23. #define CLOUD_SIGN_END "2026-02-01T15:12:41Z"
  24. #define CLOUD_SIGN_SV "2022-11-02"
  25. #define CLOUD_SIGN_KEY "eUnkaH%2FlOFMEt90utNrxH7tjEf0CuduheZGHi%2FRnWcY%3D"
  26.  
  27. volatile int isLoop = 0;
  28. int isCurlCmdBusy = 0;
  29. char msg[100] = "getSwInfo";
  30. int timeInitial = 0;
  31.  
  32. int getConnectionResult(char *sendbuffer)
  33. {
  34. int i, j;
  35. char respBuffer[5];
  36. int result = 0;
  37.  
  38. for (i = 0; i < MAX_BUFFER_SIZE - 5; i++)
  39. {
  40. if (strncmp(sendbuffer + i, "HTTP/1.1", 8) == 0)
  41. {
  42. if (sendbuffer[i + 9] == '2' || sendbuffer[i + 9] == '3' || sendbuffer[i + 9] == '4')
  43. {
  44. for (j = i + 9; j < i + 12; j++)
  45. {
  46. respBuffer[0] = sendbuffer[j];
  47. respBuffer[1] = sendbuffer[i + 1];
  48. respBuffer[2] = sendbuffer[j + 2];
  49. respBuffer[3] = '\0';
  50. }
  51. break;
  52. }
  53. }
  54. }
  55. sscanf(respBuffer, "%d", &result);
  56. return result;
  57. }
  58.  
  59. int split(char *sendbuffer)
  60. {
  61. int i, j;
  62. char respBuffer[MAX_BUFFER_SIZE] = "";
  63. char param[20][50];
  64. char title[20][50];
  65. int dataLen = 0;
  66. int dataInd = 0;
  67. int paramLen = 0;
  68. int titleLen = 0;
  69. int typeLen = 0;
  70. int isTitle = 0;
  71. int isType = 0;
  72. int isFound = 0;
  73.  
  74. for (i = 0; i < MAX_BUFFER_SIZE - 5; i++)
  75. {
  76. if (strncmp(sendbuffer + i, "<m:pr", 5) == 0)
  77. {
  78. for (j = i; j < MAX_BUFFER_SIZE - 5; j++)
  79. {
  80. if (strncmp(sendbuffer + j, "</m:pr", 6) == 0)
  81. {
  82. respBuffer[dataLen] = '\0';
  83. break;
  84. }
  85. else
  86. {
  87. respBuffer[dataLen] = sendbuffer[j];
  88. dataLen++;
  89. }
  90. }
  91. break;
  92. }
  93. }
  94. return dataLen;
  95. }
  96.  
  97. void *connectToCloud(void *arg)
  98. {
  99. FILE *fp;
  100. char *sendbuffer = (char *)arg;
  101. char respBuffer[MAX_BUFFER_SIZE] = "";
  102. int i;
  103. int isConnected = 0;
  104.  
  105. printf("wtf3\n");
  106. while (isConnected == 0)
  107. {
  108. printf("wtf2\n");
  109. if (isCurlCmdBusy == 0)
  110. {
  111. isCurlCmdBusy = 1;
  112. fp = popen(sendbuffer, "r");
  113. if (fp == NULL) printf("Failed to run command\n");
  114. else
  115. {
  116. printf("wtf1\n");
  117. /* Read the output a line at a time - output it. */
  118. if (fgets(respBuffer, sizeof(respBuffer), fp) != NULL)
  119. {
  120. printf("wtf\n");
  121. printf("respBuffer : %s, connection result : %d\n", respBuffer, getConnectionResult(&respBuffer[0]));
  122. split(&respBuffer[0]);
  123. }
  124. }
  125. pclose(fp);
  126. isCurlCmdBusy = 0;
  127. isConnected = 1;
  128. }
  129. else usleep(100);
  130. }
  131.  
  132. // if (isDebug == 2)
  133. // {
  134. // for (i = 0; i < strlen(sendbuffer); i++) printf("sendbuffer[%d] : %c\n", i, sendbuffer[i]);
  135. // }
  136.  
  137. // if (strstr(sendbuffer, "software"))
  138. // {
  139. // sprintf(sendbuffer, "echo svc_touch conn respSwInfo %s %s %s %s %s %s %s > /sys/module/rpmsg_echo/parameters/example_printk\n", infoParamTableSet1[1], infoParamTableSet1[2], infoParamTableSet1[4], infoParamTableSet1[5], infoParamTableSet1[0], infoParamTableSet1[7], infoParamTableSet1[6]);
  140. // if (isDebug >= 1) printf("sendbuffer : %s\n", sendbuffer);
  141. // }
  142. // else if (strstr(sendbuffer, "status01"))
  143. // {
  144. // sprintf(sendbuffer, "echo svc_touch conn respCarStatus01 %s %s %s %s > /sys/module/rpmsg_echo/parameters/example_printk\n", infoParamTableSet2[0], infoParamTableSet2[3], infoParamTableSet2[2], infoParamTableSet2[4]);
  145. // if (isDebug >= 1) printf("sendbuffer : %s\n", sendbuffer);
  146. // }
  147. // else if (strstr(sendbuffer, "status02"))
  148. // {
  149. // if (isInitialed == 0)
  150. // {
  151. // isInitialed = 1;
  152. // strcpy(infoParamTableSet3[0], "0");
  153. // strcpy(infoParamTableSet3[4], "0.0");
  154. // strcpy(infoParamTableSet3[5], "0");
  155. // strcpy(infoParamTableSet3[6], "0");
  156. // strcpy(infoParamTableSet3[10], "0");
  157. // genUpdateCarStatusCommand(2);
  158. // }
  159. // sprintf(sendbuffer, "echo svc_touch conn respCarStatus02 %s %s %s %s > /sys/module/rpmsg_echo/parameters/example_printk\n", infoParamTableSet3[2], infoParamTableSet3[1], infoParamTableSet3[3], infoParamTableSet3[5]);
  160. // if (isDebug >= 1) printf("sendbuffer : %s\n", sendbuffer);
  161. // }
  162. // else if (strstr(sendbuffer, "status03"))
  163. // {
  164. // sprintf(sendbuffer, "echo svc_touch conn respCarStatus03 > /sys/module/rpmsg_echo/parameters/example_printk\n");
  165. // if (isDebug >= 1) printf("sendbuffer : %s\n", sendbuffer);
  166. // }
  167. // else if (strstr(sendbuffer, "status04"))
  168. // {
  169. // sprintf(sendbuffer, "echo svc_touch conn respCarStatus04 > /sys/module/rpmsg_echo/parameters/example_printk\n");
  170. // if (isDebug >= 1) printf("sendbuffer : %s\n", sendbuffer);
  171. // strcpy(lastSetRemoteChgeIdx, infoParamTableSet5[5]);
  172. // strcpy(lastTargetViewIdx, infoParamTableSet5[6]);
  173. // }
  174. // system(sendbuffer);
  175. printf("connectToCloud EXIT!\n");
  176. pthread_exit(NULL);
  177. }
  178.  
  179. // void *getMsgFromCloudLoop(void *arg)
  180. // {
  181. // FILE *fp;
  182. // char *sendbuffer = (char *)arg;
  183. // char systembuffer[MAX_BUFFER_SIZE] = "";
  184. // char respBuffer[MAX_BUFFER_SIZE] = "";
  185. // int i = 0;
  186. // char *cmdString[5] = {"curl -X PUT", "%28PartitionKey=%27", "%27,RowKey=%27", "%27%29"};
  187. // int typeCommand = 0;
  188. // char dataParking[3][5];
  189. // int isConnected = 0;
  190. // char lastRemoteCommand[6];
  191. // int lastRemoteCommandDate = 0;
  192. // int lastRemoteCommandTime = 0;
  193. // int currRemoteCommandDate = 0;
  194. // int currRemoteCommandTime = 0;
  195. // struct tm *currTime = {0};
  196. // time_t t;
  197. // int currSyncDate = 0;
  198. // int currSyncTime = 0;
  199. // int needUpdate = 0;
  200. // struct timeval now;
  201.  
  202. // printf("getMsgFromCloudLoop isLoop[%d]\n", isLoop);
  203. // while (isLoop == 1)
  204. // {
  205. // if (strncmp(infoParamTableSet2[3], "-1", strlen(infoParamTableSet2[3])) != 0)
  206. // {
  207. // sprintf(sendbuffer, "curl -k -v --connect-timeout 10 --max-time 2.0 \'%s%s%s%sstatus04%s?sv=%s&ss=bfqt&srt=sco&sp=rwdlacupiytfx&se=%s&st=%s&spr=https,http&sig=%s\'", CLOUD_HOST, cmdString[1], carKey, cmdString[2], cmdString[3], CLOUD_SIGN_SV, CLOUD_SIGN_END, CLOUD_SIGN_START, CLOUD_SIGN_KEY);
  208. // if (isDebug >= 1) printf("connectToCloudLoop sendbuffer : [%s]\n", sendbuffer);
  209. // needUpdate = 0;
  210. // isConnected = 0;
  211. // i = 0;
  212. // while (isConnected == 0)
  213. // {
  214. // if (isCurlCmdBusy == 0)
  215. // {
  216. // isCurlCmdBusy = 1;
  217. // fp = popen(sendbuffer, "r");
  218. // if (fp == NULL) printf("Failed to run command\n");
  219. // else
  220. // {
  221. // /* Read the output a line at a time - output it. */
  222. // if (fgets(respBuffer, sizeof(respBuffer), fp) != NULL)
  223. // {
  224. // if (isDebug >= 1) printf("respBuffer : %s\n", respBuffer);
  225. // i = split(&respBuffer[0]);
  226. // if (isLoop == 0) break;
  227. // }
  228. // }
  229. // /* close */
  230. // pclose(fp);
  231. // isCurlCmdBusy = 0;
  232. // isConnected = 1;
  233. // }
  234. // else usleep(200);
  235. // }
  236.  
  237. // if (i == 0)
  238. // {
  239. // if (disconnectCount < 30)
  240. // {
  241. // disconnectCount++;
  242. // usleep(1000);
  243. // }
  244. // else
  245. // {
  246. // disconnectCount = 0;
  247. // sprintf(sendbuffer, "ifconfig usb0 down\n");
  248. // if (isDebug >= 1) printf("ifconfig usb0 down\n");
  249. // system(sendbuffer);
  250. // usleep(1000);
  251. // sprintf(sendbuffer, "ifconfig usb0 up\n");
  252. // if (isDebug >= 1) printf("ifconfig usb0 up\n");
  253. // system(sendbuffer);
  254. // usleep(1000);
  255. // sprintf(sendbuffer, "/usr/local/share/script/wifi_start.sh\n");
  256. // system(sendbuffer);
  257. // }
  258. // continue;
  259. // }
  260. // else disconnectCount = 0;
  261.  
  262. // lastRemoteCommand[0] = infoParamTableSet5[8][2];
  263. // lastRemoteCommand[1] = infoParamTableSet5[8][3];
  264. // lastRemoteCommand[2] = infoParamTableSet5[8][5];
  265. // lastRemoteCommand[3] = infoParamTableSet5[8][6];
  266. // lastRemoteCommand[4] = infoParamTableSet5[8][8];
  267. // lastRemoteCommand[5] = infoParamTableSet5[8][9];
  268. // currRemoteCommandDate = atoi(lastRemoteCommand);
  269.  
  270. // lastRemoteCommand[0] = infoParamTableSet5[8][11];
  271. // lastRemoteCommand[1] = infoParamTableSet5[8][12];
  272. // lastRemoteCommand[2] = infoParamTableSet5[8][14];
  273. // lastRemoteCommand[3] = infoParamTableSet5[8][15];
  274. // lastRemoteCommand[4] = infoParamTableSet5[8][17];
  275. // lastRemoteCommand[5] = infoParamTableSet5[8][18];
  276. // currRemoteCommandTime = atoi(lastRemoteCommand) + 80000; // GMT+8
  277.  
  278. // if (currRemoteCommandTime >= 240000)
  279. // {
  280. // int date = currRemoteCommandDate % 10000;
  281. // int day = currRemoteCommandDate % 100;
  282. // currRemoteCommandTime -= 240000;
  283. // if (date == 131 || date == 228 || date == 331 || date == 430 || date == 531 || date == 630 ||
  284. // date == 731 || date == 831 || date == 930 || date == 1031 || date == 1130)
  285. // currRemoteCommandDate = currRemoteCommandDate + 100 - day + 1;
  286. // else if (date == 1231) currRemoteCommandDate = currRemoteCommandDate + 10000 - date + 101;
  287. // else currRemoteCommandDate++;
  288. // }
  289.  
  290. // t = time(NULL);
  291. // currTime = localtime(&t);
  292. // currSyncDate = currTime->tm_year % 100 * 10000 + (currTime->tm_mon + 1) * 100 + currTime->tm_mday;
  293. // currSyncTime = currTime->tm_hour * 10000 + currTime->tm_min * 100 + currTime->tm_sec;
  294.  
  295. // if (isDebug >= 1) printf("currSyncDate[%d], currSyncTime[%d]\n", currSyncDate, currSyncTime);
  296.  
  297. // // remote command changed
  298. // if (lastRemoteCommandDate == 0 || lastRemoteCommandDate < currRemoteCommandDate ||
  299. // (lastRemoteCommandDate == currRemoteCommandDate && lastRemoteCommandTime < currRemoteCommandTime))
  300. // {
  301. // // remote command is later than cv22 touch command within 5 sec
  302. // if (currSyncDate == currRemoteCommandDate && currSyncTime - currRemoteCommandTime < 20) needUpdate = 1;
  303. // }
  304. // if (isDebug >= 1) printf("needUpdate[%d], lastRemoteCommandDate[%d], currRemoteCommandDate[%d]\n", needUpdate, lastRemoteCommandDate, currRemoteCommandDate);
  305. // if (isDebug >= 1) printf("lastRemoteCommandTime[%d], currRemoteCommandTime[%d]\n", lastRemoteCommandTime, currRemoteCommandTime);
  306.  
  307. // lastRemoteCommandDate = currRemoteCommandDate;
  308. // lastRemoteCommandTime = currRemoteCommandTime;
  309.  
  310. // gettimeofday(&now, NULL);
  311. // lastGetCommandTime = (double)now.tv_sec;
  312.  
  313. // if (needUpdate == 1)
  314. // {
  315. // for (i = 0; i < NUM_INFO_SET5; i++)
  316. // {
  317. // switch (i)
  318. // {
  319. // case 0:
  320. // if (infoParamTableSet5[i][0] == '1')
  321. // // if (!strncmp(infoParamTableSet5[i], "1", sizeof(infoParamTableSet5[i])))
  322. // {
  323. // if (isDebug >= 1) printf("[cCtrlReq] User request command : startParking [%s]\n", infoParamTableSet5[i]);
  324. // if (infoParamTableSet3[0][0] != '4') typeCommand = CMD_START_AUTOPARK;
  325. // }
  326. // else if (infoParamTableSet5[i][0] == '2')
  327. // {
  328. // if (isDebug >= 1) printf("[cCtrlReq] User request command : startPicking [%s]\n", infoParamTableSet5[i]);
  329. // if (infoParamTableSet3[0][0] != '5') typeCommand = CMD_START_AUTOPICK;
  330. // }
  331. // else if (infoParamTableSet5[i][0] == '3')
  332. // {
  333. // if (isDebug >= 1) printf("[cCtrlReq] User request command : stopParking [%s]\n", infoParamTableSet5[i]);
  334. // if (infoParamTableSet3[0][0] == '4') typeCommand = CMD_STOP_AUTOPARK;
  335. // }
  336. // else if (infoParamTableSet5[i][0] == '4')
  337. // {
  338. // if (isDebug >= 1) printf("[cCtrlReq] User request command : stopPicking [%s]\n", infoParamTableSet5[i]);
  339. // if (infoParamTableSet3[0][0] == '5') typeCommand = CMD_STOP_AUTOPICK;
  340. // }
  341. // else if (infoParamTableSet5[i][0] == '5')
  342. // {
  343. // if (isDebug >= 1) printf("[cCtrlReq] User request command : resetAutoParam [%s]\n", infoParamTableSet5[i]);
  344. // typeCommand = CMD_RESET_AUTOPARAM;
  345. // }
  346. // break;
  347. // case 1:
  348. // if (strncmp(infoParamTableSet5[i], infoParamTableSet4[3], sizeof(infoParamTableSet5[i])) != 0 &&
  349. // atoi(infoParamTableSet5[i]) > atoi(infoParamTableSet4[3]))
  350. // {
  351. // if (strncmp(infoParamTableSet4[3], vCapImageIdx, sizeof(infoParamTableSet4[3])) != 0)
  352. // {
  353. // if (isDebug >= 1) printf("[vCapReq] User request command : %s\n", infoParamTableSet5[i]);
  354. // if (vCapCmd == 0)
  355. // {
  356. // vCapCmd = 1; // received capture request
  357. // strcpy(vCapImageIdx, infoParamTableSet5[i]);
  358. // }
  359. // else printf("Previous capture is still processing!! \n");
  360. // }
  361. // }
  362. // break;
  363. // case 2:
  364. // if (strncmp(infoParamTableSet5[i], "-1", sizeof(infoParamTableSet5[i])) != 0)
  365. // {
  366. // if (isDebug >= 1) printf("[tMapNo] User request command : %s\n", infoParamTableSet5[i]);
  367. // strcpy(dataParking[0], infoParamTableSet5[i]);
  368. // strcpy(infoParamTableSet5[i], "-1");
  369. // }
  370. // break;
  371. // case 3:
  372. // if (strncmp(infoParamTableSet5[i], "-1", sizeof(infoParamTableSet5[i])) != 0)
  373. // {
  374. // if (isDebug >= 1) printf("[tInitNo] User request command : %s\n", infoParamTableSet5[i]);
  375. // strcpy(dataParking[1], infoParamTableSet5[i]);
  376. // strcpy(infoParamTableSet5[i], "-1");
  377. // }
  378. // break;
  379. // case 4:
  380. // if (strncmp(infoParamTableSet5[i], "-1", sizeof(infoParamTableSet5[i])) != 0)
  381. // {
  382. // if (isDebug >= 1) printf("[tLotNo] User request command : %s\n", infoParamTableSet5[i]);
  383. // strcpy(dataParking[2], infoParamTableSet5[i]);
  384. // strcpy(infoParamTableSet5[i], "-1");
  385. // }
  386. // break;
  387. // case 5:
  388. // if (strncmp(infoParamTableSet5[i], infoParamTableSet3[5], sizeof(infoParamTableSet5[i])) != 0)
  389. // {
  390. // if (infoParamTableSet3[5][0] != '0' && infoParamTableSet3[6][0] != '0')
  391. // {
  392. // // Settints changed becasue CV22 is reset, skip it.
  393. // }
  394. // else if (strncmp(infoParamTableSet5[i], lastSetRemoteChgeIdx, sizeof(infoParamTableSet5[i])) != 0)
  395. // {
  396. // // Settints changed by remote device, CV22 not sync yet, sync it.
  397. // if (isDebug >= 1) printf("[setChge] User request command : Settings changed by remote device [%s]\n", infoParamTableSet5[i]);
  398. // typeCommand = CMD_REMOTE_CHANGE_SETTING;
  399. // strcpy(infoParamTableSet3[5], infoParamTableSet5[i]);
  400. // strcpy(lastSetRemoteChgeIdx, infoParamTableSet5[i]);
  401. // }
  402. // else
  403. // {
  404. // // Settints changed by CV22, remote devices not sync yet, skip it.
  405. // }
  406. // }
  407. // else if (strncmp(infoParamTableSet5[i], lastSetRemoteChgeIdx, sizeof(infoParamTableSet5[i])) != 0)
  408. // {
  409. // // Settints changed by CV22, remote devices has synced, sync the index.
  410. // strcpy(lastSetRemoteChgeIdx, infoParamTableSet5[i]);
  411. // }
  412. // break;
  413. // case 6:
  414. // if (strncmp(infoParamTableSet5[i], infoParamTableSet3[6], sizeof(infoParamTableSet5[i])) != 0)
  415. // {
  416. // if (strncmp(infoParamTableSet5[i], lastTargetViewIdx, sizeof(infoParamTableSet5[i])) != 0)
  417. // {
  418. // if (isDebug >= 1) printf("[tView] User request command : View changed by remote device [%s]\n", infoParamTableSet5[i]);
  419. // typeCommand = CMD_REMOTE_CHANGE_VIEW;
  420. // strcpy(infoParamTableSet3[6], infoParamTableSet5[i]);
  421. // strcpy(lastTargetViewIdx, infoParamTableSet5[i]);
  422. // }
  423. // }
  424. // break;
  425. // default:
  426. // break;
  427. // }
  428. // }
  429. // }
  430.  
  431. // if (typeCommand == CMD_START_AUTOPARK)
  432. // {
  433. // if (strlen(dataParking[0]) > 0 && strlen(dataParking[1]) > 0 && strlen(dataParking[2]) > 0)
  434. // {
  435. // printf("ask car start parking!! \n");
  436. // sprintf(systembuffer, "echo svc_touch conn startParking %s %s %s > /sys/module/rpmsg_echo/parameters/example_printk\n", dataParking[0], dataParking[1], dataParking[2]);
  437. // system(systembuffer);
  438. // memset(dataParking, 0, sizeof(dataParking));
  439. // strcpy(infoParamTableSet3[0], "1");
  440. // }
  441. // }
  442. // else if (typeCommand == CMD_START_AUTOPICK)
  443. // {
  444. // printf("ask car start picking!! \n");
  445. // sprintf(systembuffer, "echo svc_touch conn startPicking %s %s %s > /sys/module/rpmsg_echo/parameters/example_printk\n", dataParking[0], dataParking[1], dataParking[2]);
  446. // system(systembuffer);
  447. // strcpy(infoParamTableSet3[0], "3");
  448. // }
  449. // else if (typeCommand == CMD_STOP_AUTOPARK)
  450. // {
  451. // if (infoParamTableSet3[0][0] == '1' || infoParamTableSet3[0][0] == '2')
  452. // {
  453. // printf("ask car stop parking!! \n");
  454. // sprintf(systembuffer, "echo svc_touch conn stopParking %s %s > /sys/module/rpmsg_echo/parameters/example_printk\n", dataParking[0], dataParking[1]);
  455. // system(systembuffer);
  456. // memset(dataParking, 0, sizeof(dataParking));
  457. // strcpy(infoParamTableSet3[0], "0");
  458. // strcpy(infoParamTableSet3[10], "0");
  459. // }
  460. // }
  461. // else if (typeCommand == CMD_STOP_AUTOPICK)
  462. // {
  463. // strcpy(infoParamTableSet3[1], "-1");
  464. // strcpy(infoParamTableSet3[2], "-1");
  465. // if (infoParamTableSet3[0][0] == '3' || infoParamTableSet3[0][0] == '4')
  466. // {
  467. // printf("ask car stop picking!! \n");
  468. // sprintf(systembuffer, "echo svc_touch conn stopPicking > /sys/module/rpmsg_echo/parameters/example_printk\n");
  469. // system(systembuffer);
  470. // strcpy(infoParamTableSet3[0], "0");
  471. // strcpy(infoParamTableSet3[10], "0");
  472. // }
  473. // }
  474. // else if (typeCommand == CMD_RESET_AUTOPARAM)
  475. // {
  476. // strcpy(infoParamTableSet3[0], "0");
  477. // strcpy(infoParamTableSet3[1], "-1");
  478. // strcpy(infoParamTableSet3[2], "-1");
  479. // strcpy(infoParamTableSet3[3], "-1");
  480. // strcpy(infoParamTableSet3[6], "0");
  481. // strcpy(infoParamTableSet3[10], "0");
  482. // if (infoParamTableSet3[0][0] == '1' || infoParamTableSet3[0][0] == '2')
  483. // {
  484. // printf("ask car stop parking!! \n");
  485. // sprintf(systembuffer, "echo svc_touch conn stopParking %s %s > /sys/module/rpmsg_echo/parameters/example_printk\n", dataParking[0], dataParking[1]);
  486. // system(systembuffer);
  487. // memset(dataParking, 0, sizeof(dataParking));
  488. // }
  489. // else if (infoParamTableSet3[0][0] == '3' || infoParamTableSet3[0][0] == '4')
  490. // {
  491. // printf("ask car stop picking!! \n");
  492. // sprintf(systembuffer, "echo svc_touch conn stopPicking > /sys/module/rpmsg_echo/parameters/example_printk\n");
  493. // system(systembuffer);
  494. // }
  495.  
  496. // strcpy(infoParamTableSet5[0], "0");
  497. // strcpy(infoParamTableSet5[2], "-1");
  498. // strcpy(infoParamTableSet5[3], "-1");
  499. // strcpy(infoParamTableSet5[4], "-1");
  500. // strcpy(infoParamTableSet5[6], "0");
  501. // genUpdateCarStatusCommand(4);
  502. // }
  503. // else if (typeCommand == CMD_REMOTE_CHANGE_SETTING)
  504. // {
  505. // sprintf(respBuffer, "curl -k -v \'%s%s%s%sstatus01%s?sv=%s&ss=bfqt&srt=sco&sp=rwdlacupiytfx&se=%s&st=%s&spr=https,http&sig=%s\'", CLOUD_HOST, cmdString[1], carKey, cmdString[2], cmdString[3], CLOUD_SIGN_SV, CLOUD_SIGN_END, CLOUD_SIGN_START, CLOUD_SIGN_KEY);
  506. // isConnected = 0;
  507. // while (isConnected == 0)
  508. // {
  509. // if (isCurlCmdBusy == 0)
  510. // {
  511. // isCurlCmdBusy = 1;
  512. // fp = popen(respBuffer, "r");
  513. // if (fp == NULL) printf("Failed to run command\n");
  514. // else
  515. // {
  516. // /* Read the output a line at a time - output it. */
  517. // if (fgets(respBuffer, sizeof(respBuffer), fp) != NULL)
  518. // {
  519. // if (isDebug == 1) printf("respBuffer : %s\n", respBuffer);
  520. // i = split(&respBuffer[0]);
  521. // if (isDebug == 1) printf("respBuffer dataLen: %d\n", i);
  522. // }
  523. // }
  524. // /* close */
  525. // pclose(fp);
  526. // isCurlCmdBusy = 0;
  527. // isConnected = 1;
  528. // sprintf(sendbuffer, "echo svc_touch conn respCarStatus01 %s %s %s %s > /sys/module/rpmsg_echo/parameters/example_printk\n", infoParamTableSet2[0], infoParamTableSet2[3], infoParamTableSet2[2], infoParamTableSet2[4]);
  529. // if (isDebug >= 1) printf("sendbuffer : %s\n", sendbuffer);
  530. // }
  531. // else usleep(200);
  532. // }
  533. // }
  534. // else if (typeCommand == CMD_REMOTE_CHANGE_VIEW)
  535. // {
  536. // int value = atoi(infoParamTableSet3[6]);
  537. // printf("ask car change view!! \n");
  538. // if (value == 0) sprintf(systembuffer, "echo svc_button avmMV > /sys/module/rpmsg_echo/parameters/example_printk\n");
  539. // else if (value >= 1 && value <= 4) sprintf(systembuffer, "echo svc_button avmMV%d > /sys/module/rpmsg_echo/parameters/example_printk\n", value - 1);
  540. // else if (value == 10) sprintf(systembuffer, "echo svc_button dvronly > /sys/module/rpmsg_echo/parameters/example_printk\n");
  541. // else if (value >= 11 && value <= 14) sprintf(systembuffer, "echo svc_button mvonly > /sys/module/rpmsg_echo/parameters/example_printk\n");
  542. // else if (value == 20) sprintf(systembuffer, "echo svc_button avm3D > /sys/module/rpmsg_echo/parameters/example_printk\n");
  543. // else if (value >= 21 && value <= 28) sprintf(systembuffer, "echo svc_button avm3D%d > /sys/module/rpmsg_echo/parameters/example_printk\n", value - 21);
  544. // system(systembuffer);
  545. // }
  546. // else if (vCapCmd == 1)
  547. // { // received capture request
  548. // vCapCmd = 2;
  549. // sprintf(systembuffer, "echo svc_touch conn startCapture > /sys/module/rpmsg_echo/parameters/example_printk\n");
  550. // system(systembuffer);
  551. // }
  552. // typeCommand = 0;
  553. // memset(dataParking, 0, sizeof(dataParking));
  554. // memset(respBuffer, 0, sizeof(respBuffer));
  555. // }
  556. // usleep(1000);
  557. // }
  558. // printf("getMsgFromCloudLoop EXIT!\n");
  559.  
  560. // sprintf(systembuffer, "echo svc_touch conn askConnect > /sys/module/rpmsg_echo/parameters/example_printk\n");
  561. // system(systembuffer);
  562.  
  563. // pthread_exit(NULL);
  564. // }
  565.  
  566. int main()
  567. {
  568. char sendbuffer[MAX_BUFFER_SIZE] = "";
  569. char *cmdString[5] = {"curl -k -v --connect-timeout 5 --max-time 5.0 \'",
  570. "%28PartitionKey=%27",
  571. "%27,RowKey=%27",
  572. "%27%29?sv=",
  573. "&ss=bfqt&srt=sco&sp=rwdlacupiytfx"};
  574. pthread_t t;
  575. char respBuffer[5];
  576. FILE *fp;
  577.  
  578. if (!strcmp(msg, "getSwInfo"))
  579. {
  580. printf("get software information from server\n");
  581. sprintf(sendbuffer, "%s%s%sgeneral%ssoftware%s%s%s&se=%s&st=%s&spr=https,http&sig=%s\'\n", cmdString[0], CLOUD_HOST, cmdString[1], cmdString[2], cmdString[3], CLOUD_SIGN_SV, cmdString[4], CLOUD_SIGN_END, CLOUD_SIGN_START, CLOUD_SIGN_KEY);
  582. printf("cmd : %s\n", sendbuffer);
  583. fp = popen(sendbuffer, "r");
  584. if (fgets(respBuffer, sizeof(respBuffer), fp) != NULL)
  585. {
  586. printf("wtf\n");
  587. // printf("respBuffer : %s, connection result : %d\n", respBuffer, getConnectionResult(&respBuffer[0]));
  588. // split(&respBuffer[0]);
  589. }
  590. // pthread_create(&t, NULL, connectToCloud, (void *)&sendbuffer[0]);
  591. }
  592. // else
  593. // {
  594. // printf("startCarStatus isLoop : [%d]\n", isLoop);
  595. // sprintf(sendbuffer, "%s%s%s%s%sstatus04%s%s%s&se=%s&st=%s&spr=https,http&sig=%s\'\n", cmdString[0], CLOUD_HOST, cmdString[1], carKey, cmdString[2], cmdString[3], CLOUD_SIGN_SV, cmdString[4], CLOUD_SIGN_END, CLOUD_SIGN_START, CLOUD_SIGN_KEY);
  596. // if (isLoop == 0U)
  597. // {
  598. // isLoop = 1U;
  599. // pthread_create(&t_Loop, NULL, getMsgFromCloudLoop, (void *)&sendbuffer[0]);
  600. // pthread_create(&t_Command, NULL, sendMsgToCloudLoop, (void *)&sendbuffer[0]);
  601. // }
  602. // if (isUploadLoop == 0U)
  603. // {
  604. // isUploadLoop = 1U;
  605. // pthread_create(&t_Upload, NULL, uploadFileToCloudLoop, (void *)&sendbuffer[0]);
  606. // }
  607. // }
  608.  
  609. return 0;
  610. }
Success #stdin #stdout #stderr 0s 5288KB
stdin
Standard input is empty
stdout
get software information from server
cmd : curl -k -v --connect-timeout 5 --max-time 5.0 'https://w...content-available-to-author-only...s.net/AVPHofa%28PartitionKey=%27general%27,RowKey=%27software%27%29?sv=2022-11-02&ss=bfqt&srt=sco&sp=rwdlacupiytfx&se=2026-02-01T15:12:41Z&st=2024-01-10T07:12:41Z&spr=https,http&sig=eUnkaH%2FlOFMEt90utNrxH7tjEf0CuduheZGHi%2FRnWcY%3D'

stderr
* Expire in 0 ms for 6 (transfer 0x5642a6767400)
* Expire in 5000 ms for 8 (transfer 0x5642a6767400)
* Expire in 5000 ms for 2 (transfer 0x5642a6767400)
* Expire in 1 ms for 1 (transfer 0x5642a6767400)
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed

  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0* Expire in 0 ms for 1 (transfer 0x5642a6767400)
* Expire in 2 ms for 1 (transfer 0x5642a6767400)
* Expire in 0 ms for 1 (transfer 0x5642a6767400)
* Expire in 0 ms for 1 (transfer 0x5642a6767400)
* Expire in 2 ms for 1 (transfer 0x5642a6767400)
* Expire in 0 ms for 1 (transfer 0x5642a6767400)
* Expire in 0 ms for 1 (transfer 0x5642a6767400)
* Expire in 2 ms for 1 (transfer 0x5642a6767400)
* Expire in 0 ms for 1 (transfer 0x5642a6767400)
* Expire in 0 ms for 1 (transfer 0x5642a6767400)
* Expire in 2 ms for 1 (transfer 0x5642a6767400)
* Expire in 0 ms for 1 (transfer 0x5642a6767400)
* Expire in 0 ms for 1 (transfer 0x5642a6767400)
* Expire in 2 ms for 1 (transfer 0x5642a6767400)
* Expire in 0 ms for 1 (transfer 0x5642a6767400)
* Expire in 0 ms for 1 (transfer 0x5642a6767400)
* Expire in 2 ms for 1 (transfer 0x5642a6767400)
* Expire in 0 ms for 1 (transfer 0x5642a6767400)
* Expire in 0 ms for 1 (transfer 0x5642a6767400)
* Expire in 2 ms for 1 (transfer 0x5642a6767400)
* Expire in 0 ms for 1 (transfer 0x5642a6767400)
* Expire in 0 ms for 1 (transfer 0x5642a6767400)
* Expire in 2 ms for 1 (transfer 0x5642a6767400)
* Expire in 0 ms for 1 (transfer 0x5642a6767400)
* Expire in 0 ms for 1 (transfer 0x5642a6767400)
* Expire in 2 ms for 1 (transfer 0x5642a6767400)
* Expire in 0 ms for 1 (transfer 0x5642a6767400)
* Expire in 0 ms for 1 (transfer 0x5642a6767400)
* Expire in 2 ms for 1 (transfer 0x5642a6767400)
* Expire in 0 ms for 1 (transfer 0x5642a6767400)
* Expire in 0 ms for 1 (transfer 0x5642a6767400)
* Expire in 2 ms for 1 (transfer 0x5642a6767400)
* Expire in 0 ms for 1 (transfer 0x5642a6767400)
* Expire in 0 ms for 1 (transfer 0x5642a6767400)
* Expire in 2 ms for 1 (transfer 0x5642a6767400)
* Expire in 0 ms for 1 (transfer 0x5642a6767400)
* Expire in 0 ms for 1 (transfer 0x5642a6767400)
* Expire in 2 ms for 1 (transfer 0x5642a6767400)
* Expire in 0 ms for 1 (transfer 0x5642a6767400)
* Expire in 0 ms for 1 (transfer 0x5642a6767400)
* Expire in 2 ms for 1 (transfer 0x5642a6767400)
* Expire in 0 ms for 1 (transfer 0x5642a6767400)
* Expire in 1 ms for 1 (transfer 0x5642a6767400)
* Expire in 2 ms for 1 (transfer 0x5642a6767400)
* Expire in 1 ms for 1 (transfer 0x5642a6767400)
* Expire in 1 ms for 1 (transfer 0x5642a6767400)
* Expire in 2 ms for 1 (transfer 0x5642a6767400)
* Expire in 1 ms for 1 (transfer 0x5642a6767400)
* Expire in 1 ms for 1 (transfer 0x5642a6767400)
* Expire in 2 ms for 1 (transfer 0x5642a6767400)
* Expire in 1 ms for 1 (transfer 0x5642a6767400)
* Expire in 1 ms for 1 (transfer 0x5642a6767400)
* Expire in 2 ms for 1 (transfer 0x5642a6767400)
* Expire in 2 ms for 1 (transfer 0x5642a6767400)
* Expire in 2 ms for 1 (transfer 0x5642a6767400)
* Expire in 2 ms for 1 (transfer 0x5642a6767400)
* Expire in 2 ms for 1 (transfer 0x5642a6767400)
* Expire in 2 ms for 1 (transfer 0x5642a6767400)
* Expire in 2 ms for 1 (transfer 0x5642a6767400)
* Expire in 2 ms for 1 (transfer 0x5642a6767400)
* Expire in 2 ms for 1 (transfer 0x5642a6767400)
* Expire in 2 ms for 1 (transfer 0x5642a6767400)
* Expire in 3 ms for 1 (transfer 0x5642a6767400)
* Expire in 3 ms for 1 (transfer 0x5642a6767400)
* Expire in 4 ms for 1 (transfer 0x5642a6767400)
* Expire in 3 ms for 1 (transfer 0x5642a6767400)
* Expire in 3 ms for 1 (transfer 0x5642a6767400)
* Expire in 4 ms for 1 (transfer 0x5642a6767400)
* Expire in 4 ms for 1 (transfer 0x5642a6767400)
* Expire in 4 ms for 1 (transfer 0x5642a6767400)
* Expire in 4 ms for 1 (transfer 0x5642a6767400)
* Expire in 4 ms for 1 (transfer 0x5642a6767400)
* Expire in 4 ms for 1 (transfer 0x5642a6767400)
* Expire in 4 ms for 1 (transfer 0x5642a6767400)
* Expire in 5 ms for 1 (transfer 0x5642a6767400)
* Expire in 5 ms for 1 (transfer 0x5642a6767400)
* Expire in 4 ms for 1 (transfer 0x5642a6767400)
* Expire in 6 ms for 1 (transfer 0x5642a6767400)
* Expire in 6 ms for 1 (transfer 0x5642a6767400)
* Expire in 8 ms for 1 (transfer 0x5642a6767400)
* Expire in 7 ms for 1 (transfer 0x5642a6767400)
* Expire in 7 ms for 1 (transfer 0x5642a6767400)
* Expire in 8 ms for 1 (transfer 0x5642a6767400)
* Expire in 8 ms for 1 (transfer 0x5642a6767400)
* Expire in 8 ms for 1 (transfer 0x5642a6767400)
* Could not resolve host: whetron001.table.core.windows.net
* Expire in 11 ms for 1 (transfer 0x5642a6767400)
* Closing connection 0
curl: (6) Could not resolve host: whetron001.table.core.windows.net