"conversion from void to non scalar type string"是什么意思?
what is meaning of "conversion from void to non scalar type string"?
我想使用 sim900a 模块和 arduino uno 通过短信将 GPS 坐标发送到特定号码,当他们从短信(如"发送 GPS"(请求时,这里编写了代码,但是当我编译代码时,我收到"错误:请求从'void'转换为非标量类型'字符串'".....请任何帮助不胜感激...提前谢谢你
void loop() {
RecieveMessage();
if (sim.available() > 0)
{
Serial.write(sim.read());
}
if(sim.read()=="SEND GPS")
{
SendMessage();
}
}
void RecieveMessage()
{
Serial.println ("SIM800L Read an SMS");
sim.println("AT+CNMI=2,2,0,0,0");
Serial.write ("Unread Message done");
}
void SendMessage()
{
//Serial.println ("Sending Message");
sim.println("AT+CMGF=1");
sim.println("AT+CMGS="" + number + ""r");
while (sgps.available())
{
int c = sgps.read();
if (gps.encode(c))
{
float slat,slon;
String loc=gps.f_get_position(&slat, &slon);
}
String SMS = String("http://maps.google.com/maps?q=loc:")+String(loc);
sim.println(SMS);
sim.println((char)26);
}
gps.f_get_position
返回 void,但您正在将其分配给String
。只需删除String loc=
void loop()
{
while (sgps.available())
{
int c = sgps.read();
if (gps.encode(c))
{
float slat,slon;
gps.f_get_position(&slat, &slon);
Serial.print("Latitude :");
Serial.println(slat, 6);
Serial.print("Longitude:");
Serial.println(slon, 6);
String loc = String(slat,6)+" "+String(slon,6);
Serial.println ("Sending Message");
sim.println("AT+CMGF=1"); //Sets the GSM Module in Text Mode
delay(1000);
Serial.println ("Set SMS Number");
sim.println("AT+CMGS="" + number + ""r"); //Mobile phone number to send message
delay(1000);
String SMS = String("https://www.google.com/maps/") + String(slat,6)+","+String(slon,6);
sim.println(SMS);
delay(100);
sim.println((char)26);// ASCII code of CTRL+Z
delay(1000);
_buffer = _readSerial();
}
}
}
相关文章:
- map<string, int> m= {}; 在C++中是什么意思?
- 将(临时的?)std::string传递给使用它来构造一个接受副本的对象的函数的最佳方法是什么?
- freq_table[field_pm_value] = map<string, int>(); 是什么意思?
- 方括号在"map <string, int> instance[numberFeatures];"中是什么意思
- 'context string for the given token'是什么意思?
- "conversion from void to non scalar type string"是什么意思?
- 此错误的含义是什么:从 'char* [40] 转换为非标量类型 'std::string
- 用一个字符制作 std::string 的最佳方法是什么?
- 解释"Bit String"的最佳方式是什么
- std::string::substr成员函数的复杂性是什么?
- 将 ASCII 文件读取到C++ std::string 中的最简单方法是什么?
- std::string::erase() 的定义行为是什么,带有 string::npos
- C++/CLI 中的声明“String^ strtests”是什么意思
- 替换由谓词确定的 std::string 中的字符的最 stl-ish 方法是什么
- 当使用const std::string&作为方法参数类型时,处理nullptr const char*的正确方法是什么?
- ^在bool GetDeviceInformation中是什么意思(String^端口,LibCECConfigurat
- ^(插入符号)在C++中是什么意思,就像在String^中一样
- 在 LLVM libc++ 中找到的 string::find 中实现的算法(及其复杂性)是什么?
- C++没有添加"std::vector<std::string>"作为"main()"的参数"overload"的原因是什么?
- c++中连接const char *和string的最干净的方法是什么?