Picproje Elektronik Sitesi

PROGRAMLAMA DİLLERİ => C/C++ => Konuyu başlatan: johntimber - 14 Temmuz 2018, 15:49:41

Başlık: Raspberry with C++ program
Gönderen: johntimber - 14 Temmuz 2018, 15:49:41
Hi,

I bought the Raspberry Pi 3 because I love the Raspberry Pi very much.I have to make Project with C++ language. I installed Raspbian on my Pi. I want to control my Pi in C++ language. I tried to run C++ Program and I can run c++ example program on Raspberry Pi. For Example : - g++ -o program program.cpp I would like to write the C ++ program for interacting on the hardware. I thought it's batter to do experiment with LED. I would like to Turn on/off LED on Raspberry Pi with C++ language.
I have searched on internet.. I didn't found any simple Example. From google search I think I have to install WiringPi so I have Installed WiringPi on Raspberry Pi.
I hope someone can help me with my problem?

Please help.

I didn't find the right solution from the Internet.

References:-
https://www.raspberrypi.org/forums/viewtopic.php?t=215377
AAnimated video studio (https://jobs.vidzzy.com/hire-animated-video-production-studio/)

Thanks!
Başlık: Ynt: Raspberry with C++ program
Gönderen: mufitsozen - 14 Temmuz 2018, 18:52:41
https://www.amazon.com/Learn-Program-Using-Raspberry-introduction/dp/0995791813/ref=pd_sbs_14_1?_encoding=UTF8&pd_rd_i=0995791813&pd_rd_r=c228694f-877d-11e8-aaf6-81458bf8879e&pd_rd_w=mL58q&pd_rd_wg=ehRkR&pf_rd_i=desktop-dp-sims&pf_rd_m=ATVPDKIKX0DER&pf_rd_p=5825442648805390339&pf_rd_r=ZS3KHPX5YX7J6KN0W30A&pf_rd_s=desktop-dp-sims&pf_rd_t=40701&psc=1&refRID=ZS3KHPX5YX7J6KN0W30A (https://www.amazon.com/Learn-Program-Using-Raspberry-introduction/dp/0995791813/ref=pd_sbs_14_1?_encoding=UTF8&pd_rd_i=0995791813&pd_rd_r=c228694f-877d-11e8-aaf6-81458bf8879e&pd_rd_w=mL58q&pd_rd_wg=ehRkR&pf_rd_i=desktop-dp-sims&pf_rd_m=ATVPDKIKX0DER&pf_rd_p=5825442648805390339&pf_rd_r=ZS3KHPX5YX7J6KN0W30A&pf_rd_s=desktop-dp-sims&pf_rd_t=40701&psc=1&refRID=ZS3KHPX5YX7J6KN0W30A)
Başlık: Ynt: Raspberry with C++ program
Gönderen: OptimusPrime - 14 Temmuz 2018, 21:45:32
You dont need to use any object oriented language to drive an led. However, you could compile and build your c code with c++ compiler.

There are some ways to toggle cpu pins such as gpio sysfs interface, memory mapping, writing device driver or using an external library.

If you would like to go ahead with gpio sysfs interface you could call system commands through your c/c++ code. Only thing you need to do is to export a pin you want to control than change the direction as output to turn your led on or off.

You can follow the directions on the below link.
https://www.kernel.org/doc/Documentation/gpio/sysfs.txt

You can also use an additional library to perform these actions. WiringPi would be the best one you might work on.

After this point the things are getting complicated. In order to reach directly to the cpu registers to control the output pin, you have to map the memory in advance. Moreover, you should be careful since you are about to change the contents the registers in a system where an operating system runs.

Check out the below link for more information.

https://www.raspberrypi.org/forums/viewtopic.php?t=8476

You could also write your own gpio driver which is really a pain in the ass. The only benefit writing your own driver is handling the gpio interrupts in the kernel space. You could also catch gpio interrupts in user space through user space driver if your current linux distribution has the special driver.

Take a look at the link shown below
http://derekmolloy.ie/kernel-gpio-programming-buttons-and-leds/

By the way, you can't write a kernel driver in c++. Just forward your information.