Axeda Corp
/
AxedaGo-ubloxC027
Axeda demo software for u-blox C027 (GSM)
C027_Support/GPS.h@0:a725e8eab383, 2014-08-11 (annotated)
- Committer:
- AxedaCorp
- Date:
- Mon Aug 11 19:02:42 2014 +0000
- Revision:
- 0:a725e8eab383
1st commit
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
AxedaCorp | 0:a725e8eab383 | 1 | #pragma once |
AxedaCorp | 0:a725e8eab383 | 2 | |
AxedaCorp | 0:a725e8eab383 | 3 | #include "mbed.h" |
AxedaCorp | 0:a725e8eab383 | 4 | #include "Pipe.h" |
AxedaCorp | 0:a725e8eab383 | 5 | #include "SerialPipe.h" |
AxedaCorp | 0:a725e8eab383 | 6 | |
AxedaCorp | 0:a725e8eab383 | 7 | #ifdef TARGET_UBLOX_C027 |
AxedaCorp | 0:a725e8eab383 | 8 | #define GPS_IF(onboard, shield) onboard |
AxedaCorp | 0:a725e8eab383 | 9 | #else |
AxedaCorp | 0:a725e8eab383 | 10 | #define GPS_IF(onboard, shield) shield |
AxedaCorp | 0:a725e8eab383 | 11 | #endif |
AxedaCorp | 0:a725e8eab383 | 12 | |
AxedaCorp | 0:a725e8eab383 | 13 | /** basic gps parser class |
AxedaCorp | 0:a725e8eab383 | 14 | */ |
AxedaCorp | 0:a725e8eab383 | 15 | class GPSParser |
AxedaCorp | 0:a725e8eab383 | 16 | { |
AxedaCorp | 0:a725e8eab383 | 17 | public: |
AxedaCorp | 0:a725e8eab383 | 18 | /** Power on / Wake up the gps |
AxedaCorp | 0:a725e8eab383 | 19 | */ |
AxedaCorp | 0:a725e8eab383 | 20 | virtual bool init(PinName pn) = 0; |
AxedaCorp | 0:a725e8eab383 | 21 | |
AxedaCorp | 0:a725e8eab383 | 22 | enum { |
AxedaCorp | 0:a725e8eab383 | 23 | // getLine Responses |
AxedaCorp | 0:a725e8eab383 | 24 | WAIT = -1, //!< wait for more incoming data (the start of a message was found, or no data available) |
AxedaCorp | 0:a725e8eab383 | 25 | NOT_FOUND = 0, //!< a parser concluded the the current offset of the pipe doe not contain a valid message |
AxedaCorp | 0:a725e8eab383 | 26 | |
AxedaCorp | 0:a725e8eab383 | 27 | #define LENGTH(x) (x & 0x00FFFF) //!< extract/mask the length |
AxedaCorp | 0:a725e8eab383 | 28 | #define PROTOCOL(x) (x & 0xFF0000) //!< extract/mask the type |
AxedaCorp | 0:a725e8eab383 | 29 | |
AxedaCorp | 0:a725e8eab383 | 30 | UNKNOWN = 0x000000, //!< message type is unknown |
AxedaCorp | 0:a725e8eab383 | 31 | UBX = 0x100000, //!< message if of protocol NMEA |
AxedaCorp | 0:a725e8eab383 | 32 | NMEA = 0x200000 //!< message if of protocol UBX |
AxedaCorp | 0:a725e8eab383 | 33 | }; |
AxedaCorp | 0:a725e8eab383 | 34 | |
AxedaCorp | 0:a725e8eab383 | 35 | /** Get a line from the physical interface. This fucntion |
AxedaCorp | 0:a725e8eab383 | 36 | needs to be implemented in the inherited class. |
AxedaCorp | 0:a725e8eab383 | 37 | \param buf the buffer to store it |
AxedaCorp | 0:a725e8eab383 | 38 | \param len size of the buffer |
AxedaCorp | 0:a725e8eab383 | 39 | \return type and length if something was found, |
AxedaCorp | 0:a725e8eab383 | 40 | WAIT if not enough data is available |
AxedaCorp | 0:a725e8eab383 | 41 | NOT_FOUND if nothing was found |
AxedaCorp | 0:a725e8eab383 | 42 | */ |
AxedaCorp | 0:a725e8eab383 | 43 | virtual int getMessage(char* buf, int len) = 0; |
AxedaCorp | 0:a725e8eab383 | 44 | |
AxedaCorp | 0:a725e8eab383 | 45 | /** send a buffer |
AxedaCorp | 0:a725e8eab383 | 46 | \param buf the buffer to write |
AxedaCorp | 0:a725e8eab383 | 47 | \param len size of the buffer to write |
AxedaCorp | 0:a725e8eab383 | 48 | \return bytes written |
AxedaCorp | 0:a725e8eab383 | 49 | */ |
AxedaCorp | 0:a725e8eab383 | 50 | virtual int send(const char* buf, int len); |
AxedaCorp | 0:a725e8eab383 | 51 | |
AxedaCorp | 0:a725e8eab383 | 52 | /** send a NMEA message, this function just takes the |
AxedaCorp | 0:a725e8eab383 | 53 | payload and calculates and adds checksum. ($ and *XX\r\n will be added) |
AxedaCorp | 0:a725e8eab383 | 54 | \param buf the message payload to write |
AxedaCorp | 0:a725e8eab383 | 55 | \param len size of the message payload to write |
AxedaCorp | 0:a725e8eab383 | 56 | \return total bytes written |
AxedaCorp | 0:a725e8eab383 | 57 | */ |
AxedaCorp | 0:a725e8eab383 | 58 | virtual int sendNmea(const char* buf, int len); |
AxedaCorp | 0:a725e8eab383 | 59 | |
AxedaCorp | 0:a725e8eab383 | 60 | /** send a UBX message, this function just takes the |
AxedaCorp | 0:a725e8eab383 | 61 | payload and calculates and adds checksum. |
AxedaCorp | 0:a725e8eab383 | 62 | \param cls the UBX class id |
AxedaCorp | 0:a725e8eab383 | 63 | \param id the UBX message id |
AxedaCorp | 0:a725e8eab383 | 64 | \param buf the message payload to write |
AxedaCorp | 0:a725e8eab383 | 65 | \param len size of the message payload to write |
AxedaCorp | 0:a725e8eab383 | 66 | \return total bytes written |
AxedaCorp | 0:a725e8eab383 | 67 | */ |
AxedaCorp | 0:a725e8eab383 | 68 | virtual int sendUbx(unsigned char cls, unsigned char id, |
AxedaCorp | 0:a725e8eab383 | 69 | const void* buf = NULL, int len = 0); |
AxedaCorp | 0:a725e8eab383 | 70 | |
AxedaCorp | 0:a725e8eab383 | 71 | /** Power off the gps, it can be again woken up by an |
AxedaCorp | 0:a725e8eab383 | 72 | edge on the serial port on the external interrupt pin. |
AxedaCorp | 0:a725e8eab383 | 73 | */ |
AxedaCorp | 0:a725e8eab383 | 74 | void powerOff(void); |
AxedaCorp | 0:a725e8eab383 | 75 | |
AxedaCorp | 0:a725e8eab383 | 76 | /** get the first character of a NMEA field |
AxedaCorp | 0:a725e8eab383 | 77 | \param ix the index of the field to find |
AxedaCorp | 0:a725e8eab383 | 78 | \param start the start of the buffer |
AxedaCorp | 0:a725e8eab383 | 79 | \param end the end of the buffer |
AxedaCorp | 0:a725e8eab383 | 80 | \return the pointer to the first character of the field. |
AxedaCorp | 0:a725e8eab383 | 81 | */ |
AxedaCorp | 0:a725e8eab383 | 82 | static const char* findNmeaItemPos(int ix, const char* start, const char* end); |
AxedaCorp | 0:a725e8eab383 | 83 | |
AxedaCorp | 0:a725e8eab383 | 84 | /** extract a double value from a buffer containing a NMEA message |
AxedaCorp | 0:a725e8eab383 | 85 | \param ix the index of the field to extract |
AxedaCorp | 0:a725e8eab383 | 86 | \param buf the NMEA message |
AxedaCorp | 0:a725e8eab383 | 87 | \param len the size of the NMEA message |
AxedaCorp | 0:a725e8eab383 | 88 | \param val the extracted value |
AxedaCorp | 0:a725e8eab383 | 89 | \return true if successful, false otherwise |
AxedaCorp | 0:a725e8eab383 | 90 | */ |
AxedaCorp | 0:a725e8eab383 | 91 | static bool getNmeaItem(int ix, char* buf, int len, double& val); |
AxedaCorp | 0:a725e8eab383 | 92 | |
AxedaCorp | 0:a725e8eab383 | 93 | /** extract a interger value from a buffer containing a NMEA message |
AxedaCorp | 0:a725e8eab383 | 94 | \param ix the index of the field to extract |
AxedaCorp | 0:a725e8eab383 | 95 | \param buf the NMEA message |
AxedaCorp | 0:a725e8eab383 | 96 | \param len the size of the NMEA message |
AxedaCorp | 0:a725e8eab383 | 97 | \param val the extracted value |
AxedaCorp | 0:a725e8eab383 | 98 | \param base the numeric base to be used (e.g. 8, 10 or 16) |
AxedaCorp | 0:a725e8eab383 | 99 | \return true if successful, false otherwise |
AxedaCorp | 0:a725e8eab383 | 100 | */ |
AxedaCorp | 0:a725e8eab383 | 101 | static bool getNmeaItem(int ix, char* buf, int len, int& val, int base/*=10*/); |
AxedaCorp | 0:a725e8eab383 | 102 | |
AxedaCorp | 0:a725e8eab383 | 103 | /** extract a char value from a buffer containing a NMEA message |
AxedaCorp | 0:a725e8eab383 | 104 | \param ix the index of the field to extract |
AxedaCorp | 0:a725e8eab383 | 105 | \param buf the NMEA message |
AxedaCorp | 0:a725e8eab383 | 106 | \param len the size of the NMEA message |
AxedaCorp | 0:a725e8eab383 | 107 | \param val the extracted value |
AxedaCorp | 0:a725e8eab383 | 108 | \return true if successful, false otherwise |
AxedaCorp | 0:a725e8eab383 | 109 | */ |
AxedaCorp | 0:a725e8eab383 | 110 | static bool getNmeaItem(int ix, char* buf, int len, char& val); |
AxedaCorp | 0:a725e8eab383 | 111 | |
AxedaCorp | 0:a725e8eab383 | 112 | /** extract a latitude/longitude value from a buffer containing a NMEA message |
AxedaCorp | 0:a725e8eab383 | 113 | \param ix the index of the field to extract (will extract ix and ix + 1) |
AxedaCorp | 0:a725e8eab383 | 114 | \param buf the NMEA message |
AxedaCorp | 0:a725e8eab383 | 115 | \param len the size of the NMEA message |
AxedaCorp | 0:a725e8eab383 | 116 | \param val the extracted latitude or longitude |
AxedaCorp | 0:a725e8eab383 | 117 | \return true if successful, false otherwise |
AxedaCorp | 0:a725e8eab383 | 118 | */ |
AxedaCorp | 0:a725e8eab383 | 119 | static bool getNmeaAngle(int ix, char* buf, int len, double& val); |
AxedaCorp | 0:a725e8eab383 | 120 | |
AxedaCorp | 0:a725e8eab383 | 121 | protected: |
AxedaCorp | 0:a725e8eab383 | 122 | /** Get a line from the physical interface. |
AxedaCorp | 0:a725e8eab383 | 123 | \param pipe the receiveing pipe to parse messages |
AxedaCorp | 0:a725e8eab383 | 124 | \param buf the buffer to store it |
AxedaCorp | 0:a725e8eab383 | 125 | \param len size of the buffer |
AxedaCorp | 0:a725e8eab383 | 126 | \return type and length if something was found, |
AxedaCorp | 0:a725e8eab383 | 127 | WAIT if not enough data is available |
AxedaCorp | 0:a725e8eab383 | 128 | NOT_FOUND if nothing was found |
AxedaCorp | 0:a725e8eab383 | 129 | */ |
AxedaCorp | 0:a725e8eab383 | 130 | static int _getMessage(Pipe<char>* pipe, char* buf, int len); |
AxedaCorp | 0:a725e8eab383 | 131 | |
AxedaCorp | 0:a725e8eab383 | 132 | /** Check if the current offset of the pipe contains a NMEA message. |
AxedaCorp | 0:a725e8eab383 | 133 | \param pipe the receiveing pipe to parse messages |
AxedaCorp | 0:a725e8eab383 | 134 | \param len numer of bytes to parse at maximum |
AxedaCorp | 0:a725e8eab383 | 135 | \return length if something was found (including the NMEA frame) |
AxedaCorp | 0:a725e8eab383 | 136 | WAIT if not enough data is available |
AxedaCorp | 0:a725e8eab383 | 137 | NOT_FOUND if nothing was found |
AxedaCorp | 0:a725e8eab383 | 138 | */ |
AxedaCorp | 0:a725e8eab383 | 139 | static int _parseNmea(Pipe<char>* pipe, int len); |
AxedaCorp | 0:a725e8eab383 | 140 | |
AxedaCorp | 0:a725e8eab383 | 141 | /** Check if the current offset of the pipe contains a UBX message. |
AxedaCorp | 0:a725e8eab383 | 142 | \param pipe the receiveing pipe to parse messages |
AxedaCorp | 0:a725e8eab383 | 143 | \param len numer of bytes to parse at maximum |
AxedaCorp | 0:a725e8eab383 | 144 | \return length if something was found (including the UBX frame) |
AxedaCorp | 0:a725e8eab383 | 145 | WAIT if not enough data is available |
AxedaCorp | 0:a725e8eab383 | 146 | NOT_FOUND if nothing was found |
AxedaCorp | 0:a725e8eab383 | 147 | */ |
AxedaCorp | 0:a725e8eab383 | 148 | static int _parseUbx(Pipe<char>* pipe, int len); |
AxedaCorp | 0:a725e8eab383 | 149 | |
AxedaCorp | 0:a725e8eab383 | 150 | /** Write bytes to the physical interface. This function |
AxedaCorp | 0:a725e8eab383 | 151 | needs to be implemented by the inherited class. |
AxedaCorp | 0:a725e8eab383 | 152 | \param buf the buffer to write |
AxedaCorp | 0:a725e8eab383 | 153 | \param len size of the buffer to write |
AxedaCorp | 0:a725e8eab383 | 154 | \return bytes written |
AxedaCorp | 0:a725e8eab383 | 155 | */ |
AxedaCorp | 0:a725e8eab383 | 156 | virtual int _send(const void* buf, int len) = 0; |
AxedaCorp | 0:a725e8eab383 | 157 | |
AxedaCorp | 0:a725e8eab383 | 158 | static const char toHex[16]; //!< num to hex conversion |
AxedaCorp | 0:a725e8eab383 | 159 | #ifdef TARGET_UBLOX_C027 |
AxedaCorp | 0:a725e8eab383 | 160 | bool _onboard; |
AxedaCorp | 0:a725e8eab383 | 161 | #endif |
AxedaCorp | 0:a725e8eab383 | 162 | }; |
AxedaCorp | 0:a725e8eab383 | 163 | |
AxedaCorp | 0:a725e8eab383 | 164 | /** gps class which uses a serial port |
AxedaCorp | 0:a725e8eab383 | 165 | as physical interface. |
AxedaCorp | 0:a725e8eab383 | 166 | */ |
AxedaCorp | 0:a725e8eab383 | 167 | class GPSSerial : public SerialPipe, public GPSParser |
AxedaCorp | 0:a725e8eab383 | 168 | { |
AxedaCorp | 0:a725e8eab383 | 169 | public: |
AxedaCorp | 0:a725e8eab383 | 170 | /** Constructor |
AxedaCorp | 0:a725e8eab383 | 171 | \param tx is the serial ports transmit pin (gps to CPU) |
AxedaCorp | 0:a725e8eab383 | 172 | \param rx is the serial ports receive pin (CPU to gps) |
AxedaCorp | 0:a725e8eab383 | 173 | \param baudrate the baudrate of the gps use 9600 |
AxedaCorp | 0:a725e8eab383 | 174 | \param rxSize the size of the serial rx buffer |
AxedaCorp | 0:a725e8eab383 | 175 | \param txSize the size of the serial tx buffer |
AxedaCorp | 0:a725e8eab383 | 176 | */ |
AxedaCorp | 0:a725e8eab383 | 177 | GPSSerial(PinName tx GPS_IF( = GPSTXD, /* = D8 */), // resistor on shield not populated |
AxedaCorp | 0:a725e8eab383 | 178 | PinName rx GPS_IF( = GPSRXD, /* = D9 */), // resistor on shield not populated |
AxedaCorp | 0:a725e8eab383 | 179 | int baudrate GPS_IF( = GPSBAUD, = 9600 ), |
AxedaCorp | 0:a725e8eab383 | 180 | int rxSize = 256 , |
AxedaCorp | 0:a725e8eab383 | 181 | int txSize = 128 ); |
AxedaCorp | 0:a725e8eab383 | 182 | |
AxedaCorp | 0:a725e8eab383 | 183 | //! Destructor |
AxedaCorp | 0:a725e8eab383 | 184 | virtual ~GPSSerial(void); |
AxedaCorp | 0:a725e8eab383 | 185 | |
AxedaCorp | 0:a725e8eab383 | 186 | virtual bool init(PinName pn = NC); |
AxedaCorp | 0:a725e8eab383 | 187 | |
AxedaCorp | 0:a725e8eab383 | 188 | /** Get a line from the physical interface. |
AxedaCorp | 0:a725e8eab383 | 189 | \param buf the buffer to store it |
AxedaCorp | 0:a725e8eab383 | 190 | \param len size of the buffer |
AxedaCorp | 0:a725e8eab383 | 191 | \return type and length if something was found, |
AxedaCorp | 0:a725e8eab383 | 192 | WAIT if not enough data is available |
AxedaCorp | 0:a725e8eab383 | 193 | NOT_FOUND if nothing was found |
AxedaCorp | 0:a725e8eab383 | 194 | */ |
AxedaCorp | 0:a725e8eab383 | 195 | virtual int getMessage(char* buf, int len); |
AxedaCorp | 0:a725e8eab383 | 196 | |
AxedaCorp | 0:a725e8eab383 | 197 | protected: |
AxedaCorp | 0:a725e8eab383 | 198 | /** Write bytes to the physical interface. |
AxedaCorp | 0:a725e8eab383 | 199 | \param buf the buffer to write |
AxedaCorp | 0:a725e8eab383 | 200 | \param len size of the buffer to write |
AxedaCorp | 0:a725e8eab383 | 201 | \return bytes written |
AxedaCorp | 0:a725e8eab383 | 202 | */ |
AxedaCorp | 0:a725e8eab383 | 203 | virtual int _send(const void* buf, int len); |
AxedaCorp | 0:a725e8eab383 | 204 | }; |
AxedaCorp | 0:a725e8eab383 | 205 | |
AxedaCorp | 0:a725e8eab383 | 206 | /** gps class which uses a i2c as physical interface. |
AxedaCorp | 0:a725e8eab383 | 207 | */ |
AxedaCorp | 0:a725e8eab383 | 208 | class GPSI2C : public I2C, public GPSParser |
AxedaCorp | 0:a725e8eab383 | 209 | { |
AxedaCorp | 0:a725e8eab383 | 210 | public: |
AxedaCorp | 0:a725e8eab383 | 211 | /** Constructor |
AxedaCorp | 0:a725e8eab383 | 212 | \param sda is the I2C SDA pin (between CPU and GPS) |
AxedaCorp | 0:a725e8eab383 | 213 | \param scl is the I2C SCL pin (CPU to GPS) |
AxedaCorp | 0:a725e8eab383 | 214 | \param adr the I2C address of the GPS set to (66<<1) |
AxedaCorp | 0:a725e8eab383 | 215 | \param rxSize the size of the serial rx buffer |
AxedaCorp | 0:a725e8eab383 | 216 | */ |
AxedaCorp | 0:a725e8eab383 | 217 | GPSI2C(PinName sda GPS_IF( = GPSSDA, = D14 ), |
AxedaCorp | 0:a725e8eab383 | 218 | PinName scl GPS_IF( = GPSSCL, = D15 ), |
AxedaCorp | 0:a725e8eab383 | 219 | unsigned char i2cAdr GPS_IF( = GPSADR, = (66<<1) ), |
AxedaCorp | 0:a725e8eab383 | 220 | int rxSize = 256 ); |
AxedaCorp | 0:a725e8eab383 | 221 | //! Destructor |
AxedaCorp | 0:a725e8eab383 | 222 | virtual ~GPSI2C(void); |
AxedaCorp | 0:a725e8eab383 | 223 | |
AxedaCorp | 0:a725e8eab383 | 224 | /** helper function to probe the i2c device |
AxedaCorp | 0:a725e8eab383 | 225 | \return true if successfully detected the gps. |
AxedaCorp | 0:a725e8eab383 | 226 | */ |
AxedaCorp | 0:a725e8eab383 | 227 | virtual bool init(PinName pn = GPS_IF( GPSINT, NC /* D7 resistor R67 on shield not mounted */)); |
AxedaCorp | 0:a725e8eab383 | 228 | |
AxedaCorp | 0:a725e8eab383 | 229 | /** Get a line from the physical interface. |
AxedaCorp | 0:a725e8eab383 | 230 | \param buf the buffer to store it |
AxedaCorp | 0:a725e8eab383 | 231 | \param len size of the buffer |
AxedaCorp | 0:a725e8eab383 | 232 | \return type and length if something was found, |
AxedaCorp | 0:a725e8eab383 | 233 | WAIT if not enough data is available |
AxedaCorp | 0:a725e8eab383 | 234 | NOT_FOUND if nothing was found |
AxedaCorp | 0:a725e8eab383 | 235 | */ |
AxedaCorp | 0:a725e8eab383 | 236 | virtual int getMessage(char* buf, int len); |
AxedaCorp | 0:a725e8eab383 | 237 | |
AxedaCorp | 0:a725e8eab383 | 238 | /** send a buffer |
AxedaCorp | 0:a725e8eab383 | 239 | \param buf the buffer to write |
AxedaCorp | 0:a725e8eab383 | 240 | \param len size of the buffer to write |
AxedaCorp | 0:a725e8eab383 | 241 | \return bytes written |
AxedaCorp | 0:a725e8eab383 | 242 | */ |
AxedaCorp | 0:a725e8eab383 | 243 | virtual int send(const char* buf, int len); |
AxedaCorp | 0:a725e8eab383 | 244 | |
AxedaCorp | 0:a725e8eab383 | 245 | /** send a NMEA message, this function just takes the |
AxedaCorp | 0:a725e8eab383 | 246 | payload and calculates and adds checksum. ($ and *XX\r\n will be added) |
AxedaCorp | 0:a725e8eab383 | 247 | \param buf the message payload to write |
AxedaCorp | 0:a725e8eab383 | 248 | \param len size of the message payload to write |
AxedaCorp | 0:a725e8eab383 | 249 | \return total bytes written |
AxedaCorp | 0:a725e8eab383 | 250 | */ |
AxedaCorp | 0:a725e8eab383 | 251 | virtual int sendNmea(const char* buf, int len); |
AxedaCorp | 0:a725e8eab383 | 252 | |
AxedaCorp | 0:a725e8eab383 | 253 | /** send a UBX message, this function just takes the |
AxedaCorp | 0:a725e8eab383 | 254 | payload and calculates and adds checksum. |
AxedaCorp | 0:a725e8eab383 | 255 | \param cls the UBX class id |
AxedaCorp | 0:a725e8eab383 | 256 | \param id the UBX message id |
AxedaCorp | 0:a725e8eab383 | 257 | \param buf the message payload to write |
AxedaCorp | 0:a725e8eab383 | 258 | \param len size of the message payload to write |
AxedaCorp | 0:a725e8eab383 | 259 | \return total bytes written |
AxedaCorp | 0:a725e8eab383 | 260 | */ |
AxedaCorp | 0:a725e8eab383 | 261 | virtual int sendUbx(unsigned char cls, unsigned char id, |
AxedaCorp | 0:a725e8eab383 | 262 | const void* buf = NULL, int len = 0); |
AxedaCorp | 0:a725e8eab383 | 263 | |
AxedaCorp | 0:a725e8eab383 | 264 | protected: |
AxedaCorp | 0:a725e8eab383 | 265 | /** check if the port is writeable (like SerialPipe) |
AxedaCorp | 0:a725e8eab383 | 266 | \return true if writeable |
AxedaCorp | 0:a725e8eab383 | 267 | */ |
AxedaCorp | 0:a725e8eab383 | 268 | bool writeable(void) { return true; } |
AxedaCorp | 0:a725e8eab383 | 269 | |
AxedaCorp | 0:a725e8eab383 | 270 | /** Write a character (like SerialPipe) |
AxedaCorp | 0:a725e8eab383 | 271 | \param c the character to write |
AxedaCorp | 0:a725e8eab383 | 272 | \return true if succesffully written |
AxedaCorp | 0:a725e8eab383 | 273 | */ |
AxedaCorp | 0:a725e8eab383 | 274 | bool putc(int c) { char ch = c; return send(&ch, 1); } |
AxedaCorp | 0:a725e8eab383 | 275 | |
AxedaCorp | 0:a725e8eab383 | 276 | /** Write bytes to the physical interface. |
AxedaCorp | 0:a725e8eab383 | 277 | \param buf the buffer to write |
AxedaCorp | 0:a725e8eab383 | 278 | \param len size of the buffer to write |
AxedaCorp | 0:a725e8eab383 | 279 | \return bytes written |
AxedaCorp | 0:a725e8eab383 | 280 | */ |
AxedaCorp | 0:a725e8eab383 | 281 | virtual int _send(const void* buf, int len); |
AxedaCorp | 0:a725e8eab383 | 282 | |
AxedaCorp | 0:a725e8eab383 | 283 | /** read bytes from the physical interface. |
AxedaCorp | 0:a725e8eab383 | 284 | \param buf the buffer to read into |
AxedaCorp | 0:a725e8eab383 | 285 | \param len size of the read buffer |
AxedaCorp | 0:a725e8eab383 | 286 | \return bytes read |
AxedaCorp | 0:a725e8eab383 | 287 | */ |
AxedaCorp | 0:a725e8eab383 | 288 | int _get(char* buf, int len); |
AxedaCorp | 0:a725e8eab383 | 289 | |
AxedaCorp | 0:a725e8eab383 | 290 | Pipe<char> _pipe; //!< the rx pipe |
AxedaCorp | 0:a725e8eab383 | 291 | unsigned char _i2cAdr; //!< the i2c address |
AxedaCorp | 0:a725e8eab383 | 292 | static const char REGLEN; //!< the length i2c register address |
AxedaCorp | 0:a725e8eab383 | 293 | static const char REGSTREAM;//!< the stream i2c register address |
AxedaCorp | 0:a725e8eab383 | 294 | }; |