* icom_transaction * * This function honors rigport.retry count. * * We assume that rig!=NULL, STATE(rig)!= NULL, payload!=NULL, data!=NULL, data_len!=NULL * Otherwise, you'll get a nice seg fault. You've been warned! * payload can be NULL if payload_len == 0 * subcmd can be equal to -1 (no subcmd wanted) * * return RIG_OK if transaction completed, * or a negative value otherwise indicat
| 516 | * or a negative value otherwise indicating the error. |
| 517 | */ |
| 518 | int icom_transaction(RIG *rig, int cmd, int subcmd, |
| 519 | const unsigned char *payload, int payload_len, unsigned char *data, |
| 520 | int *data_len) |
| 521 | { |
| 522 | int retval, retry; |
| 523 | |
| 524 | ENTERFUNC; |
| 525 | rig_debug(RIG_DEBUG_VERBOSE, |
| 526 | "%s: cmd=0x%02x, subcmd=0x%02x, payload_len=%d\n", __func__, |
| 527 | cmd, subcmd, payload_len); |
| 528 | |
| 529 | retry = RIGPORT(rig)->retry; |
| 530 | |
| 531 | do |
| 532 | { |
| 533 | retval = icom_one_transaction(rig, cmd, subcmd, payload, payload_len, data, |
| 534 | data_len); |
| 535 | |
| 536 | // codes that make us return immediately |
| 537 | if (retval == RIG_OK || retval == -RIG_ERJCTED || retval == -RIG_BUSERROR) |
| 538 | { |
| 539 | break; |
| 540 | } |
| 541 | |
| 542 | rig_debug(RIG_DEBUG_WARN, "%s: retry=%d: %s\n", __func__, retry, |
| 543 | rigerror(retval)); |
| 544 | |
| 545 | // On some serial errors we may need a bit of time |
| 546 | hl_usleep(100 * 1000); // pause just a bit |
| 547 | } |
| 548 | while (retry-- > 0); |
| 549 | |
| 550 | if (retval != RIG_OK) |
| 551 | { |
| 552 | rig_debug(RIG_DEBUG_VERBOSE, "%s: failed: %s\n", __func__, rigerror(retval)); |
| 553 | } |
| 554 | |
| 555 | RETURNFUNC(retval); |
| 556 | } |
| 557 | |
| 558 | /* used in read_icom_frame as end of block */ |
| 559 | static const char icom_block_end[2] = { FI, COL}; |
no test coverage detected