乱搞指针和演员表

时间:2016-04-05 13:37:34

标签: types arduino

我正在使用API​​通过无线模块发送数据,但我正在努力解决这些类型,因此我认为我无法发送数据,你能否给我一个暗示我做错了什么?

// define data to send
  char data[] = "00";

  // Getting Temperature that is 28.75
  float temperature = RTC.getTemperature();

  // HEADER,void float2String(float fl, char str[], int N);
  Utils.float2String (temperature, data, 2);

  // HEADER,uint8_t str2hex(char* str);
  uint8_t dataAux[4];

  dataAux= (char) Utils.str2hex( data);

  USB.println(dataAux);
  // HEADER,sendRadio(char * message)
  error = sendRadio(dataAux);

然后我收到了这个编译错误:

    txP2PTemp.pde: In function 'void loop()':
    txP2PTemp.pde:572:31: error: incompatible types in assignment of 'uint8_t {aka unsigned char}' to 'uint16_t* [3] {aka unsigned int* [3]}'
    txP2PTemp.pde:576:36: error: no matching function for call to 'W::sendRadio(uint16_t* [3])'
note: uint8_t W::sendRadio(char*) no known conversion for argument 1 from 'uint16_t* [3] {aka unsigned int* [3]}' to 'char*'note: uint8_t W::sendRadio(char*) 

1 个答案:

答案 0 :(得分:1)

你可能需要这个:

// define data to send
  char data[20];  // 20 char buffer (should be enough here)

  // Getting Temperature that is 28.75
  float temperature = RTC.getTemperature();

  // HEADER,void float2String(float fl, char str[], int N);
  Utils.float2String (temperature, data, 2);

  USB.println(data);
  // HEADER,sendRadio(char * message)
  error = sendRadio(data);

dataAux不需要。 sendRadioprintln需要char*,而data已经是char*