blob: 9b6815b73bd7582f6ea98027945e4228ea8e059d [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{
Kshitij Sisodiaf9c19ea2021-05-07 16:08:14 +010040 if (NULL == fgets(user_input, size, stdin)) {
41 return 1;
42 }
alexander3c798932021-03-26 21:42:19 +000043 return 0;
44}
45
46int data_acq_channel_init(data_acq_module *module)
47{
48 assert(module);
49
50 module->system_init = acquisition_init;
51 module->get_input = get_user_input;
52 strncpy(module->system_name, "native",
53 sizeof(module->system_name));
54 module->inited = !module->system_init();
55 return !module->inited;
56}
57
58int data_acq_channel_release(data_acq_module *module)
59{
60 assert(module);
61 module->inited = 0;
62 return 0;
63}