First draft for serial is ready and - let's say - it works in most situations:P. But I'm a little bit confused about a reaction/error. I'm not sure if this is a side effect or by design of usine. Maybe someone can help me out.
I'm testing with this patch:

Simple - I create a counter and send the created number to the serial interface.
This works perfect until this moment the clock is to fast (invervall <50ms). Then I loose call to the callback() method.. I traced out the numbers, usine delivers the correct numbers but the callback has gaps.
Here's the tracelog:
Code: Select all
[8638] [CallBack()()] vor do_write dataout = => .21151
[8639] [do_write()()] .21151
[8640] [write_start()()] len stream buffer => 6
[8641] [write_start()()] iTxDataLen => 6
[8642] [CallBack()()] nach do_write dataout = => .21151
[8643] data out[6]46 50 49 49 53 50
[8644] data out[6]46 50 49 49 53 51
[8645] data out[6]46 50 49 49 53 52
[8646] data out[6]46 50 49 49 53 53
[8647] [CallBack()()] vor do_write dataout = => .21155
[8648] [do_write()()] .21155
[8649] [write_start()()] len stream buffer => 6
[8650] [write_start()()] iTxDataLen => 6
[8651] [CallBack()()] nach do_write dataout = => .21155
[8652] data out[6]46 50 49 49 53 54
[8653] data out[6]46 50 49 49 53 55
[8654] data out[6]46 50 49 49 53 56
[8655] data out[6]46 50 49 49 53 57
[8656] [CallBack()()] vor do_write dataout = => 5this line: [8647] [CallBack()()] vor do_write dataout = => .21155
callback begin
and this line: [8651] [CallBack()()] nach do_write dataout = => .21155
call back end.
So when the next number is traced by Usine, no code of the user module is running. This drives me crazy. When I slow down the counter everything works fine until the point < 50ms, then for unknown reason, my callback isn't called not so often.
Maybe I must do the handling in the process() method? The serial buffer is handled in a asynchronous process, so this can't be a problem of a blocking IO.
Any ideas
This is how the callback is implemented:
Code: Select all
void CallBack (void* pModule, TMessage* Message)
{
SerialOutModule* pSerialOutModule = ((SerialOutModule*)pModule);
try {
switch(Message->wParam) {
case PARAM_PORT:
...
break;
case PARAM_BAUDRATE:
....
break;
case PARAM_DATAOUT:
// if the data changes let's read the data
if (Message->lParam == MSG_CHANGE)
{
std::string strDataOut = pSerialOutModule->GetEvtPChar( pSerialOutModule->m_pevtDataOut );
pSerialOutModule->trace("CallBack()", "vor do_write dataout = ", (PCHAR)strDataOut.c_str());
if (pSerialOutModule->m_p_SerialBasics != NULL ) {
try {
pSerialOutModule->m_p_SerialBasics->do_write(strDataOut);
}
catch(exception& e)
{
pSerialOutModule->trace("CallBack()","exception=", (PCHAR)e.what());
}
pSerialOutModule->trace("CallBack()", "nach do_write dataout = ", (PCHAR)strDataOut.c_str());
}
}
break;
default:
// do nothing
break;
}
} catch( exception& e) {
if (pSerialOutModule != NULL)
pSerialOutModule->trace("CallBack()","exception=", (PCHAR)e.what());
}
}Added:---------------------
I've tested the callback with this line commented:
pSerialOutModule->m_p_SerialBasics->do_write(strDataOut);
same result. If do_write is not called, no serial handling is done. Looks like a Usine behaviour. Maybe it's by design?
