Hello everyone, I'm new to the forums
I plan on making silly IoT stuff just to get experience. Right now, I'm building an automatic trading card sorter, with camera, motors, price database APIs and everything. I figured I'd start with the motors, and from there, start with simple GPIO programs.
I've seen two main ways for configuring GPIO pins: using "direct register access", and using sysfs 'calls'. Question is, what should I learn? And what do you recommend? Keep in mind that I'm also asking for what is preferred in the industry, in case I include my projects on a resume or in an interview. Also, I'd prefer to stick with C/C++ for various reasons.
I don't expect every question to be answered. I'd rather get more detailed answers for individual questions and eventually, all will be answered by different people. Bold questions are priority questions.
I'm experienced with programming Atmel atXmega chips using C/C++ in Atmel Studio. Thus, I'm very comfortable with the "direct register access" method for configuring GPIO pins. But the process isn't as straightforward on the BCM2835.
Questions about this method:
(1) Is it as easy as including a header file?
- The .h would have define statements that have hardware nicknames assigned to register addresses (in the I/O space). No functions. Just writing a combination of bits to the I/O addresses. (this is what I'm used to).
- Eg, PORTF_OUT_SET = 0x80; would make pin 7 turn on by assigning 0x80 to address 0x12B (or whatever).
(2) Do I need a library that does what I described in (1)? Specifically, I need special functions to write to the I/O space.
- If so, what advantages does this have over method (1)? Eg, Linux OS permissions prevent direct access, library functions prevent misuse, etc.
(3) Is this method acceptable for general IoT stuff? I'm more concerned about the security. Let's say I made a Wi-Fi light switch. What (dis/)advantages does this method have over others?
- I'm not wanting to, say, flash pin states at 25MHz, so I don't need the advantage of speed.
(4) Any recommendations (eg, libraries or tutorials) for methods (1) or (2) in C/C++?
(5) Are there any IDEs/applications I can use to view the ram contents (ie, so I can view the I/O space) for debugging purposes?
I've read about the sysfs method. Seems more useful down the road, but it also seems like I'll need to do some homework to take full advantage of it.
(6) What does this do that is different than method (1)? (maybe see question (9)).
(7) What (dis/)advantages does this have over direct register access? I know that sysfs accounts for user permissions and contradictory mis-configurations.
(8) For IoT applications in mind, is this method more secure? Or more preferred in the industry?
(9) My understanding of the Linux OS and Unix stuff is pretty much nothing. I have no idea how permissions work, what a root user is, how to use the terminal, how to call to the terminal in a program, etc. Do I need this knowledge to fully take advantage of (or just scrape by) the sysfs method? Do I need this knowledge to excel in the industry?
(10) Any recommendations of resources where I can quickly learn the stuff described in (9)? Or maybe a textbook to get an in depth education?
(11) Recommendations for resources on learning the sysfs method in C/C++?
General Questions:
(12) Are there other methods that are more preferred?
(13) In tutorials that I'll be watching, is there any reason why I can't watch in one language and then translate to C/C++?
- Eg, (if a library can be used for both, then) I can watch Python tutorials and translate the concepts to C/C++?
(14) Any mistakes in my assumptions?