473,383 Members | 1,846 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

QT and SerialPort

5
We have a project.We will connect two computers with serialports using cable.Wrote the codes in console but now we will use QT for GUI.
When the ReadFile( ...) codes began to work the program crash.Everything stop and abort.How can we solve this?Why QT cause so problem???
Jan 5 '07 #1
3 5003
hgedek
5
Project has 3 module.GUI-communication-serialport
GUI
s.listeningPort(); //s is a communication object

communication
srlObj.readMsgFromPort(); //srlobj is a serialport object

serialport-readmMsgFromPort

int size1, size2;

vector<string>msgV;
vector<string>msg;
msg.push_back("-9999");

int i=0;
char buffer[200]={0};

#ifdef WIN32
DWORD Read;
#else
int Read;
#endif


#ifdef WIN32
if (!ReadFile(hComm,&size1,sizeof(int), &Read, NULL)) //Error1
return msg;
#else
Read=read(fd,&size1,sizeof(int));

#endif


while(i<size1)
{
#ifdef WIN32
if (!ReadFile(hComm,&size2,sizeof(int), &Read, NULL)) //Error2
return msg;


if (!ReadFile(hComm,buffer,size2, &Read, NULL))
return msg;
#else
Read=read(fd,&size2,sizeof(int));
Read=read(fd,buffer,size2);

#endif
buffer[size2]=0;
msgV.push_back(buffer);

i++;

}


return msgV;


}

When Readfiles function work, program stops.But in console application everything ok.
Jan 5 '07 #2
hgedek
5
No answer???
Jan 5 '07 #3
hgedek
5
No answer???
Hello.I found something.In Console ,ReadFile wait for a signal from port.If there is nothing,it wait.But in other no.It passes directly.Not wait for something.Why....
Jan 7 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Andrea Judge | last post by:
Hi there, I'm developing an application to catch OBD sensors' data from my car. I connect it via a RS232 interface. Now. with HyperTerminal I can connect and send/receive data, but I'd like to...
0
by: Joshua Moore | last post by:
I'm trying to convert from a lot of invoked code to c# 2.0 SerialPort code. I can't find a way to set fOutxCtsFlow to true (maybe CTSEnable?) and fRtsControl = RTS_CONTROL_HANDSHAKE (RtsEnable?). ...
13
by: Jean Paul Mertens | last post by:
Hello, Someone can tell me why I dont get serial port events in a Service, I created a separate Thread to open the port but no events are coming up (the same happens when I use the timer...
1
by: sranger | last post by:
When I try to use a System.IO.Ports.SerialPort object to read from a serial port, half of the time I have no problems. However, after I successfully read from the serial port, then close the...
0
by: ricolee99 | last post by:
Hi Everyone, I'm using the System.IO.Ports.SerialPort component to attempt to kill an existing component opened by another application. I use the following code: SerialPort serialPort = new...
2
by: Jay | last post by:
Extracted from the C# example in http://msdn2.microsoft.com/en-us/library/s14dyf47.aspx... public static void Main() { string name; string message; StringComparer stringComparer =...
3
by: Adriano | last post by:
Hello, I'm developing an application in VB.NET 2005 that communicates with a device through RS232, and need to send the following sequence of hexadecimal data to the device: 0xFF, 0x01, 0xC3,...
6
by: Keith Lee | last post by:
All: I am attempting to compile the perl module Device::SerialPort and get this error during make -- Manifying blib/man3/Device::SerialPort.3pm Can't open blib/man3/Device::SerialPort.3pm for...
10
by: sklett | last post by:
I'm trying to send some printer commands (ZPLII) to an attached USB printer using the SerialPort component. I didn't get very far at all. In fact I haven't gotten anywhere. The first problem I...
0
by: cronusf | last post by:
I set up two virtual COM ports 3 and 4 using com0com. I tried to test it with the following program. However, the DataReceived event handlers never get called. Can anyone with SerialPort class...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.