2 * This file is part of the libsigrok project.
4 * Copyright (C) 2016 Vlad Ivanov <vlad.ivanov@lab-systems.ru>
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.
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.
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/>.
27 RS_CMD_CONTROL_REMOTE,
34 static char *commands[] = {
35 [RS_CMD_CONTROL_REMOTE] = "\n",
36 [RS_CMD_SET_FREQ] = "FREQ %.1fHz",
37 [RS_CMD_SET_POWER] = "POW %.1fdBm",
38 [RS_CMD_GET_FREQ] = "FREQ?",
39 [RS_CMD_GET_POWER] = "POW?",
42 SR_PRIV int rs_sme0x_mode_remote(struct sr_scpi_dev_inst *scpi)
44 return sr_scpi_send(scpi, commands[RS_CMD_CONTROL_REMOTE]);
47 SR_PRIV int rs_sme0x_get_freq(const struct sr_dev_inst *sdi, double *freq)
49 if (sr_scpi_get_double(sdi->conn, commands[RS_CMD_GET_FREQ], freq) != SR_OK)
55 SR_PRIV int rs_sme0x_get_power(const struct sr_dev_inst *sdi, double *power)
57 if (sr_scpi_get_double(sdi->conn, commands[RS_CMD_GET_POWER], power) != SR_OK)
63 SR_PRIV int rs_sme0x_set_freq(const struct sr_dev_inst *sdi, double freq)
65 struct dev_context *devc;
66 const struct rs_device_model *config;
69 config = devc->model_config;
71 if ((freq > config->freq_max) || (freq < config->freq_min))
74 return sr_scpi_send(sdi->conn, commands[RS_CMD_SET_FREQ], freq);
77 SR_PRIV int rs_sme0x_set_power(const struct sr_dev_inst *sdi, double power)
79 struct dev_context *devc;
80 const struct rs_device_model *config;
83 config = devc->model_config;
85 if ((power > config->power_max) || (power < config->power_min))
88 return sr_scpi_send(sdi->conn, commands[RS_CMD_SET_POWER], power);