Version of easy-connect with the u-blox cellular platforms C027 and C030 added.
esp8266-driver/ESP8266/ATParser/BufferedSerial/BufferedPrint.c@0:19aa55d66228, 2017-08-10 (annotated)
- Committer:
- group-ublox
- Date:
- Thu Aug 10 14:33:05 2017 +0000
- Revision:
- 0:19aa55d66228
Initial commit
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
group-ublox | 0:19aa55d66228 | 1 | /* |
group-ublox | 0:19aa55d66228 | 2 | * Copyright (c) 2014-2015 ARM Limited. All rights reserved. |
group-ublox | 0:19aa55d66228 | 3 | * SPDX-License-Identifier: Apache-2.0 |
group-ublox | 0:19aa55d66228 | 4 | * Licensed under the Apache License, Version 2.0 (the License); you may |
group-ublox | 0:19aa55d66228 | 5 | * not use this file except in compliance with the License. |
group-ublox | 0:19aa55d66228 | 6 | * You may obtain a copy of the License at |
group-ublox | 0:19aa55d66228 | 7 | * |
group-ublox | 0:19aa55d66228 | 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
group-ublox | 0:19aa55d66228 | 9 | * |
group-ublox | 0:19aa55d66228 | 10 | * Unless required by applicable law or agreed to in writing, software |
group-ublox | 0:19aa55d66228 | 11 | * distributed under the License is distributed on an AS IS BASIS, WITHOUT |
group-ublox | 0:19aa55d66228 | 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
group-ublox | 0:19aa55d66228 | 13 | * See the License for the specific language governing permissions and |
group-ublox | 0:19aa55d66228 | 14 | * limitations under the License. |
group-ublox | 0:19aa55d66228 | 15 | */ |
group-ublox | 0:19aa55d66228 | 16 | |
group-ublox | 0:19aa55d66228 | 17 | #include <stdarg.h> |
group-ublox | 0:19aa55d66228 | 18 | #include <stdint.h> |
group-ublox | 0:19aa55d66228 | 19 | #include <stdio.h> |
group-ublox | 0:19aa55d66228 | 20 | #include <string.h> |
group-ublox | 0:19aa55d66228 | 21 | |
group-ublox | 0:19aa55d66228 | 22 | #include "mbed_error.h" |
group-ublox | 0:19aa55d66228 | 23 | |
group-ublox | 0:19aa55d66228 | 24 | size_t BufferedSerialThunk(void *buf_serial, const void *s, size_t length); |
group-ublox | 0:19aa55d66228 | 25 | |
group-ublox | 0:19aa55d66228 | 26 | int BufferedPrintfC(void *stream, int size, const char* format, va_list arg) |
group-ublox | 0:19aa55d66228 | 27 | { |
group-ublox | 0:19aa55d66228 | 28 | int r; |
group-ublox | 0:19aa55d66228 | 29 | char buffer[512]; |
group-ublox | 0:19aa55d66228 | 30 | if (size >= 512) { |
group-ublox | 0:19aa55d66228 | 31 | return -1; |
group-ublox | 0:19aa55d66228 | 32 | } |
group-ublox | 0:19aa55d66228 | 33 | memset(buffer, 0, size); |
group-ublox | 0:19aa55d66228 | 34 | r = vsprintf(buffer, format, arg); |
group-ublox | 0:19aa55d66228 | 35 | // this may not hit the heap but should alert the user anyways |
group-ublox | 0:19aa55d66228 | 36 | if(r > (int32_t) size) { |
group-ublox | 0:19aa55d66228 | 37 | error("%s %d buffer overwrite (max_buf_size: %d exceeded: %d)!\r\n", __FILE__, __LINE__, size, r); |
group-ublox | 0:19aa55d66228 | 38 | return 0; |
group-ublox | 0:19aa55d66228 | 39 | } |
group-ublox | 0:19aa55d66228 | 40 | if ( r > 0 ) { |
group-ublox | 0:19aa55d66228 | 41 | BufferedSerialThunk(stream, buffer, r); |
group-ublox | 0:19aa55d66228 | 42 | } |
group-ublox | 0:19aa55d66228 | 43 | return r; |
group-ublox | 0:19aa55d66228 | 44 | } |