you didn't tell us how you are doing framing!
do you frame with line feed or carriage return? are you framing by packet length? are you framing by packet time?
this is my device code. I use cortex-m4 based mcu -> ft232rl
//uart send function
void UARTSend(uint32_t ui32UARTBase, const uint8_t *pui8Buffer, uint32_t ui32Count)
{
while(ui32Count--)
{
UARTCharPut(ui32UARTBase, *pui8Buffer++);
while(!UARTBusy(ui32UARTBase))
{
}
}
}
...
//program task
void progTask()
{
DelayMsec(100); //my milisecond delay func
//read value from adc13
Adc13Read(adcValue.ui32Part); //my adc read funct, keep adc result in adcValue union
sendData[0] = 'a';
sendData[1] = adcValue.bytes[0];
sendData[2] = (adcValue.bytes[1] & 15);
sendData[3] = 'b';
//send test data
UARTSend(UART6_BASE,sendData , 4);
}
int main()
{
progTask();
}
This code works without any issue in labview. labview always reads data like "axxb". But in qtserialprogram like this
(these are real results)
ÿb
aÿb
aÿ
b
aÿb
aÿb
aÿb
aÿb
a
ÿb
aÿb
aÿb
aÿb
aÿb
aÿb
aÿb
aûb
aûb
aÿb
Dear Gallymimu,
I thought that after your comment, i dont know somethings about framing and Labview makes these stuffs instead of me. Am I right???
Also this is my device settings,
ROM_UARTConfigSetExpClk(UART6_BASE,systemClock , baud,
(UART_CONFIG_WLEN_8 | UART_CONFIG_STOP_ONE|
UART_CONFIG_PAR_NONE));
it is same at the computer program.
Posted on: March 10, 2017, 09:21:50 21:21 - Automerged
I've had success using fixed length packets and WaitCommEvent (to detect the first character) in a seperate thread.I used fixed length because that allow you to specify the number of characters in the ReadFile rather than rely on time outs.
Try to get a copy of The Windows Serial Port Programming Handbook by Ying Bai.
I dont wait for reading data. QT's signal slot mechanism allow me that:
connect(serial,SIGNAL(readyread()),this,SLOT(readData)));
system invokes the readData func. and i read all of data in that functin like:
serial->setReadBufferSize(4);
QByteArray serData = serial->readAll();
But, although this mechanism, i think multithreading. So, my class a bit larger. I think it needs multithreading because it is doing some stuffs when data is came.