]> sigrok.org Git - sigrok-util.git/blame - source/drv-api.c
sigrok-cross-mingw: Lower Python version to 3.4 (Win XP support).
[sigrok-util.git] / source / drv-api.c
CommitLineData
a65d66c0 1/*
4b527a01 2 * This file is part of the libsigrok project.
a65d66c0 3 *
bc02c2bf 4 * Copyright (C) {year} {author} <{email}>
a65d66c0
BV
5 *
6 * This program is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19
4dfd6ece 20#include <config.h>
a65d66c0
BV
21#include "protocol.h"
22
bc02c2bf 23SR_PRIV struct sr_dev_driver {lib}_driver_info;
a65d66c0 24
87604b0c 25static GSList *scan(struct sr_dev_driver *di, GSList *options)
bc02c2bf 26{{
a65d66c0
BV
27 struct drv_context *drvc;
28 GSList *devices;
29
30 (void)options;
126eded0 31
a65d66c0 32 devices = NULL;
f03716cf 33 drvc = di->context;
a65d66c0
BV
34 drvc->instances = NULL;
35
87c5b243
BV
36 /* TODO: scan for devices, either based on a SR_CONF_CONN option
37 * or on a USB scan. */
a65d66c0
BV
38
39 return devices;
bc02c2bf 40}}
a65d66c0 41
87604b0c 42static int dev_clear(const struct sr_dev_driver *di)
bc02c2bf 43{{
87c5b243 44 return std_dev_clear(di, NULL);
bc02c2bf 45}}
87c5b243
BV
46
47static int dev_open(struct sr_dev_inst *sdi)
bc02c2bf 48{{
3aef82b3
UH
49 (void)sdi;
50
87c5b243
BV
51 /* TODO: get handle from sdi->conn and open it. */
52
53 sdi->status = SR_ST_ACTIVE;
a65d66c0
BV
54
55 return SR_OK;
bc02c2bf 56}}
a65d66c0 57
87c5b243 58static int dev_close(struct sr_dev_inst *sdi)
bc02c2bf 59{{
3aef82b3
UH
60 (void)sdi;
61
87c5b243
BV
62 /* TODO: get handle from sdi->conn and close it. */
63
64 sdi->status = SR_ST_INACTIVE;
a65d66c0
BV
65
66 return SR_OK;
bc02c2bf 67}}
a65d66c0 68
df382df5
UH
69static int config_get(uint32_t key, GVariant **data,
70 const struct sr_dev_inst *sdi, const struct sr_channel_group *cg)
bc02c2bf 71{{
87c5b243
BV
72 int ret;
73
3aef82b3 74 (void)sdi;
87c5b243 75 (void)data;
d73e0933 76 (void)cg;
3aef82b3 77
87c5b243 78 ret = SR_OK;
bc02c2bf 79 switch (key) {{
a65d66c0
BV
80 /* TODO */
81 default:
87c5b243 82 return SR_ERR_NA;
bc02c2bf 83 }}
a65d66c0 84
87c5b243 85 return ret;
bc02c2bf 86}}
a65d66c0 87
df382df5
UH
88static int config_set(uint32_t key, GVariant *data,
89 const struct sr_dev_inst *sdi, const struct sr_channel_group *cg)
bc02c2bf 90{{
a65d66c0
BV
91 int ret;
92
87c5b243 93 (void)data;
d73e0933 94 (void)cg;
87c5b243
BV
95
96 if (sdi->status != SR_ST_ACTIVE)
97 return SR_ERR_DEV_CLOSED;
a65d66c0
BV
98
99 ret = SR_OK;
bc02c2bf 100 switch (key) {{
a65d66c0
BV
101 /* TODO */
102 default:
87c5b243 103 ret = SR_ERR_NA;
bc02c2bf 104 }}
a65d66c0
BV
105
106 return ret;
bc02c2bf 107}}
a65d66c0 108
df382df5
UH
109static int config_list(uint32_t key, GVariant **data,
110 const struct sr_dev_inst *sdi, const struct sr_channel_group *cg)
bc02c2bf 111{{
87c5b243
BV
112 int ret;
113
3aef82b3
UH
114 (void)sdi;
115 (void)data;
d73e0933 116 (void)cg;
3aef82b3 117
87c5b243 118 ret = SR_OK;
bc02c2bf 119 switch (key) {{
87c5b243 120 /* TODO */
3aef82b3 121 default:
87c5b243 122 return SR_ERR_NA;
bc02c2bf 123 }}
3aef82b3 124
87c5b243 125 return ret;
bc02c2bf 126}}
3aef82b3 127
f87108ec 128static int dev_acquisition_start(const struct sr_dev_inst *sdi)
bc02c2bf 129{{
87c5b243
BV
130 if (sdi->status != SR_ST_ACTIVE)
131 return SR_ERR_DEV_CLOSED;
132
133 /* TODO: configure hardware, reset acquisition state, set up
134 * callbacks and send header packet. */
a65d66c0
BV
135
136 return SR_OK;
bc02c2bf 137}}
a65d66c0 138
f87108ec 139static int dev_acquisition_stop(struct sr_dev_inst *sdi)
bc02c2bf 140{{
87c5b243
BV
141 if (sdi->status != SR_ST_ACTIVE)
142 return SR_ERR_DEV_CLOSED;
a65d66c0 143
87c5b243 144 /* TODO: stop acquisition. */
a65d66c0
BV
145
146 return SR_OK;
bc02c2bf 147}}
a65d66c0 148
bc02c2bf
DD
149SR_PRIV struct sr_dev_driver {lib}_driver_info = {{
150 .name = "{short}",
151 .longname = "{name}",
a65d66c0 152 .api_version = 1,
f87108ec
UH
153 .init = std_init,
154 .cleanup = std_cleanup,
87c5b243 155 .scan = scan,
f87108ec 156 .dev_list = std_dev_list,
87c5b243
BV
157 .dev_clear = dev_clear,
158 .config_get = config_get,
159 .config_set = config_set,
160 .config_list = config_list,
161 .dev_open = dev_open,
162 .dev_close = dev_close,
163 .dev_acquisition_start = dev_acquisition_start,
164 .dev_acquisition_stop = dev_acquisition_stop,
f03716cf 165 .context = NULL,
bc02c2bf 166}};
466005f1
DD
167
168SR_REGISTER_DEV_DRIVER({lib}_driver_info);