blob: 01f47fa63d1cde67a23d6d6810075fe0a3d4a733 [file] [log] [blame]
alexander3c798932021-03-26 21:42:19 +00001/*
2 * Copyright (c) 2021 Arm Limited. All rights reserved.
3 * SPDX-License-Identifier: Apache-2.0
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17#include "data_acq.h"
18
19#include <assert.h>
20#include <stdio.h>
21#include <string.h>
22
23/**
24 * @brief Initialize the acuisition.
25 * @return 0 if successful, error code otherwise.
26 **/
27static int acquisition_init(void)
28{
29 return 0;
30}
31
32/**
33 * @brief Get the user input from stdin.
34 * @param[out] user_input String read from the stdin.
35 * @param[in,out] size String read length.
36 * @return 0 if successful, error code otherwise.
37 **/
38static int get_user_input(char* user_input, int size)
39{
40 fgets(user_input, size, stdin);
41 return 0;
42}
43
44int data_acq_channel_init(data_acq_module *module)
45{
46 assert(module);
47
48 module->system_init = acquisition_init;
49 module->get_input = get_user_input;
50 strncpy(module->system_name, "native",
51 sizeof(module->system_name));
52 module->inited = !module->system_init();
53 return !module->inited;
54}
55
56int data_acq_channel_release(data_acq_module *module)
57{
58 assert(module);
59 module->inited = 0;
60 return 0;
61}