ufechner Geschrieben June 30, 2017 at 20:39 Geschrieben June 30, 2017 at 20:39 Hallo, die Funktion gps_v2_get_satellite_status funktioniert nicht, wenn man versucht den Status der GLONASS Satelliten abzufragen. Könnt Ihr diesen Bug reproduzieren? Uwe Zitieren
borg Geschrieben July 3, 2017 at 07:50 Geschrieben July 3, 2017 at 07:50 Hast du folgendes gelesen: "Die Satellitennummer hat hier immer einen Bereich von 1 bis 32. Bei GLONASS entspricht dieser Bereich den Satelliten 65-96."? Zitieren
ufechner Geschrieben July 3, 2017 at 13:36 Autor Geschrieben July 3, 2017 at 13:36 Ja, wir habe die api Beschreibung gelesen. Als Anlage ein Beispielprogramm um den Bug zu demonstrieren und ein Screenshot von der Ausgabe dieses Programms. Könnt Ihr das Problem reproduzieren? Uwemain.c Zitieren
photron Geschrieben July 3, 2017 at 15:49 Geschrieben July 3, 2017 at 15:49 Welcher Fehlercode wird den vom Getter zurückgegeben in dem Fall wo dein Programm "Could not get satellite status, probably timeout" ausgibt? Zitieren
borg Geschrieben July 3, 2017 at 16:06 Geschrieben July 3, 2017 at 16:06 @ufechner: Ihr hattet die API leider nicht richtig verstanden. Der Index mit dem auf die Satellitennummer zugegriffen wird läuft immer von 1-32. Der Code müsste so aussehen: #include <stdio.h> #include <signal.h> #include <unistd.h> #include "ip_connection.h" #include "bricklet_gps_v2.h" //#define HOST "192.168.1.6" #define HOST "localhost" #define PORT 4223 #define UID "CHk" // Change XYZ to the UID of your GPS Bricklet 2.0 volatile sig_atomic_t terminate = 0; GPSV2 gps; void sig_handler(int signo) { if (signo == SIGINT) { printf("received SIGINT\n"); terminate = 1; } } void readSatelliteStatus() { uint8_t satellite_system; uint8_t ret_satellite_numbers_length; uint8_t ret_satellite_numbers_data[12]; int16_t ret_elevation; int16_t ret_azimuth; int16_t ret_snr; uint8_t ret_fix; uint16_t ret_pdop, ret_hdop, ret_vdop; uint8_t satellite_index; int sum_satellite = 0; for (satellite_system = 0; satellite_system < 2; satellite_system++) { if (gps_v2_get_satellite_system_status_low_level( &gps, satellite_system, &ret_satellite_numbers_length, ret_satellite_numbers_data, &ret_fix, &ret_pdop, &ret_hdop, &ret_vdop)< 0) { fprintf(stderr, "Could not get satellite status_low_level, probably timeout\n"); } if (satellite_system == 0){ printf("GPS satellite (Satellite system number = %d)\n", satellite_system); printf("Number of GPS satellite in use = %hu\n", ret_satellite_numbers_length); } else if (satellite_system == 1) { printf("Glonass satellite (Satellite system number = %d)\n", satellite_system); printf("Number of Glonass satellite in use = %hu\n", ret_satellite_numbers_length); } else { fprintf(stderr, "Not proper satellite system\n"); } for (int i=0; i<ret_satellite_numbers_length; i++) { switch (i) { case 0: printf("First "); break; case 1: printf("Second "); break; case 2: printf("Third "); break; default: printf("%dth", i); break; } printf("satellite number = %d\n", ret_satellite_numbers_data[i]); if (satellite_system == 0) { satellite_index = ret_satellite_numbers_data[i]; } else if (satellite_system == 1) { satellite_index = ret_satellite_numbers_data[i] - 64; } else { fprintf(stderr, "Not proper satellite system\n"); } if (gps_v2_get_satellite_status( &gps, satellite_system, satellite_index, &ret_elevation, &ret_azimuth, &ret_snr) < 0) { fprintf(stderr, "Could not get satellite status, probably timeout\n"); } printf("signal_noise = %d\n", ret_snr); } usleep(1e5); } } int main(void) { /* Register a signal handling function */ if (signal(SIGINT, sig_handler) == SIG_ERR) { fprintf(stderr, "Can't catch SIGINT\n"); abort(); } // Create IP connection IPConnection ipcon; ipcon_create(&ipcon); // Create device object gps_v2_create(&gps, UID, &ipcon); // Connect to brickd if(ipcon_connect(&ipcon, HOST, PORT) < 0) { fprintf(stderr, "Could not connect\n"); return 1; } readSatelliteStatus(); printf("Press key to exit\n"); getchar(); gps_v2_destroy(&gps); ipcon_destroy(&ipcon); // Calls ipcon_disconnect internally return 0; } Zitieren
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.