Qt development: send text messages over UDP and TCP, detect USB flash drive plugging, and port syszuxpinyin soft keyboard input method-[Source Code]

Source: Internet
Author: User

The development environment is Linux + QT. The function is to send messages over TCP and UDP, detect USB flash drive plugging, and port syszuxpinyin on the arm end. The following is my work summary. Below is:

About TCP and UDP:

 

Work

Status

And

Summary

 

 

Working Condition:

1. the TCP communication module in QT is called and tested on the board. The A8 Development Board communicates well with the PC and sends Chinese characters without garbled characters.

2. Integrate the TCP and UDP modules into a GUI. Because the TCP server and client are different, the code is divided into two parts after the combination.

3. solve the problem that the tiny210 Development Board cannot be entered without a keyboard, especially Chinese. Port and improve the syszuxpinyin input method. In the QT program, you can call up the keyboard and use the keyboard to input Chinese characters. Because syszuxpinyin's text encoding method is gb2312, and Linux qt's default normal display of Chinese encoding method is UTF-8, in order to solve the conflict between the two, it took some effort. The final solution is smooth, and both sending and receiving can display Chinese characters normally.

4. Use QT to check the USB flash disk insertion and removal. The kernel module of QT is used. It has been initially detected on the PC, but when transplanted to arm, it is found that the default QT compilation does not contain the kernel module. Now we need to re-compile the arm QT with the kernel module. You must first install the keystore library during compilation.

Summary:

1, transplant input method, because both to solve the conflict between gb2312 and UTF-8 encoding, but also to solve the UDP, TCP communication module in the Peer side to receive the text can be resolved normally, let me spend a lot of money. This makes it easy for users to have no online materials. Finally, they can solve the problem by reading the help documents provided by QT and referring to many materials.

2. Using QT to detect USB flash drive insertion and removal, we found that after the USB flash drive is inserted in Linux, about 7 USB-devices will be registered, and only the last one is the real USB storage device. You can read and write the USB flash drive only after the real USB storage device is successfully registered.

 

About USB flash drive Detection:

 

Work

Status

And

Summary

 

 

Working Condition:

1. on the PC X86 platform, the q6. Based on the Hal and udisks mechanisms, the q6.

2. When we transplanted the above two methods to the ARM platform, we found that the ARM platform does not support Hal and udisks. The reason is that the Hal and udisks mechanisms both receive udev messages, while udev requires support from the sysfs file system, and most of the embedded file systems are the yaffs system.

3. Based on the above problems, we finally chose the kernel's hotplug mechanism to receive messages from the kernel. When a USB flash drive is inserted or pulled out, a message is sent from the kernel. Using the keywords such as "add" and "Remove" sent by these messages, you can detect the USB flash drive plugging and the entire process of identifying USB through the kernel.

4. Considering that when the user still pulls the USB flash drive from the USB flash drive directory, the Development Board will recognize exceptions if it is not restarted. Before restarting the Development Board, you need to check the USB flash disk and remind the user. Many methods have been tested, and a test file has been written into the USB flash drive to check whether the USB flash drive is truly recognized.

Conclusion: After careful research, it is found that when the user still pulls the USB flash disk directly under the USB disk directory, the Linux system is too late to unmount the original Mount directory/udisk of the USB flash disk. Therefore, if the USB flash disk is not restarted, an error occurs when the USB flash drive still needs to be accessed and mounted to/udisk. In addition to writing data to/udisk for testing, this situation is difficult to detect. Therefore, you may wish to determine whether the/udisk directory exists when detecting the USB flash drive. If so, run umount/udisk to enable normal access by inserting the USB flash drive again.

The code can be divided into the server side and the client side. Each side has an x86 version and a compiled arm version. A total of four source codes are provided for your reference.

The following is a description:

Esto-client-arm.tar ---------- after the cross-compiled arm version of the client program, the implementation of functions are: UDP transmission, TCP transmission, U disk monitoring, cross compiler for the arm-linux-gcc-4.5.1
Esto-server-arm.tar ---------- cross-compiled arm version of the server-side program, to achieve the functions of UDP transmission, TCP transmission, soft keyboard Transplantation
Esto-client-x86.tar ---------- PC, client program, the realization of the functions are: UDP transmission, TCP transmission, U disk monitoring
Esto-server-x86.tar ---------- PC, the server program, the realization of the functions are: UDP transmission, TCP transmission
Note: syszuxpinyin can only be compiled on arm and cannot be compiled and run on x86 because it is implemented based on qwsinputmethod. This class is unique to the arm version library.

 

Client two source code: http://www.pudn.com/downloads529/sourcecode/embedded/detail2190912.html

Two Server Source Code: http://www.pudn.com/downloads529/sourcecode/embedded/detail2190909.html

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.