jrcs111
Posts: 4
Joined: Thu Oct 12, 2017 3:17 pm

Console and UI?

Thu Oct 12, 2017 3:36 pm

Hi,

I'm new to Raspberry Pi and Windows 10 IoT programming.

I need to control GPIO in c++... on a console application. How can I do that? I've been looking for tutorials everywhere but I couldn't find any information. I see a lot of samples in C# but I can barelly write code in C++.. C# it's foreign.

What I'm trying to do is to read some DIs state and then record the state's change (with information about time and date that change occoured) to a file but I'm stuck on the first step.

Can somebody help me? I would be great if someone could recommend me a place to read and learn about IoT + C++ on raspberry.


Thanks

scotty101
Posts: 2378
Joined: Fri Jun 08, 2012 6:03 pm

Re: Console and UI?

Fri Oct 13, 2017 8:43 am

Are you particularly tied to using Window IoT and C++?

Things are much simpler if you use Raspbian and follow one of the many GPIO pin examples for languages such as python.
Electronic and Computer Engineer
Pi Interests: Home Automation, IOT, Python and Tkinter

jahboater
Posts: 1923
Joined: Wed Feb 04, 2015 6:38 pm

Re: Console and UI?

Fri Oct 13, 2017 9:08 am

+1
In fact with Raspbian, there is great GPIO support in many languages, even the shell.
But Python, C, or C++ are an obvious choice.

jrcs111
Posts: 4
Joined: Thu Oct 12, 2017 3:17 pm

Re: Console and UI?

Fri Oct 13, 2017 2:38 pm

Hi,


Thanks for your answers.
I'm tied to C++ because I only know C (from arduino and pic). Therefore, C++ it's a (big to me) "next step" to program and understand.

For know, I can work with a console app to read the ports.. but couldn't figure out how to do it.

Yesterday I started to learn C# on a online course from microsoft. Is learning C# worth it for this project? I didn't thought that working with gpios was this way out of my league...

About Raspbian... I'm completely blind about it. Need to search and learn. I'll take a look.

Regards

jahboater
Posts: 1923
Joined: Wed Feb 04, 2015 6:38 pm

Re: Console and UI?

Fri Oct 13, 2017 5:55 pm

jrcs111 wrote:
Fri Oct 13, 2017 2:38 pm
I'm tied to C++ because I only know C (from arduino and pic). Therefore, C++ it's a (big to me) "next step" to program and understand.
Then program the GPIO in C !!!
There is no need at all to learn C++ (though you can if you wish), and definitely no need to learn C# (bizarre idea). You are just complicating things for no reason at all. Keep it simple :)

The main libraries (included as standard in Raspbian) can be accessed from C (and are probably written in C). For example pigpio http://abyz.co.uk/rpi/pigpio/.

The included compiler GCC fully supports C11 and C++14 (and the draft C++17 for that matter).
About Raspbian... I'm completely blind about it. Need to search and learn. I'll take a look.
If the Raspbian is new and difficult for you, stick with what you know (C) and just learn the Linux side of things and enjoy!

jrcs111
Posts: 4
Joined: Thu Oct 12, 2017 3:17 pm

Re: Console and UI?

Thu Oct 19, 2017 10:19 am

Hi jahboater,

Thanks for you answer. Sorry about the delay but I've been afected bu the wild fire in Portugal.

Can I program C in Visual Studio (on my laptop) an then deploy the app to the pi? Or do I have to /should program the pi in the linux, directly in the pi?

Sorry about this mess in my head but programming (and "piying" :P ) it's really not my field :oops:

User avatar
fruitoftheloom
Posts: 15039
Joined: Tue Mar 25, 2014 12:40 pm
Location: Bognor Regis UK

Re: Console and UI?

Thu Oct 19, 2017 10:48 am

jrcs111 wrote:
Thu Oct 19, 2017 10:19 am
Hi jahboater,

Thanks for you answer. Sorry about the delay but I've been afected bu the wild fire in Portugal.

Can I program C in Visual Studio (on my laptop) an then deploy the app to the pi? Or do I have to /should program the pi in the linux, directly in the pi?

Sorry about this mess in my head but programming (and "piying" :P ) it's really not my field :oops:

Maybe Microsoft's Windows 10 IoT Core Website contains everything you need to know ???

https://developer.microsoft.com/en-us/windows/iot
My only "PC" is an Asus ChromeBit running ChromeOS, cloudcentric at its best !
Rockchip Quad-Core RK3288C SoC as used in ASUS Chromebook C201 & Chromebook Flip C100PA as well as the Tinker SBC.
3 Mobile Huawei E5330 Mobile Mi-Fi

jahboater
Posts: 1923
Joined: Wed Feb 04, 2015 6:38 pm

Re: Console and UI?

Thu Oct 19, 2017 11:28 am

jrcs111 wrote:
Thu Oct 19, 2017 10:19 am
Thanks for you answer. Sorry about the delay but I've been afected bu the wild fire in Portugal.
Sorry to hear this. Hope you are OK.

Do you specifically want to use Windows IoT? Or do you just want to program something on the Pi - and you are familiar with Windows, so Windows IoT seemed a good idea? If you need Windows IoT for a particular purpose, then see the link in the previous post by @fruitoftheloom.
jrcs111 wrote:
Thu Oct 19, 2017 10:19 am
Can I program C in Visual Studio (on my laptop) an then deploy the app to the pi? Or do I have to /should program the pi in the linux, directly in the pi?
You can do either, however it is usually far simpler and easier to program directly on the Pi than attempt to setup cross compiling (IMHO).

I suggest, get an SD card, put Raspbian on it with etcher, boot it up and play with some of the languages that come ready installed - Python, C, C++. You will learn lots and have fun!

jrcs111
Posts: 4
Joined: Thu Oct 12, 2017 3:17 pm

Re: Console and UI?

Tue Oct 24, 2017 2:18 pm

Hi,

So, I've installed raspbian and managed to program somethings in C with CodeBlocks 8-)

I wish I could use Geany but I couldn't execute the programs.. even the simplest "Hello World" :oops: it opens a cmd windows the shows nothing and says at the top, in the window title, something about "geany script". Even googled the problem but nothing helped me. :| Codeblocks needs to be opened as sudo user and it crashes one in a while..

Other than that, I'm making some progress. I can manipulate the GPIO and write to a .txt file when - date and time - some input gets it's state changed. Next step is getting that .txt file copied to a usb drive automatically when inserted. Can I do it in C/C++? I'm guessing it would be better so I can fclose the file, copy it to the usb drive and then reopen it to continue writing the events.

Any help would be apreciated
Regards

hbelton
Posts: 1
Joined: Wed Oct 25, 2017 1:26 pm

Re: Console and UI?

Wed Oct 25, 2017 1:29 pm

VisualStudio is the tool of choice for IoT development. it supports C/C++ as well as C#. Additional extensions are also available

Return to “Windows 10 for IoT”

Who is online

Users browsing this forum: No registered users and 8 guests