PDA

View Full Version : writing the variable value on port.



jjbabu
1st October 2007, 07:54
hi to all,
regarding my project,i used qextserialport to communicate my gui with serialport.upto now i did evrything fine,but now i got one problem,i have to write the varible value on the port,while am using port->write("i");// 'i' is variable function instead of giving 'i' value simply am getting 'i'(charactor) on my hyperterminal.how can i avoid this.
please provide some help with sample code or atleast function prototype.
thanx in advance.

wysota
1st October 2007, 11:57
You certainly shouldn't surround the variable name with quotes... And depending on the type of "i", you might need to convert it to a string.

jacek
1st October 2007, 11:58
You are writing "i" string to the port, not the variable. If you want to write variable's value, you have to first convert it to a byte array.

You need something like:
port->write( QString::number( i ).toAscii() );

jjbabu
2nd October 2007, 07:01
thanx for ur sharp response.i did well with ur suggession.thank u.bye