Add rig_lock to icom.c -- testing multicast capability

https://github.com/Hamlib/Hamlib/issues/695
pull/875/head
Mike Black W9MDB 2021-11-15 07:23:18 -06:00
rodzic 3de368f6a2
commit d9d247cad3
2 zmienionych plików z 24 dodań i 1 usunięć

Wyświetl plik

@ -137,6 +137,7 @@ int icom_one_transaction(RIG *rig, int cmd, int subcmd,
int ctrl_id;
ENTERFUNC;
rig_lock();
memset(buf, 0, 200);
memset(sendbuf, 0, MAXFRAMELEN);
rs = &rig->state;
@ -162,6 +163,7 @@ int icom_one_transaction(RIG *rig, int cmd, int subcmd,
if (retval != RIG_OK)
{
Unhold_Decode(rig);
rig_unlock();
RETURNFUNC(retval);
}
@ -183,12 +185,14 @@ int icom_one_transaction(RIG *rig, int cmd, int subcmd,
{
/* Nothing received, CI-V interface is not echoing */
Unhold_Decode(rig);
rig_unlock();
RETURNFUNC(-RIG_BUSERROR);
}
if (retval < 0)
{
Unhold_Decode(rig);
rig_unlock();
/* Other error, return it */
RETURNFUNC(retval);
}
@ -196,6 +200,7 @@ int icom_one_transaction(RIG *rig, int cmd, int subcmd,
if (retval < 1)
{
Unhold_Decode(rig);
rig_unlock();
RETURNFUNC(-RIG_EPROTO);
}
@ -204,6 +209,7 @@ int icom_one_transaction(RIG *rig, int cmd, int subcmd,
case COL:
/* Collision */
Unhold_Decode(rig);
rig_unlock();
RETURNFUNC(-RIG_BUSBUSY);
case FI:
@ -214,6 +220,7 @@ int icom_one_transaction(RIG *rig, int cmd, int subcmd,
/* Timeout after reading at least one character */
/* Problem on ci-v bus? */
Unhold_Decode(rig);
rig_unlock();
RETURNFUNC(-RIG_BUSERROR);
}
@ -223,6 +230,7 @@ int icom_one_transaction(RIG *rig, int cmd, int subcmd,
/* Problem on ci-v bus? */
/* Someone else got a packet in? */
Unhold_Decode(rig);
rig_unlock();
RETURNFUNC(-RIG_EPROTO);
}
@ -232,6 +240,7 @@ int icom_one_transaction(RIG *rig, int cmd, int subcmd,
/* Problem on ci-v bus? */
/* Someone else got a packet in? */
Unhold_Decode(rig);
rig_unlock();
RETURNFUNC(-RIG_EPROTO);
}
}
@ -242,6 +251,7 @@ int icom_one_transaction(RIG *rig, int cmd, int subcmd,
if (data_len == NULL)
{
Unhold_Decode(rig);
rig_unlock();
RETURNFUNC(RIG_OK);
}
@ -272,6 +282,7 @@ read_another_frame:
if (frm_len < 0)
{
rig_unlock();
Unhold_Decode(rig);
/* RIG_TIMEOUT: timeout getting response, return timeout */
/* other error: return it */
@ -280,6 +291,7 @@ read_another_frame:
if (frm_len < 1)
{
rig_unlock();
Unhold_Decode(rig);
RETURNFUNC(-RIG_EPROTO);
}
@ -289,6 +301,7 @@ read_another_frame:
if (retval < 0)
{
Unhold_Decode(rig);
rig_unlock();
RETURNFUNC(retval);
}
@ -297,6 +310,7 @@ read_another_frame:
if (frm_len < 1)
{
rig_debug(RIG_DEBUG_ERR, "Unexpected frame len=%d\n", frm_len);
rig_unlock();
RETURNFUNC(-RIG_EPROTO);
}
@ -305,6 +319,7 @@ read_another_frame:
case COL:
Unhold_Decode(rig);
/* Collision */
rig_unlock();
RETURNFUNC(-RIG_BUSBUSY);
case FI:
@ -313,18 +328,21 @@ read_another_frame:
case NAK:
Unhold_Decode(rig);
rig_unlock();
RETURNFUNC(-RIG_ERJCTED);
default:
Unhold_Decode(rig);
/* Timeout after reading at least one character */
/* Problem on ci-v bus? */
rig_unlock();
RETURNFUNC(-RIG_EPROTO);
}
if (frm_len < ACKFRMLEN)
{
Unhold_Decode(rig);
rig_unlock();
RETURNFUNC(-RIG_EPROTO);
}
@ -333,6 +351,7 @@ read_another_frame:
if (frm_len == 6 && NAK == buf[frm_len - 2])
{
Unhold_Decode(rig);
rig_unlock();
RETURNFUNC(-RIG_ERJCTED);
}
@ -343,6 +362,7 @@ read_another_frame:
if (FI != buf[frm_len - 1] && ACK != buf[frm_len - 1])
{
Unhold_Decode(rig);
rig_unlock();
RETURNFUNC(-RIG_BUSBUSY);
}
@ -351,6 +371,7 @@ read_another_frame:
if (frm_data_len <= 0)
{
Unhold_Decode(rig);
rig_unlock();
RETURNFUNC(-RIG_EPROTO);
}
@ -368,6 +389,7 @@ read_another_frame:
if (elapsed_ms > rs->rigport.timeout)
{
Unhold_Decode(rig);
rig_unlock();
RETURNFUNC(-RIG_ETIMEOUT);
}
@ -383,6 +405,7 @@ read_another_frame:
* TODO: check addresses in reply frame
*/
rig_unlock();
RETURNFUNC(RIG_OK);
}

Wyświetl plik

@ -30,7 +30,7 @@
#include <sys/time.h>
#endif
#define BACKEND_VER "20211114"
#define BACKEND_VER "20211115"
#define ICOM_IS_SECONDARY_VFO(vfo) ((vfo) & (RIG_VFO_B | RIG_VFO_SUB | RIG_VFO_SUB_B | RIG_VFO_MAIN_B))
#define ICOM_GET_VFO_NUMBER(vfo) (ICOM_IS_SECONDARY_VFO(vfo) ? 0x01 : 0x00)