簡體   English   中英

Arduino Uno或PHP

[英]Arduino Uno or php

我想使用Google Maps API獲取地理位置坐標,將其發送到Arduino Uno,然后將消息解析為一個浮點數數組。

我已經使用strok(),作為分隔符,但我無法解析的文字和括號中的短信。

Sent from your Twilio trial account - (43.39114023431447, -80.40987968444824)(43.387210701009224, -80.41219711303711)(43.38602555366178, -80.38970947265625)

我只需要將坐標解析為一個float數組。

我使用strok()函數自行解決了

{
     const char *delim  = "(";   //a '(' is the delimiter
     const char *delim1  = ",";
     const char *delim3  = ")";
     char *text;
     char *firstItem;
     char *secondItem;
     char *thirdItem;
     char *fourthItem;
     char *fivethItem;
     char *sixthItem;
     char *seventhItem;
     char *eighthItem;
     text = strtok(password,delim);
     firstItem = strtok(NULL,delim1);
     secondItem = strtok(NULL,delim3);
     secondItem++;
     thirdItem = strtok(NULL,delim1);
     thirdItem++;
     fourthItem = strtok(NULL,delim3);
     fourthItem++;
     fivethItem = strtok(NULL,delim1);
     fivethItem++;
     sixthItem = strtok(NULL,delim3);
     sixthItem++;
     polyX[0] = atof(firstItem);
     polyY[0] = atof(secondItem);
     polyX[1] = atof(thirdItem);
     polyY[1] = atof(fourthItem);
     polyX[2] = atof(fivethItem);
     polyY[2] = atof(sixthItem);
     memset (password,NULL,sizeof(password));
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM