|
46 | 46 | #include <gps.h> /* for DEFAULT_GPSD_PORT (2947) */
|
47 | 47 | #endif
|
48 | 48 |
|
| 49 | +#ifdef USE_HAMLIB |
| 50 | +#include <hamlib/rig.h> |
| 51 | +#endif |
| 52 | + |
49 | 53 | #include "ax25_pad.h"
|
50 | 54 | #include "textcolor.h"
|
51 | 55 | #include "audio.h"
|
@@ -608,6 +612,12 @@ void config_init (char *fname, struct audio_s *p_audio_config,
|
608 | 612 | int adevice;
|
609 | 613 | int m;
|
610 | 614 |
|
| 615 | +#if USE_HAMLIB |
| 616 | + RIG *rig; |
| 617 | + int rigs = 0; |
| 618 | +#endif |
| 619 | + |
| 620 | + |
611 | 621 | #if DEBUG
|
612 | 622 | text_color_set(DW_COLOR_DEBUG);
|
613 | 623 | dw_printf ("config_init ( %s )\n", fname);
|
@@ -1531,6 +1541,24 @@ void config_init (char *fname, struct audio_s *p_audio_config,
|
1531 | 1541 | text_color_set(DW_COLOR_ERROR);
|
1532 | 1542 | dw_printf ("Config file line %d: %s with LPT is only available on x86 Linux.\n", line, otname);
|
1533 | 1543 | #endif
|
| 1544 | + } |
| 1545 | + else if (strcasecmp(t, "RIG") == 0) { |
| 1546 | +#ifdef USE_HAMLIB |
| 1547 | + p_audio_config->achan[channel].octrl[ot].ptt_method = PTT_METHOD_HAMLIB; |
| 1548 | + |
| 1549 | + t = strtok (NULL, " ,\t\n\r"); |
| 1550 | + if (t == NULL) { |
| 1551 | + text_color_set(DW_COLOR_ERROR); |
| 1552 | + dw_printf ("Config file line %d: Missing RIG number.\n", line); |
| 1553 | + continue; |
| 1554 | + } |
| 1555 | + |
| 1556 | + p_audio_config->achan[channel].octrl[ot].ptt_rig = atoi(t); |
| 1557 | + |
| 1558 | +#else |
| 1559 | + text_color_set(DW_COLOR_ERROR); |
| 1560 | + dw_printf ("Config file line %d: %s with RIG is only available when hamlib support is enabled.\n", line, otname); |
| 1561 | +#endif |
1534 | 1562 | }
|
1535 | 1563 | else {
|
1536 | 1564 |
|
@@ -1663,6 +1691,80 @@ void config_init (char *fname, struct audio_s *p_audio_config,
|
1663 | 1691 | }
|
1664 | 1692 | }
|
1665 | 1693 |
|
| 1694 | +/* |
| 1695 | + * RIG - HAMLib rig configuration. |
| 1696 | + * |
| 1697 | + * xxx port model |
| 1698 | + * |
| 1699 | + * For example a Yeasu FT-817 on /dev/ttyUSB0: |
| 1700 | + * RIG /dev/ttyUSB0 120 |
| 1701 | + * |
| 1702 | + * For example rigctld on localhost: |
| 1703 | + * RIG 127.0.0.1:4532 2 |
| 1704 | + */ |
| 1705 | + |
| 1706 | + else if (strcasecmp(t, "RIG") == 0) { |
| 1707 | +#ifdef USE_HAMLIB |
| 1708 | + int n; |
| 1709 | + hamlib_port_t port; |
| 1710 | + rig_model_t rig_model; |
| 1711 | + |
| 1712 | + if (rigs == MAX_RIGS) { |
| 1713 | + text_color_set(DW_COLOR_ERROR); |
| 1714 | + dw_printf ("Config file line %d: Maximum number of rigs reached.\n", line); |
| 1715 | + continue; |
| 1716 | + } |
| 1717 | + |
| 1718 | + t = strtok (NULL, " ,\t\n\r"); |
| 1719 | + if (t == NULL) { |
| 1720 | + text_color_set(DW_COLOR_ERROR); |
| 1721 | + dw_printf ("Config file line %d: Missing port, model[, key=value].\n", |
| 1722 | + line); |
| 1723 | + continue; |
| 1724 | + } |
| 1725 | + |
| 1726 | + strncpy (port.pathname, t, FILPATHLEN - 1); |
| 1727 | + |
| 1728 | + t = strtok (NULL, " ,\t\n\r"); |
| 1729 | + if (t == NULL) { |
| 1730 | + text_color_set(DW_COLOR_ERROR); |
| 1731 | + dw_printf ("Config file line %d: Missing model[, key=value]\n", line); |
| 1732 | + continue; |
| 1733 | + } |
| 1734 | + |
| 1735 | + if (strcasecmp(t, "AUTO") == 0) { |
| 1736 | + rig_load_all_backends(); |
| 1737 | + rig_model = rig_probe(&port); |
| 1738 | + } |
| 1739 | + else { |
| 1740 | + rig_model = atoi(t); |
| 1741 | + } |
| 1742 | + |
| 1743 | + rig = rig_init(rig_model); |
| 1744 | + if (!rig) { |
| 1745 | + text_color_set(DW_COLOR_ERROR); |
| 1746 | + dw_printf ("Config file line %d: Unknown rig %d, please check riglist.h.\n", line, rig_model); |
| 1747 | + continue; |
| 1748 | + } |
| 1749 | + |
| 1750 | + strncpy (rig->state.rigport.pathname, port.pathname, FILPATHLEN - 1); |
| 1751 | + n = rig_open(rig); |
| 1752 | + if (n != RIG_OK) { |
| 1753 | + text_color_set(DW_COLOR_ERROR); |
| 1754 | + dw_printf ("Config file line %d: Rig open error %d: %s\n", line, n, rigerror(n)); |
| 1755 | + continue; |
| 1756 | + } |
| 1757 | + |
| 1758 | + p_audio_config->rig[rigs++] = rig; |
| 1759 | + p_audio_config->rigs = rigs; |
| 1760 | + |
| 1761 | +#else |
| 1762 | + text_color_set(DW_COLOR_ERROR); |
| 1763 | + dw_printf ("Config file line %d: RIG is only available when hamlib support is enabled.\n", line); |
| 1764 | + continue; |
| 1765 | +#endif |
| 1766 | + } |
| 1767 | + |
1666 | 1768 | /*
|
1667 | 1769 | * DWAIT - Extra delay for receiver squelch.
|
1668 | 1770 | */
|
|
0 commit comments