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 use SIO in Component

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

Share

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

This article mainly shows you "how to use SIO in Component", the content is easy to understand, clear, hope to help you solve doubts, the following let the editor lead you to study and learn "how to use SIO in Component" this article.

Component INCLUDE_SIO,Serial IO, serial port IO

After it is included, VxWorks calls usrSerial.c 's usrSerialInit () to load the serial device.

Usually N_UART_CHANNELS is defined as 2 in BSP, so after VxWorks starts, you can see two serial ports.

If the component INCLUDE_PC_CONSOLE,VxWorks is not included, the serial port (0) of CONSOLE _ TTY will be regarded as the standard IO device of the system, and the default baud rate is CONSOLE_BAUD_RATE (9600). In this case, the result of printf () will be output from serial port 0. However, in X86 devices, pcConsole is usually used as the standard IO,printf () of the system, and the result is output from the video card.

If the Target does not have a network card or network card driver, in the development process, you can connect the WDB through the serial port, that is, use the serial port to debug. WDB_TTY_CHANNEL (1) is used by default, so it is better for Target to have at least two serial ports. However, the transmission rate of serial port is much slower than that of network card, so it is very difficult to debug.

My current Target is the CPU,VxWorks image of X86 that contains PC console components and uses END to connect to WDB, so both serial ports are free.

The serial port transmits data in bytes, so let's see how the application layer operates it.

Connect the serial port 0 of VxWorks with the serial port of Host, and the host port opens a serial port tool, such as the PuTTY used by my Windows terminal. The serial port is generally configured with default values: baud rate 9600, data bit 8, stop bit 1, parity none, flow control none.

Because VxWorks generally uses the same initial value when initializing the serial port.

Try it directly in Shell.

The string hello can be received in Host's serial port tool.

Let's write a piece of code: this code opens the serial port, reads the default configuration of the serial port, and then sends a segment of character

The execution result is

Run another example of receiving

Enter some characters from the serial port tool on the host side and end with'q'

This example is simple, just print out the received information with printf (). In a specific project, printf () will be replaced by more complex operations.

Finally, let's see which operations are supported by ioctl () of the serial port. For example, you can use SIO_BAUD_SET or FIOBAUDRATE to set the baud rate.

If you want to expand the function of serial port yourself, you can add branches to the ioctl function of the driver file, and the numbering starts at least from 0x100a.

This is exactly:

VX defaults to two serial ports (/ tyCo/x), which can do system I and O (no PC Console).

The default configuration is the most commonly used (CS8). For more functions, see Control (ioctl).

The above is all the contents of the article "how to use SIO in Component". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, 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