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

Example Analysis of Linux Application Development

2025-03-29 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

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

This article mainly explains the "Linux application development example analysis", the article explains the content is simple and clear, easy to learn and understand, the following please follow the editor's ideas slowly in depth, together to study and learn "Linux application development example analysis" bar!

Development case description

The development cases covered in this document are located in the base-demos and python-demos directories under the "4-Software data\ Demo\ tl-linux-application\" path.

The base-demos directory stores Linux common development cases, the case bin directory stores executable files, and the case src directory stores source code. The python-demos directory stores the Python development case, and the case script file can be run directly without compilation.

To recompile a common Linux development case, copy the corresponding case src directory to the Ubuntu working directory, enter the src directory and execute the following command to load the Linux Processor SDK environment variable, and execute the make command to compile the case. When the compilation is complete, the executable is generated in the current directory.

Host# source / home/tronlong/ti-processor-sdk-linux-rt-am335x-evm-04.03.00.05/linux-devkit/environment-setup

Host# make

Figure 1

Linux common development cases tl_led_flash cases

Case function

In this case, the value of 1 and 0 is written alternately to the user indicator LED device node of the evaluation backplane to achieve the LED flicker effect. The lighting and extinguishing time of LED is 0.5s.

The program flow is shown in the following figure:

Figure 3

Operation instruction

Copy the executable program tl_led_flash in the bin directory of this case to the evaluation board file system, and execute the following command in the directory where the executable program is located to run the program, you can see that the evaluation backplane LED flashes at an interval of 0.5s. At the same time, the serial terminal prints all the LED device information and the LED device information currently controlled by the program.

Target#. / tl_led_flash-help

Target#. / tl_led_flash-n 3

Figure 4

Key code

Predefined LED array. The program gets the LED information from the array, and the array information must be the LED information already in the system, otherwise the program runs with an error.

Figure 5

LED flashing operation and time interval.

Figure 6

Tl_key_test case

Case function

This case detects keystroke events by monitoring the status of user keystroke device nodes.

The program flow is shown in the following figure:

Figure 7

The user key device node is "/ dev/input/event1". After getting the keystroke event, the keystroke value is matched, and then the event is handled.

Operation instruction

Copy the executable program tl_key_test under the bin directory of this case to the evaluation board file system, execute the following command to run the program in the directory where the executable program is located, and the serial port terminal will print prompt information. Then press the evaluation board user button, the program will detect the key event and print the key status information.

Target#. / tl_key_test-help

Target#. / tl_key_test-d / dev/input/event1

Figure 8

Key code

Define the button.

Figure 9

Listen for button events.

Figure 10

Cyclic monitoring.

Figure 11

Tl_uart_rw case

Case function

The main purpose of this case is to realize the reading and writing function of serial port.

The program flow is shown in the following figure:

Figure 12

The serial device nodes of RS232 and RS485 are "/ dev/ttyS0" and "/ dev/ttyS1" respectively. When the serial port is initialized, parameters such as baud rate, mode, data bit, stop bit and so on will be set. Read and write the serial port through the device file descriptor.

Operation instruction

Using RS232 cross serial port bus and USB to RS232 male serial port, connect the RS232 serial port of the evaluation board to the USB interface of PC, as shown in the following figure.

Figure 13

Copy the executable program tl_uart_rw under the bin directory of this case to the evaluation board file system, enter the directory where the executable program is located, and execute the following command to view the program parameter information.

Target#. / tl_uart_rw-h

Figure 14

Execute the following command to read RS232 serial port data.

Target#. / tl_uart_rw-d / dev/ttyS0-r-s 8

Open the serial port debugging tool SerialDebug.exe in the product data "\ 4-product data\ Tools\ Windows\" directory, open the PC device manager, confirm the RS232 serial port COM port number, and follow the steps in the following figure to send data from the serial port debugging tool to the RS232 serial port. Debugging the serial port terminal will print the data read from the RS232 serial port.

Figure 15

Figure 16

Execute the following command to write RS232 serial data, the data has been defined in the program. The serial debugging tool will print the data received from the RS232 serial port.

Target#. / tl_uart_rw-d / dev/ttyS0-w-s 8

Figure 17

Figure 18

Transfer RS232 to RS485 module and USB to RS232 male serial port, and connect the RS485 serial port of the evaluation board to the USB interface of PC, as shown in the following figure.

Figure 19

The method of connecting RS232 to RS485 module and RS485 serial port on the evaluation board is as follows:

RS232 to RS485 module 485 + terminal, connect the evaluation board RS485 serial port A terminal.

RS232 to RS485 module 485-terminal, connect the evaluation board RS485 serial port B terminal.

RS232 to RS485 module GND terminal, connect the evaluation board RS485 serial port GND terminal.

Execute the following command to read and write RS458 serial port data. The RS485 serial port test procedure is similar to RS232, and the device node in the command can be changed from ttyS0 to ttyS1.

Target#. / tl_uart_rw-d / dev/ttyS1-r-s 8 / / RS485 serial port data read operation

Target#. / tl_uart_rw-d / dev/ttyS1-w-s 8 / / RS485 serial port data write operation

Key code

Serial port initialization function.

Figure 20

Serial port read and write function.

Figure 21

Figure 22

Loopback test.

Figure 23

Related logic.

Figure 24

Tl_can_echo case

Case function

This case uses the canecho program of canutils toolkit to realize the function of CAN interface data receiving and resending.

The canutils toolkit contains five independent programs, namely canconfig, candump, canecho, cansend and cansequence. The functions of each program are summarized as follows:

Canconfig: used to configure CAN interface parameters, such as baud rate, mode, etc.

Candump: receives data from the CAN interface and prints it to standard output in hexadecimal form, or to a specified file.

Canecho: receives data from the CAN interface and sends the received data to the outside.

Cansend: sends data to the specified CAN interface.

Cansequence: sends an automatically repeating increment number to the specified CAN interface, or specifies the receive mode and verifies the received increment number.

This case only uses the canecho function. If you need to achieve other functions, you can download the canutils toolkit and obtain the source code of the corresponding function program. Download link: https://public.pengutronix.de/software/socket-can/canutils/.

The program flow is shown in the following figure:

Figure 25

Operation instruction

Use the USB to CAN module to connect the CAN0 interface of the evaluation board and the USB interface of the PC, as shown in the following figure.

Figure 26

Refer to the debugging tool installation documentation to install the USB to CAN driver and ECAN Tools debugging software, double-click to open the ECAN Tools software, select the device type, and then click "Open device".

Figure 27

Open ECAN Tools and the interface is shown in the following figure.

Figure 28

Enter the evaluation board file system, use the canconfig tool that comes with the file system to set the baud rate, and start the CAN0 interface.

Target# canconfig can0 stop

Target# canconfig can0 bitrate 125000

Target# canconfig can0 start

Figure 29

Copy the executable program tl_can_echo under the bin directory of this case to the evaluation board file system, enter the directory where the executable program is located, and execute the following command to view the program parameter information.

Target#. / tl_can_echo-help

Figure 30

Execute the following command to bind the CAN0 interface, receive the data sent by ECAN Tools, and then resend the received data. Enter the data in the ECAN Tools and click the send button, you can see that there are two frames of data, one is to send data, the other is to receive data.

Target#. / tl_can_echo-v can0

Figure 31

Figure 32

Press "Ctrl+Z" to pause the program and execute the following command to exit the program.

Target# killall-9 tl_can_echo

Figure 33

Key code

Use socket to listen on the CAN interface.

Figure 34

Resend the data received from the CAN interface.

Figure 35

Thank you for your reading, the above is the content of "Linux Application Development example Analysis". After the study of this article, I believe you have a deeper understanding of the problem of Linux application development example analysis, and the specific use situation still needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

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