From 51bf7686e40c0cbed9762862ab9f86052ae36e88 Mon Sep 17 00:00:00 2001 From: k3ng Date: Sun, 20 Feb 2022 19:29:11 -0500 Subject: [PATCH] 2022.02.20.01 FEATURE_SATELLITE_TRACKING: Updated P13 library to have observer.update_location function. Controller code now uses update_location rather than instantiating new Observer objects Updated hardcoded AO17TEST TLE --- .../k3ng_rotator_controller.ino | 1761 +++++++---------- k3ng_rotator_controller/rotator.h | 9 +- .../rotator_debug_log_activation.h | 2 +- .../rotator_features_wb6kcn_k3ng.h | 6 +- k3ng_rotator_controller/rotator_settings.h | 2 +- .../rotator_settings_test.h | 10 +- .../rotator_settings_wb6kcn_k3ng.h | 20 +- libraries/P13/P13.cpp | 77 + libraries/P13/P13.h | 12 +- 9 files changed, 824 insertions(+), 1075 deletions(-) diff --git a/k3ng_rotator_controller/k3ng_rotator_controller.ino b/k3ng_rotator_controller/k3ng_rotator_controller.ino index 1177464..4bedf2b 100644 --- a/k3ng_rotator_controller/k3ng_rotator_controller.ino +++ b/k3ng_rotator_controller/k3ng_rotator_controller.ino @@ -1079,6 +1079,10 @@ 2021.12.27.02 Tested FEATURE_MASTER_SEND_AZ_ROTATION_COMMANDS_TO_REMOTE and FEATURE_MASTER_SEND_EL_ROTATION_COMMANDS_TO_REMOTE and fixed issue with link pings (PG) being sent way too often + 2022.02.20.01 + FEATURE_SATELLITE_TRACKING: Updated P13 library to have observer.update_location function. Controller code now uses update_location rather than instantiating new Observer objects + Updated hardcoded AO17TEST TLE + All library files should be placed in directories likes \sketchbook\libraries\library1\ , \sketchbook\libraries\library2\ , etc. Anything rotator_*.* should be in the ino directory! @@ -1092,7 +1096,7 @@ */ -#define CODE_VERSION "2021.12.27.01" +#define CODE_VERSION "2022.02.20.01" #include @@ -1469,8 +1473,9 @@ struct config_t { byte control_port_buffer_carriage_return_flag = 0; #endif -#if defined(FEATURE_REMOTE_UNIT_SLAVE) - unsigned long last_pg_receive_time = 0; +#if defined(FEATURE_REMOTE_UNIT_SLAVE) || defined(FEATURE_MASTER_WITH_SERIAL_SLAVE) || defined(FEATURE_MASTER_WITH_ETHERNET_SLAVE) + unsigned long last_ping_receive_time = 0; + byte master_remote_link_state = MASTER_REMOTE_LINK_DOWN; #endif #if defined(FEATURE_MASTER_WITH_SERIAL_SLAVE) || defined(FEATURE_MASTER_WITH_ETHERNET_SLAVE) @@ -1478,20 +1483,22 @@ struct config_t { int remote_unit_port_buffer_index = 0; byte remote_unit_port_buffer_carriage_return_flag = 0; unsigned long serial1_last_receive_time = 0; - byte remote_unit_command_submitted = 0; - unsigned long last_remote_unit_command_time = 0; + // byte remote_unit_command_submitted = 0; + // unsigned long last_remote_unit_command_time = 0; unsigned int remote_unit_command_timeouts = 0; unsigned int remote_unit_bad_results = 0; unsigned long remote_unit_good_results = 0; unsigned int remote_unit_incoming_buffer_timeouts = 0; - byte remote_unit_command_results_available = 0; - float remote_unit_command_result_float = 0; + // byte remote_unit_command_results_available = 0; + // float remote_unit_command_result_float = 0; + float remote_unit_azimuth_float = 0; + float remote_unit_elevation_float = 0; byte remote_port_rx_sniff = 0; byte remote_port_tx_sniff = 0; byte suspend_remote_commands = 0; #if defined(OPTION_SYNC_MASTER_CLOCK_TO_SLAVE) && defined(FEATURE_CLOCK) byte clock_synced_to_remote = 0; - #endif + #endif #endif //FEATURE_MASTER_WITH_SERIAL_SLAVE #ifdef DEBUG_POSITION_PULSE_INPUT @@ -1802,9 +1809,11 @@ struct config_t { Satellite sat; SatDateTime sat_datetime; - #if defined(DEBUG_SATELLITE_USE_OLD_OBSERVER_OBJECT) - Observer obs("",DEFAULT_LATITUDE,DEFAULT_LONGITUDE,DEFAULT_ALTITUDE_M); - #endif + // #if defined(DEBUG_SATELLITE_USE_OLD_OBSERVER_OBJECT) + // Observer obs("",DEFAULT_LATITUDE,DEFAULT_LONGITUDE,DEFAULT_ALTITUDE_M); + // #endif + + Observer obs("",DEFAULT_LATITUDE,DEFAULT_LONGITUDE,DEFAULT_ALTITUDE_M); struct satellite_list{ char name[SATELLITE_NAME_LENGTH]; @@ -1961,9 +1970,12 @@ void loop() { #if defined(FEATURE_MASTER_WITH_SERIAL_SLAVE) || defined(FEATURE_MASTER_WITH_ETHERNET_SLAVE) service_remote_communications_incoming_buffer(); - service_remote_ping(); #endif // defined(FEATURE_MASTER_WITH_SERIAL_SLAVE) || defined(FEATURE_MASTER_WITH_ETHERNET_SLAVE) + #if defined(FEATURE_REMOTE_UNIT_SLAVE) || defined(FEATURE_MASTER_WITH_SERIAL_SLAVE) || defined(FEATURE_MASTER_WITH_ETHERNET_SLAVE) + service_master_remote_link_state(); + #endif + #ifdef FEATURE_JOYSTICK_CONTROL check_joystick(); #endif // FEATURE_JOYSTICK_CONTROL @@ -3357,363 +3369,6 @@ void clear_command_buffer(){ } - - -// -------------------------------------------------------------- -// #ifdef FEATURE_REMOTE_UNIT_SLAVE -// void service_remote_unit_serial_buffer(){ - -// Goody 2021-12-19 this is dead code; commented it out - - -// // Goody 2015-03-09 - this may be dead code - all done in check_serial() and proces_remote_slave_command? - -// /* -// * -// * This implements a protocol for host unit to remote unit communications -// * -// * -// * Remote Slave Unit Protocol Reference -// * -// * PG - ping -// * AZ - read azimuth -// * EL - read elevation -// * DOxx - digital pin initialize as output; -// * DIxx - digital pin initialize as input -// * DPxx - digital pin initialize as input with pullup -// * DRxx - digital pin read -// * DLxx - digital pin write low -// * DHxx - digital pin write high -// * DTxxyyyy - digital pin tone output -// * NTxx - no tone -// * ARxx - analog pin read -// * AWxxyyy - analog pin write -// * SWxy - serial write byte -// * SDx - deactivate serial read event; x = port # -// * SSxyyyyyy... - serial write sting; x = port #, yyyy = string of characters to send -// * SAx - activate serial read event; x = port # -// * RB - reboot -// * -// * Responses -// * -// * ER - report an error (remote to host only) -// * EV - report an event (remote to host only) -// * OK - report success (remote to host only) -// * CS - report a cold start (remote to host only) -// * -// * Error Codes -// * -// * ER01 - Serial port buffer timeout -// * ER02 - Command syntax error -// * -// * Events -// * -// * EVSxy - Serial port read event; x = serial port number, y = byte returned -// * -// * -// */ - - -// static String command_string; // changed to static 2013-03-27 -// byte command_good = 0; - -// if (control_port_buffer_carriage_return_flag) { - -// if (control_port_buffer_index < 3) { -// control_port->println(F("ER02")); // we don't have enough characters - syntax error -// } else { -// command_string = String(char(toupper(control_port_buffer[0]))) + String(char(toupper(control_port_buffer[1]))); - -// #ifdef DEBUG_SERVICE_SERIAL_BUFFER -// debug.print("serial_serial_buffer: command_string: "); -// debug.print(command_string); -// debug.print("$ control_port_buffer_index: "); -// debug.print(control_port_buffer_index); -// debug.println(""); -// #endif // DEBUG_SERVICE_SERIAL_BUFFER - -// if ((command_string == "SS") && (control_port_buffer[2] > 47) && (control_port_buffer[2] < 53)) { // this is a variable length command -// command_good = 1; -// for (byte x = 3; x < control_port_buffer_index; x++) { -// switch (control_port_buffer[2] - 48) { -// case 0: control_port->write(control_port_buffer[x]); break; -// #if defined(FEATURE_MASTER_WITH_SERIAL_SLAVE) -// case 1: REMOTE_PORT.write(control_port_buffer[x]); break; -// #endif -// } -// } -// } - -// if (control_port_buffer_index == 3) { - -// if (command_string == "PG") { -// control_port->println(F("PG")); command_good = 1; -// } // PG - ping -// if (command_string == "RB") { -// reset_the_unit = 1; -// // wdt_enable(WDTO_30MS); while (1) { -// // } -// } // RB - reboot -// if (command_string == "AZ") { -// control_port->print(F("AZ")); -// if (raw_azimuth < 1000) { -// control_port->print("0"); -// } -// if (raw_azimuth < 100) { -// control_port->print("0"); -// } -// if (raw_azimuth < 10) { -// control_port->print("0"); -// } -// control_port->println(raw_azimuth); -// command_good = 1; -// } -// #ifdef FEATURE_ELEVATION_CONTROL -// if (command_string == "EL") { -// control_port->print(F("EL")); -// if (elevation >= 0) { -// control_port->print("+"); -// } else { -// control_port->print("-"); -// } -// if (abs(elevation) < 1000) { -// control_port->print("0"); -// } -// if (abs(elevation) < 100) { -// control_port->print("0"); -// } -// if (abs(elevation) < 10) { -// control_port->print("0"); -// } -// control_port->println(abs(elevation)); -// command_good = 1; -// } -// #endif // FEATURE_ELEVATION_CONTROL -// } // end of three byte commands - - - -// if (control_port_buffer_index == 4) { -// if ((command_string == "SA") & (control_port_buffer[2] > 47) && (control_port_buffer[2] < 53)) { -// serial_read_event_flag[control_port_buffer[2] - 48] = 1; -// command_good = 1; -// control_port->println("OK"); -// } -// if ((command_string == "SD") & (control_port_buffer[2] > 47) && (control_port_buffer[2] < 53)) { -// serial_read_event_flag[control_port_buffer[2] - 48] = 0; -// command_good = 1; -// control_port->println("OK"); -// } - -// } - - -// if (control_port_buffer_index == 5) { -// if (command_string == "SW") { // Serial Write command -// switch (control_port_buffer[2]) { -// case '0': control_port->write(control_port_buffer[3]); command_good = 1; break; -// #if defined(FEATURE_MASTER_WITH_SERIAL_SLAVE) -// case '1': REMOTE_PORT.write(control_port_buffer[3]); command_good = 1; break; -// #endif -// } -// } - -// if (command_string == "DO") { -// if ((((control_port_buffer[2] > 47) && (control_port_buffer[2] < 58)) || (toupper(control_port_buffer[2]) == 'A')) && (control_port_buffer[3] > 47) && (control_port_buffer[3] < 58)) { -// command_good = 1; -// byte pin_value = 0; -// if (toupper(control_port_buffer[2]) == 'A') { -// pin_value = get_analog_pin(control_port_buffer[3] - 48); -// } else { -// pin_value = ((control_port_buffer[2] - 48) * 10) + (control_port_buffer[3] - 48); -// } -// #ifdef DEBUG_SERVICE_SERIAL_BUFFER -// debug.print("service_serial_buffer: pin_value: "); -// debug.print(pin_value); -// debug.println(""); -// #endif // DEBUG_SERVICE_SERIAL_BUFFER -// control_port->println("OK"); -// pinModeEnhanced(pin_value, OUTPUT); -// } -// } - -// if (command_string == "DH") { -// if ((((control_port_buffer[2] > 47) && (control_port_buffer[2] < 58)) || (toupper(control_port_buffer[2]) == 'A')) && (control_port_buffer[3] > 47) && (control_port_buffer[3] < 58)) { -// command_good = 1; -// byte pin_value = 0; -// if (toupper(control_port_buffer[2]) == 'A') { -// pin_value = get_analog_pin(control_port_buffer[3] - 48); -// } else { -// pin_value = ((control_port_buffer[2] - 48) * 10) + (control_port_buffer[3] - 48); -// } -// digitalWriteEnhanced(pin_value, HIGH); -// control_port->println("OK"); -// } -// } - -// if (command_string == "DL") { -// if ((((control_port_buffer[2] > 47) && (control_port_buffer[2] < 58)) || (toupper(control_port_buffer[2]) == 'A')) && (control_port_buffer[3] > 47) && (control_port_buffer[3] < 58)) { -// command_good = 1; -// byte pin_value = 0; -// if (toupper(control_port_buffer[2]) == 'A') { -// pin_value = get_analog_pin(control_port_buffer[3] - 48); -// } else { -// pin_value = ((control_port_buffer[2] - 48) * 10) + (control_port_buffer[3] - 48); -// } -// digitalWriteEnhanced(pin_value, LOW); -// control_port->println("OK"); -// } -// } - -// if (command_string == "DI") { -// if ((((control_port_buffer[2] > 47) && (control_port_buffer[2] < 58)) || (toupper(control_port_buffer[2]) == 'A')) && (control_port_buffer[3] > 47) && (control_port_buffer[3] < 58)) { -// command_good = 1; -// byte pin_value = 0; -// if (toupper(control_port_buffer[2]) == 'A') { -// pin_value = get_analog_pin(control_port_buffer[3] - 48); -// } else { -// pin_value = ((control_port_buffer[2] - 48) * 10) + (control_port_buffer[3] - 48); -// } -// pinModeEnhanced(pin_value, INPUT); -// control_port->println("OK"); -// } -// } - -// if (command_string == "DP") { -// if ((((control_port_buffer[2] > 47) && (control_port_buffer[2] < 58)) || (toupper(control_port_buffer[2]) == 'A')) && (control_port_buffer[3] > 47) && (control_port_buffer[3] < 58)) { -// command_good = 1; -// byte pin_value = 0; -// if (toupper(control_port_buffer[2]) == 'A') { -// pin_value = get_analog_pin(control_port_buffer[3] - 48); -// } else { -// pin_value = ((control_port_buffer[2] - 48) * 10) + (control_port_buffer[3] - 48); -// } -// // pinModeEnhanced(pin_value,INPUT_PULLUP); -// pinModeEnhanced(pin_value, INPUT); -// digitalWriteEnhanced(pin_value, HIGH); -// control_port->println("OK"); -// } -// } - -// if (command_string == "DR") { -// if ((((control_port_buffer[2] > 47) && (control_port_buffer[2] < 58)) || (toupper(control_port_buffer[2]) == 'A')) && (control_port_buffer[3] > 47) && (control_port_buffer[3] < 58)) { -// command_good = 1; -// byte pin_value = 0; -// if (toupper(control_port_buffer[2]) == 'A') { -// pin_value = get_analog_pin(control_port_buffer[3] - 48); -// } else { -// pin_value = ((control_port_buffer[2] - 48) * 10) + (control_port_buffer[3] - 48); -// } -// byte pin_read = digitalReadEnhanced(pin_value); -// control_port->print("DR"); -// control_port->write(control_port_buffer[2]); -// control_port->write(control_port_buffer[3]); -// if (pin_read) { -// control_port->println("1"); -// } else { -// control_port->println("0"); -// } -// } -// } -// if (command_string == "AR") { -// if ((((control_port_buffer[2] > 47) && (control_port_buffer[2] < 58)) || (toupper(control_port_buffer[2]) == 'A')) && (control_port_buffer[3] > 47) && (control_port_buffer[3] < 58)) { -// command_good = 1; -// byte pin_value = 0; -// if (toupper(control_port_buffer[2]) == 'A') { -// pin_value = get_analog_pin(control_port_buffer[3] - 48); -// } else { -// pin_value = ((control_port_buffer[2] - 48) * 10) + (control_port_buffer[3] - 48); -// } -// int pin_read = analogReadEnhanced(pin_value); -// control_port->print("AR"); -// control_port->write(control_port_buffer[2]); -// control_port->write(control_port_buffer[3]); -// if (pin_read < 1000) { -// control_port->print("0"); -// } -// if (pin_read < 100) { -// control_port->print("0"); -// } -// if (pin_read < 10) { -// control_port->print("0"); -// } -// control_port->println(pin_read); -// } -// } - -// if (command_string == "NT") { -// if ((((control_port_buffer[2] > 47) && (control_port_buffer[2] < 58)) || (toupper(control_port_buffer[2]) == 'A')) && (control_port_buffer[3] > 47) && (control_port_buffer[3] < 58)) { -// command_good = 1; -// byte pin_value = 0; -// if (toupper(control_port_buffer[2]) == 'A') { -// pin_value = get_analog_pin(control_port_buffer[3] - 48); -// } else { -// pin_value = ((control_port_buffer[2] - 48) * 10) + (control_port_buffer[3] - 48); -// } -// noTone(pin_value); -// control_port->println("OK"); -// } -// } - -// } // if (control_port_buffer_index == 5) - -// if (control_port_buffer_index == 8) { -// if (command_string == "AW") { -// if ((((control_port_buffer[2] > 47) && (control_port_buffer[2] < 58)) || (toupper(control_port_buffer[2]) == 'A')) && (control_port_buffer[3] > 47) && (control_port_buffer[3] < 58)) { -// byte pin_value = 0; -// if (toupper(control_port_buffer[2]) == 'A') { -// pin_value = get_analog_pin(control_port_buffer[3] - 48); -// } else { -// pin_value = ((control_port_buffer[2] - 48) * 10) + (control_port_buffer[3] - 48); -// } -// int write_value = ((control_port_buffer[4] - 48) * 100) + ((control_port_buffer[5] - 48) * 10) + (control_port_buffer[6] - 48); -// if ((write_value >= 0) && (write_value < 256)) { -// analogWriteEnhanced(pin_value, write_value); -// control_port->println("OK"); -// command_good = 1; -// } -// } -// } -// } - -// if (control_port_buffer_index == 9) { -// if (command_string == "DT") { -// if ((((control_port_buffer[2] > 47) && (control_port_buffer[2] < 58)) || (toupper(control_port_buffer[2]) == 'A')) && (control_port_buffer[3] > 47) && (control_port_buffer[3] < 58)) { -// byte pin_value = 0; -// if (toupper(control_port_buffer[2]) == 'A') { -// pin_value = get_analog_pin(control_port_buffer[3] - 48); -// } else { -// pin_value = ((control_port_buffer[2] - 48) * 10) + (control_port_buffer[3] - 48); -// } -// int write_value = ((control_port_buffer[4] - 48) * 1000) + ((control_port_buffer[5] - 48) * 100) + ((control_port_buffer[6] - 48) * 10) + (control_port_buffer[7] - 48); -// if ((write_value >= 0) && (write_value <= 9999)) { -// tone(pin_value, write_value); -// control_port->println("OK"); -// command_good = 1; -// } -// } -// } -// } - - -// if (!command_good) { -// control_port->println(F("ER02")); -// } -// } -// control_port_buffer_carriage_return_flag = 0; -// control_port_buffer_index = 0; -// } else { -// if (((millis() - last_serial_receive_time) > REMOTE_BUFFER_TIMEOUT_MS) && control_port_buffer_index) { -// control_port->println(F("ER01")); -// control_port_buffer_index = 0; -// } -// } - - - -// } /* service_remote_unit_serial_buffer */ - -// #endif // FEATURE_REMOTE_UNIT_SLAVE // -------------------------------------------------------------- void check_serial(){ @@ -8230,25 +7885,14 @@ void az_check_operation_timeout(){ // check if the last executed rotation operation has been going on too long - #if defined(FEATURE_REMOTE_UNIT_SLAVE) - if ((((millis() - az_last_rotate_initiation) > OPERATION_TIMEOUT) || ((millis() - last_pg_receive_time) > REMOTE_UNIT_ROTATION_TIMEOUT)) && (az_state != IDLE)) { - submit_request(AZ, REQUEST_KILL, 0, 78); - #ifdef DEBUG_AZ_CHECK_OPERATION_TIMEOUT - debug.println("az_check_operation_timeout: timeout reached, aborting rotation"); - #endif // DEBUG_AZ_CHECK_OPERATION_TIMEOUT - } + if (((millis() - az_last_rotate_initiation) > OPERATION_TIMEOUT) && (az_state != IDLE)) { + submit_request(AZ, REQUEST_KILL, 0, 78); + #ifdef DEBUG_AZ_CHECK_OPERATION_TIMEOUT + debug.println("az_check_operation_timeout: timeout reached, aborting rotation"); + #endif // DEBUG_AZ_CHECK_OPERATION_TIMEOUT + } - #else - - if (((millis() - az_last_rotate_initiation) > OPERATION_TIMEOUT) && (az_state != IDLE)) { - submit_request(AZ, REQUEST_KILL, 0, 78); - #ifdef DEBUG_AZ_CHECK_OPERATION_TIMEOUT - debug.println("az_check_operation_timeout: timeout reached, aborting rotation"); - #endif // DEBUG_AZ_CHECK_OPERATION_TIMEOUT - } - - #endif } @@ -8525,7 +8169,7 @@ void read_azimuth(byte force_read){ #if defined(FEATURE_MASTER_WITH_SERIAL_SLAVE) || defined(FEATURE_MASTER_WITH_ETHERNET_SLAVE) static unsigned long last_remote_unit_az_query_time = 0; // do we have a command result waiting for us? - if (remote_unit_command_results_available == REMOTE_UNIT_AZ_COMMAND) { + if (master_remote_link_state == MASTER_REMOTE_LINK_UP) { #ifdef DEBUG_HEADING_READING_TIME average_read_time = (average_read_time + (millis() - last_time)) / 2.0; @@ -8540,7 +8184,7 @@ void read_azimuth(byte force_read){ } } #endif // DEBUG_HEADING_READING_TIME - raw_azimuth = remote_unit_command_result_float; + raw_azimuth = remote_unit_azimuth_float; #ifdef FEATURE_AZIMUTH_CORRECTION @@ -8558,14 +8202,14 @@ void read_azimuth(byte force_read){ convert_raw_azimuth_to_real_azimuth(); - remote_unit_command_results_available = 0; - } else { + // remote_unit_command_results_available = 0; + /*} else { // is it time to request the azimuth? if ((millis() - last_remote_unit_az_query_time) > AZ_REMOTE_UNIT_QUERY_TIME_MS) { if (submit_remote_command(REMOTE_UNIT_AZ_COMMAND, 0, 0)) { last_remote_unit_az_query_time = millis(); } - } + }*/ } #endif // defined(FEATURE_MASTER_WITH_SERIAL_SLAVE) || defined(FEATURE_MASTER_WITH_ETHERNET_SLAVE) #endif // FEATURE_AZ_POSITION_GET_FROM_REMOTE_UNIT @@ -9351,9 +8995,13 @@ void output_debug(){ #if defined(FEATURE_MASTER_WITH_SERIAL_SLAVE) || defined(FEATURE_MASTER_WITH_ETHERNET_SLAVE) - /*debug.print("\tRemote Slave: Command: "); - debug.print(remote_unit_command_submitted);*/ - debug.print("\tRemote_Slave: Good:"); + debug.print("\tRemote_Unit: Link:"); + if (master_remote_link_state == MASTER_REMOTE_LINK_UP){ + debug.print("UP"); + } else { + debug.print("DOWN"); + } + debug.print(" Good:"); debug.print(remote_unit_good_results,0); debug.print(" Bad:"); debug.print(remote_unit_bad_results); @@ -9782,29 +9430,15 @@ void el_check_operation_timeout(){ // check if the last executed rotation operation has been going on too long - #if defined(FEATURE_REMOTE_UNIT_SLAVE) + if (((millis() - el_last_rotate_initiation) > OPERATION_TIMEOUT) && (el_state != IDLE)) { + submit_request(EL, REQUEST_KILL, 0, 85); + #ifdef DEBUG_EL_CHECK_OPERATION_TIMEOUT + if (debug_mode) { + debug.print(F("el_check_operation_timeout: timeout reached, aborting rotation\n")); + } + #endif // DEBUG_EL_CHECK_OPERATION_TIMEOUT + } - if ((((millis() - el_last_rotate_initiation) > OPERATION_TIMEOUT) || ((millis() - last_pg_receive_time) > REMOTE_UNIT_ROTATION_TIMEOUT)) && (el_state != IDLE)) { - submit_request(EL, REQUEST_KILL, 0, 85); - #ifdef DEBUG_EL_CHECK_OPERATION_TIMEOUT - if (debug_mode) { - debug.print(F("el_check_operation_timeout: timeout reached, aborting rotation\n")); - } - #endif // DEBUG_EL_CHECK_OPERATION_TIMEOUT - } - - #else - - if (((millis() - el_last_rotate_initiation) > OPERATION_TIMEOUT) && (el_state != IDLE)) { - submit_request(EL, REQUEST_KILL, 0, 85); - #ifdef DEBUG_EL_CHECK_OPERATION_TIMEOUT - if (debug_mode) { - debug.print(F("el_check_operation_timeout: timeout reached, aborting rotation\n")); - } - #endif // DEBUG_EL_CHECK_OPERATION_TIMEOUT - } - - #endif } #endif @@ -10079,7 +9713,7 @@ void read_elevation(byte force_read){ #if defined(FEATURE_MASTER_WITH_SERIAL_SLAVE) || defined(FEATURE_MASTER_WITH_ETHERNET_SLAVE) static unsigned long last_remote_unit_el_query_time = 0; // do we have a command result waiting for us? - if (remote_unit_command_results_available == REMOTE_UNIT_EL_COMMAND) { + if (master_remote_link_state == MASTER_REMOTE_LINK_UP) { #ifdef DEBUG_HEADING_READING_TIME average_read_time = (average_read_time + (millis() - last_time)) / 2.0; @@ -10093,7 +9727,7 @@ void read_elevation(byte force_read){ } } #endif // DEBUG_HEADING_READING_TIME - elevation = remote_unit_command_result_float; + elevation = remote_unit_elevation_float; #ifdef FEATURE_ELEVATION_CORRECTION elevation = correct_elevation(elevation); #endif // FEATURE_ELEVATION_CORRECTION @@ -10104,14 +9738,14 @@ void read_elevation(byte force_read){ if (elevation < 0){elevation = 0;} elevation = (elevation * ((float)1 - ((float)ELEVATION_SMOOTHING_FACTOR / (float)100))) + ((float)previous_elevation * ((float)ELEVATION_SMOOTHING_FACTOR / (float)100)); } - remote_unit_command_results_available = 0; - } else { + // remote_unit_command_results_available = 0; + /*} else { // is it time to request the elevation? if ((millis() - last_remote_unit_el_query_time) > EL_REMOTE_UNIT_QUERY_TIME_MS) { if (submit_remote_command(REMOTE_UNIT_EL_COMMAND, 0, 0)) { last_remote_unit_el_query_time = millis(); } - } + }*/ } #endif // defined(FEATURE_MASTER_WITH_SERIAL_SLAVE) || defined(FEATURE_MASTER_WITH_ETHERNET_SLAVE) #endif // FEATURE_EL_POSITION_GET_FROM_REMOTE_UNIT @@ -12989,590 +12623,6 @@ void el_position_pulse_interrupt_handler(){ #endif // FEATURE_EL_POSITION_PULSE_INPUT #endif // FEATURE_ELEVATION_CONTROL // -------------------------------------------------------------------------- -#if defined(FEATURE_MASTER_WITH_SERIAL_SLAVE) || defined(FEATURE_MASTER_WITH_ETHERNET_SLAVE) -byte submit_remote_command(byte remote_command_to_send, byte parm1, int parm2){ - - #ifdef FEATURE_MASTER_WITH_ETHERNET_SLAVE - char ethernet_send_string[32]; - char temp_string[32]; - #endif //FEATURE_MASTER_WITH_ETHERNET_SLAVE - - #ifdef FEATURE_MASTER_WITH_ETHERNET_SLAVE - if (ethernetslavelinkclient0_state != ETHERNET_SLAVE_CONNECTED){return 0;} - #endif //FEATURE_MASTER_WITH_ETHERNET_SLAVE - - if ((remote_unit_command_submitted && ((remote_command_to_send == REMOTE_UNIT_AZ_COMMAND) || (remote_command_to_send == REMOTE_UNIT_EL_COMMAND) || (remote_command_to_send == REMOTE_UNIT_CL_COMMAND))) || suspend_remote_commands) { - return 0; - } else { - switch (remote_command_to_send) { - case REMOTE_UNIT_CL_COMMAND: - #ifdef FEATURE_MASTER_WITH_SERIAL_SLAVE - REMOTE_PORT.println("CL"); - #endif //FEATURE_MASTER_WITH_SERIAL_SLAVE - #ifdef FEATURE_MASTER_WITH_ETHERNET_SLAVE - ethernet_slave_link_send("CL"); - #endif //FEATURE_MASTER_WITH_ETHERNET_SLAVE - #if defined(FEATURE_REMOTE_UNIT_SLAVE) || defined(FEATURE_YAESU_EMULATION) || defined(FEATURE_EASYCOM_EMULATION) - if (remote_port_tx_sniff) {control_port->println("CL");} - #endif - remote_unit_command_submitted = REMOTE_UNIT_CL_COMMAND; - break; - - - case REMOTE_UNIT_PG_COMMAND: - #ifdef FEATURE_MASTER_WITH_SERIAL_SLAVE - REMOTE_PORT.println("PG"); - #endif //FEATURE_MASTER_WITH_SERIAL_SLAVE - #ifdef FEATURE_MASTER_WITH_ETHERNET_SLAVE - ethernet_slave_link_send("PG"); - #endif //FEATURE_MASTER_WITH_ETHERNET_SLAVE - #if defined(FEATURE_REMOTE_UNIT_SLAVE) || defined(FEATURE_YAESU_EMULATION) || defined(FEATURE_EASYCOM_EMULATION) - if (remote_port_tx_sniff) {control_port->println("PG");} - #endif - break; - - case REMOTE_UNIT_AZ_COMMAND: - #ifdef FEATURE_MASTER_WITH_SERIAL_SLAVE - REMOTE_PORT.println("AZ"); - #endif //FEATURE_MASTER_WITH_SERIAL_SLAVE - #ifdef FEATURE_MASTER_WITH_ETHERNET_SLAVE - ethernet_slave_link_send("AZ"); - #endif //FEATURE_MASTER_WITH_ETHERNET_SLAVE - #if defined(FEATURE_REMOTE_UNIT_SLAVE) || defined(FEATURE_YAESU_EMULATION) || defined(FEATURE_EASYCOM_EMULATION) - if (remote_port_tx_sniff) {control_port->println("AZ");} - #endif - remote_unit_command_submitted = REMOTE_UNIT_AZ_COMMAND; - break; - - case REMOTE_UNIT_EL_COMMAND: - #ifdef FEATURE_MASTER_WITH_SERIAL_SLAVE - REMOTE_PORT.println("EL"); - #endif //FEATURE_MASTER_WITH_SERIAL_SLAVE - #ifdef FEATURE_MASTER_WITH_ETHERNET_SLAVE - ethernet_slave_link_send("EL"); - #endif //FEATURE_MASTER_WITH_ETHERNET_SLAVE - #if defined(FEATURE_REMOTE_UNIT_SLAVE) || defined(FEATURE_YAESU_EMULATION) || defined(FEATURE_EASYCOM_EMULATION) - if (remote_port_tx_sniff) {control_port->println("EL");} - #endif - remote_unit_command_submitted = REMOTE_UNIT_EL_COMMAND; - break; - - - case REMOTE_UNIT_AW_COMMAND: - #ifdef FEATURE_MASTER_WITH_SERIAL_SLAVE - take_care_of_pending_remote_command(); - REMOTE_PORT.print("AW"); - #if defined(FEATURE_REMOTE_UNIT_SLAVE) || defined(FEATURE_YAESU_EMULATION) || defined(FEATURE_EASYCOM_EMULATION) - if (remote_port_tx_sniff) {control_port->print("AW");} - #endif - parm1 = parm1 - 100; // pin number - if (parm1 < 10) { - REMOTE_PORT.print("0"); - #if defined(FEATURE_REMOTE_UNIT_SLAVE) || defined(FEATURE_YAESU_EMULATION) || defined(FEATURE_EASYCOM_EMULATION) - if (remote_port_tx_sniff) {control_port->print("0");} - #endif - } - REMOTE_PORT.print(parm1); - #if defined(FEATURE_REMOTE_UNIT_SLAVE) || defined(FEATURE_YAESU_EMULATION) || defined(FEATURE_EASYCOM_EMULATION) - if (remote_port_tx_sniff) {control_port->print(parm1);} - #endif - if (parm2 < 10) { - REMOTE_PORT.print("0"); - #if defined(FEATURE_REMOTE_UNIT_SLAVE) || defined(FEATURE_YAESU_EMULATION) || defined(FEATURE_EASYCOM_EMULATION) - if (remote_port_tx_sniff) {control_port->print("0");} - #endif - } - if (parm2 < 100) { - REMOTE_PORT.print("0"); - #if defined(FEATURE_REMOTE_UNIT_SLAVE) || defined(FEATURE_YAESU_EMULATION) || defined(FEATURE_EASYCOM_EMULATION) - if (remote_port_tx_sniff) {control_port->print("0");} - #endif - } - REMOTE_PORT.println(parm2); - #if defined(FEATURE_REMOTE_UNIT_SLAVE) || defined(FEATURE_YAESU_EMULATION) || defined(FEATURE_EASYCOM_EMULATION) - if (remote_port_tx_sniff) {control_port->println(parm2);} - #endif - #endif //FEATURE_MASTER_WITH_SERIAL_SLAVE - - #ifdef FEATURE_MASTER_WITH_ETHERNET_SLAVE - take_care_of_pending_remote_command(); - strcpy(ethernet_send_string,"AW"); - parm1 = parm1 - 100; // pin number - if (parm1 < 10) {strcat(ethernet_send_string,"0");} - dtostrf(parm1,0,0,temp_string); - if (parm2 < 10) {strcat(ethernet_send_string,"0");} - if (parm2 < 100) {strcat(ethernet_send_string,"0");} - dtostrf(parm2,0,0,temp_string); - strcat(ethernet_send_string,temp_string); - ethernet_slave_link_send(ethernet_send_string); - #endif //FEATURE_MASTER_WITH_ETHERNET_SLAVE - - remote_unit_command_submitted = REMOTE_UNIT_OTHER_COMMAND; - break; - - case REMOTE_UNIT_DHL_COMMAND: - #ifdef FEATURE_MASTER_WITH_SERIAL_SLAVE - take_care_of_pending_remote_command(); - REMOTE_PORT.print("D"); - #if defined(FEATURE_REMOTE_UNIT_SLAVE) || defined(FEATURE_YAESU_EMULATION) || defined(FEATURE_EASYCOM_EMULATION) - if (remote_port_tx_sniff) {control_port->print("D");} - #endif - if (parm2 == HIGH) { - REMOTE_PORT.print("H"); - #if defined(FEATURE_REMOTE_UNIT_SLAVE) || defined(FEATURE_YAESU_EMULATION) || defined(FEATURE_EASYCOM_EMULATION) - if (remote_port_tx_sniff) {control_port->print("H");} - #endif - } else { - REMOTE_PORT.print("L"); - #if defined(FEATURE_REMOTE_UNIT_SLAVE) || defined(FEATURE_YAESU_EMULATION) || defined(FEATURE_EASYCOM_EMULATION) - if (remote_port_tx_sniff) {control_port->print("L");} - #endif - } - parm1 = parm1 - 100; - if (parm1 < 10) { - REMOTE_PORT.print("0"); - #if defined(FEATURE_REMOTE_UNIT_SLAVE) || defined(FEATURE_YAESU_EMULATION) || defined(FEATURE_EASYCOM_EMULATION) - if (remote_port_tx_sniff) {control_port->print("0");} - #endif - } - REMOTE_PORT.println(parm1); - #if defined(FEATURE_REMOTE_UNIT_SLAVE) || defined(FEATURE_YAESU_EMULATION) || defined(FEATURE_EASYCOM_EMULATION) - if (remote_port_tx_sniff) {control_port->println(parm1);} - #endif - #endif //FEATURE_MASTER_WITH_SERIAL_SLAVE - - - #ifdef FEATURE_MASTER_WITH_ETHERNET_SLAVE - take_care_of_pending_remote_command(); - strcpy(ethernet_send_string,"D"); - if (parm2 == HIGH) {strcat(ethernet_send_string,"H");} else {strcat(ethernet_send_string,"L");} - parm1 = parm1 - 100; - if (parm1 < 10) {strcat(ethernet_send_string,"0");} - dtostrf(parm1,0,0,temp_string); - strcat(ethernet_send_string,temp_string); - ethernet_slave_link_send(ethernet_send_string); - #endif //FEATURE_MASTER_WITH_ETHERNET_SLAVE - - remote_unit_command_submitted = REMOTE_UNIT_OTHER_COMMAND; - - break; - - case REMOTE_UNIT_DOI_COMMAND: - #ifdef FEATURE_MASTER_WITH_SERIAL_SLAVE - take_care_of_pending_remote_command(); - REMOTE_PORT.print("D"); - #if defined(FEATURE_REMOTE_UNIT_SLAVE) || defined(FEATURE_YAESU_EMULATION) || defined(FEATURE_EASYCOM_EMULATION) - if (remote_port_tx_sniff) {control_port->print("D");} - #endif - if (parm2 == OUTPUT) { - REMOTE_PORT.print("O"); - #if defined(FEATURE_REMOTE_UNIT_SLAVE) || defined(FEATURE_YAESU_EMULATION) || defined(FEATURE_EASYCOM_EMULATION) - if (remote_port_tx_sniff) {control_port->print("O");} - #endif - } else { - REMOTE_PORT.print("I");} - #if defined(FEATURE_REMOTE_UNIT_SLAVE) || defined(FEATURE_YAESU_EMULATION) || defined(FEATURE_EASYCOM_EMULATION) - if (remote_port_tx_sniff) {control_port->print("I");} - #endif - parm1 = parm1 - 100; - if (parm1 < 10) { - REMOTE_PORT.print("0"); - #if defined(FEATURE_REMOTE_UNIT_SLAVE) || defined(FEATURE_YAESU_EMULATION) || defined(FEATURE_EASYCOM_EMULATION) - if (remote_port_tx_sniff) {control_port->print("0");} - #endif - } - REMOTE_PORT.println(parm1); - #if defined(FEATURE_REMOTE_UNIT_SLAVE) || defined(FEATURE_YAESU_EMULATION) || defined(FEATURE_EASYCOM_EMULATION) - if (remote_port_tx_sniff) {control_port->println(parm1);} - #endif - remote_unit_command_submitted = REMOTE_UNIT_OTHER_COMMAND; - // get_remote_port_ok_response(); - #endif //FEATURE_MASTER_WITH_SERIAL_SLAVE - - #ifdef FEATURE_MASTER_WITH_ETHERNET_SLAVE - take_care_of_pending_remote_command(); - strcpy(ethernet_send_string,"D"); - if (parm2 == OUTPUT) {strcat(ethernet_send_string,"O");} else {strcat(ethernet_send_string,"I");} - parm1 = parm1 - 100; - if (parm1 < 10) {strcat(ethernet_send_string,"0");} - dtostrf(parm1,0,0,temp_string); - strcat(ethernet_send_string,temp_string); - ethernet_slave_link_send(ethernet_send_string); - remote_unit_command_submitted = REMOTE_UNIT_OTHER_COMMAND; - #endif //FEATURE_MASTER_WITH_ETHERNET_SLAVE - - break; - - case REMOTE_UNIT_GS_COMMAND: - #ifdef FEATURE_MASTER_WITH_SERIAL_SLAVE - REMOTE_PORT.println("GS"); - #endif //FEATURE_MASTER_WITH_SERIAL_SLAVE - #ifdef FEATURE_MASTER_WITH_ETHERNET_SLAVE - ethernet_slave_link_send("GS"); - #endif //FEATURE_MASTER_WITH_ETHERNET_SLAVE - #if defined(FEATURE_REMOTE_UNIT_SLAVE) || defined(FEATURE_YAESU_EMULATION) || defined(FEATURE_EASYCOM_EMULATION) - if (remote_port_tx_sniff) {control_port->println("GS");} - #endif - remote_unit_command_submitted = REMOTE_UNIT_GS_COMMAND; - break; - - case REMOTE_UNIT_RC_COMMAND: - #ifdef FEATURE_MASTER_WITH_SERIAL_SLAVE - REMOTE_PORT.println("RC"); - #endif //FEATURE_MASTER_WITH_SERIAL_SLAVE - #ifdef FEATURE_MASTER_WITH_ETHERNET_SLAVE - ethernet_slave_link_send("RC"); - #endif //FEATURE_MASTER_WITH_ETHERNET_SLAVE - #if defined(FEATURE_REMOTE_UNIT_SLAVE) || defined(FEATURE_YAESU_EMULATION) || defined(FEATURE_EASYCOM_EMULATION) - if (remote_port_tx_sniff) {control_port->println("RC");} - #endif - remote_unit_command_submitted = REMOTE_UNIT_RC_COMMAND; - break; - - // zzzzzz - - case REMOTE_UNIT_RL_COMMAND: - #ifdef FEATURE_MASTER_WITH_SERIAL_SLAVE - REMOTE_PORT.println("RL"); - #endif //FEATURE_MASTER_WITH_SERIAL_SLAVE - #ifdef FEATURE_MASTER_WITH_ETHERNET_SLAVE - ethernet_slave_link_send("RL"); - #endif //FEATURE_MASTER_WITH_ETHERNET_SLAVE - #if defined(FEATURE_REMOTE_UNIT_SLAVE) || defined(FEATURE_YAESU_EMULATION) || defined(FEATURE_EASYCOM_EMULATION) - if (remote_port_tx_sniff) {control_port->println("RL");} - #endif - remote_unit_command_submitted = REMOTE_UNIT_RL_COMMAND; - break; - - - case REMOTE_UNIT_RR_COMMAND: - #ifdef FEATURE_MASTER_WITH_SERIAL_SLAVE - REMOTE_PORT.println("RR"); - #endif //FEATURE_MASTER_WITH_SERIAL_SLAVE - #ifdef FEATURE_MASTER_WITH_ETHERNET_SLAVE - ethernet_slave_link_send("RR"); - #endif //FEATURE_MASTER_WITH_ETHERNET_SLAVE - #if defined(FEATURE_REMOTE_UNIT_SLAVE) || defined(FEATURE_YAESU_EMULATION) || defined(FEATURE_EASYCOM_EMULATION) - if (remote_port_tx_sniff) {control_port->println("RR");} - #endif - remote_unit_command_submitted = REMOTE_UNIT_RR_COMMAND; - break; - - case REMOTE_UNIT_RD_COMMAND: - #ifdef FEATURE_MASTER_WITH_SERIAL_SLAVE - REMOTE_PORT.println("RD"); - #endif //FEATURE_MASTER_WITH_SERIAL_SLAVE - #ifdef FEATURE_MASTER_WITH_ETHERNET_SLAVE - ethernet_slave_link_send("RD"); - #endif //FEATURE_MASTER_WITH_ETHERNET_SLAVE - #if defined(FEATURE_REMOTE_UNIT_SLAVE) || defined(FEATURE_YAESU_EMULATION) || defined(FEATURE_EASYCOM_EMULATION) - if (remote_port_tx_sniff) {control_port->println("RD");} - #endif - remote_unit_command_submitted = REMOTE_UNIT_RD_COMMAND; - break; - - case REMOTE_UNIT_RU_COMMAND: - #ifdef FEATURE_MASTER_WITH_SERIAL_SLAVE - REMOTE_PORT.println("RU"); - #endif //FEATURE_MASTER_WITH_SERIAL_SLAVE - #ifdef FEATURE_MASTER_WITH_ETHERNET_SLAVE - ethernet_slave_link_send("RU"); - #endif //FEATURE_MASTER_WITH_ETHERNET_SLAVE - #if defined(FEATURE_REMOTE_UNIT_SLAVE) || defined(FEATURE_YAESU_EMULATION) || defined(FEATURE_EASYCOM_EMULATION) - if (remote_port_tx_sniff) {control_port->println("RU");} - #endif - remote_unit_command_submitted = REMOTE_UNIT_RU_COMMAND; - break; - - case REMOTE_UNIT_RA_COMMAND: - #ifdef FEATURE_MASTER_WITH_SERIAL_SLAVE - REMOTE_PORT.println("RA"); - #endif //FEATURE_MASTER_WITH_SERIAL_SLAVE - #ifdef FEATURE_MASTER_WITH_ETHERNET_SLAVE - ethernet_slave_link_send("RA"); - #endif //FEATURE_MASTER_WITH_ETHERNET_SLAVE - #if defined(FEATURE_REMOTE_UNIT_SLAVE) || defined(FEATURE_YAESU_EMULATION) || defined(FEATURE_EASYCOM_EMULATION) - if (remote_port_tx_sniff) {control_port->println("RA");} - #endif - remote_unit_command_submitted = REMOTE_UNIT_RA_COMMAND; - break; - - case REMOTE_UNIT_RE_COMMAND: - #ifdef FEATURE_MASTER_WITH_SERIAL_SLAVE - REMOTE_PORT.println("RE"); - #endif //FEATURE_MASTER_WITH_SERIAL_SLAVE - #ifdef FEATURE_MASTER_WITH_ETHERNET_SLAVE - ethernet_slave_link_send("RE"); - #endif //FEATURE_MASTER_WITH_ETHERNET_SLAVE - #if defined(FEATURE_REMOTE_UNIT_SLAVE) || defined(FEATURE_YAESU_EMULATION) || defined(FEATURE_EASYCOM_EMULATION) - if (remote_port_tx_sniff) {control_port->println("RE");} - #endif - remote_unit_command_submitted = REMOTE_UNIT_RE_COMMAND; - break; - - case REMOTE_UNIT_RS_COMMAND: - #ifdef FEATURE_MASTER_WITH_SERIAL_SLAVE - REMOTE_PORT.println("RS"); - #endif //FEATURE_MASTER_WITH_SERIAL_SLAVE - #ifdef FEATURE_MASTER_WITH_ETHERNET_SLAVE - ethernet_slave_link_send("RS"); - #endif //FEATURE_MASTER_WITH_ETHERNET_SLAVE - #if defined(FEATURE_REMOTE_UNIT_SLAVE) || defined(FEATURE_YAESU_EMULATION) || defined(FEATURE_EASYCOM_EMULATION) - if (remote_port_tx_sniff) {control_port->println("RS");} - #endif - remote_unit_command_submitted = REMOTE_UNIT_RS_COMMAND; - break; - - } /* switch */ - last_remote_unit_command_time = millis(); - remote_unit_command_results_available = 0; - return 1; - } - - - -} /* submit_remote_command */ -#endif // defined(FEATURE_MASTER_WITH_SERIAL_SLAVE) || defined(FEATURE_MASTER_WITH_ETHERNET_SLAVE) - -// -------------------------------------------------------------------------- - -#if defined(FEATURE_MASTER_WITH_SERIAL_SLAVE) || defined(FEATURE_MASTER_WITH_ETHERNET_SLAVE) -byte is_ascii_number(byte char_in){ - - if ((char_in > 47) && (char_in < 58)) { - return 1; - } else { - return 0; - } - -} -#endif // defined(FEATURE_MASTER_WITH_SERIAL_SLAVE) || defined(FEATURE_MASTER_WITH_ETHERNET_SLAVE) -// -------------------------------------------------------------------------- -#if defined(FEATURE_MASTER_WITH_SERIAL_SLAVE) || defined(FEATURE_MASTER_WITH_ETHERNET_SLAVE) -void service_remote_communications_incoming_buffer(){ - - - #if defined(FEATURE_CLOCK) && defined(OPTION_SYNC_MASTER_CLOCK_TO_SLAVE) - int temp_year = 0; - byte temp_month = 0; - byte temp_day = 0; - byte temp_minute = 0; - byte temp_hour = 0; - byte temp_sec = 0; - #endif // defined(FEATURE_CLOCK) && defined(OPTION_SYNC_MASTER_CLOCK_TO_SLAVE) - - float temp_float_latitude = 0; - float temp_float_longitude = 0; - - - - byte good_data = 0; - - if (remote_unit_port_buffer_carriage_return_flag) { - - #ifdef DEBUG_SVC_REMOTE_COMM_INCOMING_BUFFER - debug.print("service_remote_communications_incoming_buffer: remote_unit_port_buffer_index: "); - debug.print(remote_unit_port_buffer_index); - debug.print(" buffer: "); - for (int x = 0; x < remote_unit_port_buffer_index; x++) { - debug.write((char*)remote_unit_port_buffer[x]); - debug.println("$"); - } - #endif // DEBUG_SVC_REMOTE_COMM_INCOMING_BUFFER - - if (remote_unit_command_submitted) { // this was a solicited response - switch (remote_unit_command_submitted) { - #ifdef OPTION_SYNC_MASTER_COORDINATES_TO_SLAVE - case REMOTE_UNIT_RC_COMMAND: //RC+40.9946 -075.6596 - if ((remote_unit_port_buffer[0] == 'R') && (remote_unit_port_buffer[1] == 'C') && (remote_unit_port_buffer[5] == '.') && (remote_unit_port_buffer[10] == ' ') && (remote_unit_port_buffer[15] == '.')){ - temp_float_latitude = ((remote_unit_port_buffer[3]-48)*10) + (remote_unit_port_buffer[4]-48) + ((remote_unit_port_buffer[6]-48)/10.0) + ((remote_unit_port_buffer[7]-48)/100.0) + ((remote_unit_port_buffer[8]-48)/1000.0) + ((remote_unit_port_buffer[9]-48)/10000.0); - if (remote_unit_port_buffer[2] == '-') { - temp_float_latitude = temp_float_latitude * -1; - } - temp_float_longitude = ((remote_unit_port_buffer[12]-48)*100) + ((remote_unit_port_buffer[13]-48)*10) + (remote_unit_port_buffer[14]-48) + ((remote_unit_port_buffer[16]-48)/10.0)+ ((remote_unit_port_buffer[17]-48)/100.0) + ((remote_unit_port_buffer[18]-48)/1000.0) + ((remote_unit_port_buffer[19]-48)/10000.0); - if (remote_unit_port_buffer[11] == '-') { - temp_float_longitude = temp_float_longitude * -1; - } - if ((temp_float_latitude <= 90) && (temp_float_latitude >= -90) && (temp_float_longitude <= 180) && (temp_float_longitude >= -180)){ - latitude = temp_float_latitude; - longitude = temp_float_longitude; - #ifdef DEBUG_SYNC_MASTER_COORDINATES_TO_SLAVE - debug.println("service_remote_communications_incoming_buffer: coordinates synced to slave"); - #endif //DEBUG_SYNC_MASTER_COORDINATES_TO_SLAVE - } - good_data = 1; - } - break; - #endif //OPTION_SYNC_MASTER_COORDINATES_TO_SLAVE - #if defined(OPTION_SYNC_MASTER_CLOCK_TO_SLAVE) && defined(FEATURE_CLOCK) - case REMOTE_UNIT_GS_COMMAND: - if ((remote_unit_port_buffer[0] == 'G') && (remote_unit_port_buffer[1] == 'S')){ - if (remote_unit_port_buffer[2] == '1'){ - if (clock_status == SLAVE_SYNC) {clock_status = SLAVE_SYNC_GPS;} - good_data = 1; - } else { - if (remote_unit_port_buffer[2] == '0') {good_data = 1;} - } - } - break; - #endif //OPTION_SYNC_MASTER_CLOCK_TO_SLAVE - - case REMOTE_UNIT_CL_COMMAND: - if ((remote_unit_port_buffer[0] == 'C') && (remote_unit_port_buffer[1] == 'L') && - (remote_unit_port_buffer[12] == ' ') && (remote_unit_port_buffer[21] == 'Z')) - { - #if defined(FEATURE_CLOCK) && defined(OPTION_SYNC_MASTER_CLOCK_TO_SLAVE) - //zzzzzz - temp_year = ((remote_unit_port_buffer[2] - 48) * 1000) + ((remote_unit_port_buffer[3] - 48) * 100) + ((remote_unit_port_buffer[4] - 48) * 10) + (remote_unit_port_buffer[5] - 48); - temp_month = ((remote_unit_port_buffer[7] - 48) * 10) + (remote_unit_port_buffer[8] - 48); - temp_day = ((remote_unit_port_buffer[10] - 48) * 10) + (remote_unit_port_buffer[11] - 48); - temp_hour = ((remote_unit_port_buffer[13] - 48) * 10) + (remote_unit_port_buffer[14] - 48); - temp_minute = ((remote_unit_port_buffer[16] - 48) * 10) + (remote_unit_port_buffer[17] - 48); - temp_sec = ((remote_unit_port_buffer[19] - 48) * 10) + (remote_unit_port_buffer[20] - 48); - if ((temp_year > 2013) && (temp_year < 2070) && - (temp_month > 0) && (temp_month < 13) && - (temp_day > 0) && (temp_day < 32) && - (temp_hour >= 0) && (temp_hour < 24) && - (temp_minute >= 0) && (temp_minute < 60) && - (temp_sec >= 0) && (temp_sec < 60) ) { - #if defined(OPTION_USE_OLD_TIME_CODE) - set_clock.year = temp_year; - set_clock.month = temp_month; - set_clock.day = temp_day; - set_clock.hours = temp_hour; - set_clock.minutes = temp_minute; - set_clock.seconds = temp_sec; - millis_at_last_calibration = millis(); - //update_time(); - #else //OPTION_USE_OLD_TIME_CODE - setTime(temp_hour, temp_minute, temp_sec, temp_day, temp_month, temp_year); - #endif //OPTION_USE_OLD_TIME_CODE - - #ifdef DEBUG_SYNC_MASTER_CLOCK_TO_SLAVE - debug.println("service_remote_communications_incoming_buffer: clock synced to slave clock"); - #endif //DEBUG_SYNC_MASTER_CLOCK_TO_SLAVE - good_data = 1; - clock_synced_to_remote = 1; - if (clock_status == FREE_RUNNING) {clock_status = SLAVE_SYNC;} - } else { - - #ifdef DEBUG_SYNC_MASTER_CLOCK_TO_SLAVE - debug.println("service_remote_communications_incoming_buffer: slave clock sync error"); - #endif //DEBUG_SYNC_MASTER_CLOCK_TO_SLAVE - if ((clock_status == SLAVE_SYNC) || (clock_status == SLAVE_SYNC_GPS)) {clock_status = FREE_RUNNING;} - } - #endif // defined(FEATURE_CLOCK) && defined(OPTION_SYNC_MASTER_CLOCK_TO_SLAVE) - - #if !defined(FEATURE_CLOCK) || !defined(OPTION_SYNC_MASTER_CLOCK_TO_SLAVE) - good_data = 1; - #endif //!defined(FEATURE_CLOCK) || !defined(OPTION_SYNC_MASTER_CLOCK_TO_SLAVE) - } else { - #if defined(FEATURE_CLOCK) && defined(OPTION_SYNC_MASTER_CLOCK_TO_SLAVE) - #ifdef DEBUG_SYNC_MASTER_CLOCK_TO_SLAVE - debug.print("service_remote_communications_incoming_buffer: REMOTE_UNIT_CL_COMMAND format error. remote_unit_port_buffer_index: "); - debug.print(remote_unit_port_buffer_index); - debug.println(""); - #endif //DEBUG_SYNC_MASTER_CLOCK_TO_SLAVE - if ((clock_status == SLAVE_SYNC) || (clock_status == SLAVE_SYNC_GPS)) {clock_status = FREE_RUNNING;} - #endif // defined(FEATURE_CLOCK) && defined(OPTION_SYNC_MASTER_CLOCK_TO_SLAVE) - } - break; - case REMOTE_UNIT_AZ_COMMAND: - if ((remote_unit_port_buffer_index == 13) && (remote_unit_port_buffer[0] == 'A') && (remote_unit_port_buffer[1] == 'Z') && - (is_ascii_number(remote_unit_port_buffer[2])) && (is_ascii_number(remote_unit_port_buffer[3])) && (is_ascii_number(remote_unit_port_buffer[4])) && (is_ascii_number(remote_unit_port_buffer[6])) && (is_ascii_number(remote_unit_port_buffer[7])) && (is_ascii_number(remote_unit_port_buffer[8])) && (is_ascii_number(remote_unit_port_buffer[9])) && (is_ascii_number(remote_unit_port_buffer[10])) && (is_ascii_number(remote_unit_port_buffer[11]))) { - remote_unit_command_result_float = float((remote_unit_port_buffer[2] - 48) * 100) + float((remote_unit_port_buffer[3] - 48) * 10) + float(remote_unit_port_buffer[4] - 48) + (float(remote_unit_port_buffer[6] - 48) / (float)10.0) + (float(remote_unit_port_buffer[7] - 48) / (float)100.0) + (float(remote_unit_port_buffer[8] - 48) / (float)1000.0) + (float(remote_unit_port_buffer[9] - 48) / (float)10000.0) + (float(remote_unit_port_buffer[10] - 48) / (float)100000.0) + (float(remote_unit_port_buffer[11] - 48) / (float)1000000.0); - good_data = 1; - } - break; - case REMOTE_UNIT_EL_COMMAND: - if ((remote_unit_port_buffer_index == 14) && (remote_unit_port_buffer[0] == 'E') && (remote_unit_port_buffer[1] == 'L') && - (is_ascii_number(remote_unit_port_buffer[3])) && (is_ascii_number(remote_unit_port_buffer[4])) && (is_ascii_number(remote_unit_port_buffer[5])) && (is_ascii_number(remote_unit_port_buffer[7])) && (is_ascii_number(remote_unit_port_buffer[8])) && (is_ascii_number(remote_unit_port_buffer[9])) && (is_ascii_number(remote_unit_port_buffer[10])) && (is_ascii_number(remote_unit_port_buffer[11])) && (is_ascii_number(remote_unit_port_buffer[12]))) { - remote_unit_command_result_float = (float(remote_unit_port_buffer[3] - 48) * 100) + float((remote_unit_port_buffer[4] - 48) * 10) + float(remote_unit_port_buffer[5] - 48) + (float(remote_unit_port_buffer[7] - 48) / (float)10.0) + (float(remote_unit_port_buffer[8] - 48) / (float)100.0) + (float(remote_unit_port_buffer[9] - 48) / (float)1000.0) + (float(remote_unit_port_buffer[10] - 48) / (float)10000.0) + (float(remote_unit_port_buffer[11] - 48) / (float)100000.0) + (float(remote_unit_port_buffer[12] - 48) / (float)1000000.0); - if (remote_unit_port_buffer[2] == '+') { - good_data = 1; - } - if (remote_unit_port_buffer[2] == '-') { - remote_unit_command_result_float = remote_unit_command_result_float * (float)-1.0; - good_data = 1; - } - } - break; - case REMOTE_UNIT_OTHER_COMMAND: - if ((remote_unit_port_buffer[0] == 'O') && (remote_unit_port_buffer[1] == 'K')) { - good_data = 1; - } - break; - } /* switch */ - if (good_data) { - if (remote_unit_command_submitted != REMOTE_UNIT_OTHER_COMMAND) { - remote_unit_command_results_available = remote_unit_command_submitted; - } - remote_unit_good_results++; - - #ifdef DEBUG_SVC_REMOTE_COMM_INCOMING_BUFFER - debug.print("service_remote_communications_incoming_buffer: remote_unit_command_results_available: "); - debug.print(remote_unit_command_results_available); - debug.print(" remote_unit_command_result_float: "); - debug.print(remote_unit_command_result_float,2); - debug.println(""); - #endif // DEBUG_SVC_REMOTE_COMM_INCOMING_BUFFER - - - } else { - - #ifdef DEBUG_SVC_REMOTE_COMM_INCOMING_BUFFER_BAD_DATA - debug.print("service_remote_communications_incoming_buffer: bad data: remote_unit_command_submitted: "); - switch (remote_unit_command_submitted) { - case REMOTE_UNIT_AZ_COMMAND: debug.print("REMOTE_UNIT_AZ_COMMAND"); break; - case REMOTE_UNIT_EL_COMMAND: debug.print("REMOTE_UNIT_EL_COMMAND"); break; - case REMOTE_UNIT_OTHER_COMMAND: debug.print("REMOTE_UNIT_OTHER_COMMAND"); break; - default: debug.print("UNDEFINED"); break; - } - debug.print(" buffer_index:"); - debug.print(remote_unit_port_buffer_index); - debug.print(" buffer: "); - for (int x = 0; x < remote_unit_port_buffer_index; x++) { - debug.write((char*)remote_unit_port_buffer[x]); - } - debug.println("$"); - #endif // DEBUG_SVC_REMOTE_COMM_INCOMING_BUFFER_BAD_DATA - - - remote_unit_command_results_available = 0; - remote_unit_bad_results++; - } - remote_unit_command_submitted = 0; - } else { // this was an unsolicited message - - } - remote_unit_port_buffer_carriage_return_flag = 0; - remote_unit_port_buffer_index = 0; - } - - // has a command timed out? - if ((remote_unit_command_submitted) && ((millis() - last_remote_unit_command_time) > REMOTE_UNIT_COMMAND_TIMEOUT_MS)) { - - #if defined(FEATURE_CLOCK) && defined(OPTION_SYNC_MASTER_CLOCK_TO_SLAVE) - if ((remote_unit_command_submitted == REMOTE_UNIT_CL_COMMAND) && ((clock_status == SLAVE_SYNC) || (clock_status == SLAVE_SYNC_GPS))){ - clock_status = FREE_RUNNING; - } - #endif //defined(FEATURE_CLOCK) && defined(OPTION_SYNC_MASTER_CLOCK_TO_SLAVE) - - remote_unit_command_timeouts++; - remote_unit_command_submitted = 0; - remote_unit_port_buffer_index = 0; - - } - - // have characters been in the buffer for some time but no carriage return? - if ((remote_unit_port_buffer_index) && (!remote_unit_command_submitted) && ((millis() - serial1_last_receive_time) > REMOTE_UNIT_COMMAND_TIMEOUT_MS)) { - remote_unit_port_buffer_index = 0; - remote_unit_incoming_buffer_timeouts++; - } - -} /* service_remote_communications_incoming_buffer */ - -#endif // defined(FEATURE_MASTER_WITH_SERIAL_SLAVE) || defined(FEATURE_MASTER_WITH_ETHERNET_SLAVE) // -------------------------------------------------------------------------- #ifdef FEATURE_AZIMUTH_CORRECTION float correct_azimuth(float azimuth_in){ @@ -14268,26 +13318,26 @@ void analogWriteEnhanced(uint8_t pin, int writevalue){ // -------------------------------------------------------------- -#if defined(FEATURE_MASTER_WITH_SERIAL_SLAVE) || defined(FEATURE_MASTER_WITH_ETHERNET_SLAVE) -void take_care_of_pending_remote_command(){ +// #if defined(FEATURE_MASTER_WITH_SERIAL_SLAVE) || defined(FEATURE_MASTER_WITH_ETHERNET_SLAVE) +// void take_care_of_pending_remote_command(){ - // if there's a command already sent to the remote and we're awaiting the response, service the serial buffer and the queue +// // if there's a command already sent to the remote and we're awaiting the response, service the serial buffer and the queue - unsigned long start_time = millis(); +// unsigned long start_time = millis(); - while ((remote_unit_command_submitted) && ((millis() - start_time) < 200)) { - #if defined(FEATURE_MASTER_WITH_SERIAL_SLAVE) - check_serial(); - #endif //defined(FEATURE_MASTER_WITH_SERIAL_SLAVE) - #if defined(FEATURE_MASTER_WITH_ETHERNET_SLAVE) - service_ethernet(); - #endif //defined(FEATURE_MASTER_WITH_ETHERNET_SLAVE) - service_remote_communications_incoming_buffer(); - } +// while ((remote_unit_command_submitted) && ((millis() - start_time) < 200)) { +// #if defined(FEATURE_MASTER_WITH_SERIAL_SLAVE) +// check_serial(); +// #endif //defined(FEATURE_MASTER_WITH_SERIAL_SLAVE) +// #if defined(FEATURE_MASTER_WITH_ETHERNET_SLAVE) +// service_ethernet(); +// #endif //defined(FEATURE_MASTER_WITH_ETHERNET_SLAVE) +// service_remote_communications_incoming_buffer(); +// } -} -#endif // defined(FEATURE_MASTER_WITH_SERIAL_SLAVE) || defined(FEATURE_MASTER_WITH_ETHERNET_SLAVE) +// } +// #endif // defined(FEATURE_MASTER_WITH_SERIAL_SLAVE) || defined(FEATURE_MASTER_WITH_ETHERNET_SLAVE) // -------------------------------------------------------------- @@ -18341,12 +17391,6 @@ void process_dcu_1_command(byte * dcu_1_command_buffer, int dcu_1_command_buffer // -------------------------------------------------------------- - - - - - - #ifdef FEATURE_REMOTE_UNIT_SLAVE void process_remote_slave_command(byte * slave_command_buffer, int slave_command_buffer_index, byte source_port, char * return_string){ @@ -18516,11 +17560,17 @@ void process_remote_slave_command(byte * slave_command_buffer, int slave_command #endif //FEATURE_CLOCK #endif //FEATURE_GPS - if ((slave_command_buffer[0] == 'P') && (slave_command_buffer[1] == 'G')) { - strcpy(return_string,"PG"); + // PM - ping from master, respond back with a ping + if ((slave_command_buffer[0] == 'P') && (slave_command_buffer[1] == 'M')) { + strcpy(return_string,"PM"); command_good = 1; - last_pg_receive_time = millis(); - } // PG - ping + } + // PM - ping sent from remote pinged back by master + if ((slave_command_buffer[0] == 'P') && (slave_command_buffer[1] == 'R')) { + command_good = 1; + last_ping_receive_time = millis(); + } + if ((slave_command_buffer[0] == 'R') && (slave_command_buffer[1] == 'B')) { reset_the_unit = 1; // wdt_enable(WDTO_30MS); while (1) { @@ -19587,19 +18637,19 @@ void service_ethernet(){ process_backslash_command(ethernet_port_buffer0, ethernet_port_buffer_index0, ETHERNET_PORT0, INCLUDE_RESPONSE_CODE, return_string, SOURCE_CONTROL_PORT); } else { #ifdef FEATURE_YAESU_EMULATION - process_yaesu_command(ethernet_port_buffer0,ethernet_port_buffer_index0,ETHERNET_PORT0,return_string); + process_yaesu_command(ethernet_port_buffer0,ethernet_port_buffer_index0,ETHERNET_PORT0,return_string); #endif //FEATURE_YAESU_EMULATION #ifdef FEATURE_EASYCOM_EMULATION - process_easycom_command(ethernet_port_buffer0,ethernet_port_buffer_index0,ETHERNET_PORT0,return_string); + process_easycom_command(ethernet_port_buffer0,ethernet_port_buffer_index0,ETHERNET_PORT0,return_string); #endif //FEATURE_EASYCOM_EMULATION #ifdef FEATURE_REMOTE_UNIT_SLAVE - process_remote_slave_command(ethernet_port_buffer0,ethernet_port_buffer_index0,ETHERNET_PORT0,return_string); + process_remote_slave_command(ethernet_port_buffer0,ethernet_port_buffer_index0,ETHERNET_PORT0,return_string); #endif //FEATURE_REMOTE_UNIT_SLAVE } ethernetclient0.println(return_string); ethernet_port_buffer_index0 = 0; #ifdef FEATURE_REMOTE_UNIT_SLAVE - preamble_received = 0; + preamble_received = 0; #endif //FEATURE_REMOTE_UNIT_SLAVE } @@ -19638,13 +18688,13 @@ void service_ethernet(){ process_backslash_command(ethernet_port_buffer1, ethernet_port_buffer_index1, ETHERNET_PORT1, INCLUDE_RESPONSE_CODE, return_string, SOURCE_CONTROL_PORT); } else { #ifdef FEATURE_YAESU_EMULATION - process_yaesu_command(ethernet_port_buffer1,ethernet_port_buffer_index1,ETHERNET_PORT1,return_string); + process_yaesu_command(ethernet_port_buffer1,ethernet_port_buffer_index1,ETHERNET_PORT1,return_string); #endif //FEATURE_YAESU_EMULATION #ifdef FEATURE_EASYCOM_EMULATION - process_easycom_command(ethernet_port_buffer1,ethernet_port_buffer_index1,ETHERNET_PORT1,return_string); + process_easycom_command(ethernet_port_buffer1,ethernet_port_buffer_index1,ETHERNET_PORT1,return_string); #endif //FEATURE_EASYCOM_EMULATION #ifdef FEATURE_REMOTE_UNIT_SLAVE - process_remote_slave_command(ethernet_port_buffer1,ethernet_port_buffer_index1,ETHERNET_PORT1,return_string); + process_remote_slave_command(ethernet_port_buffer1,ethernet_port_buffer_index1,ETHERNET_PORT1,return_string); #endif //FEATURE_REMOTE_UNIT_SLAVE } ethernetclient1.println(return_string); @@ -20431,8 +19481,8 @@ void convert_polar_to_cartesian(byte coordinate_conversion,double azimuth_in,dou if (load_hardcoded_tle == LOAD_HARDCODED_TLE){ // push a hardcoded TLE into the array position 0 and write to EEPROM strcpy_P(name,(const char*) F("AO7TEST")); - strcpy_P(hardcoded_tle_line_1,(const char*) F("1 07530U 74089B 21280.85174194 -.00000049 ")); //2021-10-13 - strcpy_P(hardcoded_tle_line_2,(const char*) F("2 07530 101.8690 255.2887 0012171 164.7462 264.0607 12.53650626146058")); + strcpy_P(hardcoded_tle_line_1,(const char*) F("1 07530U 74089B 22048.56983860 -.00000047 ")); //2022-02-20 + strcpy_P(hardcoded_tle_line_2,(const char*) F("2 07530 101.8912 28.1243 0011959 272.1572 198.3347 12.53652980162443")); sat.tle(name,hardcoded_tle_line_1,hardcoded_tle_line_2); #if defined(DEBUG_SATELLITE_TRACKING_LOAD) debug.print(name); @@ -20952,9 +20002,13 @@ void convert_polar_to_cartesian(byte coordinate_conversion,double azimuth_in,dou byte pull_result = 0; - #if !defined(DEBUG_SATELLITE_USE_OLD_OBSERVER_OBJECT) - /*static*/ Observer obs("",latitude,longitude,altitude_m); // don't do static here. it doesn't work - #endif + // #if !defined(DEBUG_SATELLITE_USE_OLD_OBSERVER_OBJECT) + // /*static*/ Observer obs("",latitude,longitude,altitude_m); // don't do static here. it doesn't work + // #else + // obs.update_location("",latitude,longitude,altitude_m); + // #endif + + obs.update_location("",latitude,longitude,altitude_m); if (service_action == SERVICE_CALC_REPORT_STATE){return service_calc_satellite_data_service_state;} @@ -22137,16 +21191,627 @@ void send_vt100_code(char* code_to_send){ } #endif //FEATURE_SATELLITE_TRACKING +//------------------------------------------------------ + #if defined(FEATURE_MASTER_WITH_SERIAL_SLAVE) || defined(FEATURE_MASTER_WITH_ETHERNET_SLAVE) - void service_remote_ping(){ +byte submit_remote_command(byte remote_command_to_send, byte parm1, int parm2){ - static unsigned long last_pg_send_time = REMOTE_UNIT_ROTATION_TIMEOUT; + #ifdef FEATURE_MASTER_WITH_ETHERNET_SLAVE + char ethernet_send_string[32]; + char temp_string[32]; + #endif //FEATURE_MASTER_WITH_ETHERNET_SLAVE - if ((float)(millis() - (float)last_pg_send_time) > ((float)REMOTE_UNIT_ROTATION_TIMEOUT * (float)0.8)){ - submit_remote_command(REMOTE_UNIT_PG_COMMAND,0,0); - last_pg_send_time = millis(); - } + #ifdef FEATURE_MASTER_WITH_ETHERNET_SLAVE + if (ethernetslavelinkclient0_state != ETHERNET_SLAVE_CONNECTED){return 0;} + #endif //FEATURE_MASTER_WITH_ETHERNET_SLAVE + + // if ((remote_unit_command_submitted && ((remote_command_to_send == REMOTE_UNIT_AZ_COMMAND) || (remote_command_to_send == REMOTE_UNIT_EL_COMMAND) || (remote_command_to_send == REMOTE_UNIT_CL_COMMAND))) || suspend_remote_commands) { + if (/*remote_unit_command_submitted ||*/ suspend_remote_commands) { + return 0; + } else { + switch (remote_command_to_send) { + case REMOTE_UNIT_CL_COMMAND: + #ifdef FEATURE_MASTER_WITH_SERIAL_SLAVE + REMOTE_PORT.println("CL"); + #endif //FEATURE_MASTER_WITH_SERIAL_SLAVE + #ifdef FEATURE_MASTER_WITH_ETHERNET_SLAVE + ethernet_slave_link_send("CL"); + #endif //FEATURE_MASTER_WITH_ETHERNET_SLAVE + #if defined(FEATURE_REMOTE_UNIT_SLAVE) || defined(FEATURE_YAESU_EMULATION) || defined(FEATURE_EASYCOM_EMULATION) + if (remote_port_tx_sniff) {control_port->println("CL");} + #endif + // remote_unit_command_submitted = REMOTE_UNIT_CL_COMMAND; + break; + + + case REMOTE_UNIT_PM_COMMAND: + #ifdef FEATURE_MASTER_WITH_SERIAL_SLAVE + REMOTE_PORT.println("PM"); + #endif //FEATURE_MASTER_WITH_SERIAL_SLAVE + #ifdef FEATURE_MASTER_WITH_ETHERNET_SLAVE + ethernet_slave_link_send("PM"); + #endif //FEATURE_MASTER_WITH_ETHERNET_SLAVE + #if defined(FEATURE_REMOTE_UNIT_SLAVE) || defined(FEATURE_YAESU_EMULATION) || defined(FEATURE_EASYCOM_EMULATION) + if (remote_port_tx_sniff) {control_port->println("PM");} + #endif + //remote_unit_command_submitted = REMOTE_UNIT_PG_COMMAND; + break; + + // case REMOTE_UNIT_AZ_COMMAND: + // #ifdef FEATURE_MASTER_WITH_SERIAL_SLAVE + // REMOTE_PORT.println("AZ"); + // #endif //FEATURE_MASTER_WITH_SERIAL_SLAVE + // #ifdef FEATURE_MASTER_WITH_ETHERNET_SLAVE + // ethernet_slave_link_send("AZ"); + // #endif //FEATURE_MASTER_WITH_ETHERNET_SLAVE + // #if defined(FEATURE_REMOTE_UNIT_SLAVE) || defined(FEATURE_YAESU_EMULATION) || defined(FEATURE_EASYCOM_EMULATION) + // if (remote_port_tx_sniff) {control_port->println("AZ");} + // #endif + // remote_unit_command_submitted = REMOTE_UNIT_AZ_COMMAND; + // break; + + // case REMOTE_UNIT_EL_COMMAND: + // #ifdef FEATURE_MASTER_WITH_SERIAL_SLAVE + // REMOTE_PORT.println("EL"); + // #endif //FEATURE_MASTER_WITH_SERIAL_SLAVE + // #ifdef FEATURE_MASTER_WITH_ETHERNET_SLAVE + // ethernet_slave_link_send("EL"); + // #endif //FEATURE_MASTER_WITH_ETHERNET_SLAVE + // #if defined(FEATURE_REMOTE_UNIT_SLAVE) || defined(FEATURE_YAESU_EMULATION) || defined(FEATURE_EASYCOM_EMULATION) + // if (remote_port_tx_sniff) {control_port->println("EL");} + // #endif + // remote_unit_command_submitted = REMOTE_UNIT_EL_COMMAND; + // break; + + + case REMOTE_UNIT_AW_COMMAND: + #ifdef FEATURE_MASTER_WITH_SERIAL_SLAVE + // take_care_of_pending_remote_command(); + REMOTE_PORT.print("AW"); + #if defined(FEATURE_REMOTE_UNIT_SLAVE) || defined(FEATURE_YAESU_EMULATION) || defined(FEATURE_EASYCOM_EMULATION) + if (remote_port_tx_sniff) {control_port->print("AW");} + #endif + parm1 = parm1 - 100; // pin number + if (parm1 < 10) { + REMOTE_PORT.print("0"); + #if defined(FEATURE_REMOTE_UNIT_SLAVE) || defined(FEATURE_YAESU_EMULATION) || defined(FEATURE_EASYCOM_EMULATION) + if (remote_port_tx_sniff) {control_port->print("0");} + #endif + } + REMOTE_PORT.print(parm1); + #if defined(FEATURE_REMOTE_UNIT_SLAVE) || defined(FEATURE_YAESU_EMULATION) || defined(FEATURE_EASYCOM_EMULATION) + if (remote_port_tx_sniff) {control_port->print(parm1);} + #endif + if (parm2 < 10) { + REMOTE_PORT.print("0"); + #if defined(FEATURE_REMOTE_UNIT_SLAVE) || defined(FEATURE_YAESU_EMULATION) || defined(FEATURE_EASYCOM_EMULATION) + if (remote_port_tx_sniff) {control_port->print("0");} + #endif + } + if (parm2 < 100) { + REMOTE_PORT.print("0"); + #if defined(FEATURE_REMOTE_UNIT_SLAVE) || defined(FEATURE_YAESU_EMULATION) || defined(FEATURE_EASYCOM_EMULATION) + if (remote_port_tx_sniff) {control_port->print("0");} + #endif + } + REMOTE_PORT.println(parm2); + #if defined(FEATURE_REMOTE_UNIT_SLAVE) || defined(FEATURE_YAESU_EMULATION) || defined(FEATURE_EASYCOM_EMULATION) + if (remote_port_tx_sniff) {control_port->println(parm2);} + #endif + #endif //FEATURE_MASTER_WITH_SERIAL_SLAVE + + #ifdef FEATURE_MASTER_WITH_ETHERNET_SLAVE + // take_care_of_pending_remote_command(); + strcpy(ethernet_send_string,"AW"); + parm1 = parm1 - 100; // pin number + if (parm1 < 10) {strcat(ethernet_send_string,"0");} + dtostrf(parm1,0,0,temp_string); + if (parm2 < 10) {strcat(ethernet_send_string,"0");} + if (parm2 < 100) {strcat(ethernet_send_string,"0");} + dtostrf(parm2,0,0,temp_string); + strcat(ethernet_send_string,temp_string); + ethernet_slave_link_send(ethernet_send_string); + #endif //FEATURE_MASTER_WITH_ETHERNET_SLAVE + + // remote_unit_command_submitted = REMOTE_UNIT_OTHER_COMMAND; + break; + + case REMOTE_UNIT_DHL_COMMAND: + #ifdef FEATURE_MASTER_WITH_SERIAL_SLAVE + // take_care_of_pending_remote_command(); + REMOTE_PORT.print("D"); + #if defined(FEATURE_REMOTE_UNIT_SLAVE) || defined(FEATURE_YAESU_EMULATION) || defined(FEATURE_EASYCOM_EMULATION) + if (remote_port_tx_sniff) {control_port->print("D");} + #endif + if (parm2 == HIGH) { + REMOTE_PORT.print("H"); + #if defined(FEATURE_REMOTE_UNIT_SLAVE) || defined(FEATURE_YAESU_EMULATION) || defined(FEATURE_EASYCOM_EMULATION) + if (remote_port_tx_sniff) {control_port->print("H");} + #endif + } else { + REMOTE_PORT.print("L"); + #if defined(FEATURE_REMOTE_UNIT_SLAVE) || defined(FEATURE_YAESU_EMULATION) || defined(FEATURE_EASYCOM_EMULATION) + if (remote_port_tx_sniff) {control_port->print("L");} + #endif + } + parm1 = parm1 - 100; + if (parm1 < 10) { + REMOTE_PORT.print("0"); + #if defined(FEATURE_REMOTE_UNIT_SLAVE) || defined(FEATURE_YAESU_EMULATION) || defined(FEATURE_EASYCOM_EMULATION) + if (remote_port_tx_sniff) {control_port->print("0");} + #endif + } + REMOTE_PORT.println(parm1); + #if defined(FEATURE_REMOTE_UNIT_SLAVE) || defined(FEATURE_YAESU_EMULATION) || defined(FEATURE_EASYCOM_EMULATION) + if (remote_port_tx_sniff) {control_port->println(parm1);} + #endif + #endif //FEATURE_MASTER_WITH_SERIAL_SLAVE + + + #ifdef FEATURE_MASTER_WITH_ETHERNET_SLAVE + // take_care_of_pending_remote_command(); + strcpy(ethernet_send_string,"D"); + if (parm2 == HIGH) {strcat(ethernet_send_string,"H");} else {strcat(ethernet_send_string,"L");} + parm1 = parm1 - 100; + if (parm1 < 10) {strcat(ethernet_send_string,"0");} + dtostrf(parm1,0,0,temp_string); + strcat(ethernet_send_string,temp_string); + ethernet_slave_link_send(ethernet_send_string); + #endif //FEATURE_MASTER_WITH_ETHERNET_SLAVE + + // remote_unit_command_submitted = REMOTE_UNIT_OTHER_COMMAND; + + break; + + case REMOTE_UNIT_DOI_COMMAND: + #ifdef FEATURE_MASTER_WITH_SERIAL_SLAVE + // take_care_of_pending_remote_command(); + REMOTE_PORT.print("D"); + #if defined(FEATURE_REMOTE_UNIT_SLAVE) || defined(FEATURE_YAESU_EMULATION) || defined(FEATURE_EASYCOM_EMULATION) + if (remote_port_tx_sniff) {control_port->print("D");} + #endif + if (parm2 == OUTPUT) { + REMOTE_PORT.print("O"); + #if defined(FEATURE_REMOTE_UNIT_SLAVE) || defined(FEATURE_YAESU_EMULATION) || defined(FEATURE_EASYCOM_EMULATION) + if (remote_port_tx_sniff) {control_port->print("O");} + #endif + } else { + REMOTE_PORT.print("I");} + #if defined(FEATURE_REMOTE_UNIT_SLAVE) || defined(FEATURE_YAESU_EMULATION) || defined(FEATURE_EASYCOM_EMULATION) + if (remote_port_tx_sniff) {control_port->print("I");} + #endif + parm1 = parm1 - 100; + if (parm1 < 10) { + REMOTE_PORT.print("0"); + #if defined(FEATURE_REMOTE_UNIT_SLAVE) || defined(FEATURE_YAESU_EMULATION) || defined(FEATURE_EASYCOM_EMULATION) + if (remote_port_tx_sniff) {control_port->print("0");} + #endif + } + REMOTE_PORT.println(parm1); + #if defined(FEATURE_REMOTE_UNIT_SLAVE) || defined(FEATURE_YAESU_EMULATION) || defined(FEATURE_EASYCOM_EMULATION) + if (remote_port_tx_sniff) {control_port->println(parm1);} + #endif + // remote_unit_command_submitted = REMOTE_UNIT_OTHER_COMMAND; + // get_remote_port_ok_response(); + #endif //FEATURE_MASTER_WITH_SERIAL_SLAVE + + #ifdef FEATURE_MASTER_WITH_ETHERNET_SLAVE + // take_care_of_pending_remote_command(); + strcpy(ethernet_send_string,"D"); + if (parm2 == OUTPUT) {strcat(ethernet_send_string,"O");} else {strcat(ethernet_send_string,"I");} + parm1 = parm1 - 100; + if (parm1 < 10) {strcat(ethernet_send_string,"0");} + dtostrf(parm1,0,0,temp_string); + strcat(ethernet_send_string,temp_string); + ethernet_slave_link_send(ethernet_send_string); + // remote_unit_command_submitted = REMOTE_UNIT_OTHER_COMMAND; + #endif //FEATURE_MASTER_WITH_ETHERNET_SLAVE + + break; + + case REMOTE_UNIT_GS_COMMAND: + #ifdef FEATURE_MASTER_WITH_SERIAL_SLAVE + REMOTE_PORT.println("GS"); + #endif //FEATURE_MASTER_WITH_SERIAL_SLAVE + #ifdef FEATURE_MASTER_WITH_ETHERNET_SLAVE + ethernet_slave_link_send("GS"); + #endif //FEATURE_MASTER_WITH_ETHERNET_SLAVE + #if defined(FEATURE_REMOTE_UNIT_SLAVE) || defined(FEATURE_YAESU_EMULATION) || defined(FEATURE_EASYCOM_EMULATION) + if (remote_port_tx_sniff) {control_port->println("GS");} + #endif + // remote_unit_command_submitted = REMOTE_UNIT_GS_COMMAND; + break; + + case REMOTE_UNIT_RC_COMMAND: + #ifdef FEATURE_MASTER_WITH_SERIAL_SLAVE + REMOTE_PORT.println("RC"); + #endif //FEATURE_MASTER_WITH_SERIAL_SLAVE + #ifdef FEATURE_MASTER_WITH_ETHERNET_SLAVE + ethernet_slave_link_send("RC"); + #endif //FEATURE_MASTER_WITH_ETHERNET_SLAVE + #if defined(FEATURE_REMOTE_UNIT_SLAVE) || defined(FEATURE_YAESU_EMULATION) || defined(FEATURE_EASYCOM_EMULATION) + if (remote_port_tx_sniff) {control_port->println("RC");} + #endif + // remote_unit_command_submitted = REMOTE_UNIT_RC_COMMAND; + break; + + // zzzzzz + + case REMOTE_UNIT_RL_COMMAND: + #ifdef FEATURE_MASTER_WITH_SERIAL_SLAVE + REMOTE_PORT.println("RL"); + #endif //FEATURE_MASTER_WITH_SERIAL_SLAVE + #ifdef FEATURE_MASTER_WITH_ETHERNET_SLAVE + ethernet_slave_link_send("RL"); + #endif //FEATURE_MASTER_WITH_ETHERNET_SLAVE + #if defined(FEATURE_REMOTE_UNIT_SLAVE) || defined(FEATURE_YAESU_EMULATION) || defined(FEATURE_EASYCOM_EMULATION) + if (remote_port_tx_sniff) {control_port->println("RL");} + #endif + // remote_unit_command_submitted = REMOTE_UNIT_RL_COMMAND; + break; + + + case REMOTE_UNIT_RR_COMMAND: + #ifdef FEATURE_MASTER_WITH_SERIAL_SLAVE + REMOTE_PORT.println("RR"); + #endif //FEATURE_MASTER_WITH_SERIAL_SLAVE + #ifdef FEATURE_MASTER_WITH_ETHERNET_SLAVE + ethernet_slave_link_send("RR"); + #endif //FEATURE_MASTER_WITH_ETHERNET_SLAVE + #if defined(FEATURE_REMOTE_UNIT_SLAVE) || defined(FEATURE_YAESU_EMULATION) || defined(FEATURE_EASYCOM_EMULATION) + if (remote_port_tx_sniff) {control_port->println("RR");} + #endif + // remote_unit_command_submitted = REMOTE_UNIT_RR_COMMAND; + break; + + case REMOTE_UNIT_RD_COMMAND: + #ifdef FEATURE_MASTER_WITH_SERIAL_SLAVE + REMOTE_PORT.println("RD"); + #endif //FEATURE_MASTER_WITH_SERIAL_SLAVE + #ifdef FEATURE_MASTER_WITH_ETHERNET_SLAVE + ethernet_slave_link_send("RD"); + #endif //FEATURE_MASTER_WITH_ETHERNET_SLAVE + #if defined(FEATURE_REMOTE_UNIT_SLAVE) || defined(FEATURE_YAESU_EMULATION) || defined(FEATURE_EASYCOM_EMULATION) + if (remote_port_tx_sniff) {control_port->println("RD");} + #endif + // remote_unit_command_submitted = REMOTE_UNIT_RD_COMMAND; + break; + + case REMOTE_UNIT_RU_COMMAND: + #ifdef FEATURE_MASTER_WITH_SERIAL_SLAVE + REMOTE_PORT.println("RU"); + #endif //FEATURE_MASTER_WITH_SERIAL_SLAVE + #ifdef FEATURE_MASTER_WITH_ETHERNET_SLAVE + ethernet_slave_link_send("RU"); + #endif //FEATURE_MASTER_WITH_ETHERNET_SLAVE + #if defined(FEATURE_REMOTE_UNIT_SLAVE) || defined(FEATURE_YAESU_EMULATION) || defined(FEATURE_EASYCOM_EMULATION) + if (remote_port_tx_sniff) {control_port->println("RU");} + #endif + // remote_unit_command_submitted = REMOTE_UNIT_RU_COMMAND; + break; + + case REMOTE_UNIT_RA_COMMAND: + #ifdef FEATURE_MASTER_WITH_SERIAL_SLAVE + REMOTE_PORT.println("RA"); + #endif //FEATURE_MASTER_WITH_SERIAL_SLAVE + #ifdef FEATURE_MASTER_WITH_ETHERNET_SLAVE + ethernet_slave_link_send("RA"); + #endif //FEATURE_MASTER_WITH_ETHERNET_SLAVE + #if defined(FEATURE_REMOTE_UNIT_SLAVE) || defined(FEATURE_YAESU_EMULATION) || defined(FEATURE_EASYCOM_EMULATION) + if (remote_port_tx_sniff) {control_port->println("RA");} + #endif + // remote_unit_command_submitted = REMOTE_UNIT_RA_COMMAND; + break; + + case REMOTE_UNIT_RE_COMMAND: + #ifdef FEATURE_MASTER_WITH_SERIAL_SLAVE + REMOTE_PORT.println("RE"); + #endif //FEATURE_MASTER_WITH_SERIAL_SLAVE + #ifdef FEATURE_MASTER_WITH_ETHERNET_SLAVE + ethernet_slave_link_send("RE"); + #endif //FEATURE_MASTER_WITH_ETHERNET_SLAVE + #if defined(FEATURE_REMOTE_UNIT_SLAVE) || defined(FEATURE_YAESU_EMULATION) || defined(FEATURE_EASYCOM_EMULATION) + if (remote_port_tx_sniff) {control_port->println("RE");} + #endif + // remote_unit_command_submitted = REMOTE_UNIT_RE_COMMAND; + break; + + case REMOTE_UNIT_RS_COMMAND: + #ifdef FEATURE_MASTER_WITH_SERIAL_SLAVE + REMOTE_PORT.println("RS"); + #endif //FEATURE_MASTER_WITH_SERIAL_SLAVE + #ifdef FEATURE_MASTER_WITH_ETHERNET_SLAVE + ethernet_slave_link_send("RS"); + #endif //FEATURE_MASTER_WITH_ETHERNET_SLAVE + #if defined(FEATURE_REMOTE_UNIT_SLAVE) || defined(FEATURE_YAESU_EMULATION) || defined(FEATURE_EASYCOM_EMULATION) + if (remote_port_tx_sniff) {control_port->println("RS");} + #endif + // remote_unit_command_submitted = REMOTE_UNIT_RS_COMMAND; + break; + + } /* switch */ + // last_remote_unit_command_time = millis(); + // remote_unit_command_results_available = 0; + return 1; } + + + +} /* submit_remote_command */ +#endif // defined(FEATURE_MASTER_WITH_SERIAL_SLAVE) || defined(FEATURE_MASTER_WITH_ETHERNET_SLAVE) + +// -------------------------------------------------------------------------- + +#if defined(FEATURE_MASTER_WITH_SERIAL_SLAVE) || defined(FEATURE_MASTER_WITH_ETHERNET_SLAVE) + byte is_ascii_number(byte char_in){ + + if ((char_in > 47) && (char_in < 58)) { + return 1; + } else { + return 0; + } + + } +#endif // defined(FEATURE_MASTER_WITH_SERIAL_SLAVE) || defined(FEATURE_MASTER_WITH_ETHERNET_SLAVE) +// -------------------------------------------------------------------------- +#if defined(FEATURE_MASTER_WITH_SERIAL_SLAVE) || defined(FEATURE_MASTER_WITH_ETHERNET_SLAVE) + void service_remote_communications_incoming_buffer(){ + + + #if defined(FEATURE_CLOCK) && defined(OPTION_SYNC_MASTER_CLOCK_TO_SLAVE) + int temp_year = 0; + byte temp_month = 0; + byte temp_day = 0; + byte temp_minute = 0; + byte temp_hour = 0; + byte temp_sec = 0; + #endif // defined(FEATURE_CLOCK) && defined(OPTION_SYNC_MASTER_CLOCK_TO_SLAVE) + + float temp_float_latitude = 0; + float temp_float_longitude = 0; + + + + byte good_data = 0; + + if (remote_unit_port_buffer_carriage_return_flag) { + + #ifdef DEBUG_SVC_REMOTE_COMM_INCOMING_BUFFER + debug.print("service_remote_communications_incoming_buffer: remote_unit_port_buffer_index: "); + debug.print(remote_unit_port_buffer_index); + debug.print(" buffer: "); + for (int x = 0; x < remote_unit_port_buffer_index; x++) { + debug.write((char*)remote_unit_port_buffer[x]); + debug.println("$"); + } + #endif // DEBUG_SVC_REMOTE_COMM_INCOMING_BUFFER + + + // Ping for Master Response + if ((remote_unit_port_buffer[0] == 'P') && (remote_unit_port_buffer[1] == 'M')) { + last_ping_receive_time = millis(); + good_data = 1; + } + + // OK Response - Still Needed? + if ((remote_unit_port_buffer[0] == 'O') && (remote_unit_port_buffer[1] == 'K')) { + good_data = 1; + } + + //REMOTE_UNIT_RC_COMMAND: //RC+40.9946 -075.6596 + #if defined(OPTION_SYNC_MASTER_COORDINATES_TO_SLAVE) + if ((remote_unit_port_buffer[0] == 'R') && (remote_unit_port_buffer[1] == 'C') && (remote_unit_port_buffer[5] == '.') && (remote_unit_port_buffer[10] == ' ') && (remote_unit_port_buffer[15] == '.')){ + temp_float_latitude = ((remote_unit_port_buffer[3]-48)*10) + (remote_unit_port_buffer[4]-48) + ((remote_unit_port_buffer[6]-48)/10.0) + ((remote_unit_port_buffer[7]-48)/100.0) + ((remote_unit_port_buffer[8]-48)/1000.0) + ((remote_unit_port_buffer[9]-48)/10000.0); + if (remote_unit_port_buffer[2] == '-') { + temp_float_latitude = temp_float_latitude * -1; + } + temp_float_longitude = ((remote_unit_port_buffer[12]-48)*100) + ((remote_unit_port_buffer[13]-48)*10) + (remote_unit_port_buffer[14]-48) + ((remote_unit_port_buffer[16]-48)/10.0)+ ((remote_unit_port_buffer[17]-48)/100.0) + ((remote_unit_port_buffer[18]-48)/1000.0) + ((remote_unit_port_buffer[19]-48)/10000.0); + if (remote_unit_port_buffer[11] == '-') { + temp_float_longitude = temp_float_longitude * -1; + } + if ((temp_float_latitude <= 90) && (temp_float_latitude >= -90) && (temp_float_longitude <= 180) && (temp_float_longitude >= -180)){ + latitude = temp_float_latitude; + longitude = temp_float_longitude; + #ifdef DEBUG_SYNC_MASTER_COORDINATES_TO_SLAVE + debug.println("service_remote_communications_incoming_buffer: coordinates synced to slave"); + #endif //DEBUG_SYNC_MASTER_COORDINATES_TO_SLAVE + } + good_data = 1; + } + #endif //OPTION_SYNC_MASTER_COORDINATES_TO_SLAVE + + // REMOTE_UNIT_GS_COMMAND: + #if defined(OPTION_SYNC_MASTER_CLOCK_TO_SLAVE) && defined(FEATURE_CLOCK) + if ((remote_unit_port_buffer[0] == 'G') && (remote_unit_port_buffer[1] == 'S')){ + if (remote_unit_port_buffer[2] == '1'){ + if (clock_status == SLAVE_SYNC) {clock_status = SLAVE_SYNC_GPS;} + good_data = 1; + } else { + if (remote_unit_port_buffer[2] == '0') {good_data = 1;} + } + } + #endif // defined(OPTION_SYNC_MASTER_CLOCK_TO_SLAVE) && defined(FEATURE_CLOCK) + + + // REMOTE_UNIT_CL_COMMAND: + if ((remote_unit_port_buffer[0] == 'C') && (remote_unit_port_buffer[1] == 'L') && (remote_unit_port_buffer[12] == ' ') && (remote_unit_port_buffer[21] == 'Z')){ + #if defined(FEATURE_CLOCK) && defined(OPTION_SYNC_MASTER_CLOCK_TO_SLAVE) + temp_year = ((remote_unit_port_buffer[2] - 48) * 1000) + ((remote_unit_port_buffer[3] - 48) * 100) + ((remote_unit_port_buffer[4] - 48) * 10) + (remote_unit_port_buffer[5] - 48); + temp_month = ((remote_unit_port_buffer[7] - 48) * 10) + (remote_unit_port_buffer[8] - 48); + temp_day = ((remote_unit_port_buffer[10] - 48) * 10) + (remote_unit_port_buffer[11] - 48); + temp_hour = ((remote_unit_port_buffer[13] - 48) * 10) + (remote_unit_port_buffer[14] - 48); + temp_minute = ((remote_unit_port_buffer[16] - 48) * 10) + (remote_unit_port_buffer[17] - 48); + temp_sec = ((remote_unit_port_buffer[19] - 48) * 10) + (remote_unit_port_buffer[20] - 48); + if ((temp_year > 2013) && (temp_year < 2070) && (temp_month > 0) && (temp_month < 13) && (temp_day > 0) && (temp_day < 32) && (temp_hour < 24) && (temp_minute < 60) && (temp_sec < 60)){ + #if defined(OPTION_USE_OLD_TIME_CODE) + set_clock.year = temp_year; + set_clock.month = temp_month; + set_clock.day = temp_day; + set_clock.hours = temp_hour; + set_clock.minutes = temp_minute; + set_clock.seconds = temp_sec; + millis_at_last_calibration = millis(); + //update_time(); + #else //OPTION_USE_OLD_TIME_CODE + setTime(temp_hour, temp_minute, temp_sec, temp_day, temp_month, temp_year); + #endif //OPTION_USE_OLD_TIME_CODE + #ifdef DEBUG_SYNC_MASTER_CLOCK_TO_SLAVE + debug.println("service_remote_communications_incoming_buffer: clock synced to slave clock"); + #endif //DEBUG_SYNC_MASTER_CLOCK_TO_SLAVE + good_data = 1; + clock_synced_to_remote = 1; + if (clock_status == FREE_RUNNING) {clock_status = SLAVE_SYNC;} + } else { + #ifdef DEBUG_SYNC_MASTER_CLOCK_TO_SLAVE + debug.println("service_remote_communications_incoming_buffer: slave clock sync error"); + #endif //DEBUG_SYNC_MASTER_CLOCK_TO_SLAVE + if ((clock_status == SLAVE_SYNC) || (clock_status == SLAVE_SYNC_GPS)) {clock_status = FREE_RUNNING;} + } + #endif // defined(FEATURE_CLOCK) && defined(OPTION_SYNC_MASTER_CLOCK_TO_SLAVE) + #if !defined(FEATURE_CLOCK) || !defined(OPTION_SYNC_MASTER_CLOCK_TO_SLAVE) + good_data = 1; + #endif //!defined(FEATURE_CLOCK) || !defined(OPTION_SYNC_MASTER_CLOCK_TO_SLAVE) + } else { + #if defined(FEATURE_CLOCK) && defined(OPTION_SYNC_MASTER_CLOCK_TO_SLAVE) + #if defined(DEBUG_SYNC_MASTER_CLOCK_TO_SLAVE) + debug.print("service_remote_communications_incoming_buffer: REMOTE_UNIT_CL_COMMAND format error. remote_unit_port_buffer_index: "); + debug.print(remote_unit_port_buffer_index); + debug.println(""); + #endif // defined(DEBUG_SYNC_MASTER_CLOCK_TO_SLAVE) + if ((clock_status == SLAVE_SYNC) || (clock_status == SLAVE_SYNC_GPS)) {clock_status = FREE_RUNNING;} + #endif // defined(FEATURE_CLOCK) && defined(OPTION_SYNC_MASTER_CLOCK_TO_SLAVE) + } + + if ((remote_unit_port_buffer_index == 13) && (remote_unit_port_buffer[0] == 'A') && (remote_unit_port_buffer[1] == 'Z') && + (is_ascii_number(remote_unit_port_buffer[2])) && (is_ascii_number(remote_unit_port_buffer[3])) && (is_ascii_number(remote_unit_port_buffer[4])) && (is_ascii_number(remote_unit_port_buffer[6])) && (is_ascii_number(remote_unit_port_buffer[7])) && (is_ascii_number(remote_unit_port_buffer[8])) && (is_ascii_number(remote_unit_port_buffer[9])) && (is_ascii_number(remote_unit_port_buffer[10])) && (is_ascii_number(remote_unit_port_buffer[11]))) { + remote_unit_azimuth_float = float((remote_unit_port_buffer[2] - 48) * 100) + float((remote_unit_port_buffer[3] - 48) * 10) + float(remote_unit_port_buffer[4] - 48) + (float(remote_unit_port_buffer[6] - 48) / (float)10.0) + (float(remote_unit_port_buffer[7] - 48) / (float)100.0) + (float(remote_unit_port_buffer[8] - 48) / (float)1000.0) + (float(remote_unit_port_buffer[9] - 48) / (float)10000.0) + (float(remote_unit_port_buffer[10] - 48) / (float)100000.0) + (float(remote_unit_port_buffer[11] - 48) / (float)1000000.0); + good_data = 1; + } + + if ((remote_unit_port_buffer_index == 14) && (remote_unit_port_buffer[0] == 'E') && (remote_unit_port_buffer[1] == 'L') && + (is_ascii_number(remote_unit_port_buffer[3])) && (is_ascii_number(remote_unit_port_buffer[4])) && (is_ascii_number(remote_unit_port_buffer[5])) && (is_ascii_number(remote_unit_port_buffer[7])) && (is_ascii_number(remote_unit_port_buffer[8])) && (is_ascii_number(remote_unit_port_buffer[9])) && (is_ascii_number(remote_unit_port_buffer[10])) && (is_ascii_number(remote_unit_port_buffer[11])) && (is_ascii_number(remote_unit_port_buffer[12]))) { + remote_unit_elevation_float = (float(remote_unit_port_buffer[3] - 48) * 100) + float((remote_unit_port_buffer[4] - 48) * 10) + float(remote_unit_port_buffer[5] - 48) + (float(remote_unit_port_buffer[7] - 48) / (float)10.0) + (float(remote_unit_port_buffer[8] - 48) / (float)100.0) + (float(remote_unit_port_buffer[9] - 48) / (float)1000.0) + (float(remote_unit_port_buffer[10] - 48) / (float)10000.0) + (float(remote_unit_port_buffer[11] - 48) / (float)100000.0) + (float(remote_unit_port_buffer[12] - 48) / (float)1000000.0); + if (remote_unit_port_buffer[2] == '+') { + good_data = 1; + } + if (remote_unit_port_buffer[2] == '-') { + remote_unit_elevation_float = remote_unit_elevation_float * (float)-1.0; + good_data = 1; + } + } + + + if (good_data) { + + remote_unit_good_results++; + + // #ifdef DEBUG_SVC_REMOTE_COMM_INCOMING_BUFFER + // debug.print("service_remote_communications_incoming_buffer: remote_unit_command_results_available: "); + // debug.print(remote_unit_command_results_available); + // debug.print(" remote_unit_command_result_float: "); + // debug.print(remote_unit_command_result_float,2); + // debug.println(""); + // #endif // DEBUG_SVC_REMOTE_COMM_INCOMING_BUFFER + } else { + #ifdef DEBUG_SVC_REMOTE_COMM_INCOMING_BUFFER_BAD_DATA + debug.print("service_remote_communications_incoming_buffer:"); + // switch (remote_unit_command_submitted) { + // case REMOTE_UNIT_AZ_COMMAND: debug.print("REMOTE_UNIT_AZ_COMMAND"); break; + // case REMOTE_UNIT_EL_COMMAND: debug.print("REMOTE_UNIT_EL_COMMAND"); break; + // case REMOTE_UNIT_OTHER_COMMAND: debug.print("REMOTE_UNIT_OTHER_COMMAND"); break; + // default: debug.print("UNDEFINED"); break; + // } + debug.print(" buffer_index:"); + debug.print(remote_unit_port_buffer_index); + debug.print(" buffer: "); + for (int x = 0; x < remote_unit_port_buffer_index; x++) { + debug.write((char*)remote_unit_port_buffer[x]); + } + debug.println("$"); + #endif // DEBUG_SVC_REMOTE_COMM_INCOMING_BUFFER_BAD_DATA + + + // remote_unit_command_results_available = 0; + remote_unit_bad_results++; + } + // remote_unit_command_submitted = 0; + + remote_unit_port_buffer_carriage_return_flag = 0; + remote_unit_port_buffer_index = 0; + } + + // has a command timed out? + // if ((remote_unit_command_submitted) && ((millis() - last_remote_unit_command_time) > REMOTE_UNIT_COMMAND_TIMEOUT_MS)){ + + // #if defined(FEATURE_CLOCK) && defined(OPTION_SYNC_MASTER_CLOCK_TO_SLAVE) + // if ((remote_unit_command_submitted == REMOTE_UNIT_CL_COMMAND) && ((clock_status == SLAVE_SYNC) || (clock_status == SLAVE_SYNC_GPS))){ + // clock_status = FREE_RUNNING; + // } + // #endif //defined(FEATURE_CLOCK) && defined(OPTION_SYNC_MASTER_CLOCK_TO_SLAVE) + + // remote_unit_command_timeouts++; + // remote_unit_command_submitted = 0; + // remote_unit_port_buffer_index = 0; + + // } + + // have characters been in the buffer for some time but no carriage return? + if ((remote_unit_port_buffer_index) /*&& (!remote_unit_command_submitted)*/ && ((millis() - serial1_last_receive_time) > REMOTE_UNIT_COMMAND_TIMEOUT_MS)) { + remote_unit_port_buffer_index = 0; + remote_unit_incoming_buffer_timeouts++; + } + + } /* service_remote_communications_incoming_buffer */ + +#endif // defined(FEATURE_MASTER_WITH_SERIAL_SLAVE) || defined(FEATURE_MASTER_WITH_ETHERNET_SLAVE) + + +//------------------------------------------------------ + +#if defined(FEATURE_MASTER_WITH_SERIAL_SLAVE) || defined(FEATURE_MASTER_WITH_ETHERNET_SLAVE) || defined(FEATURE_REMOTE_UNIT_SLAVE) + void service_master_remote_link_state(){ + + static unsigned long last_ping_send_time = 0; + + #if defined(FEATURE_MASTER_WITH_SERIAL_SLAVE) || defined(FEATURE_MASTER_WITH_ETHERNET_SLAVE) + + if (((float)(millis() - (float)last_ping_send_time) > ((float)MASTER_REMOTE_LINK_PING_TIME_MS * (float)0.8)) || (master_remote_link_state == MASTER_REMOTE_LINK_DOWN)){ + submit_remote_command(REMOTE_UNIT_PM_COMMAND,0,0); + last_ping_send_time = millis(); + } + + if ((millis() - last_ping_receive_time) < MASTER_REMOTE_LINK_PING_TIME_MS){ + master_remote_link_state = MASTER_REMOTE_LINK_UP; + } else { + master_remote_link_state = MASTER_REMOTE_LINK_DOWN; + } + + #endif //defined(FEATURE_MASTER_WITH_SERIAL_SLAVE) || defined(FEATURE_MASTER_WITH_ETHERNET_SLAVE) + + + #if defined(FEATURE_REMOTE_UNIT_SLAVE) + + if (((float)(millis() - (float)last_ping_send_time) > ((float)MASTER_REMOTE_LINK_PING_TIME_MS * (float)0.8)) || (master_remote_link_state == MASTER_REMOTE_LINK_DOWN)){ + // submit_remote_command(REMOTE_UNIT_PM_COMMAND,0,0); + last_ping_send_time = millis(); + } + + if ((millis() - last_ping_receive_time) < MASTER_REMOTE_LINK_PING_TIME_MS){ + master_remote_link_state = MASTER_REMOTE_LINK_UP; + } else { + master_remote_link_state = MASTER_REMOTE_LINK_DOWN; + } + + + #endif //defined(FEATURE_REMOTE_UNIT_SLAVE) + + + } + + + #endif //defined(FEATURE_MASTER_WITH_SERIAL_SLAVE) || defined(FEATURE_MASTER_WITH_ETHERNET_SLAVE) + + // that's all, folks ! diff --git a/k3ng_rotator_controller/rotator.h b/k3ng_rotator_controller/rotator.h index ea6129a..6041f47 100755 --- a/k3ng_rotator_controller/rotator.h +++ b/k3ng_rotator_controller/rotator.h @@ -116,8 +116,8 @@ #define ROTATING_DOWN 4 #define REMOTE_UNIT_NO_COMMAND 0 -#define REMOTE_UNIT_AZ_COMMAND 1 -#define REMOTE_UNIT_EL_COMMAND 2 +// #define REMOTE_UNIT_AZ_COMMAND 1 +// #define REMOTE_UNIT_EL_COMMAND 2 #define REMOTE_UNIT_OTHER_COMMAND 3 #define REMOTE_UNIT_AW_COMMAND 4 #define REMOTE_UNIT_DHL_COMMAND 5 @@ -132,7 +132,7 @@ #define REMOTE_UNIT_RA_COMMAND 14 #define REMOTE_UNIT_RE_COMMAND 15 #define REMOTE_UNIT_RS_COMMAND 16 -#define REMOTE_UNIT_PG_COMMAND 17 +#define REMOTE_UNIT_PM_COMMAND 17 #define NOT_PARKED 0 #define PARK_INITIATED 1 @@ -334,6 +334,7 @@ #define NEXTION_TRANSIENT_MESSAGE_REQUESTED 1 #define NEXTION_TRANSIENT_MESSAGE_IN_PROGRESS 2 - +#define MASTER_REMOTE_LINK_DOWN 0 +#define MASTER_REMOTE_LINK_UP 1 /* ------end of macros ------- */ \ No newline at end of file diff --git a/k3ng_rotator_controller/rotator_debug_log_activation.h b/k3ng_rotator_controller/rotator_debug_log_activation.h index 81d8ef6..88a6b69 100644 --- a/k3ng_rotator_controller/rotator_debug_log_activation.h +++ b/k3ng_rotator_controller/rotator_debug_log_activation.h @@ -80,4 +80,4 @@ // #define DEBUG_SATELLITE_POPULATE_LIST_ARRAY // #define DEBUG_SATELLITE_LIST_EXTRA_INFO // #define DEBUG_SATELLITE_CALC_RESET -// #define DEBUG_SATELLITE_USE_OLD_OBSERVER_OBJECT \ No newline at end of file +// #define DEBUG_SATELLITE_USE_OLD_OBSERVER_OBJECT // Deprecated 2022-02-20 \ No newline at end of file diff --git a/k3ng_rotator_controller/rotator_features_wb6kcn_k3ng.h b/k3ng_rotator_controller/rotator_features_wb6kcn_k3ng.h index ddecca2..0c58304 100755 --- a/k3ng_rotator_controller/rotator_features_wb6kcn_k3ng.h +++ b/k3ng_rotator_controller/rotator_features_wb6kcn_k3ng.h @@ -7,7 +7,7 @@ /* main features */ #define FEATURE_ELEVATION_CONTROL // uncomment this for AZ/EL rotators -// #define FEATURE_YAESU_EMULATION // uncomment this for Yaesu GS-232 emulation on control port +#define FEATURE_YAESU_EMULATION // uncomment this for Yaesu GS-232 emulation on control port // #define FEATURE_EASYCOM_EMULATION // Easycom protocol emulation on control port // #define FEATURE_DCU_1_EMULATION // DCU-1 protocol emulation on control port (only supports azimuth only systems) @@ -23,7 +23,7 @@ // #define FEATURE_TEST_DISPLAY_AT_STARTUP // #define FEATURE_CALIBRATION // under development - this will get rid of azimuth and elevation offsets and replace with runtime calibration tables -// #define FEATURE_SATELLITE_TRACKING // https://github.com/k3ng/k3ng_rotator_controller/wiki/707-Satellite-Tracking +#define FEATURE_SATELLITE_TRACKING // https://github.com/k3ng/k3ng_rotator_controller/wiki/707-Satellite-Tracking #define LANGUAGE_ENGLISH // all languages customized in rotator_language.h // #define LANGUAGE_SPANISH @@ -36,7 +36,7 @@ // #define LANGUAGE_NORWEGIAN_BOKMAAL /* master and remote slave unit functionality */ -#define FEATURE_REMOTE_UNIT_SLAVE // uncomment this to make this unit a remote unit controlled by a host unit +// #define FEATURE_REMOTE_UNIT_SLAVE // uncomment this to make this unit a remote unit controlled by a host unit // #define FEATURE_MASTER_WITH_SERIAL_SLAVE // [master]{remote_port}<-------serial-------->{control_port}[slave] // #define FEATURE_MASTER_WITH_ETHERNET_SLAVE // [master]<-------------------ethernet--------------------->[slave] diff --git a/k3ng_rotator_controller/rotator_settings.h b/k3ng_rotator_controller/rotator_settings.h index 3859f81..f938aec 100755 --- a/k3ng_rotator_controller/rotator_settings.h +++ b/k3ng_rotator_controller/rotator_settings.h @@ -111,7 +111,7 @@ You can tweak these, but read the online documentation! #define ELEVATION_TOLERANCE 0.1 //1.0 #define OPERATION_TIMEOUT 120000 // timeout for any rotation operation in mS ; 120 seconds is usually enough unless you have the speed turned down -#define REMOTE_UNIT_ROTATION_TIMEOUT 5000 // timeout any remote unit rotation operation if a ping (PG) is not receive within 5 seconds +#define MASTER_REMOTE_LINK_PING_TIME_MS 5000 #define TIMED_INTERVAL_ARRAY_SIZE 20 diff --git a/k3ng_rotator_controller/rotator_settings_test.h b/k3ng_rotator_controller/rotator_settings_test.h index 9084d90..f85f372 100755 --- a/k3ng_rotator_controller/rotator_settings_test.h +++ b/k3ng_rotator_controller/rotator_settings_test.h @@ -121,7 +121,7 @@ You can tweak these, but read the online documentation! #define ELEVATION_TOLERANCE 5.0 #define OPERATION_TIMEOUT 120000 // timeout for any rotation operation in mS ; 120 seconds is usually enough unless you have the speed turned down -#define REMOTE_UNIT_ROTATION_TIMEOUT 5000 // timeout any remote unit rotation operation if a ping (PG) is not receive within 5 seconds +#define MASTER_REMOTE_LINK_PING_TIME_MS 5000 #define TIMED_INTERVAL_ARRAY_SIZE 20 @@ -181,9 +181,9 @@ You can tweak these, but read the online documentation! #define COMMAND_BUFFER_SIZE 50 #define REMOTE_BUFFER_TIMEOUT_MS 250 -#define REMOTE_UNIT_COMMAND_TIMEOUT_MS 2000 -#define AZ_REMOTE_UNIT_QUERY_TIME_MS 150 // how often we query the remote remote for azimuth -#define EL_REMOTE_UNIT_QUERY_TIME_MS 150 // how often we query the remote remote for elevation +// #define REMOTE_UNIT_COMMAND_TIMEOUT_MS 2000 +// #define AZ_REMOTE_UNIT_QUERY_TIME_MS 150 // how often we query the remote remote for azimuth +// #define EL_REMOTE_UNIT_QUERY_TIME_MS 150 // how often we query the remote remote for elevation #define AZIMUTH_SMOOTHING_FACTOR 0 // value = 0 to 99.9 #define ELEVATION_SMOOTHING_FACTOR 0 // value = 0 to 99.9 @@ -354,7 +354,7 @@ You can tweak these, but read the online documentation! #define CONTROL_PORT_MAPPED_TO &Serial // change this line to map the control port to a different serial port (Serial1, Serial2, etc.) #define CONTROL_PORT_BAUD_RATE 115200 #define REMOTE_PORT Serial3 // used to control remote unit -#define REMOTE_UNIT_PORT_BAUD_RATE 9600 +#define REMOTE_UNIT_PORT_BAUD_RATE 57600 #define GPS_PORT Serial2 #define GPS_PORT_BAUD_RATE 9600 // #define GPS_MIRROR_PORT Serial1 // use this to mirror output from a GPS unit into the Arduino out another port (uncomment to enable) diff --git a/k3ng_rotator_controller/rotator_settings_wb6kcn_k3ng.h b/k3ng_rotator_controller/rotator_settings_wb6kcn_k3ng.h index 8343760..bec5c91 100755 --- a/k3ng_rotator_controller/rotator_settings_wb6kcn_k3ng.h +++ b/k3ng_rotator_controller/rotator_settings_wb6kcn_k3ng.h @@ -111,7 +111,7 @@ You can tweak these, but read the online documentation! #define ELEVATION_TOLERANCE 0.01 //1.0 #define OPERATION_TIMEOUT 120000 // timeout for any rotation operation in mS ; 120 seconds is usually enough unless you have the speed turned down -#define REMOTE_UNIT_ROTATION_TIMEOUT 5000 // timeout any remote unit rotation operation if a ping (PG) is not receive within 5 seconds +#define MASTER_REMOTE_LINK_PING_TIME_MS 5000 #define REMOTE_UNIT_ROTATION_COMMAND_REPEAT_MS 500 // used by the master unit; this need to be less than OPERATION_TIMEOUT on the remote unit @@ -173,9 +173,9 @@ You can tweak these, but read the online documentation! #define COMMAND_BUFFER_SIZE 50 #define REMOTE_BUFFER_TIMEOUT_MS 250 -#define REMOTE_UNIT_COMMAND_TIMEOUT_MS 2000 -#define AZ_REMOTE_UNIT_QUERY_TIME_MS 150 // how often we query the remote remote for azimuth -#define EL_REMOTE_UNIT_QUERY_TIME_MS 150 // how often we query the remote remote for elevation +// #define REMOTE_UNIT_COMMAND_TIMEOUT_MS 2000 +// #define AZ_REMOTE_UNIT_QUERY_TIME_MS 150 // how often we query the remote remote for azimuth +// #define EL_REMOTE_UNIT_QUERY_TIME_MS 150 // how often we query the remote remote for elevation #define AZIMUTH_SMOOTHING_FACTOR 0 // value = 0 to 99.9 #define ELEVATION_SMOOTHING_FACTOR 0 // value = 0 to 99.9 @@ -197,10 +197,10 @@ You can tweak these, but read the online documentation! #define SERIAL_LED_TIME_MS 250 -// #define DEFAULT_LATITUDE 1.0 -// #define DEFAULT_LONGITUDE -2.0 -#define DEFAULT_LATITUDE 40.889958 -#define DEFAULT_LONGITUDE -75.585972 +#define DEFAULT_LATITUDE 1.0 +#define DEFAULT_LONGITUDE -2.0 +// #define DEFAULT_LATITUDE 40.889958 +// #define DEFAULT_LONGITUDE -75.585972 #define MOON_TRACKING_CHECK_INTERVAL 5000 // This is only written to the configuration upon first boot of the code or when EEPROM_MAGIC_NUMBER is changed in rotator.h #define MOON_AOS_AZIMUTH_MIN 0 @@ -348,8 +348,8 @@ You can tweak these, but read the online documentation! // Changed in 2020.06.26.02 // Serial Port Settings -#define CONTROL_PORT_MAPPED_TO &Serial3 // change this line to map the control port to a different serial port (Serial1, Serial2, etc.) -#define CONTROL_PORT_BAUD_RATE 9600 //115200 +#define CONTROL_PORT_MAPPED_TO &Serial // change this line to map the control port to a different serial port (Serial1, Serial2, etc.) +#define CONTROL_PORT_BAUD_RATE 115200 //57600 #define REMOTE_PORT Serial3 // used to control remote unit #define REMOTE_UNIT_PORT_BAUD_RATE 9600 #define GPS_PORT Serial2 diff --git a/libraries/P13/P13.cpp b/libraries/P13/P13.cpp index 71a2233..34e8bb3 100755 --- a/libraries/P13/P13.cpp +++ b/libraries/P13/P13.cpp @@ -24,6 +24,44 @@ // So, here it is! // +/* + +Copyright 2011, Mark VandeWettering. All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer + in the documentation and/or other materials provided with the + distribution. + +THIS SOFTWARE IS PROVIDED BY MARK VANDEWETTERING ''AS IS'' AND ANY +EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL OR +CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR +PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF +LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +The views and conclusions contained in the software and documentation +are those of the authors and should not be interpreted as representing +official policies, either expressed or implied, of Mark VandeWettering + +*/ + +// Modification by Anthony Good, K3NG 2020-07-24: Changed DateTime to SatDateTime to avoid a conflict with an RTC library I'm using + +// Modification by Anthony Good, K3NG 2022-02-20: Added Observer.update_location function + #include "P13.h" double @@ -184,6 +222,45 @@ Observer::Observer(const char *nm, double lat, double lng, double hgt) V[2] = 0 ; } +// START - 2022-02-20 Added by Goody K3NG +void +Observer::update_location(const char *nm, double lat, double lng, double hgt) +{ + this->name = nm ; + LA = RADIANS(lat) ; + LO = RADIANS(lng) ; + HT = hgt / 1000 ; + + U[0] = cos(LA)*cos(LO) ; + U[1] = cos(LA)*sin(LO) ; + U[2] = sin(LA) ; + + E[0] = -sin(LO) ; + E[1] = cos(LO) ; + E[2] = 0. ; + + N[0] = -sin(LA)*cos(LO) ; + N[1] = -sin(LA)*sin(LO) ; + N[2] = cos(LA) ; + + double RP = RE * (1 - FL) ; + double XX = RE * RE ; + double ZZ = RP * RP ; + double D = sqrt(XX*cos(LA)*cos(LA) + + ZZ*sin(LA)*sin(LA)) ; + double Rx = XX / D + HT ; + double Rz = ZZ / D + HT ; + + O[0] = Rx * U[0] ; + O[1] = Rx * U[1] ; + O[2] = Rz * U[2] ; + + V[0] = -O[1] * W0 ; + V[1] = O[0] * W0 ; + V[2] = 0 ; +} +// END - 2022-02-20 Added by Goody K3NG + //---------------------------------------------------------------------- // _ ___ _ _ _ _ _ // __| |__ _ ______ / __| __ _| |_ ___| | (_) |_ ___ diff --git a/libraries/P13/P13.h b/libraries/P13/P13.h index 2f3450d..80ee84b 100755 --- a/libraries/P13/P13.h +++ b/libraries/P13/P13.h @@ -58,7 +58,9 @@ official policies, either expressed or implied, of Mark VandeWettering */ -// Modification by Anthony Good, K3NG 2020-07-24: Change DateTime to SatDateTime to avoid a conflict with an RTC library I'm using +// Modification by Anthony Good, K3NG 2020-07-24: Changed DateTime to SatDateTime to avoid a conflict with an RTC library I'm using + +// Modification by Anthony Good, K3NG 2022-02-20: Added Observer.update_location function //---------------------------------------------------------------------- @@ -139,6 +141,8 @@ public: Observer(const char *, double, double, double) ; ~Observer() { } ; + + void update_location(const char *nm, double lat, double lng, double hgt); // 2022-02-20 Added by Goody K3NG } ; //---------------------------------------------------------------------- @@ -147,7 +151,7 @@ public: class Satellite { long N ; long YE ; - long DE ; + long DE ; double TE ; double IN ; double RA ; @@ -171,7 +175,9 @@ class Satellite { double RS ; public: - const char *name ; + + const char *name ; + Vec3 SAT, VEL ; // celestial coordinates Vec3 S, V ; // geocentric coordinates