|
| 1 | +/* |
| 2 | + * Copyright (c) 2025 Arm Limited. All rights reserved. |
| 3 | + * |
| 4 | + * SPDX-License-Identifier: Apache-2.0 |
| 5 | + * |
| 6 | + * Licensed under the Apache License, Version 2.0 (the License); you may |
| 7 | + * not use this file except in compliance with the License. |
| 8 | + * You may obtain a copy of the License at |
| 9 | + * |
| 10 | + * www.apache.org/licenses/LICENSE-2.0 |
| 11 | + * |
| 12 | + * Unless required by applicable law or agreed to in writing, software |
| 13 | + * distributed under the License is distributed on an AS IS BASIS, WITHOUT |
| 14 | + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 15 | + * See the License for the specific language governing permissions and |
| 16 | + * limitations under the License. |
| 17 | + */ |
| 18 | + |
| 19 | +// SDS I/O Client: Template for custom implementation |
| 20 | + |
| 21 | +#include "sdsio.h" |
| 22 | +#include "sdsio_client.h" |
| 23 | + |
| 24 | +/** |
| 25 | + \fn int32_t sdsioClientInit (void) |
| 26 | + \brief Initialize SDS I/O Client |
| 27 | + \return SDIOS_OK: initialization success |
| 28 | + SDSIO_ERROR: initialization failed |
| 29 | +*/ |
| 30 | +int32_t sdsioClientInit (void) { |
| 31 | + int32_t ret = SDSIO_ERROR; |
| 32 | + |
| 33 | + // ToDo: Add code for SDS I/O Client initialization |
| 34 | + |
| 35 | + return ret; |
| 36 | +} |
| 37 | + |
| 38 | +/** |
| 39 | + \fn int32_t sdsioClientUninit (void) |
| 40 | + \brief Un-Initialize SDS I/O Client |
| 41 | + \return SDIOS_OK: un-initialization success |
| 42 | + SDSIO_ERROR: un-initialization failed |
| 43 | +*/ |
| 44 | +int32_t sdsioClientUninit (void) { |
| 45 | + |
| 46 | + // ToDo: Add code for SDS I/O Client de-initialization |
| 47 | + |
| 48 | + return SDSIO_OK; |
| 49 | +} |
| 50 | + |
| 51 | +/** |
| 52 | + \fn uint32_t sdsioClientSend (const header_t *header, const void *data, uint32_t data_size) |
| 53 | + \brief Send data to SDSIO-Server |
| 54 | + \param[in] header pointer to header |
| 55 | + \param[in] data pointer to buffer with data to send |
| 56 | + \param[in] data_size data size in bytes |
| 57 | + \return number of bytes sent (including header) |
| 58 | +*/ |
| 59 | +uint32_t sdsioClientSend (const header_t *header, const void *data, uint32_t data_size) { |
| 60 | + uint32_t num = 0U; |
| 61 | + // uint32_t cnt; |
| 62 | + |
| 63 | + if (header == NULL) { |
| 64 | + return 0U; |
| 65 | + } |
| 66 | + |
| 67 | + // Send header |
| 68 | + // ToDo: Modify code below to send header to SDSIO-Server |
| 69 | + // cnt = 0U; |
| 70 | + // while (cnt < sizeof(header_t)) { |
| 71 | + // cnt += CustomSend((const uint8_t *)header + cnt, sizeof(header_t) - cnt); |
| 72 | + // } |
| 73 | + // num = cnt; |
| 74 | + |
| 75 | + |
| 76 | + // Send data |
| 77 | + // ToDo: Modify code below to send data to SDSIO-Server |
| 78 | + // cnt = 0U; |
| 79 | + // if ((data != NULL) && (data_size != 0U)) { |
| 80 | + // while (cnt < data_size) { |
| 81 | + // cnt += CustomSend((const uint8_t *)data + cnt, data_size - cnt); |
| 82 | + // } |
| 83 | + // } |
| 84 | + // num += cnt; |
| 85 | + |
| 86 | + return num; |
| 87 | +} |
| 88 | + |
| 89 | +/** |
| 90 | + \fn uint32_t sdsioClientReceive (header_t *header, void *data, uint32_t data_size) |
| 91 | + \brief Receive data from SDSIO-Server |
| 92 | + \param[out] header pointer to header |
| 93 | + \param[out] data pointer to buffer for data to read |
| 94 | + \param[in] data_size data size in bytes |
| 95 | + \return number of bytes received (including header) |
| 96 | +*/ |
| 97 | +uint32_t sdsioClientReceive (header_t *header, void *data, uint32_t data_size) { |
| 98 | + uint32_t num = 0U; |
| 99 | + // uint32_t cnt, size; |
| 100 | + |
| 101 | + if (header == NULL) { |
| 102 | + return 0U; |
| 103 | + } |
| 104 | + |
| 105 | + // Receive header |
| 106 | + // ToDo: Modify code below to receive header from SDSIO-Server |
| 107 | + // cnt = 0U; |
| 108 | + // while (cnt < sizeof(header_t)) { |
| 109 | + // cnt += CustomReceive((uint8_t *)header + cnt, sizeof(header_t) - cnt); |
| 110 | + // } |
| 111 | + // num = cnt; |
| 112 | + |
| 113 | + // Receive data |
| 114 | + // ToDo: Modify code below to receive data from SDSIO-Server |
| 115 | + // cnt = 0U; |
| 116 | + // if ((num != 0U) && (header->data_size != 0U) && |
| 117 | + // (data != NULL) && (data_size != 0U)) { |
| 118 | + |
| 119 | + // if (header->data_size < data_size) { |
| 120 | + // size = header->data_size; |
| 121 | + // } else { |
| 122 | + // size = data_size; |
| 123 | + // } |
| 124 | + // while (cnt < size) { |
| 125 | + // cnt += CustomReceive((uint8_t *)data + cnt, size - cnt); |
| 126 | + // } |
| 127 | + // } |
| 128 | + // num += cnt; |
| 129 | + |
| 130 | + return num; |
| 131 | +} |
0 commit comments