| 245 | |
| 246 | |
| 247 | static int netrigctl_open(RIG *rig) |
| 248 | { |
| 249 | int ret, i; |
| 250 | struct rig_state *rs = STATE(rig); |
| 251 | hamlib_port_t *rp = RIGPORT(rig); |
| 252 | int prot_ver; |
| 253 | char cmd[CMD_MAX]; |
| 254 | char buf[BUF_MAX]; |
| 255 | struct netrigctl_priv_data *priv; |
| 256 | |
| 257 | |
| 258 | ENTERFUNC; |
| 259 | |
| 260 | priv = (struct netrigctl_priv_data *)STATE(rig)->priv; |
| 261 | priv->rx_vfo = RIG_VFO_A; |
| 262 | priv->tx_vfo = RIG_VFO_B; |
| 263 | |
| 264 | SNPRINTF(cmd, sizeof(cmd), "\\chk_vfo\n"); |
| 265 | ret = netrigctl_transaction(rig, cmd, strlen(cmd), buf); |
| 266 | |
| 267 | if (sscanf(buf, "%d", &priv->rigctld_vfo_mode) == 1) |
| 268 | { |
| 269 | STATE(rig)->vfo_opt = priv->rigctld_vfo_mode; |
| 270 | rig_debug(RIG_DEBUG_TRACE, "%s: chkvfo=%d\n", __func__, priv->rigctld_vfo_mode); |
| 271 | } |
| 272 | else if (ret == 2) |
| 273 | { |
| 274 | if (buf[0]) { sscanf(buf, "%d", &priv->rigctld_vfo_mode); } |
| 275 | } |
| 276 | else if (ret < 0) |
| 277 | { |
| 278 | rig_debug(RIG_DEBUG_WARN, "%s: chk_vfo error: %s\n", __func__, |
| 279 | rigerror(ret)); |
| 280 | } |
| 281 | else |
| 282 | { |
| 283 | rig_debug(RIG_DEBUG_ERR, "%s: unknown value returned from netrigctl_transaction=%d\n", |
| 284 | __func__, ret); |
| 285 | } |
| 286 | |
| 287 | rig_debug(RIG_DEBUG_VERBOSE, "%s: vfo_mode=%d\n", __func__, |
| 288 | priv->rigctld_vfo_mode); |
| 289 | |
| 290 | SNPRINTF(cmd, sizeof(cmd), "\\dump_state\n"); |
| 291 | |
| 292 | ret = netrigctl_transaction(rig, cmd, strlen(cmd), buf); |
| 293 | |
| 294 | if (ret <= 0) |
| 295 | { |
| 296 | RETURNFUNC((ret < 0) ? ret : -RIG_EPROTO); |
| 297 | } |
| 298 | |
| 299 | prot_ver = atoi(buf); |
| 300 | #define RIGCTLD_PROT_VER 0 |
| 301 | |
| 302 | if (prot_ver < RIGCTLD_PROT_VER) |
| 303 | { |
| 304 | RETURNFUNC(-RIG_EPROTO); |
nothing calls this directly
no test coverage detected