Qt app crashes on WriteFile() to named pipe (\\.\pipe\tubotest) – need help writing to DAQ simulator
-
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 likeDO#0#1
to control virtual switches.I'm using
CreateFileW()
andWriteFile()
to write to the pipe, andOpenEventW()
+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 validHANDLE
. - When I run the simulator manually (
tvirt.vir
) and use a minimal C test program, I getERROR_BROKEN_PIPE
(109) onWriteFile
. - 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.
- My Qt application crashes as soon as I call
-
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 likeDO#0#1
to control virtual switches.I'm using
CreateFileW()
andWriteFile()
to write to the pipe, andOpenEventW()
+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 validHANDLE
. - When I run the simulator manually (
tvirt.vir
) and use a minimal C test program, I getERROR_BROKEN_PIPE
(109) onWriteFile
. - 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.
@AmineMSR
Does this have anything to do with Qt? Sounds like a Windows/program issue, nothing to do with Qt, especially as perWhen 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 yourWriteFile()
sounds like the other side isn't listening or has gone away? - My Qt application crashes as soon as I call
-
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.
- Sending the message