Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

[ARM] coading help requires for raspberry in C.

Status
Not open for further replies.

r@wboom

Newbie level 6
Newbie level 6
Joined
Apr 2, 2014
Messages
14
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Location
chirawa
Activity points
101
helo everyone
i am woring on raspberry pi same as ardunio board diff. is only it work on linux platform as raspbian OS in it version of DEBIAN.
i have wrote a gps code in it to receive the $GPGGA data only;;
Code:
[syntax=dot]//code for reading the gps using raspberry pi

#include<stdio.h>
#include<errno.h>
#include<wiringPi.h>
#include<string.h>
#include<wiringSerial.h>
int main()
{
char gps[65];   //gps string array
int fd,flag=0;    //handler
char arr[]="$GPGGA";
printf("raspberry gps programme");
if(wiringPiSetup()<0)     //setup wiringpi
return -1;
else
printf("setup is ok\n");
if((fd=serialOpen("/dev/ttyAMA0",9600))<0)
{
fprintf(stderr,"unable to open serial device%s\n",strerror(errno));
}
else
{
printf("serial UART is Ok\n");
}
while(1)
{
int i=0;
int c;
if(c=serialGetchar(fd)==13||10)
{
for(i=0;i<6;i++)
{
if(serialGetchar(fd)==arr[i])
flag++;
}
}
if(flag==6)
{
flag=0;
for(i=0;i<=65;i++)
gps[i]=serialGetchar(fd);
}

printf("%d",gps);
}
fflush(stdout);
}[/syntax]



THESE ARE THE WIRINGPI LIB



Then the following functions are available:

[B]int serialOpen (char *device, int baud) ;[/B]

This opens and initialises the serial device and sets the baud rate. It sets the port into “raw” mode (character at a time and no translations), and sets the read timeout to 10 seconds. The return value is the file descriptor or -1 for any error, in which case errno will be set as appropriate.

[B]void serialClose (int fd) ;[/B]
Closes the device identified by the file descriptor given.

[B]void  serialPutchar (int fd, unsigned char c) ;[/B]
Sends the single byte to the serial device identified by the given file descriptor.

[B]void  serialPuts (int fd, char *s) ;[/B]
Sends the nul-terminated string to the serial device identified by the given file descriptor.

[B]void  serialPrintf (int fd, char *message, …) ;[/B]
Emulates the system printf function to the serial device.

[B]int   serialDataAvail (int fd) ;[/B]
Returns the number of characters available for reading, or -1 for any error condition, in which case errno will be set appropriately.

int serialGetchar (int fd) ;
Returns the next character available on the serial device. This call will block for up to 10 seconds if no data is available (when it will return -1)

void serialFlush (int fd) ;
This discards all data received, or waiting to be send down the given device.
please help me..
 
Last edited by a moderator:

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top