Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Qt app crashes on WriteFile() to named pipe (\\.\pipe\tubotest) – need help writing to DAQ simulator
Forum Updated to NodeBB v4.3 + New Features

Qt app crashes on WriteFile() to named pipe (\\.\pipe\tubotest) – need help writing to DAQ simulator

Scheduled Pinned Locked Moved Unsolved General and Desktop
3 Posts 2 Posters 120 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.
  • A Offline
    A Offline
    AmineMSR
    wrote last edited by
    #1

    Hi everyone,

    I'm working on a Qt application that needs to communicate with an external DAQ simulator called tvirt.vir. The simulator creates a named pipe \\.\pipe\tubotest, and my application is supposed to send messages like DO#0#1 to control virtual switches.

    I'm using CreateFileW() and WriteFile() to write to the pipe, and OpenEventW() + SetEvent() to signal the DAQ.

    The problem is:

    • My Qt application crashes as soon as I call WriteFile(...).
    • This happens even though CreateFileW(...) returns a valid HANDLE.
    • When I run the simulator manually (tvirt.vir) and use a minimal C test program, I get ERROR_BROKEN_PIPE (109) on WriteFile.
    • The simulator seems to open the pipe but never reads from it, so any attempt to write fails or crashes the process.

    What I need:

    • I want to safely write to the pipe from Qt and trigger the switch change in the simulator.
    • I want to see the input state update in the Code::Blocks console output (e.g., Entrada digital: 1).
    • But I don't know if tvirt.vir expects a special handshake or message before reading from the pipe.

    If anyone has experience dealing with external Windows named pipes from Qt, or has ideas on preventing WriteFile() from crashing the app when the server isn’t listening, I'd really appreciate your help!

    Thanks in advance.
    19c28119-c0ee-4f17-882a-df65b3d599c3-image.png

    JonBJ 1 Reply Last reply
    0
    • A AmineMSR

      Hi everyone,

      I'm working on a Qt application that needs to communicate with an external DAQ simulator called tvirt.vir. The simulator creates a named pipe \\.\pipe\tubotest, and my application is supposed to send messages like DO#0#1 to control virtual switches.

      I'm using CreateFileW() and WriteFile() to write to the pipe, and OpenEventW() + SetEvent() to signal the DAQ.

      The problem is:

      • My Qt application crashes as soon as I call WriteFile(...).
      • This happens even though CreateFileW(...) returns a valid HANDLE.
      • When I run the simulator manually (tvirt.vir) and use a minimal C test program, I get ERROR_BROKEN_PIPE (109) on WriteFile.
      • The simulator seems to open the pipe but never reads from it, so any attempt to write fails or crashes the process.

      What I need:

      • I want to safely write to the pipe from Qt and trigger the switch change in the simulator.
      • I want to see the input state update in the Code::Blocks console output (e.g., Entrada digital: 1).
      • But I don't know if tvirt.vir expects a special handshake or message before reading from the pipe.

      If anyone has experience dealing with external Windows named pipes from Qt, or has ideas on preventing WriteFile() from crashing the app when the server isn’t listening, I'd really appreciate your help!

      Thanks in advance.
      19c28119-c0ee-4f17-882a-df65b3d599c3-image.png

      JonBJ Offline
      JonBJ Offline
      JonB
      wrote last edited by
      #2

      @AmineMSR
      Does this have anything to do with Qt? Sounds like a Windows/program issue, nothing to do with Qt, especially as per

      When I run the simulator manually (tvirt.vir) and use a minimal C test program, I get ERROR_BROKEN_PIPE (109) on WriteFile.
      The simulator seems to open the pipe but never reads from it, so any attempt to write fails or crashes the process.

      I would stick to non-Qt program till I got this working. Whatever tvirt.vir is don't you need to ask them or look at their documentation? ERROR_BROKEN_PIPE on your WriteFile() sounds like the other side isn't listening or has gone away?

      1 Reply Last reply
      0
      • A Offline
        A Offline
        AmineMSR
        wrote last edited by
        #3

        Thanks for the reply!

        Yes, I agree this really seems to be a tvirt.vir issue, not Qt. That's why I wrote a standalone C program (outside Qt) to test the pipe communication.

        I’ve already tried:

        • Sending the message DO#0#1 to \\.\pipe\\tubotest
        • Triggering the EventoEnviar event after writing

        Still, nothing changes on the simulator side, and the input value shown in my DAQ console remains 0.

        I do have some documentation, and it says tvirt.vir listens for specific commands and events, but I’ll try to confirm exactly what sequence it expects.

        Thanks again. I’ll keep testing with the C version for now.

        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