Uart data corrupt if working with Qt Qml on Allwinner A20 legacy kernel



  • I am working with embed device with Allwinner A20 cortex-a7 cpu.
    Qt was build with mali support, to work direct with framebuffer like here, no x11
    My app are using uart to recieve data.

    If i run own app and (for example) standart Qml Oscilliscope from Qt 5.7 examples simultaneously, data bytes recieved from uart lost or become wrong in my app. I have test with QSerialPort and basic C serial implemintation in my app(like here), same result.
    Htop return system load under 0.75(A20 has 2 cores), so looks like a system not fully load.

    If i run my app and sysbench --test=cpu --cpu-max-prime=20000 --num-threads=2 run, htop return 100% load on both cores, but my app not lost any data.


  • Lifetime Qt Champion

    Hi and welcome to devnet,

    Did you check that you are setting up your serial port correctly ?
    How do you know whether you got all data ?



  • This post is deleted!


  • @SGaist
    Hi!
    I am sending 96 bytes packet with CRC every 155ms, its about (65hz)
    If i use 115200 or 250000 baud, all 65 packets in every second pass crc check. But if i increase speed to 1mbit or more and run qt gui app with dynamic qml interface, data in uart losts, error percent is about 20-24%. If i run only my app, and no qt qml gui app near, all data is correct, error percent is lower than 1% even on 1,5mbit. looks like qml render engine gets a lot of cpu time in critical moment, when data is recieved. Maybe there is some possible solution to resolve this?


  • Lifetime Qt Champion

    How are you setting up the QSerialPort you are using for your application ?



  • @SGaist

    setPortName("/dev/ttyS1");
    setBaudRate(1500000);
    setDataBits(8);
    setParity(0);
    setStopBits(1);
    setFlowControl(0);
    
    if (open(QIODevice::ReadWrite))
    {
    

    ..............

    it working well, if run alone


  • Lifetime Qt Champion

    You should also check that setBaudRate is successful.

    Then are you using in your port in the main thread ? If so, you should move its handling in its own thread.



  • @SGaist
    baud is correct, i can see it with logic analyzer
    i have made new class inherit from QSerialPort and then

    QThread *serialThread = new QThread();
    mySerialClass = new MySerialClass();
    mySerialClass->moveToThread(serialThread);
    serialThread->start();
    serialThread->setPriority(QThread::TimeCriticalPriority);

  • Lifetime Qt Champion

    I didn't imply that the value was wrong, setBaudRate returns a boolean, that's the return value I suggested to check.



  • @SGaist thank you.
    seems i get a solution. According to datasheet a20, i found that this SoC has 64 bytes hardware uart buffer. My packet size was 156.
    So now i have tried to split packet to 4 part(39 bytes) and now get 0% bad packets, even if cpu fully loaded.


  • Lifetime Qt Champion

    Nice !

    In that case, please mark the thread as solved using the "Topic Tools" button so that other forum users may know a solution has been found :)


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.