PDA

View Full Version : Qserial Port for windows



vishme7
29th August 2013, 10:54
hiii,

I am Developing win32 serial port in QT5.0.2 for my hardware.
for this i manually write the openport, closeport, read, write function
but confusing about "CreateFile" fuction.
how to use the first Parameter which is port number.

// open selected device
hSerial = CreateFile( (WCHAR *) deviceName->constData() , GENERIC_READ | GENERIC_WRITE, 0, 0, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0);


more info. is:
QString *deviceName;
deviceName = new QString(device_Name->toLatin1());

how to use deviceName so that i get selected port name .

Santosh Reddy
29th August 2013, 12:00
Thread title is missleading



WCHAR WideChar[256];
deviceName->toWCharArray(WideChar);

kuzulis
29th August 2013, 12:59
vishme7,

Please use http://qt-project.org/wiki/QtSerialPort

Also you can update your Qt to v5.1.1 where QtSerialPort is present by default, then you not need to build it manually as for Qt 5.0.x and Qt 4.8.x.