MCPcopy Create free account
hub / github.com/Hamlib/Hamlib / rig_send_raw

Function rig_send_raw

src/rig.c:8930–9043  ·  view source on GitHub ↗

* \brief Send verbatim data * * \a reply_len should be max bytes expected + 1 * * If \a term is NULL then will read \a reply_len bytes exactly and reply will not be '\0' terminated. * \param rig The rig handle * \param send The buffer containing the data to be sent * \param send_len The length of send buffer * \param reply The buffer that will contain the data to be received * \param repl

Source from the content-addressed store, hash-verified

8928 * set appropriately).
8929 */
8930HAMLIB_EXPORT(int) rig_send_raw(RIG *rig, const unsigned char *send,
8931 int send_len, unsigned char *reply, int reply_len, unsigned char *term)
8932{
8933 int nbytes;
8934 int retval;
8935 hamlib_port_t *rp = RIGPORT(rig);
8936 int simulate = rig->caps->rig_model == RIG_MODEL_DUMMY ||
8937 rig->caps->rig_model == RIG_MODEL_NONE ||
8938 rp->rig == RIG_PORT_NONE;
8939 ENTERFUNC;
8940
8941 ELAPSED1;
8942
8943 rig_debug(RIG_DEBUG_VERBOSE, "%s: writing %d bytes\n", __func__, send_len);
8944
8945 set_transaction_active(rig);
8946
8947 if (simulate)
8948 {
8949 rig_debug(RIG_DEBUG_VERBOSE, "%s: simulating write for model %s\n",
8950 __func__, rig->caps->model_name);
8951 retval = RIG_OK;
8952 }
8953 else
8954 {
8955 retval = write_block(rp, send, send_len);
8956
8957 if (retval < 0)
8958 {
8959 // TODO: error handling? can writing to a pipe really fail in ways we can recover from?
8960 rig_debug(RIG_DEBUG_ERR, "%s: write_block_sync() failed, result=%d\n", __func__,
8961 retval);
8962 }
8963 }
8964
8965 if (reply)
8966 {
8967 unsigned char buf[200];
8968
8969 if (simulate)
8970 {
8971 // Simulate a response by copying the command
8972 rig_debug(RIG_DEBUG_VERBOSE, "%s: simulating response for model %s\n",
8973 __func__, rig->caps->model_name);
8974
8975 nbytes = send_len < reply_len ? send_len : reply_len;
8976 for (int i = 0; i < nbytes; i++)
8977 {
8978 buf[i] = send[i];
8979 if (term && memchr(term, send[i], 1)) {
8980 nbytes = i + 1;
8981 break;
8982 }
8983 }
8984 }
8985 else
8986 {
8987 if (term == NULL)

Callers 3

handle_socketFunction · 0.85
mainFunction · 0.85
rigctl_parse.cFile · 0.85

Calls 5

rig_debugFunction · 0.85
write_blockFunction · 0.85
read_stringFunction · 0.85
read_icom_frameFunction · 0.85
rig_flush_forceFunction · 0.85

Tested by

no test coverage detected