Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to call shell command to control GPIO input and output in linux system environment

2025-04-06 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/01 Report--

In this article, the editor introduces in detail "how to use shell commands to control GPIO input and output in linux system environment" with detailed content, clear steps and proper handling of details. I hope that this article "how to call shell commands to control GPIO input and output in linux system environment" can help you solve your doubts.

As the shell of Linux operating system, shell provides users with the interface to use the operating system. It is a general term for command language, command interpreter, and programming language. It interprets commands entered by users and sends them to the kernel.

Use the shell command to directly operate the gpio node under / sys/, first comment out the LED and keystroke functions of the device tree in imx6ull-14x14-evk.dts, and the LED pin is GPIO0_3,key pin and GPIO1_18 pin.

Read the key value and control the LED lamp through the shell command in the program.

1. Execute shell commands through popen

The function of the popen and pclose functions is to create a pipe to connect to another process, and then read the output of that process or send input to it by fork a child process and exec a shell to execute commands.

two。 Fill in the shell command and set the pin status

3. Control Led

Cross-compile arm-linux-gnueabihf-gcc-o led shellGpio.c and copy the led file to the development board.

The test shows that the lights of the development board are flashing and the terminal has printed messages:

4. Read key valu

Post-compilation testing:

Read this, the "how to use shell commands in the linux system environment to control GPIO input and output" article has been introduced, want to master the knowledge of this article also need to practice and use in order to understand, if you want to know more about the article, welcome to follow the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report