Daha önce tasarlamış olduğum anten seçici için yeni cihazlar için bazı eklemeler yaptım. yapan arkadaşlar için güncellemelerinde fayda var.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 |
#include "Arduino.h" #include "UserSettings.h" #include <SimpleList.h> #include <AltSoftSerial.h> //istek yanıt işlevi tanımı, her telsiz bu yöntemleri uygular typedef void (*RadioRequest) (AltSoftSerial* serial); typedef unsigned long (*RadioResponse) (AltSoftSerial* serial); /************************************************************* Arayüz uygulamaları ****************************************************************** her telsizin farklı bir arayüzü vardır. üç ayrı arayüz vardır. KENWOOD - FA interface YAESU - Y interface (5 bit request / response) ICOM - CI V çoğu üretici kenwood arayüzünü kullanır. ***************************************************************************************************************************************************************/ //************* Y arabirim ************* void Y_Request(AltSoftSerial* serial) { byte ReadFreq[] = {0x00, 0x00, 0x00, 0x00, 0x03}; for (byte i = 0; i < sizeof(ReadFreq); i++) { serial->write(ReadFreq[i]); } } unsigned long Y_Response(AltSoftSerial* serial) { int i = 0; String response = ""; while (serial->available()) { if (i++ < 4) { int inChar = (int)serial->read(); response += (inChar < 10) ? "0" + String(inChar, HEX) : String(inChar, HEX); delay(5); } else { serial->read(); } } unsigned long j = 0; String pattern = "%lu"; sscanf (&response[0], &pattern[0], &j); return j; } //***************** FA arabirim ****************** void FA_Request(AltSoftSerial* serial) { serial->println("FA;"); } unsigned long FA_Response(AltSoftSerial* serial) { String response = ""; while (serial->available()) { char inChar = (char)serial->read(); response += inChar; if (inChar == ';') { response.trim(); //trim the string break; } delay(5); } unsigned long j = 0; String pattern = "FA%lu"; sscanf (&response[0], &pattern[0], &j); return j / 10; } //**************************************************************************************************************************************************// //Radio Enumeration const int FT817 = 101; const int FT857 = 102; const int FT897 = 103; const int FT991 = 104; const int TS450 = 201; const int TS480 = 202; const int TS590 = 203; const int TS690 = 204; const int TS850 = 205; const int TS950 = 206; const int K2 = 301; const int KX2 = 302; const int K3S = 303; const int K3 = 304; const int KX3 = 305; const int SDR1000 = 401; struct Radio { int Id; char* displayname; RadioRequest FrequencyCommand; RadioResponse FrequencyResponse; }; //the supported radios at the moment Radio DummyRadio = { -1, (char*)"DUMMY RADIO", 0, 0 }; Radio Generic_FA_Radio = {1, (char*)"FA", FA_Request, FA_Response}; Radio Generic_Y_Radio = {2, (char*)"Y", Y_Request, Y_Response}; Radio FT817_Radio = {FT817, (char*)"FT-817", Y_Request, Y_Response}; Radio FT857_Radio = {FT857, (char*)"FT-857", Y_Request, Y_Response}; Radio FT897_Radio = {FT897, (char*)"FT-897", Y_Request, Y_Response}; Radio FT991_Radio = {FT991, (char*)"FT-991", FA_Request, FA_Response}; Radio TS450_Radio = {TS450, (char*)"TS-450", FA_Request, FA_Response}; Radio TS480_Radio = {TS480, (char*)"TS-480", FA_Request, FA_Response}; Radio TS590_Radio = {TS590, (char*)"TS-590", FA_Request, FA_Response}; Radio TS690_Radio = {TS690, (char*)"TS-690", FA_Request, FA_Response}; Radio TS850_Radio = {TS850, (char*)"TS-850", FA_Request, FA_Response}; Radio TS950_Radio = {TS950, (char*)"TS-950", FA_Request, FA_Response}; Radio K2_Radio = {K2, (char*)"K2", FA_Request, FA_Response}; Radio KX2_Radio = {KX2, (char*)"KX2", FA_Request, FA_Response}; Radio K3S_Radio = {K3S, (char*)"K3S", FA_Request, FA_Response}; Radio K3_Radio = {K3, (char*)"K3", FA_Request, FA_Response}; Radio KX3_Radio = {KX3, (char*)"KX3", FA_Request, FA_Response}; Radio SDR1000_Radio = {SDR1000, (char*)"SDR-1000", FA_Request, FA_Response}; SimpleList<Radio> RadioList; //desteklenen radyoları içeren bir liste /********************************************************************************************************** DİKKAT: Listede ki cihazlar pasif. hangi radyoyu istiyorsan başından // silmelisin **********************************************************************************************************/ void InitRadioList() { //Arduino nano 14 radyo hafızası ile sınırlıdır RadioList.reserve(14); // belleği önceden ayırın böylece işlemler hızlı olacaktır. // RadioList.push_back(FT817_Radio); RadioList.push_back(FT857_Radio); // RadioList.push_back(FT897_Radio); RadioList.push_back(FT991_Radio); // RadioList.push_back(TS450_Radio); // RadioList.push_back(TS480_Radio); // RadioList.push_back(TS590_Radio); // RadioList.push_back(TS690_Radio); // RadioList.push_back(TS850_Radio); // RadioList.push_back(TS950_Radio); // RadioList.push_back(K2_Radio); // RadioList.push_back(KX2_Radio); // RadioList.push_back(K3S_Radio); // RadioList.push_back(K3_Radio); // RadioList.push_back(KX3_Radio); // RadioList.push_back(SDR1000_Radio); } Radio GetInterface(AltSoftSerial* serial) { //TODO: burası biraz karışık //Tty "Y;" interface Y_Request(serial); delay(100); unsigned long y = 0; y = Y_Response(serial); if (y > 10000) return Generic_Y_Radio; //Tty "FA;" interface FA_Request(serial); delay(500); unsigned long fa = 0; fa = FA_Response(serial); if (fa > 0) return Generic_FA_Radio; return DummyRadio; } Radio GetMyRadio() { for (SimpleList<Radio>::iterator itr = RadioList.begin(); itr != RadioList.end(); ++itr) { if (itr->Id == MY_RADIO) { return *itr; } } return DummyRadio; } |