Mr_kangyuli 2016-01-22 04:17 采纳率: 0%
浏览 1633

求解释代码BridgeClass(Stream &_stream);

/*
Copyright (c) 2013 Arduino LLC. All right reserved.

This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.

This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/

#ifndef BRIDGE_H_
#define BRIDGE_H_

#ifndef BRIDGE_BAUDRATE
#define BRIDGE_BAUDRATE 250000
#endif

#include
#include

class BridgeClass {
public:
BridgeClass(Stream &_stream);//求解?
void begin();

// Methods to handle key/value datastore
void put(const char *key, const char *value);
void put(const String &key, const String &value)
{
  put(key.c_str(), value.c_str());
}
unsigned int get(const char *key, uint8_t *buff, unsigned int size);
unsigned int get(const char *key, char *value, unsigned int maxlen)
{
  return get(key, reinterpret_cast<uint8_t *>(value), maxlen);
}

// Trasnfer a frame (with error correction and response)
uint16_t transfer(const uint8_t *buff1, uint16_t len1,
                  const uint8_t *buff2, uint16_t len2,
                  const uint8_t *buff3, uint16_t len3,
                  uint8_t *rxbuff, uint16_t rxlen);
// multiple inline versions of the same function to allow efficient frame concatenation
uint16_t transfer(const uint8_t *buff1, uint16_t len1)
{
  return transfer(buff1, len1, NULL, 0);
}
uint16_t transfer(const uint8_t *buff1, uint16_t len1,
                  uint8_t *rxbuff, uint16_t rxlen)
{
  return transfer(buff1, len1, NULL, 0, rxbuff, rxlen);
}
uint16_t transfer(const uint8_t *buff1, uint16_t len1,
                  const uint8_t *buff2, uint16_t len2,
                  uint8_t *rxbuff, uint16_t rxlen)
{
  return transfer(buff1, len1, buff2, len2, NULL, 0, rxbuff, rxlen);
}

uint16_t getBridgeVersion()
{
  return bridgeVersion;
}

static const int TRANSFER_TIMEOUT = 0xFFFF;

private:
uint8_t index;
int timedRead(unsigned int timeout);
void dropAll();
uint16_t bridgeVersion;

private:
void crcUpdate(uint8_t c);
void crcReset();
void crcWrite();
bool crcCheck(uint16_t _CRC);
uint16_t CRC;

private:
static const char CTRL_C = 3;
Stream &stream;
bool started;
uint8_t max_retries;
};

// This subclass uses a serial port Stream
class SerialBridgeClass : public BridgeClass {
public:
SerialBridgeClass(HardwareSerial &_serial)
: BridgeClass(_serial), serial(_serial) {
// Empty
}

void begin(unsigned long baudrate = BRIDGE_BAUDRATE) {
  serial.begin(baudrate);
  BridgeClass::begin();
}

private:
HardwareSerial &serial;
};

extern SerialBridgeClass Bridge;

#endif /* BRIDGE_H_ */

#include
#include

  • 写回答

1条回答

  • threenewbee 2016-01-22 05:10
    关注

    BridgeClass(Stream &_stream);
    用stream创建一个BridgeClass对象,这是一个编码类

    评论

报告相同问题?

悬赏问题

  • ¥50 易语言把MYSQL数据库中的数据添加至组合框
  • ¥20 求数据集和代码#有偿答复
  • ¥15 关于下拉菜单选项关联的问题
  • ¥20 java-OJ-健康体检
  • ¥15 rs485的上拉下拉,不会对a-b<-200mv有影响吗,就是接受时,对判断逻辑0有影响吗
  • ¥15 使用phpstudy在云服务器上搭建个人网站
  • ¥15 应该如何判断含间隙的曲柄摇杆机构,轴与轴承是否发生了碰撞?
  • ¥15 vue3+express部署到nginx
  • ¥20 搭建pt1000三线制高精度测温电路
  • ¥15 使用Jdk8自带的算法,和Jdk11自带的加密结果会一样吗,不一样的话有什么解决方案,Jdk不能升级的情况