ufechner Posted June 30, 2017 at 08:39 PM Share Posted June 30, 2017 at 08:39 PM 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 Quote Link to comment Share on other sites More sharing options...
borg Posted July 3, 2017 at 07:50 AM Share Posted July 3, 2017 at 07:50 AM Hast du folgendes gelesen: "Die Satellitennummer hat hier immer einen Bereich von 1 bis 32. Bei GLONASS entspricht dieser Bereich den Satelliten 65-96."? Quote Link to comment Share on other sites More sharing options...
ufechner Posted July 3, 2017 at 01:36 PM Author Share Posted July 3, 2017 at 01:36 PM 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 Quote Link to comment Share on other sites More sharing options...
photron Posted July 3, 2017 at 03:49 PM Share Posted July 3, 2017 at 03:49 PM Welcher Fehlercode wird den vom Getter zurückgegeben in dem Fall wo dein Programm "Could not get satellite status, probably timeout" ausgibt? Quote Link to comment Share on other sites More sharing options...
borg Posted July 3, 2017 at 04:06 PM Share Posted July 3, 2017 at 04:06 PM @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; } Quote Link to comment Share on other sites More sharing options...
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.