Home >Industry dynamics>Industry dynamics
Device Identification and Management Using the CH348 Chip in QT Environment

Background

The CH348 is a widely-used USB-to-serial chip, which converts USB signals to serial communication, allowing a computer to communicate with various serial devices. In applications where multiple serial devices are connected to a single computer, the CH348 chip's multi-serial port functionality becomes valuable. However, when multiple CH348 chips are in use, it becomes challenging to differentiate between them.


QT Environment

Problem Description

  1. Port Naming Issue: When multiple CH348 chips are connected to the same computer, each chip generates 8 virtual serial ports with identical descriptions. Consequently, it’s difficult to identify which serial port corresponds to a particular device. System-generated port numbers are unreliable identifiers, as they can change when USB ports are switched.

  2. QT Limitation: In a QT environment, attempts to differentiate ports based on Vendor ID or Product ID fail, and no other unique identifiers are accessible by default.

Solution

To address this issue, we can modify the Serial String field in each CH348 chip using its host tool. This field can be customized with unique identifiers, such as the device model or serial number. By reading this Serial String field in the QT application, we can uniquely identify each CH348 chip and its corresponding virtual serial ports.

Implementation Steps

  1. Install CH348 Drivers

    • Download and install the CH348 driver and related tools from the official website or other trusted sources. Open the USBMSER.exe tool, select the card type “USB to Multi-Serial Port (USB1.1/2.0),” and click on “Install Driver.” Wait for the installation to complete.

  2. Use the Serial String Configuration Tool

    • Download the CH34xSerCfg.ZIP file containing the configuration tool for modifying CH348’s Serial String field.

    • Open the tool, where you will see a list of connected CH348 chips and their respective virtual serial ports.

  3. Modify the Serial String Field

    • Select the desired CH348 chip from the tool’s interface, locate the Serial String field, and enter unique information (e.g., device model or serial number) into this field.

    • Check the Serial String option and save the configuration to apply these changes.

  4. Read the Serial String Field in QT

    • In your QT application, use the QSerialPortInfo class to iterate over all available serial ports and call the serialNumber() method to read the Serial String field.

    • Compare the returned values to the previously configured Serial String entries. A match confirms the identity of the corresponding CH348 chip and its virtual serial port.


By modifying the Serial String field in each CH348 chip and accessing this information in QT, you can reliably identify specific CH348 chips and their virtual serial ports in multi-chip environments. This method not only solves the identification issue but also enhances the system’s maintainability and scalability. However, it may introduce some additional setup work and potential risks, so the pros and cons should be weighed carefully in practical applications.


Recommend