Robofun 機器人論壇

標題: 小弟想請教Arduino+xBee api框架的問題 [打印本頁]

作者: max9907200    時間: 2015-5-21 13:39
標題: 小弟想請教Arduino+xBee api框架的問題
小弟 我想在Arduino 裡寫api框架 讓我電腦端 sink node 接收到api框架的資料  
不過我在arduino裡面 寫的程式不知道是否有問題  我的電腦接收端卻接收不到資料

想請各位高手來幫我看看是否可指教

小弟我是用serial 1 的xbee
以下是Tx Request 64bit 的api框架

#include <SoftwareSerial.h>
// creo una porta seriale di tipo software sui pin 2(RX) e 3(TX)
uint8_t rxxbee = 2;
uint8_t txxbee = 3;
SoftwareSerial Serial_xbee(rxxbee,txxbee);


// variable to store the data received
int sensorValue = 0;

// costant values of the frame
const byte startDelimeter = 0x7E;

  // length
const byte MSB_1 = 0x00;
const byte LSB_2 = 0x0B;  

  // Frame-specific data
const byte frameType = 0x00;
const byte frameID = 0x01;

  // 64-bit destination address
const byte MSB_5  = 0x00;
const byte b_6    = 0x00;
const byte b_7    = 0x00;
const byte b_8    = 0x00;
const byte b_9    = 0x00;
const byte b_10   = 0x00;
const byte b_11   = 0x00;
const byte LSB_12 = 0x00;

  // options
const byte opt = 0x0;
  //RF Data
const byte RFdata = 0x68;

//checksum
const byte checksum = 0x96;






byte spedisci (byte value) {
Serial_xbee.write(value);
Serial.write(value);
return value;
}


void setup()
{
  // starts serial communication
  Serial.begin(9600);
  Serial_xbee.begin(9600);


}

void loop()
{
  // send data through xBee
  spedisci(startDelimeter);
  spedisci(MSB_1);
  spedisci(LSB_2);
  long sum = 0; // accumulate the checksum  
  sum += spedisci(frameType);
  sum += spedisci(frameID);
  sum += spedisci(MSB_5);
  sum += spedisci(b_6);
  sum += spedisci(b_7);
  sum += spedisci(b_8);
  sum += spedisci(b_9);
  sum += spedisci(b_10);
  sum += spedisci(b_11);
  sum += spedisci(LSB_12);

  sum += spedisci(opt);
   sum += spedisci(checksum);
  spedisci( sum );
}




歡迎光臨 Robofun 機器人論壇 (https://robofun.net/forum/) Powered by Discuz! X3.2