[Hamlib-commits] Hamlib -- Ham radio control libraries branch master updated. 99170c10259dbe0b4903c
Library to control radio transceivers and receivers
Brought to you by:
n0nb
From: n0nb <n0...@us...> - 2023-04-05 01:53:27
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "Hamlib -- Ham radio control libraries". The branch, master has been updated via 99170c10259dbe0b4903ce6ce3d47bac623769de (commit) via 3053263c5203d4c1a6c9e3fef59dcc80423a4647 (commit) via 38d685869827a0cdad53a726bc2a51a2015356a7 (commit) via 1ec7dc07ec96aee27ed8c24ea5f72b75cec59646 (commit) via 7236942d89d6f6dca2b163f9073c48c09fd3a7c2 (commit) via c331899d94424bffd4ad4d5b214ad7249f55b08a (commit) via 9d7ac000e5e315b25d484d5bdd109cc026af801d (commit) via 8d407320648445a50b98119aae53ed5081a617b5 (commit) via f11db5c94955b87e7f2f0ce4b935d3d2f851ebed (commit) via bbda209fc0ab7bf1e139b253d165900729e7f4d6 (commit) via 7395ef0e3f1e34ae43f01a4938f021cd3f2c0fde (commit) via 403ec07b6b5c7d68d1382bbf99ed960524e136c3 (commit) via 79db09c201ea25abb07f0c363819f7c4eaab4161 (commit) via 224820fb44c262c9c966becc9afa795c165808cc (commit) via 5aab96beff06f89feacef864eb1d0d107d0a06eb (commit) via d34983f495520e2136f150dd93000f729f3d9d57 (commit) via d522967b320a93bc01529bd0ebb0b3a97f6acc6f (commit) via 692deca638a548d464ba102cc50910531f19bb23 (commit) via 30b2087f5d3b80ce8badf7d860d98908df5a5d59 (commit) via 2db37fe7dbca630a95c2437cd4de8500cd80b838 (commit) via dd75f55b1fcb3ef1e3e9049dfe8af5a4f1e3af67 (commit) via ac197389a2fdd958c6566a3a235fa2aaf4172594 (commit) via 8cce59b048158e92a32a455d1f30b82a968e57fb (commit) via 8cdb21b6f385e36cd3c5381817108cc0435f0b32 (commit) via 7914842c2dfeef3b9cd4e752c404b71b5ce53935 (commit) via 9f960fa5317aa98942d89243e6ecc2c69b92b4ac (commit) via 2712c57058b05723cb5b3ee523755052391c9eab (commit) via d893de407ebac2529709d244b2a1c129790e6691 (commit) via 56907442abd2e86940a0659a2d22e1cd9f01baa0 (commit) via cf956daf17ee0099b9151002ece37ce1d268f911 (commit) via 3254ac70a1583f04b6b165a8d526e930a97c4d93 (commit) via 0f0bbeb612b322f8929385e821c8f6d5689627e7 (commit) via 558747fab36994493aaa12c0fcfa1011aa0cdcb4 (commit) via 4004046d49a6880a0a11a8bcc5e25142c17d25ae (commit) via 26d3e79cf5dc3fbca64a6fd6c68ed58fdcfbaa3c (commit) via 8e24746a3e14d0e3ed78e42d37a5132b99573b1e (commit) via 3c94527fb6a33db6a1f70955bc56e86da6be95d2 (commit) via 38cc75c5681b932809634724ef1adfefb467461d (commit) via 6de5aa78386a493a64eec12bfcc8814c8e9f8dc7 (commit) via 389ee47f76eb83b0b722f4d1a68caa786870b977 (commit) via 113cad3ee179f1260e234c8f3d5d5711295542cc (commit) via 2adf0490842e14c2f10921235e2288ceb75f29e0 (commit) via 0f7908be22cd238921be2a66fc6389b880514e00 (commit) via 5e00bed9cbbaee517260389bb75be114403973a7 (commit) via fd473062d1813a6fc8660a4cd5e305621a7e52c2 (commit) via 18c4eb46315ef44bdf22f5ac7774ba017e186564 (commit) via e022ff2314016d1ec62b00068f28dea22800a25a (commit) via 01a2dd23ed256eeeb190bbf813232a658b28ffc7 (commit) via 51c88e0a6d0d6e3a3d3b73f4217f7adcee6939c6 (commit) via c3e7021c61fbdad5b83360c0bcdfc26945c825fc (commit) via e9979846623935c217c023b26f2057838b3a153d (commit) via b02ff9daa13a578879d5c41ff0e78e88795a7a02 (commit) via c9e2c5f6972cfbd058ba7d03a405c867c72bdf13 (commit) via c3265dc905058ac7133897121d77f634b6d05853 (commit) via 52d41236a72512fc25a2aad289b87691bafb9788 (commit) via 57b7cd1860ce5bb8c46ab686260a5176a5bced7f (commit) via 24a4a094843c5c149be76277a9ab3704b8b097b7 (commit) via e05eb7743b40acaf3bd942ceb1feb86fc2cc985b (commit) via dff890a143c78e2c7e166cad9b826434a07fee36 (commit) via 9823a41f48ba6ff2d622e88afaa160c7ea9a550a (commit) via 8e08385d2dd31912d1face09eb69772d7b7daaa5 (commit) via a64bb4fc7dc4f6f7c0d65e64cab0ec9cbbd3affb (commit) via 631a7a5faa3327cc14df79934788709f8f41a2fc (commit) via 16f03dcdfb80583fcdac0167f4d03cadae71cdcb (commit) via f5c26bf235c24aa7c1f1f02bf11f06a4c96e2dd3 (commit) via 19b2c33e62a5ee71568ad911dd2b33cd97859153 (commit) via 09a6bbf7c7e97d156cef60db9ecf8c3f51426739 (commit) via 77dd85289c6c9e83546d16ad585167b09b031474 (commit) via 94b8e53be97ddbd05ee2df2186846817f494058f (commit) via f17f6f0f42ce99c130618fa02b4e3955a461b622 (commit) via 0e6fd996bc37a3ec1b14f4896569a88ba7601833 (commit) via 6cf65cc0993054d13d41ac750b7102ae23f20a2a (commit) via 2f68033840def43482389a043fc42ead934cd1d8 (commit) via 95196ca96ca9db98f0cf42f2eba9a8a5d819194e (commit) via ec0645780cfc20a252b31ad84429e77e2e1ebe8f (commit) via 0591aee8e6062bf42e088495abcbdd2b58f5c2fb (commit) via edc18103f005f05c0ad5458970b9da7b96c516a1 (commit) via a8aba7c13b523915cfa554f63de0d8140e3a9cdb (commit) via 2622113d2f7069c93546fd81359a29c9bc7d0604 (commit) via 3d4fe8fead62d864f98ba893108cceb0bafee62a (commit) via d06244c47f4dffdf9f47172385c8dfac738c24e2 (commit) via eb5767c0ca2590d51beb92dd73ecaed35c32df51 (commit) via e428d824cdf238dc028ad13f773f22dbd8a96385 (commit) via 126e7dfefd66e06a7b89fbe6c0944d780d9242af (commit) via 9ad9f23fe170b0277a5045fc7510dd645063bea6 (commit) via decc056662ea892cba32cc35a4a3476b7d383124 (commit) via fe1eabf531f23f9057270a68cc18905567c91c05 (commit) via ee7ecc71a1d2a0945e3629e74b40f1fe60da7ddf (commit) via 07fc69f3e8aa34f463f22dd27e8e25aa5573ec3c (commit) via a9b9154a2d721948f124553b1d952a703f1c268a (commit) via 14aa095362c082ab56d4823fc350a37f2f70dc04 (commit) via 00e2797c6fe44ca1941f374d85aae0095da972e4 (commit) via bc476a1c948a85f8b29554c24e1e9fd349afeb79 (commit) via f161ae7b3507e4417ca05f809ae26d7d4199730f (commit) via f5a1dabd06fd43ddcc3cbf1a3965e36e5d9b5b28 (commit) via a9cb12158471a6235f34658ae6fb7ae754e78809 (commit) via 717dae50272e06b66a447ca80c83df93f4f5c349 (commit) via fb12668f066f837f6ded07398e5c49437d8afd4e (commit) via 514d87dcc9b7bf99225336f0885d68b19667657e (commit) via c0030fa01de4aa20e47425b972bf7bff1206a24b (commit) via 10ac497c0b45757ac7da7bbc84381d551380325c (commit) via fef9737a47d0164399987960432803bfad757f1c (commit) via dbd9ff45fa74df614d5402ab2c1d6a315c7af192 (commit) via 3d38f8b214c9f4398f9623a38eb60ee679244baa (commit) via 1edb21a38dd587f665131367e1df7b9daefd910b (commit) via 51712b9a663b45e7d4c19c41a70bf7a977399b03 (commit) via 51d95bb8f794468e2dc5aa1dff4df11a72968729 (commit) via 3f900869917d618c9433f3cf2030c4db737a1f55 (commit) via cdb3a60f023f4164ff070fc7db877869cf3c3724 (commit) via 52be0797d82da0e2c957b100f9fa8f1e31718bab (commit) via 7673abc59b2b3632d58252818a0486bb62d22f98 (commit) via 420125b8bc5bec3e1d6d3cb1dbdab4fe3c156793 (commit) via 72117308663f97bc7ae396a108f6c5ffd51b2258 (commit) via 72e94b6069a2b1d4ca1e16e37c1e869e137761b8 (commit) via 561f65a56dc7f12d879265dc24298389c39fabb7 (commit) via 1213d874480707d6bb78ad2ff3d1ab6fc74c8592 (commit) via d09c048161d42e237e46f2af23d43a48de044dd7 (commit) via b6fe95ae801084f77d53800ba266b04c06ad203b (commit) via b6ec70fcb2c27f747257dc5626463f8963f2e708 (commit) via a04abe6e04d91dc9c3b1c2ffcee76d5c7b1d617c (commit) via 5c170542957f7584ae2be6c5885f21d87e818a2d (commit) via 2e894dd9cc5a3ee91dbeb27607a624ad189b3561 (commit) via 9dbe4ef79a46a9dedc62e5362ce4acf33608d2df (commit) via 58700c6e9f2526ef6f1f0365f76904887542e2be (commit) via 4078fa9248a1080862c7750bee1e9cfe92576fd2 (commit) via 111627533f3c811d4aa8e282271c8019f635f747 (commit) via f9adf5de0a8ab7908bf295f05a3a1ac1ae6a481d (commit) via cbd5f9ad3ea68952fec121705ce43a79723fa63a (commit) via 1e1abaccbc32e1b2c9e7132b17b168cdea13b4d2 (commit) via 907a178aa670d862bc7d158f2b72527e57f8876c (commit) via 73fc563ceb69b842d7e2ceefb856c7a96a8fac45 (commit) via e9724a905823e09627acd2054836ecd2206ce67f (commit) via 321c3660455e718d8b2abe64b5bfb64879e1d4d9 (commit) via cc7c335dc5b3939b6c28c19f3fa8fdf946d47be7 (commit) via c903c09cd1d4942ba413e787fd141af22c36b196 (commit) via b037c72c50422c3b644efdb46569065375814e94 (commit) via 44e8389e0030606d9b786c110e7dffa60f2af9bc (commit) via 0e9bdc5d043906cb07480191209aef5d5c11f166 (commit) via 1efff461e384ff366df35b438e5295531eae0536 (commit) via c055817c27f58fd98d0bdc6b918c9574ad565290 (commit) via 8c0bb2034d34a2cac7187422688d0b349ebfb1f1 (commit) via fa503c5b3bc7f021e938312e9f0893a3d951bf8d (commit) via 61e4e8d6764e04fb0277fda33f414722530f2b16 (commit) via d645bae2074eca68900c1e7917a8322b8fccf5f6 (commit) from fa4a96e6a6c8e2ad4fcb016d6034ebfc91375a1c (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 99170c10259dbe0b4903ce6ce3d47bac623769de Author: Mike Black W9MDB <mdb...@ya...> Date: Thu Mar 30 22:28:09 2023 -0500 Add error message when rig is not turned on that mentions auto_power_on diff --git a/src/rig.c b/src/rig.c index bb0d1ee2..d08616e4 100644 --- a/src/rig.c +++ b/src/rig.c @@ -1280,7 +1280,12 @@ int HAMLIB_API rig_open(RIG *rig) powerstat_t powerflag; status = rig_get_powerstat(rig, &powerflag); - if (status == RIG_OK && powerflag == RIG_POWER_OFF && rig->state.auto_power_on == 0) { return (-RIG_EPOWER); } + if (status == RIG_OK && powerflag == RIG_POWER_OFF && rig->state.auto_power_on == 0) + { + rig_debug(RIG_DEBUG_ERR, "%s: rig power is off, use --set-conf=auto_power_on if power on is wanted\n", __func__); + + return (-RIG_EPOWER); + } // don't need auto_power_on if power is already on if (status == RIG_OK && powerflag == RIG_POWER_ON) { rig->state.auto_power_on = 0; } commit 3053263c5203d4c1a6c9e3fef59dcc80423a4647 Author: Mike Black W9MDB <mdb...@ya...> Date: Wed Mar 29 08:46:05 2023 -0500 Update NEWS diff --git a/NEWS b/NEWS index 25e5eeb6..d407df76 100644 --- a/NEWS +++ b/NEWS @@ -31,6 +31,8 @@ Version 4.6 * Fix FTDX3000 rig split Version 4.5.5 + * Add park to rotorez.c + * Fix rig power on/off from rigctl cmd line and rigctld * Enable async mode by default to prevent WSJT-X crash on IC9700 with transceive on * Fix IC7610 get_powerstat to disable it -- cannot read power status * Fix K3 K22 command error for remote operations @@ -47,7 +49,7 @@ Version 4.5.5 * Add fix for TMD700 * Improve FT-857 get_vfo response when error occurs * Allow FT-857 to use cached vfo on get_vfo when error occurs reading EEPROM - * Fix FTDX10 FT710 set_level AFy + * Fix FTDX10 FT710 set_level AF * Fix FT-450D detection * Fix VFO A/B swapping for gpredict -- hopefully better behavior for VFO swapping rigs Should avoid setting RX freq while TX and avoid TX freq while RX commit 38d685869827a0cdad53a726bc2a51a2015356a7 Author: Mike Black W9MDB <mdb...@ya...> Date: Tue Mar 28 17:23:54 2023 -0500 Progress on Expert ampctl diff --git a/amplifiers/expert/expert.c b/amplifiers/expert/expert.c index 913ac6db..2be064a9 100644 --- a/amplifiers/expert/expert.c +++ b/amplifiers/expert/expert.c @@ -111,7 +111,7 @@ int expert_transaction(AMP *amp, const unsigned char *cmd, int cmd_len, unsigned int loop; char cmdbuf[64]; int checksum=0; - int bytes; + int bytes = 0; rig_debug(RIG_DEBUG_VERBOSE, "%s called, cmd=%s\n", __func__, cmd); @@ -626,9 +626,6 @@ struct expert_priv_data *expert_priv; * Private helper function prototypes */ -//static int kpa1500_send_priv_cmd(AMP *amp, const char *cmd); -//static int kpa1500_flush_buffer(AMP *amp); - /* ************************************* * * Separate model capabilities @@ -643,7 +640,7 @@ struct expert_priv_data *expert_priv; const struct amp_caps expert_amp_caps = { - AMP_MODEL(AMP_MODEL_ELECRAFT_KPA1500), + AMP_MODEL(AMP_MODEL_EXPERT_FA), .model_name = "1.3K-FA/1.5K-FA/2K-FA", .mfg_name = "Expert", .version = "20230320.0", @@ -693,7 +690,7 @@ const struct amp_caps expert_amp_caps = * Send command string to amplifier */ -static int kpa1500_send_priv_cmd(AMP *amp, const char *cmdstr) +static int expert_send_priv_cmd(AMP *amp, const char *cmdstr) { struct amp_state *rs; int err; diff --git a/src/amp_reg.c b/src/amp_reg.c index 98892790..95187c4a 100644 --- a/src/amp_reg.c +++ b/src/amp_reg.c @@ -89,6 +89,7 @@ static struct { AMP_DUMMY, AMP_BACKEND_DUMMY, AMP_FUNCNAMA(dummy) }, { AMP_ELECRAFT, AMP_BACKEND_ELECRAFT, AMP_FUNCNAMA(kpa1500) }, { AMP_GEMINI, AMP_BACKEND_GEMINI, AMP_FUNCNAMA(gemini) }, + { AMP_EXPERT, AMP_BACKEND_EXPERT, AMP_FUNCNAMA(expert) }, { 0, NULL }, /* end */ }; commit 1ec7dc07ec96aee27ed8c24ea5f72b75cec59646 Author: Mike Black W9MDB <mdb...@ya...> Date: Tue Mar 28 17:14:59 2023 -0500 Fix expert_amp_caps diff --git a/amplifiers/expert/expert.c b/amplifiers/expert/expert.c index 212f447a..913ac6db 100644 --- a/amplifiers/expert/expert.c +++ b/amplifiers/expert/expert.c @@ -641,7 +641,7 @@ struct expert_priv_data *expert_priv; * Expert 1.3K-FA, 1.5K-FA, and 2K-FA */ -const struct amp_caps kpa1500_amp_caps = +const struct amp_caps expert_amp_caps = { AMP_MODEL(AMP_MODEL_ELECRAFT_KPA1500), .model_name = "1.3K-FA/1.5K-FA/2K-FA", commit 7236942d89d6f6dca2b163f9073c48c09fd3a7c2 Author: Mike Black W9MDB <mdb...@ya...> Date: Tue Mar 28 17:08:40 2023 -0500 Adding Expert Linear amplifier diff --git a/amplifiers/expert/expert.c b/amplifiers/expert/expert.c index f66256d4..212f447a 100644 --- a/amplifiers/expert/expert.c +++ b/amplifiers/expert/expert.c @@ -23,6 +23,7 @@ #include <string.h> #include "expert.h" #include "register.h" +#include "misc.h" struct fault_list { @@ -102,12 +103,15 @@ int expert_flushbuffer(AMP *amp) return rig_flush(&rs->ampport); } -int expert_transaction(AMP *amp, const char *cmd, char *response, int response_len) +int expert_transaction(AMP *amp, const unsigned char *cmd, int cmd_len, unsigned char *response, int response_len) { struct amp_state *rs; int err; int len = 0; int loop; + char cmdbuf[64]; + int checksum=0; + int bytes; rig_debug(RIG_DEBUG_VERBOSE, "%s called, cmd=%s\n", __func__, cmd); @@ -117,43 +121,35 @@ int expert_transaction(AMP *amp, const char *cmd, char *response, int response_l rs = &->state; - loop = 3; - - do // wake up the amp by sending ; until we receive ; - { - char c = ';'; - rig_debug(RIG_DEBUG_VERBOSE, "%s waiting for ;\n", __func__); - err = write_block(&rs->ampport, (unsigned char *) &c, 1); - - if (err != RIG_OK) { return err; } - - len = read_string(&rs->ampport, (unsigned char *) response, response_len, ";", - 1, 0, 1); - - if (len < 0) { return len; } - } - while (--loop > 0 && (len != 1 || response[0] != ';')); + cmdbuf[0] = cmdbuf[1] = cmdbuf[2] = 0x55; + memcpy(&cmdbuf,cmd,cmd_len); + for(int i=0;i<cmd_len;++i) checksum += cmd[i]; + checksum = checksum % 256; + cmdbuf[3] = cmd_len; + cmdbuf[3+cmd_len+1] = checksum; // Now send our command - err = write_block(&rs->ampport, (unsigned char *) cmd, strlen(cmd)); + err = write_block(&rs->ampport, (unsigned char *) cmdbuf, 3+cmd_len+2); if (err != RIG_OK) { return err; } if (response) // if response expected get it { response[0] = 0; - len = read_string(&rs->ampport, (unsigned char *) response, response_len, ";", - 1, 0, 1); + // read the 4-byte header x55x55x55xXX where XX is the hex # of bytes + len = read_block_direct(&rs->ampport, (unsigned char *) response, 4); + rig_debug(RIG_DEBUG_ERR, "%s: len=%d, bytes=%02x\n", __func__, len, response[3]); if (len < 0) { - rig_debug(RIG_DEBUG_VERBOSE, "%s called, error=%s\n", __func__, + rig_debug(RIG_DEBUG_VERBOSE, "%s: error=%s\n", __func__, rigerror(len)); return len; } - - rig_debug(RIG_DEBUG_VERBOSE, "%s called, response='%s'\n", __func__, - response); + if (len == 4) bytes = response[3]; + rig_debug(RIG_DEBUG_ERR, "%s: bytes=%d\n", __func__, bytes); + len = read_block_direct(&rs->ampport, (unsigned char *) response, bytes-3 ); + dump_hex(response,len); } else // if no response expected try to get one { @@ -208,7 +204,7 @@ int expert_get_freq(AMP *amp, freq_t *freq) if (!amp) { return -RIG_EINVAL; } - retval = expert_transaction(amp, "^FR;", responsebuf, sizeof(responsebuf)); + retval = expert_transaction(amp, NULL,0, NULL, sizeof(responsebuf)); if (retval != RIG_OK) { return retval; } @@ -231,14 +227,14 @@ int expert_set_freq(AMP *amp, freq_t freq) int retval; unsigned long tfreq; int nargs; - char cmd[KPABUFSZ]; + unsigned char cmd[KPABUFSZ]; rig_debug(RIG_DEBUG_VERBOSE, "%s called, freq=%"PRIfreq"\n", __func__, freq); if (!amp) { return -RIG_EINVAL; } - SNPRINTF(cmd, sizeof(cmd), "^FR%05ld;", (long)freq / 1000); - retval = expert_transaction(amp, cmd, NULL, 0); +// SNPRINTF(cmd, sizeof(cmd), "^FR%05ld;", (long)freq / 1000); + retval = expert_transaction(amp, cmd, 0, NULL, 0); if (retval != RIG_OK) { return retval; } @@ -265,7 +261,7 @@ int expert_set_freq(AMP *amp, freq_t freq) int expert_get_level(AMP *amp, setting_t level, value_t *val) { char responsebuf[KPABUFSZ]; - char *cmd; + unsigned char cmd[8]; int retval; int fault; int i; @@ -284,8 +280,8 @@ int expert_get_level(AMP *amp, setting_t level, value_t *val) rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); // get the current antenna selected - cmd = "^AE;"; - retval = expert_transaction(amp, cmd, responsebuf, sizeof(responsebuf)); + cmd[0] = 0x00; + retval = expert_transaction(amp, cmd, 0, NULL, sizeof(responsebuf)); if (retval != RIG_OK) { return retval; } @@ -305,46 +301,46 @@ int expert_get_level(AMP *amp, setting_t level, value_t *val) switch (level) { case AMP_LEVEL_SWR: - cmd = "^SW;"; + cmd[0] = 0x00; break; case AMP_LEVEL_NH: - cmd = "^DF;"; + cmd[0] = 0x00; break; case AMP_LEVEL_PF: - cmd = "^DF;"; + cmd[0] = 0x00; break; case AMP_LEVEL_PWR_INPUT: - cmd = "^PWI;"; + cmd[0] = 0x00; break; case AMP_LEVEL_PWR_FWD: - cmd = "^PWF;"; + cmd[0] = 0x00; break; case AMP_LEVEL_PWR_REFLECTED: - cmd = "^PWR;"; + cmd[0] = 0x00; break; case AMP_LEVEL_PWR_PEAK: - cmd = "^PWK;"; + cmd[0] = 0x00; break; case AMP_LEVEL_FAULT: - cmd = "^SF;"; + cmd[0] = 0x00; break; } - retval = expert_transaction(amp, cmd, responsebuf, sizeof(responsebuf)); + retval = expert_transaction(amp, cmd, 0, NULL, sizeof(responsebuf)); if (retval != RIG_OK) { return retval; } switch (level) { case AMP_LEVEL_SWR: - nargs = sscanf(responsebuf, "^SW%f", &float_value); + //nargs = sscanf(responsebuf, "^SW%f", &float_value); if (nargs != 1) { @@ -358,7 +354,7 @@ int expert_get_level(AMP *amp, setting_t level, value_t *val) case AMP_LEVEL_NH: case AMP_LEVEL_PF: - nargs = sscanf(responsebuf, "^DF%d,%d", &int_value, &int_value2); + //nargs = sscanf(responsebuf, "^DF%d,%d", &int_value, &int_value2); if (nargs != 2) { @@ -407,7 +403,7 @@ int expert_get_level(AMP *amp, setting_t level, value_t *val) case AMP_LEVEL_PWR_INPUT: - cmd = "^PWI;"; + cmd[0] = 0x00; nargs = sscanf(responsebuf, "^SW%d", &pwrinput); if (nargs != 1) @@ -423,7 +419,7 @@ int expert_get_level(AMP *amp, setting_t level, value_t *val) break; case AMP_LEVEL_PWR_FWD: - cmd = "^PWF;"; + cmd[0] = 0x00; nargs = sscanf(responsebuf, "^SW%d", &pwrfwd); if (nargs != 1) @@ -439,7 +435,7 @@ int expert_get_level(AMP *amp, setting_t level, value_t *val) break; case AMP_LEVEL_PWR_REFLECTED: - cmd = "^PWR;"; + cmd[0] = 0x00; nargs = sscanf(responsebuf, "^SW%d", &pwrref); if (nargs != 1) @@ -455,7 +451,7 @@ int expert_get_level(AMP *amp, setting_t level, value_t *val) break; case AMP_LEVEL_PWR_PEAK: - cmd = "^PWK;"; + cmd[0] = 0x00; nargs = sscanf(responsebuf, "^SW%d", &pwrpeak); if (nargs != 1) @@ -471,7 +467,7 @@ int expert_get_level(AMP *amp, setting_t level, value_t *val) break; case AMP_LEVEL_FAULT: - cmd = "^SF;"; + cmd[0] = 0x00; nargs = sscanf(responsebuf, "^SW%d", &fault); if (nargs != 1) @@ -509,11 +505,11 @@ int expert_get_level(AMP *amp, setting_t level, value_t *val) int expert_get_powerstat(AMP *amp, powerstat_t *status) { - char responsebuf[KPABUFSZ]; + unsigned char responsebuf[KPABUFSZ]; int retval; - int operate; - int ampon; - int nargs; + int operate = 0; + int ampon = 0; + int nargs = 0; rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); @@ -522,11 +518,11 @@ int expert_get_powerstat(AMP *amp, powerstat_t *status) if (!amp) { return -RIG_EINVAL; } - retval = expert_transaction(amp, "^ON;", responsebuf, sizeof(responsebuf)); + retval = expert_transaction(amp, NULL, 0, responsebuf, sizeof(responsebuf)); if (retval != RIG_OK) { return retval; } - nargs = sscanf(responsebuf, "^ON%d", &on); + //nargs = sscanf(responsebuf, "^ON%d", &on); if (nargs != 1) { @@ -547,11 +543,11 @@ int expert_get_powerstat(AMP *amp, powerstat_t *status) return -RIG_EPROTO; } - retval = expert_transaction(amp, "^OP;", responsebuf, sizeof(responsebuf)); + retval = expert_transaction(amp, NULL, 0, responsebuf, sizeof(responsebuf)); if (retval != RIG_OK) { return retval; } - nargs = sscanf(responsebuf, "^ON%d", &operate); + //nargs = sscanf(responsebuf, "^ON%d", &operate); if (nargs != 1) { @@ -568,7 +564,8 @@ int expert_get_powerstat(AMP *amp, powerstat_t *status) int expert_set_powerstat(AMP *amp, powerstat_t status) { int retval; - char *cmd = NULL; + unsigned char cmd[8]; + int cmd_len = 1; rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); @@ -578,13 +575,13 @@ int expert_set_powerstat(AMP *amp, powerstat_t status) { case RIG_POWER_UNKNOWN: break; - case RIG_POWER_OFF: cmd = "^ON0;"; break; + case RIG_POWER_OFF: cmd[0] = 0x0a; break; - case RIG_POWER_ON: cmd = "^ON1;"; break; + case RIG_POWER_ON: cmd[0] = 0x0b; break; - case RIG_POWER_OPERATE: cmd = "^OS1;"; break; + case RIG_POWER_OPERATE: cmd[0] = 0x0d; break; - case RIG_POWER_STANDBY: cmd = "^OS0;"; break; + case RIG_POWER_STANDBY: cmd[0] = 0x0a; break; default: @@ -592,7 +589,7 @@ int expert_set_powerstat(AMP *amp, powerstat_t status) } - retval = expert_transaction(amp, cmd, NULL, 0); + retval = expert_transaction(amp, cmd, cmd_len, NULL, 0); if (retval != RIG_OK) { return retval; } diff --git a/amplifiers/expert/expert.h b/amplifiers/expert/expert.h index f8ef1de8..d2fdb4f3 100644 --- a/amplifiers/expert/expert.h +++ b/amplifiers/expert/expert.h @@ -48,7 +48,7 @@ int expert_init(AMP *amp); int expert_close(AMP *amp); int expert_reset(AMP *amp, amp_reset_t reset); int expert_flush_buffer(AMP *amp); -int expert_transaction(AMP *amp, const char *cmd, char *response, +int expert_transaction(AMP *amp, const unsigned char *cmd, int cmd_len, unsigned char *response, int response_len); const char *expert_get_info(AMP *amp); int expert_get_freq(AMP *amp, freq_t *freq); diff --git a/configure.ac b/configure.ac index 92ce17f8..e07bc085 100644 --- a/configure.ac +++ b/configure.ac @@ -52,7 +52,7 @@ dnl here but will be added later, e.g. "winradio". RIG_BACKEND_LIST="rigs/adat rigs/alinco rigs/aor rigs/barrett rigs/codan rigs/dorji rigs/drake rigs/dummy rigs/elad rigs/flexradio rigs/icom rigs/icmarine rigs/jrc rigs/kachina rigs/kenwood rigs/kit rigs/lowe rigs/pcr rigs/prm80 rigs/racal rigs/rft rigs/rs rigs/skanti rigs/tapr rigs/tentec rigs/tuner rigs/uniden rigs/winradio rigs/wj rigs/yaesu rigs/gomspace rigs/mds" ROT_BACKEND_LIST="rotators/amsat rotators/apex rotators/ars rotators/celestron rotators/cnctrk rotators/grbltrk rotators/easycomm rotators/ether6 rotators/flir rotators/fodtrack rotators/gs232a rotators/heathkit rotators/m2 rotators/meade rotators/rotorez rotators/sartek rotators/saebrtrack rotators/spid rotators/ts7400 rotators/prosistel rotators/ioptron rotators/satel rotators/radant" # Amplifiers are all in the amplifiers directory -AMP_BACKEND_LIST="amplifiers/elecraft amplifiers/gemini" +AMP_BACKEND_LIST="amplifiers/elecraft amplifiers/gemini amplifiers/expert" dnl See README.release on setting these values # Values given to -version-info when linking. See libtool documentation. @@ -907,6 +907,7 @@ scripts/Makefile android/Makefile amplifiers/elecraft/Makefile amplifiers/gemini/Makefile +amplifiers/expert/Makefile simulators/Makefile hamlib.pc ]) diff --git a/include/hamlib/amplist.h b/include/hamlib/amplist.h index 3e954c86..4122062c 100644 --- a/include/hamlib/amplist.h +++ b/include/hamlib/amplist.h @@ -106,10 +106,15 @@ //! @endcond #define AMP_MODEL_ELECRAFT_KPA1500 AMP_MAKE_MODEL(AMP_ELECRAFT, 1) //#define AMP_MODEL_ELECRAFT_KPA500 AMP_MAKE_MODEL(AMP_ELECRAFT, 2) + #define AMP_GEMINI 3 #define AMP_BACKEND_GEMINI "gemini" #define AMP_MODEL_GEMINI_DX1200 AMP_MAKE_MODEL(AMP_GEMINI, 1) +#define AMP_EXPERT 4 +#define AMP_BACKEND_EXPERT "expert" +#define AMP_MODEL_EXPERT_FA AMP_MAKE_MODEL(AMP_EXPERT, 1) + /** * \brief Convenience type definition for an amplifier model. diff --git a/src/amp_reg.c b/src/amp_reg.c index 998a58ff..98892790 100644 --- a/src/amp_reg.c +++ b/src/amp_reg.c @@ -65,6 +65,7 @@ DEFINE_INITAMP_BACKEND(dummy); DEFINE_INITAMP_BACKEND(kpa1500); DEFINE_INITAMP_BACKEND(gemini); +DEFINE_INITAMP_BACKEND(expert); //! @endcond /** commit c331899d94424bffd4ad4d5b214ad7249f55b08a Author: Mike Black W9MDB <mdb...@ya...> Date: Tue Mar 28 15:57:24 2023 -0500 Fix expert in rotators/Android.mk diff --git a/amplifiers/expert/Android.mk b/amplifiers/expert/Android.mk index 57d2dd17..502f300f 100644 --- a/amplifiers/expert/Android.mk +++ b/amplifiers/expert/Android.mk @@ -3,7 +3,7 @@ LOCAL_PATH:= $(call my-dir) include $(CLEAR_VARS) LOCAL_SRC_FILES := expert.c -LOCAL_MODULE := expoert +LOCAL_MODULE := expert LOCAL_CFLAGS := LOCAL_C_INCLUDES := android include src commit 9d7ac000e5e315b25d484d5bdd109cc026af801d Merge: f11db5c9 8d407320 Author: Michael Black <mdb...@ya...> Date: Tue Mar 28 14:25:11 2023 -0500 Merge pull request #1265 from dforsi/fix/duplicated-initializers Fix initializer-overrides warnings by clang commit 8d407320648445a50b98119aae53ed5081a617b5 Author: Daniele Forsi IU5HKX <iu...@gm...> Date: Tue Mar 28 19:49:01 2023 +0200 Fix initializer-overrides warnings by clang Fixes: dx77.c:225:5: warning: initializer overrides prior initialization of this subobject [-Winitializer-overrides] { ^ dx77.c:217:23: note: previous initialization is here .tx_range_list2 = {RIG_FRNG_END,}, ^~~~~~~~~~~~~~~ ft991.c:356:27: warning: initializer overrides prior initialization of this subobject [-Winitializer-overrides] .scan = newcat_scan, ^~~~~~~~~~~ ft991.c:352:27: note: previous initialization is here .scan = newcat_scan, ^~~~~~~~~~~ diff --git a/rigs/alinco/dx77.c b/rigs/alinco/dx77.c index baa5a448..870bc83b 100644 --- a/rigs/alinco/dx77.c +++ b/rigs/alinco/dx77.c @@ -214,7 +214,6 @@ const struct rig_caps dx77_caps = RIG_FRNG_END, }, .tx_range_list1 = {RIG_FRNG_END,}, - .tx_range_list2 = {RIG_FRNG_END,}, .rx_range_list2 = { diff --git a/rigs/yaesu/ft991.c b/rigs/yaesu/ft991.c index 2191d59b..69206e60 100644 --- a/rigs/yaesu/ft991.c +++ b/rigs/yaesu/ft991.c @@ -353,7 +353,6 @@ const struct rig_caps ft991_caps = .send_voice_mem = newcat_send_voice_mem, .set_clock = newcat_set_clock, .get_clock = newcat_get_clock, - .scan = newcat_scan, .hamlib_check_rig_caps = HAMLIB_CHECK_RIG_CAPS }; commit f11db5c94955b87e7f2f0ce4b935d3d2f851ebed Merge: bbda209f 7395ef0e Author: Mike Black W9MDB <mdb...@ya...> Date: Tue Mar 28 11:53:30 2023 -0500 Merge branch 'master' of https://github.com/Hamlib/Hamlib commit bbda209fc0ab7bf1e139b253d165900729e7f4d6 Author: Mike Black W9MDB <mdb...@ya...> Date: Tue Mar 28 11:52:26 2023 -0500 Add park to rotorez https://github.com/Hamlib/Hamlib/issues/1257 diff --git a/amplifiers/expert/Android.mk b/amplifiers/expert/Android.mk new file mode 100644 index 00000000..57d2dd17 --- /dev/null +++ b/amplifiers/expert/Android.mk @@ -0,0 +1,12 @@ +LOCAL_PATH:= $(call my-dir) + +include $(CLEAR_VARS) + +LOCAL_SRC_FILES := expert.c +LOCAL_MODULE := expoert + +LOCAL_CFLAGS := +LOCAL_C_INCLUDES := android include src +LOCAL_LDLIBS := -lhamlib + +include $(BUILD_STATIC_LIBRARY) diff --git a/amplifiers/expert/Makefile.am b/amplifiers/expert/Makefile.am new file mode 100644 index 00000000..2733ef26 --- /dev/null +++ b/amplifiers/expert/Makefile.am @@ -0,0 +1,8 @@ +SRC = expert.c + +EXPERTSRC = expert.h + +noinst_LTLIBRARIES = libhamlib-expert.la +libhamlib_expert_la_SOURCES = $(SRC) $(EXPERTSRC) + +EXTRA_DIST = README.expert Android.mk diff --git a/amplifiers/expert/README.expert b/amplifiers/expert/README.expert new file mode 100644 index 00000000..331bc178 --- /dev/null +++ b/amplifiers/expert/README.expert @@ -0,0 +1,7 @@ +hamlib - Copyright (C) 2023 The Hamlib Group + +File: README.expert + +Notes on Expert backends + +2023-03-20 Initial prototype for Expert amplifiers diff --git a/amplifiers/expert/expert.c b/amplifiers/expert/expert.c new file mode 100644 index 00000000..f66256d4 --- /dev/null +++ b/amplifiers/expert/expert.c @@ -0,0 +1,734 @@ +/* + * Hamlib Expert amplifier backend - low level communication routines + * Copyright (c) 2023 by Michael Black W9MDB + * + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + */ + +#include <stdlib.h> +#include <string.h> +#include "expert.h" +#include "register.h" + +struct fault_list +{ + int code; + char *errmsg; +}; +const struct fault_list expert_fault_list [] = +{ + {0, "No fault condition"}, + {0x10, "Watchdog Timer was reset"}, + {0x20, "PA Current is too high"}, + {0x40, "Temperature is too high"}, + {0x60, "Input power is too high"}, + {0x61, "Gain is too low"}, + {0x70, "Invalid frequency"}, + {0x80, "50V supply voltage too low or too high"}, + {0x81, "5V supply voltage too low or too high"}, + {0x82, "10V supply voltage too low or too high"}, + {0x83, "12V supply voltage too low or too high"}, + {0x84, "-12V supply voltage too low or too high"}, + {0x85, "5V or 400V LPF board supply voltages not detected"}, + {0x90, "Reflected power is too high"}, + {0x91, "SWR very high"}, + {0x92, "ATU no match"}, + {0xB0, "Dissipated power too high"}, + {0xC0, "Forward power too high"}, + {0xE0, "Forward power too high for current setting"}, + {0xF0, "Gain is too high"}, + {0, NULL} +}; + +/* + * Initialize data structures + */ + +int expert_init(AMP *amp) +{ + rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); + + if (!amp) + { + return -RIG_EINVAL; + } + + amp->state.priv = (struct expert_priv_data *) + calloc(1, sizeof(struct expert_priv_data)); + + if (!amp->state.priv) + { + return -RIG_ENOMEM; + } + + amp->state.ampport.type.rig = RIG_PORT_SERIAL; + + return RIG_OK; +} + +int expert_close(AMP *amp) +{ + rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); + + if (amp->state.priv) { free(amp->state.priv); } + + amp->state.priv = NULL; + + return RIG_OK; +} + +int expert_flushbuffer(AMP *amp) +{ + struct amp_state *rs; + + rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); + + rs = &->state; + + return rig_flush(&rs->ampport); +} + +int expert_transaction(AMP *amp, const char *cmd, char *response, int response_len) +{ + struct amp_state *rs; + int err; + int len = 0; + int loop; + + rig_debug(RIG_DEBUG_VERBOSE, "%s called, cmd=%s\n", __func__, cmd); + + if (!amp) { return -RIG_EINVAL; } + + expert_flushbuffer(amp); + + rs = &->state; + + loop = 3; + + do // wake up the amp by sending ; until we receive ; + { + char c = ';'; + rig_debug(RIG_DEBUG_VERBOSE, "%s waiting for ;\n", __func__); + err = write_block(&rs->ampport, (unsigned char *) &c, 1); + + if (err != RIG_OK) { return err; } + + len = read_string(&rs->ampport, (unsigned char *) response, response_len, ";", + 1, 0, 1); + + if (len < 0) { return len; } + } + while (--loop > 0 && (len != 1 || response[0] != ';')); + + // Now send our command + err = write_block(&rs->ampport, (unsigned char *) cmd, strlen(cmd)); + + if (err != RIG_OK) { return err; } + + if (response) // if response expected get it + { + response[0] = 0; + len = read_string(&rs->ampport, (unsigned char *) response, response_len, ";", + 1, 0, 1); + + if (len < 0) + { + rig_debug(RIG_DEBUG_VERBOSE, "%s called, error=%s\n", __func__, + rigerror(len)); + return len; + } + + rig_debug(RIG_DEBUG_VERBOSE, "%s called, response='%s'\n", __func__, + response); + } + else // if no response expected try to get one + { + char responsebuf[KPABUFSZ]; + responsebuf[0] = 0; + loop = 3; + + do + { + char c = ';'; + rig_debug(RIG_DEBUG_VERBOSE, "%s waiting for ;\n", __func__); + err = write_block(&rs->ampport, (unsigned char *) &c, 1); + + if (err != RIG_OK) { return err; } + + len = read_string(&rs->ampport, (unsigned char *) responsebuf, KPABUFSZ, ";", 1, + 0, 1); + + if (len < 0) { return len; } + } + while (--loop > 0 && (len != 1 || responsebuf[0] != ';')); + } + + return RIG_OK; +} + +/* + * Get Info + * returns the model name string + */ +const char *expert_get_info(AMP *amp) +{ + const struct amp_caps *rc; + + rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); + + if (!amp) { return (const char *) - RIG_EINVAL; } + + rc = amp->caps; + + return rc->model_name; +} + +int expert_get_freq(AMP *amp, freq_t *freq) +{ + char responsebuf[KPABUFSZ]; + int retval; + unsigned long tfreq; + int nargs; + + rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); + + if (!amp) { return -RIG_EINVAL; } + + retval = expert_transaction(amp, "^FR;", responsebuf, sizeof(responsebuf)); + + if (retval != RIG_OK) { return retval; } + + nargs = sscanf(responsebuf, "^FR%lu", &tfreq); + + if (nargs != 1) + { + rig_debug(RIG_DEBUG_VERBOSE, "%s Error: ^FR response='%s'\n", __func__, + responsebuf); + return -RIG_EPROTO; + } + + *freq = tfreq * 1000; + return RIG_OK; +} + +int expert_set_freq(AMP *amp, freq_t freq) +{ + char responsebuf[KPABUFSZ]; + int retval; + unsigned long tfreq; + int nargs; + char cmd[KPABUFSZ]; + + rig_debug(RIG_DEBUG_VERBOSE, "%s called, freq=%"PRIfreq"\n", __func__, freq); + + if (!amp) { return -RIG_EINVAL; } + + SNPRINTF(cmd, sizeof(cmd), "^FR%05ld;", (long)freq / 1000); + retval = expert_transaction(amp, cmd, NULL, 0); + + if (retval != RIG_OK) { return retval; } + + nargs = sscanf(responsebuf, "^FR%lu", &tfreq); + + if (nargs != 1) + { + rig_debug(RIG_DEBUG_ERR, "%s Error: ^FR response='%s'\n", __func__, + responsebuf); + return -RIG_EPROTO; + } + + if (tfreq * 1000 != freq) + { + rig_debug(RIG_DEBUG_ERR, + "%s Error setting freq: ^FR freq!=freq2, %f=%lu '%s'\n", __func__, + freq, tfreq * 1000, responsebuf); + return -RIG_EPROTO; + } + + return RIG_OK; +} + +int expert_get_level(AMP *amp, setting_t level, value_t *val) +{ + char responsebuf[KPABUFSZ]; + char *cmd; + int retval; + int fault; + int i; + int nargs; + int antenna; + int pwrpeak; + int pwrref; + int pwrfwd; + int pwrinput; + float float_value = 0; + int int_value = 0, int_value2 = 0; + struct amp_state *rs = &->state; + struct expert_priv_data *priv = amp->state.priv; + + + rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); + + // get the current antenna selected + cmd = "^AE;"; + retval = expert_transaction(amp, cmd, responsebuf, sizeof(responsebuf)); + + if (retval != RIG_OK) { return retval; } + + antenna = 0; + nargs = sscanf(responsebuf, "^AE%d", &antenna); + + if (nargs != 1) + { + rig_debug(RIG_DEBUG_ERR, "%s: invalid value %s='%s'\n", __func__, cmd, + responsebuf); + return -RIG_EPROTO; + } + + rig_debug(RIG_DEBUG_VERBOSE, "%s: cmd=%s, antenna=%d\n", __func__, cmd, + antenna); + + switch (level) + { + case AMP_LEVEL_SWR: + cmd = "^SW;"; + break; + + case AMP_LEVEL_NH: + cmd = "^DF;"; + break; + + case AMP_LEVEL_PF: + cmd = "^DF;"; + break; + + case AMP_LEVEL_PWR_INPUT: + cmd = "^PWI;"; + break; + + case AMP_LEVEL_PWR_FWD: + cmd = "^PWF;"; + break; + + case AMP_LEVEL_PWR_REFLECTED: + cmd = "^PWR;"; + break; + + case AMP_LEVEL_PWR_PEAK: + cmd = "^PWK;"; + break; + + case AMP_LEVEL_FAULT: + cmd = "^SF;"; + break; + } + + retval = expert_transaction(amp, cmd, responsebuf, sizeof(responsebuf)); + + if (retval != RIG_OK) { return retval; } + + switch (level) + { + case AMP_LEVEL_SWR: + nargs = sscanf(responsebuf, "^SW%f", &float_value); + + if (nargs != 1) + { + rig_debug(RIG_DEBUG_ERR, "%s invalid value %s='%s'\n", __func__, cmd, + responsebuf); + return -RIG_EPROTO; + } + + val->f = float_value / 10.0f; + return RIG_OK; + + case AMP_LEVEL_NH: + case AMP_LEVEL_PF: + nargs = sscanf(responsebuf, "^DF%d,%d", &int_value, &int_value2); + + if (nargs != 2) + { + rig_debug(RIG_DEBUG_ERR, "%s invalid value %s='%s'\n", __func__, cmd, + responsebuf); + return -RIG_EPROTO; + } + + rig_debug(RIG_DEBUG_VERBOSE, "%s freq range=%dKHz,%dKHz\n", __func__, + int_value, int_value2); + + // + do + { + retval = read_string(&rs->ampport, (unsigned char *) responsebuf, + sizeof(responsebuf), ";", 1, 0, + 1); + + if (retval != RIG_OK) { return retval; } + + if (strstr(responsebuf, "BYPASS") != 0) + { + int antenna2 = 0; + nargs = sscanf(responsebuf, "AN%d Side TX %d %*s %*s %d", &antenna2, &int_value, + &int_value2); + rig_debug(RIG_DEBUG_VERBOSE, "%s response='%s'\n", __func__, responsebuf); + + if (nargs != 3) + { + rig_debug(RIG_DEBUG_ERR, "%s invalid value %s='%s'\n", __func__, cmd, + responsebuf); + return -RIG_EPROTO; + } + + rig_debug(RIG_DEBUG_VERBOSE, "%s antenna=%d,nH=%d\n", __func__, antenna2, + int_value); + + val->i = level == AMP_LEVEL_NH ? int_value : int_value2; + return RIG_OK; + } + } + while (strstr(responsebuf, "BYPASS")); + + + break; + + + case AMP_LEVEL_PWR_INPUT: + cmd = "^PWI;"; + nargs = sscanf(responsebuf, "^SW%d", &pwrinput); + + if (nargs != 1) + { + rig_debug(RIG_DEBUG_ERR, "%s invalid value %s='%s'\n", __func__, cmd, + responsebuf); + return -RIG_EPROTO; + } + + val->i = pwrinput; + return RIG_OK; + + break; + + case AMP_LEVEL_PWR_FWD: + cmd = "^PWF;"; + nargs = sscanf(responsebuf, "^SW%d", &pwrfwd); + + if (nargs != 1) + { + rig_debug(RIG_DEBUG_ERR, "%s invalid value %s='%s'\n", __func__, cmd, + responsebuf); + return -RIG_EPROTO; + } + + val->i = pwrfwd; + return RIG_OK; + + break; + + case AMP_LEVEL_PWR_REFLECTED: + cmd = "^PWR;"; + nargs = sscanf(responsebuf, "^SW%d", &pwrref); + + if (nargs != 1) + { + rig_debug(RIG_DEBUG_ERR, "%s invalid value %s='%s'\n", __func__, cmd, + responsebuf); + return -RIG_EPROTO; + } + + val->i = pwrref; + return RIG_OK; + + break; + + case AMP_LEVEL_PWR_PEAK: + cmd = "^PWK;"; + nargs = sscanf(responsebuf, "^SW%d", &pwrpeak); + + if (nargs != 1) + { + rig_debug(RIG_DEBUG_ERR, "%s invalid value %s='%s'\n", __func__, cmd, + responsebuf); + return -RIG_EPROTO; + } + + val->i = pwrpeak; + return RIG_OK; + + break; + + case AMP_LEVEL_FAULT: + cmd = "^SF;"; + nargs = sscanf(responsebuf, "^SW%d", &fault); + + if (nargs != 1) + { + rig_debug(RIG_DEBUG_ERR, "%s invalid value %s='%s'\n", __func__, cmd, + responsebuf); + return -RIG_EPROTO; + } + + for (i = 0; expert_fault_list[i].errmsg != NULL; ++i) + { + if (expert_fault_list[i].code == fault) + { + val->s = expert_fault_list[i].errmsg; + return RIG_OK; + } + } + + rig_debug(RIG_DEBUG_ERR, "%s unknown fault from %s\n", __func__, responsebuf); + SNPRINTF(priv->tmpbuf, sizeof(priv->tmpbuf), "Unknown fault code=0x%02x", + fault); + val->s = priv->tmpbuf; + return RIG_OK; + + break; + + default: + rig_debug(RIG_DEBUG_ERR, "%s unknown level=%s\n", __func__, + rig_strlevel(level)); + + } + + return -RIG_EINVAL; +} + +int expert_get_powerstat(AMP *amp, powerstat_t *status) +{ + char responsebuf[KPABUFSZ]; + int retval; + int operate; + int ampon; + int nargs; + + + rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); + + *status = RIG_POWER_UNKNOWN; + + if (!amp) { return -RIG_EINVAL; } + + retval = expert_transaction(amp, "^ON;", responsebuf, sizeof(responsebuf)); + + if (retval != RIG_OK) { return retval; } + + nargs = sscanf(responsebuf, "^ON%d", &on); + + if (nargs != 1) + { + rig_debug(RIG_DEBUG_VERBOSE, "%s Error: ^ON response='%s'\n", __func__, + responsebuf); + return -RIG_EPROTO; + } + + switch (ampon) + { + case 0: *status = RIG_POWER_OFF; return RIG_OK; + + case 1: *status = RIG_POWER_ON; break; + + default: + rig_debug(RIG_DEBUG_VERBOSE, "%s Error: ^ON unknown response='%s'\n", __func__, + responsebuf); + return -RIG_EPROTO; + } + + retval = expert_transaction(amp, "^OP;", responsebuf, sizeof(responsebuf)); + + if (retval != RIG_OK) { return retval; } + + nargs = sscanf(responsebuf, "^ON%d", &operate); + + if (nargs != 1) + { + rig_debug(RIG_DEBUG_VERBOSE, "%s Error: ^ON response='%s'\n", __func__, + responsebuf); + return -RIG_EPROTO; + } + + *status = operate == 1 ? RIG_POWER_OPERATE : RIG_POWER_STANDBY; + + return RIG_OK; +} + +int expert_set_powerstat(AMP *amp, powerstat_t status) +{ + int retval; + char *cmd = NULL; + + rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); + + if (!amp) { return -RIG_EINVAL; } + + switch (status) + { + case RIG_POWER_UNKNOWN: break; + + case RIG_POWER_OFF: cmd = "^ON0;"; break; + + case RIG_POWER_ON: cmd = "^ON1;"; break; + + case RIG_POWER_OPERATE: cmd = "^OS1;"; break; + + case RIG_POWER_STANDBY: cmd = "^OS0;"; break; + + + default: + rig_debug(RIG_DEBUG_ERR, "%s invalid status=%d\n", __func__, status); + + } + + retval = expert_transaction(amp, cmd, NULL, 0); + + if (retval != RIG_OK) { return retval; } + + return RIG_OK; +} + +int expert_reset(AMP *amp, amp_reset_t reset) +{ + int retval; + + rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); + + // toggling from standby to operate supposed to reset + retval = expert_set_powerstat(amp, RIG_POWER_STANDBY); + + if (retval != RIG_OK) + { + rig_debug(RIG_DEBUG_ERR, "%s: error setting RIG_POWER_STANDBY '%s'\n", __func__, + strerror(retval)); + + } + + return expert_set_powerstat(amp, RIG_POWER_OPERATE); +} + + +struct expert_priv_data *expert_priv; +/* + * API local implementation + * + */ + +/* + * Private helper function prototypes + */ + +//static int kpa1500_send_priv_cmd(AMP *amp, const char *cmd); +//static int kpa1500_flush_buffer(AMP *amp); + +/* ************************************* + * + * Separate model capabilities + * + * ************************************* + */ + + +/* + * Expert 1.3K-FA, 1.5K-FA, and 2K-FA + */ + +const struct amp_caps kpa1500_amp_caps = +{ + AMP_MODEL(AMP_MODEL_ELECRAFT_KPA1500), + .model_name = "1.3K-FA/1.5K-FA/2K-FA", + .mfg_name = "Expert", + .version = "20230320.0", + .copyright = "LGPL", + .status = RIG_STATUS_ALPHA, + .amp_type = AMP_TYPE_OTHER, + .port_type = RIG_PORT_SERIAL, + .serial_rate_min = 9600, + .serial_rate_max = 115200, + .serial_data_bits = 8, + .serial_stop_bits = 1, + .serial_parity = RIG_PARITY_NONE, + .serial_handshake = RIG_HANDSHAKE_NONE, + .write_delay = 0, + .post_write_delay = 0, + .timeout = 2000, + .retry = 2, + .has_get_level = AMP_LEVEL_SWR | AMP_LEVEL_NH | AMP_LEVEL_PF | AMP_LEVEL_PWR_INPUT | AMP_LEVEL_PWR_FWD | AMP_LEVEL_PWR_REFLECTED | AMP_LEVEL_FAULT, + .has_set_level = 0, + + .amp_open = NULL, + .amp_init = expert_init, + .amp_close = expert_close, + .reset = expert_reset, + .get_info = expert_get_info, + .get_powerstat = expert_get_powerstat, + .set_powerstat = expert_set_powerstat, + .set_freq = expert_set_freq, + .get_freq = expert_get_freq, + .get_level = expert_get_level, +}; + + +/* ************************************ + * + * API functions + * + * ************************************ + */ + +/* + * + */ + +#if 0 // not implemented yet +/* + * Send command string to amplifier + */ + +static int kpa1500_send_priv_cmd(AMP *amp, const char *cmdstr) +{ + struct amp_state *rs; + int err; + + rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); + + if (!amp) + { + return -RIG_EINVAL; + } + + rs = &->state; + err = write_block(&rs->ampport, cmdstr, strlen(cmdstr)); + + if (err != RIG_OK) + { + return err; + } + + return RIG_OK; +} +#endif + +/* + * Initialize backend + */ + +DECLARE_INITAMP_BACKEND(expert) +{ + rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); + + amp_register(&expert_amp_caps); + + return RIG_OK; +} diff --git a/amplifiers/expert/expert.h b/amplifiers/expert/expert.h new file mode 100644 index 00000000..f8ef1de8 --- /dev/null +++ b/amplifiers/expert/expert.h @@ -0,0 +1,62 @@ +/* + * Hamlib backend library for the Expert amplifier set. + * + * expert.h - (C) Michael Black W9MDB 2023 + * + * This shared library provides an API for communicating + * via serial interface to Expert amplifiers. + * + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + */ + +#ifndef _AMP_EXPERT_H +#define _AMP_EXPERT_H 1 + +#include <hamlib/amplifier.h> +#include <iofunc.h> +#include <serial.h> + +// Is this big enough? +#define KPABUFSZ 100 + +extern const struct amp_caps expert_amp_caps; + +/* + * Private data structure + */ +struct expert_priv_data +{ + char tmpbuf[256]; // for unknown error msg +}; + + +int expert_init(AMP *amp); +int expert_close(AMP *amp); +int expert_reset(AMP *amp, amp_reset_t reset); +int expert_flush_buffer(AMP *amp); +int expert_transaction(AMP *amp, const char *cmd, char *response, + int response_len); +const char *expert_get_info(AMP *amp); +int expert_get_freq(AMP *amp, freq_t *freq); +int expert_set_freq(AMP *amp, freq_t freq); + +int expert_get_level(AMP *amp, setting_t level, value_t *val); +int expert_get_powerstat(AMP *amp, powerstat_t *status); +int expert_set_powerstat(AMP *amp, powerstat_t status); + +#endif /* _AMP_EXPERT_H */ + diff --git a/rotators/rotorez/rotorez.c b/rotators/rotorez/rotorez.c index 6867acea..6411a3ad 100644 --- a/rotators/rotorez/rotorez.c +++ b/rotators/rotorez/rotorez.c @@ -55,6 +55,7 @@ static int rotorez_rot_set_position(ROT *rot, azimuth_t azimuth, elevation_t elevation); static int rotorez_rot_get_position(ROT *rot, azimuth_t *azimuth, elevation_t *elevation); +static int rotorez_park(ROT *rot); static int erc_rot_get_position(ROT *rot, azimuth_t *azimuth, elevation_t *elevation); static int rt21_rot_get_position(ROT *rot, azimuth_t *azimuth, @@ -129,7 +130,7 @@ const struct rot_caps rotorez_rot_caps = ROT_MODEL(ROT_MODEL_ROTOREZ), .model_name = "Rotor-EZ", .mfg_name = "Idiom Press", - .version = "20220109.0", + .version = "20230328.0", .copyright = "LGPL", .status = RIG_STATUS_STABLE, .rot_type = ROT_TYPE_OTHER, @@ -157,6 +158,7 @@ const struct rot_caps rotorez_rot_caps = .rot_cleanup = rotorez_rot_cleanup, .set_position = rotorez_rot_set_position, .get_position = rotorez_rot_get_position, + .park = rotorez_park, .stop = rotorez_rot_stop, .set_conf = rotorez_rot_set_conf, .get_info = rotorez_rot_get_info, @@ -174,7 +176,7 @@ const struct rot_caps rotorcard_rot_caps = ROT_MODEL(ROT_MODEL_ROTORCARD), .model_name = "RotorCard", .mfg_name = "Idiom Press", - .version = "20100214.0", + .version = "20230328.0", .copyright = "LGPL", .status = RIG_STATUS_BETA, .rot_type = ROT_TYPE_OTHER, @@ -202,6 +204,7 @@ const struct rot_caps rotorcard_rot_caps = .rot_cleanup = rotorez_rot_cleanup, .set_position = rotorez_rot_set_position, .get_position = rotorez_rot_get_position, + .park = rotorez_park, .stop = rotorez_rot_stop, .set_conf = rotorez_rot_set_conf, .get_info = rotorez_rot_get_info, @@ -218,7 +221,7 @@ const struct rot_caps dcu_rot_caps = ROT_MODEL(ROT_MODEL_DCU), .model_name = "DCU-1/DCU-1X", .mfg_name = "Hy-Gain", - .version = "20100823.0", + .version = "20230328.0", .copyright = "LGPL", .status = RIG_STATUS_STABLE, .rot_type = ROT_TYPE_OTHER, @@ -262,7 +265,7 @@ const struct rot_caps erc_rot_caps = ROT_MODEL(ROT_MODEL_ERC), .model_name = "ERC", .mfg_name = "DF9GR", - .version = "20100823.2", /* second revision on 23 Aug 2010 */ + .version = "20230328.2", /* second revision on 23 Aug 2010 */ .copyright = "LGPL", .status = RIG_STATUS_STABLE, .rot_type = ROT_TYPE_OTHER, @@ -290,6 +293,7 @@ const struct rot_caps erc_rot_caps = .rot_cleanup = rotorez_rot_cleanup, .set_position = rotorez_rot_set_position, .get_position = erc_rot_get_position, + .park = rotorez_park, .stop = dcu1_rot_stop, .reset = rotorez_rot_reset, // .stop = rotorez_rot_stop, @@ -309,7 +313,7 @@ const struct rot_caps yrc1_rot_caps = ROT_MODEL(ROT_MODEL_YRC1), .model_name = "DCU2/DCU3/YRC-1", .mfg_name = "Hy-Gain", - .version = "20100823.2", + .version = "20230328.2", .copyright = "LGPL", .status = RIG_STATUS_STABLE, .rot_type = ROT_TYPE_OTHER, @@ -337,6 +341,7 @@ const struct rot_caps yrc1_rot_caps = .rot_cleanup = rotorez_rot_cleanup, .set_position = rotorez_rot_set_position, .get_position = erc_rot_get_position, + .park = rotorez_park, .stop = dcu1_rot_stop, .reset = rotorez_rot_reset, // .stop = rotorez_rot_stop, @@ -351,7 +356,7 @@ const struct rot_caps rt21_rot_caps = ROT_MODEL(ROT_MODEL_RT21), .model_name = "RT-21", .mfg_name = "Green Heron", - .version = "20220104.0", + .version = "20230328.0", .copyright = "LGPL", .status = RIG_STATUS_STABLE, .rot_type = ROT_TYPE_OTHER, @@ -379,6 +384,7 @@ const struct rot_caps rt21_rot_caps = .rot_cleanup = rotorez_rot_cleanup, .set_position = rt21_rot_set_position, .get_position = rt21_rot_get_position, + .park = rotorez_park, .stop = rotorez_rot_stop, // .set_conf = rotorez_rot_set_conf, // .get_info = rotorez_rot_get_info, @@ -1128,6 +1134,20 @@ static int rotorez_flush_buffer(ROT *rot) return RIG_OK; } +/* + * Moves to Home Position + */ +static int rotorez_park(ROT *rot) +{ + rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); + + /* Assume home is 0,0 */ + rotorez_rot_set_position(rot, 0, 0); + + return RIG_OK; +} + + /* * Initialize backend commit 7395ef0e3f1e34ae43f01a4938f021cd3f2c0fde Author: Mike Black W9MDB <mdb...@ya...> Date: Tue Mar 28 11:52:26 2023 -0500 Add park to rotorez diff --git a/rotators/rotorez/rotorez.c b/rotators/rotorez/rotorez.c index 6867acea..6411a3ad 100644 --- a/rotators/rotorez/rotorez.c +++ b/rotators/rotorez/rotorez.c @@ -55,6 +55,7 @@ static int rotorez_rot_set_position(ROT *rot, azimuth_t azimuth, elevation_t elevation); static int rotorez_rot_get_position(ROT *rot, azimuth_t *azimuth, elevation_t *elevation); +static int rotorez_park(ROT *rot); static int erc_rot_get_position(ROT *rot, azimuth_t *azimuth, elevation_t *elevation); static int rt21_rot_get_position(ROT *rot, azimuth_t *azimuth, @@ -129,7 +130,7 @@ const struct rot_caps rotorez_rot_caps = ROT_MODEL(ROT_MODEL_ROTOREZ), .model_name = "Rotor-EZ", .mfg_name = "Idiom Press", - .version = "20220109.0", + .version = "20230328.0", .copyright = "LGPL", .status = RIG_STATUS_STABLE, .rot_type = ROT_TYPE_OTHER, @@ -157,6 +158,7 @@ const struct rot_caps rotorez_rot_caps = .rot_cleanup = rotorez_rot_cleanup, .set_position = rotorez_rot_set_position, .get_position = rotorez_rot_get_position, + .park = rotorez_park, .stop = rotorez_rot_stop, .set_conf = rotorez_rot_set_conf, .get_info = rotorez_rot_get_info, @@ -174,7 +176,7 @@ const struct rot_caps rotorcard_rot_caps = ROT_MODEL(ROT_MODEL_ROTORCARD), .model_name = "RotorCard", .mfg_name = "Idiom Press", - .version = "20100214.0", + .version = "20230328.0", .copyright = "LGPL", .status = RIG_STATUS_BETA, .rot_type = ROT_TYPE_OTHER, @@ -202,6 +204,7 @@ const struct rot_caps rotorcard_rot_caps = .rot_cleanup = rotorez_rot_cleanup, .set_position = rotorez_rot_set_position, .get_position = rotorez_rot_get_position, + .park = rotorez_park, .stop = rotorez_rot_stop, .set_conf = rotorez_rot_set_conf, .get_info = rotorez_rot_get_info, @@ -218,7 +221,7 @@ const struct rot_caps dcu_rot_caps = ROT_MODEL(ROT_MODEL_DCU), .model_name = "DCU-1/DCU-1X", .mfg_name = "Hy-Gain", - .version = "20100823.0", + .version = "20230328.0", .copyright = "LGPL", .status = RIG_STATUS_STABLE, .rot_type = ROT_TYPE_OTHER, @@ -262,7 +265,7 @@ const struct rot_caps erc_rot_caps = ROT_MODEL(ROT_MODEL_ERC), .model_name = "ERC", .mfg_name = "DF9GR", - .version = "20100823.2", /* second revision on 23 Aug 2010 */ + .version = "20230328.2", /* second revision on 23 Aug 2010 */ .copyright = "LGPL", .status = RIG_STATUS_STABLE, .rot_type = ROT_TYPE_OTHER, @@ -290,6 +293,7 @@ const struct rot_caps erc_rot_caps = .rot_cleanup = rotorez_rot_cleanup, .set_position = rotorez_rot_set_position, .get_position = erc_rot_get_position, + .park = rotorez_park, .stop = dcu1_rot_stop, .reset = rotorez_rot_reset, // .stop = rotorez_rot_stop, @@ -309,7 +313,7 @@ const struct rot_caps yrc1_rot_caps = ROT_MODEL(ROT_MODEL_YRC1), .model_n... [truncated message content] |