Adafruit ultimate gps breakout module with beaglebone black wireless- UART issue - c

I am using the Adafruit Ultimate GPS breakout module to interface with the beaglebone black using c code. I am using UART 4 for that, but while running after compile it won't show any output. I changed the port name to "dev/ttyO4" in serial.h file.
thank you!!!
git hub link for the library: https://github.com/joyalraju/libgps
#include <stdio.h>
#include <stdlib.h>
#include <gps.h>
int main(void) {
// Open
gps_init();
loc_t data;
while (1) {
gps_location(&data);
printf("%lf %lf\n", data.latitude, data.longitude);
}
return EXIT_SUCCESS;
}

Joyal If you add your code with question make it easy to find out the problem.

Related

How do I run the PWM with wiringPi?? (Issue with pwmMode PWM)

I am trying to run a PWM programm in geany (C language with a Raspberry 4B). I can compile and build the program; however, when I run it the next erro appears:
pinMode PWM: unable to do this when using /dev(gpiomem. Try sudo?
Does anyone have had experience something like this? How can I fix it?
My program is the following:
#include <wiringPi.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#define MFOR_MOTOR 25
#define MBACK_MOTOR 24
#define PWM_MOTOR 1
#define ENCODER_A 21
#define ENCODER_B 22
int main (void){
if (wiringPiSetup()==-1)
exit (1) ;
int pwm_user;
wiringPiSetup();
pinMode(MFOR_MOTOR, OUTPUT);
pinMode(MBACK_MOTOR, OUTPUT);
pinMode(PWM_MOTOR, PWM_OUTPUT);
pinMode(ENCODER_A, INPUT);
pinMode(ENCODER_B, INPUT);
printf ("Raspberry Pi wiringPi Motor PWM program\n") ;
printf("PWM from motor: ");
scanf("%d", &pwm_user);
pwmWrite(PWM_MOTOR, pwm_user);
digitalWrite(MFOR_MOTOR, HIGH);
while(1){
digitalRead(ENCODER_A);
}
digitalWrite(MFOR_MOTOR, LOW);
return 0;
}
Thanks #Craig Estey for your help. I "fixed" the problem running the program directly to the terminal in the RaspberryPi so I used the next format for running it
$ nano pwm_motor.c //for creating the programm
$ gcc -Waöö pwm_motor.c -lwiring -o pwm_motor // for compile the programm
$ chmod +x pwm_motor // for build the program
$ sudo ./pwm_motor //for running the program
Maybe is not the best way but it worked for me. if someone else knows another idea I love reading it.

Reading a GPIO port from C using wiringPi on a rpi 2b always says there is no signal

I am trying to read a GPIO port from a raspberry pi 2B with C. I am using the wiringPi module and I have written a little program to try it out but it just always prints 0, even if I directly connect the pin to 3.3 or 5V. I also tried pulling it up but then it just always says 1, even when I try connecting it directly to ground. When I tried to read the pin with python it worked correctly so I am at a loss as to what is wrong. The code is as below:
#include <stdio.h>
#include <stdlib.h>
#include <wiringPi.h>
void main(){
wiringPiSetup();
pinMode(4, INPUT);
pullUpDnControl(4, PUD_DOWN);
printf("%d", digitalRead(4));
}
I am running raspbian 7 (wheezy)

Tera Term with Atmel Board in C

Trying to debug an issue using Atmel Mega 328p Board.
#include <stdio.h>
#include <avr/io.h>
void main()
{
while(1)
{
printf("hello world,");
}
return;
}
Viewing this port in Tera Term returns nothing at all.
Warning : Implicit declaration of printf();
What could be the problem in our code?
You must initialize UART of the uC and write custom function for redirecting output on it, if you want to view output on tera-term. printf does not output on UART unless it is written in that way.
However in this case, the output of the program can be viewed in the output console of the IDE which you are using.

Allegro error in DevC++

I am running the latest DevC++ 5.5.3 and I need to use the Allegro 5.0.4 so I downloaded it from devpaks and install it common way. But when I want to run the project with allegro the compiler show me error "allegro.h: No such file or directory". I was looking for the answer but I haven't found the relevant one. And what more I have to use DevC++.
#include <stdio.h>
#include <allegro.h>
int main(void)
{
allegro_init();
allegro_message("Hello World");
return 0;
}
END_OF_MAIN()
Linker is set to -lalleg
Allegro 5 is not backward compatible with Allegro 4. It is a brand new library made by the same people.
Your code snippet is for Allegro 4.
The equivalent is:
#include <allegro5/allegro.h>
#include <allegro5/allegro_native_dialog.h>
int main(void)
{
al_init();
// al_init_native_dialog_addon(); // Introduced in 5.0.9
al_show_native_message_box( /* fill in params */ );
return 0;
}
You would need to link against the main Allegro library along with the native dialogs library.

c program graphics error

I have implemented the boundary fill algorithm in C language with the following code:--
/* WAP to fill the polygon using boundary fill 4 connected algo */
#include "stdio.h"
#include "conio.h"
#include "graphics.h"
#include "dos.h"
void main()
{
int gd = DETECT, gm;
clrscr();
detectgraph(&gd, &gm);
initgraph(&gd, &gm , "C:\\TC\\BGI");
rectangle(60,60,500,500);
boundary_fill(65,65,4,15);
getch();
closegraph();
}
boundary_fill(int x, int y, int fclr, int bclr)
{
if(getpixel(x,y)!= bclr && getpixel(x,y)!= fclr)
{
putpixel(x,y,fclr);
boundary_fill(x+1,y,fclr,bclr);
boundary_fill(x-1,y,fclr,bclr);
boundary_fill(x,y+1,fclr,bclr);
boundary_fill(x,y-1,fclr,bclr);
}
}
when i compile it no error come. But When i run the program the window closes and i get the following error:--
C:\TC\BIN\TC.EXE
The NTVDM CPU has encounterer an illegal instruction.. . . . . .
PLease help
stop using turboC. run your 16 bit programs(such as TurboC/C++) with DosBox instead. NTVDM error occurs because of 32bit COMMAND-PROMPT trying to run a 16 Bit Program.

Resources