I am trying to connect an Adafruit Ultimate GPS to my Raspberry Pi 3 and read data from it using the WiringPi Serial library. I have set the serial connection up and removed the serial console through raspi config. When I turn on my pi I was able to sudo cat /dev/ttyAMA0 and I received what looked like good data from the gps so I know the gps is wired correctly and works. Here is my gps_main.c file

int main(){

        int serial = serialOpen("/dev/serial0",115200);
                printf("error on comms %i\n",serial);
        printf("Errno is %s \n", strerror(errno));
        printf("gps test\n");
        return 0;

When I run this the wiring pi serialOpen function returns a -1 (which is an error) and the errno for the linux list is "Permission Denied". I tried running things as sudo and then recieved a "No such file or destination"

What am I missing? I know the GPS works and I confirmed it does, but I can't talk to it at all.

Thank you, Mike

  • Hello jsotola, not sure what you mean? All the printf() statements are in main. The first one runs if there is an error, the second give me the linux errno and the third was just there for a sanity check to make sure the program ran all the way through.
    – mike
    Jan 30 '19 at 21:35
  • just questioning whether the second printf() statement should not be inside the if block ......... have you noticed how most of your code is formatted as code on gray background? ..... indent the other two lines by 4 spaces to get them formatted also
    – jsotola
    Jan 30 '19 at 21:39
  • sudo cat /dev/ttyAMA0 is connected to Bluetooth. Without knowing what you did who knows what /dev/serial0 is connected to?
    – Milliways
    Jan 30 '19 at 22:59
  • Hello everyone, I don't think I did a very good job explaining my problem and to be honest I just tried a different install of Raspbian and just enabled the serial comms and disabled the logger from sudo raspi-config and things worked. I don't think my question is gonna help anyone out, though. How can I go about removing it or making sure it doesn't affect anyone else's search so that they don't end up in a dead end with bad information? Thanks, Mike
    – mike
    Jan 31 '19 at 1:20
  • @mike you can delete your own question, look in the help center to find out how. You could also re-word it to be more clear and write and accept an answer if you can explain how to resolve the issue.
    – T. M.
    Jan 31 '19 at 13:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.