PDA

View Full Version : how to process hexadecimal



mohanakrishnan
19th November 2009, 08:48
hi all
i am creating an application that received and sends data thru serialport.pls see the below code


if(comport->bytesAvailable())
{
long count =comport->bytesAvailable();
QByteArray comdata=comport->read(count);
comdata=comdata.toHex();
qDebug()<< comdata;
}

It displays the ascii value of sent data and displays the hexadecimal value,but i need them
in array of hexadecimal like below
byte data[];
data[0]=0x01;
data[0]=0xff;
so that i can check the arrays each position easily ??jus im tired by searching
can any one help me??
thanks in advance:crying::crying::confused:

high_flyer
19th November 2009, 11:30
Do you mean something like this?:


if(comport->bytesAvailable())
{
long count =comport->bytesAvailable();
QByteArray comdata=comport->read(count);
//comdata=comdata.toHex();
//qDebug()<< comdata;
for(int i=0; comdata.size(); i++){
qDebug()<<"data[%d] = "<<i<<" %x"<<comdata[i];
}
}

mohanakrishnan
20th November 2009, 04:33
hi
i hav tried it and accessed the hexadecimals.
thanks for ur help
....