Version of easy-connect with the u-blox cellular platforms C027 and C030 added.
Embed:
(wiki syntax)
Show/hide line numbers
BufferedPrint.c
00001 /* 00002 * Copyright (c) 2014-2015 ARM Limited. All rights reserved. 00003 * SPDX-License-Identifier: Apache-2.0 00004 * Licensed under the Apache License, Version 2.0 (the License); you may 00005 * not use this file except in compliance with the License. 00006 * You may obtain a copy of the License at 00007 * 00008 * http://www.apache.org/licenses/LICENSE-2.0 00009 * 00010 * Unless required by applicable law or agreed to in writing, software 00011 * distributed under the License is distributed on an AS IS BASIS, WITHOUT 00012 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00013 * See the License for the specific language governing permissions and 00014 * limitations under the License. 00015 */ 00016 00017 #include <stdarg.h> 00018 #include <stdint.h> 00019 #include <stdio.h> 00020 #include <string.h> 00021 00022 #include "mbed_error.h" 00023 00024 size_t BufferedSerialThunk(void *buf_serial, const void *s, size_t length); 00025 00026 int BufferedPrintfC(void *stream, int size, const char* format, va_list arg) 00027 { 00028 int r; 00029 char buffer[512]; 00030 if (size >= 512) { 00031 return -1; 00032 } 00033 memset(buffer, 0, size); 00034 r = vsprintf(buffer, format, arg); 00035 // this may not hit the heap but should alert the user anyways 00036 if(r > (int32_t) size) { 00037 error("%s %d buffer overwrite (max_buf_size: %d exceeded: %d)!\r\n", __FILE__, __LINE__, size, r); 00038 return 0; 00039 } 00040 if ( r > 0 ) { 00041 BufferedSerialThunk(stream, buffer, r); 00042 } 00043 return r; 00044 }
Generated on Tue Jul 12 2022 15:14:29 by 1.7.2