[Qt-interest] Serial Communication

Robert Wood robert.wood at apostrophe.co.uk
Wed Feb 10 10:36:52 CET 2010


> Error opened serial device  "ttyS0"
> Serial device  "ttyS0"  is closed
> Linux: NativeSerialEnginePrivate::nativeClose
>  -> fd == -1. Error!
> 
> [yuvraj at localhost release]$ ./reader
> Please enter serial device name, specific by OS : /dev/ttyS*
> Linux: NativeSerialEnginePrivate::nativeOpen
>  -> Trying to open device:  "/dev/ttyS*"
>  
> Linux: NativeSerialEnginePrivate::nativeOpen
>  -> function open returned  -1 . Error!
>  
> Linux: NativeSerialEnginePrivate::nativeClose
>  -> fd == -1. Error!
> 
> Error opened serial device  "/dev/ttyS*"
> Serial device  "/dev/ttyS*"  is closed
> Linux: NativeSerialEnginePrivate::nativeClose
>  -> fd == -1. Error!

Hi Yuvraj,

The device name is /dev/ttyS* (or /dev/ttyUSB* if it's a VCP).

So, for example, if you were using ttyS0, the device name must be 
/dev/ttyS0, *not* just ttyS0. (At least this is the case with QExtSerialPort

Here's a little bit of what works for me using QExtSerialPort, with the 
values hard coded rather than taken from comboboxes and radio buttons.


         QextSerialPort *vcp = new QextSerialPort("/dev/ttyS0");

	vcp->setBaudRate(BAUD38400);
	vcp->setFlowControl(FLOW_OFF);
	vcp->setParity(PAR_NONE);
	vcp->setDataBits(DATA_8);
	vcp->setStopBits(STOP_1);
	a= vcp->open(QIODevice::ReadWrite);
	if (a == true)
		vcpLabel->setText("Port Opened");

Hope that makes sense. :~)

On the latest version of Mandriva I have had problems with udev not 
giving user permissions to VCPs, so someone else's suggestions of double 
checking permissions is worth looking at.

Cheers,

Rob




More information about the Qt-interest-old mailing list