Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. 3rd Party Software
  4. Exception Triggered(read access violation) if QSerialPort instance is created with VECTOR dll(vxlapi.dll)
QtWS25 Last Chance

Exception Triggered(read access violation) if QSerialPort instance is created with VECTOR dll(vxlapi.dll)

Scheduled Pinned Locked Moved 3rd Party Software
1 Posts 1 Posters 2.3k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • L Offline
    L Offline
    lunchtime82
    wrote on last edited by
    #1

    Hello,

    I have struggled with exception problem during few weeks. :(
    Please give me some tips for this~

    I'm trying to a program that receive GPS data by serial port, and send CAN message using the data.
    Development environment is,

    • IDE : Qt Creator 3.1.2(based on Qt 5.3.1)
    • Qt version : Qt5.3 MSVC2013 32bit
    • Compiler : Microsoft Visual C++ compiler 12.0(x86)
    • Device type : Desktop(Local PC)

    And for device,

    • GPS device : ASCEN GPS (GPS742)
      a. This is connected with PC by USB cable.
      b. PC recognize it by serial port(COM12, Baud115200, 8 bit, No parity, one stop bit, No flowControl).
      c. It send GPS data periodically(about 1 second.)
    • CAN device : VECTOR CAN/LIN Interface (VN1630)
      a. This is connected with PC by USB cable.
      b. It can control by dll files('vxlapi.h', 'vxlapi.dll', and 'vxlapi.lib')

    At first, I made two individual programs,

    • 'Receiving & show GPS data' : using 'QSerialPort' class. It works well.
    • 'Sending dummy CAN message' : using dll files. It works well.

    But when I merged these programs, It compiled well but generated exception error.(read access violation)

    For Debug, I made simple console project like below,

    [SerialPortControlExample_ref.pro]
    @
    QT += core
    QT += serialport
    QT -= gui

    TARGET = SerialPortControlExample_ref
    CONFIG += console
    CONFIG -= app_bundle

    TEMPLATE = app

    SOURCES += main.cpp

    OTHER_FILES +=
    vxlapi.lib

    HEADERS +=
    vxlapi.h

    win32: LIBS += -L$$PWD/ -lvxlapi

    INCLUDEPATH += $$PWD/
    DEPENDPATH += $$PWD/
    @

    [main.cpp]
    @
    #include <QtCore/QCoreApplication>
    #include <QtCore/QDebug>
    #include <QtSerialPort/QSerialPort>
    #include <QtSerialPort/QSerialPortInfo>
    #include <windows.h>
    #include "vxlapi.h"

    QT_USE_NAMESPACE

    int main(int argc, char *argv[])
    {
    XLstatus xlStatus;
    QCoreApplication a(argc, argv);

    //------------ 1st Section --------------------------------------------------
    xlStatus = xlOpenDriver();
    if(xlStatus == XL_SUCCESS) qDebug() << "Open Success!!";
    else qDebug() << "Open Fail!!!";
    //------------- End of 1st Section-------------------------------------------

    //------------ 2nd Section --------------------------------------------------
    // Example use QSerialPortInfo
    foreach (const QSerialPortInfo &info, QSerialPortInfo::availablePorts()) {
    qDebug() << "Name : " << info.portName();
    qDebug() << "Description : " << info.description();
    qDebug() << "Manufacturer: " << info.manufacturer();

        // Example use QSerialPort
        QSerialPort serial;
        serial.setPort(info);
        if (serial.open(QIODevice::ReadWrite))
            serial.close();
    }
    

    //------------- End of 2nd Section-------------------------------------------

    return a.exec&#40;&#41;;
    

    }
    @

    [vxlapi.h, vxlapi.lib, vxlapi.dll]

    • These files are included 'XL Driver Library 8.3'.
      It can be downloaded at VECTOR site :
      https://vector.com/vi_downloadcenter_en.html?product=xllib&formular_treffer_submit=1
    • I copied these files on project directory.

    Among above 'main.cpp' file, if one of section is commented out, it is compiled and running correctly.

    A. If 1st section is commented out...
    [Commannd Window]
    @
    Name : "COM12"
    Description : "GPS USB Serial Interface Driver"
    Manufacturer: "Media Tek Inc."
    @

    B. If 2nd section is commented out,
    [Commannd Window]
    @
    Open Success!!
    @

    But when I use both section, it is compiled well but generated exception message once I run this program, like below,
    [Exception Triggered Window]
    @
    The inferior stopped because it triggered an exception.
    Stopped in thread 0 by: Exception at 0x77a1e066, code: 0xc0000005: read access violation at: 0x0, flags=0x0 (first chance).
    @

    The debugging result is below,
    @
    ...
    Running.
    dState changed from EngineRunRequested(7) to InferiorRunOk(11) [master]
    ModLoad: 75570000 755d0000 C:\WINDOWS\SysWOW64\IMM32.DLL
    ModLoad: 76df0000 76ebc000 C:\WINDOWS\syswow64\MSCTF.dll
    (2d4.2558): Access violation - code c0000005 (first chance)

    s
    sException at 0x77a1e066, code: 0xc0000005: read access violation at: 0x0, flags=0x0 (first chance) in ntdll!RtlAllocateHeap
    First chance exceptions are reported before any exception handling.
    This exception may be expected and handled.
    eax=77280334 ebx=00000000 ecx=00000010 edx=003bf1ec esi=00000000 edi=000000e0
    eip=77a1e066 esp=003bee50 ebp=003beebc iopl=0 nv up ei ng nz ac pe cy
    cs=0023 ss=002b ds=002b es=002b fs=0053 gs=002b efl=00010297
    ntdll!RtlAllocateHeap+0x1c:
    77a1e066 8b4344 mov eax,dword ptr [ebx+44h] ds:002b:00000044=????????

    *** WARNING: Unable to verify checksum for C:\JayKim\EnS\JaySW\SerialPortControlExample_ref\vxlapi.dll
    *** ERROR: Symbol file could not be found. Defaulted to export symbols for C:\JayKim\EnS\JaySW\SerialPortControlExample_ref\vxlapi.dll -
    s
    sException at 0x77a1e066, code: 0xc0000005: read access violation at: 0x0, flags=0x0 (first chance)
    dNOTE: INFERIOR SPONTANEOUS STOP
    sStopped.
    dState changed from InferiorRunOk(11) to InferiorStopOk(14) [master]
    Resolving symbol: ntdll!RtlAllocateHeap...
    <x ntdll!RtlAllocateHeap

    Obtained 0x77a1e046 for ntdll!RtlAllocateHeap (#1)
    <u 0x77a1e046 0x77a1e168
    @

    Please let me know some tips for these issues.

    Thank you.

    1 Reply Last reply
    0

    • Login

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved