ArrayArrayArrayArrayArrayArrayArrayArrayArrayArray
CODE:
SerialBasics(const char *dev_name, TUserModule* pTUserModule) : m_io_service(), // build instance of IO_SERVICEm_serial_port(m_io_service, dev_name), // initialize the COM Portm_work(m_io_service) // bind IO_SERIVCE to a worker thread pattern, so the run() method is repeated endless { // must be set before any trace output! No tracing before this point! m_p_user_module = pTUserModule; // start the endless running worker thread to process the async data. boost::thread t(boost::bind(&boost::asio::io_service::run, &m_io_service)); m_tWorker = &t; trace("SerialBasics","constructed"); }; void runner() { trace("SerialBasics","before run"); m_io_service.run(); trace("SerialBasics","after run"); }CODE:
/*Tries to send all async data available in the streambuffer.*/inline void write_start(void){// compute the data length to send in the streamint iTxDataLen = prepareSendBuffer();trace("write_start()","iTxDataLen", iTxDataLen);// try to send data much as possibleboost::asio::async_write(m_serial_port,boost::asio::buffer(m_TxBuffer, iTxDataLen ),//m_buff,boost::bind(&SerialBasics::write_complete, // called when all data was send.this,boost::asio::placeholders::error));}Statistics: Posted by hesspet — 09 Dec 2012, 15:10
Statistics: Posted by headphoner — 09 Dec 2012, 15:00
yep, it's a good way to have feedback and in this area, more is better.The raw output module works. Should I post it here as a "alpha" version?Testing serial is allways a little bit difficult, so feedback may help to make it bulletprove.
seem's the good choice for Hollyhock and mac compatibility.I used the boost libary als underlying framework and I had a lot of problems to solve, but this may help to port the serial module to the upcomming new Usine (mac) version.
Statistics: Posted by martignasse — 09 Dec 2012, 14:35
Maybe this could also be an alternative for sending slow data, e.g. to an arduino. Depends on what should be solved with an Arduino. If the Arduino is driven with 9600 baud e.g. to send a command to switch on a led or a motor, it's so slow that this mode is ok.ctAsynchronous :
Usine event are injected in a complete separate thread event loop
it's not fast, it's asynchronous but ideal, for example, to an open file popup or to write to a file.
The raw output module works. Should I post it here as a "alpha" version?great, can't wait to test your module
my arduino is hot and ready
Statistics: Posted by hesspet — 09 Dec 2012, 13:46
Statistics: Posted by martignasse — 09 Dec 2012, 13:12
Statistics: Posted by hesspet — 09 Dec 2012, 12:32
CODE:
pParamInfo->CallBackType = ctImmediate;Statistics: Posted by martignasse — 09 Dec 2012, 12:07
Statistics: Posted by hesspet — 09 Dec 2012, 12:06

CODE:
[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 = => 5CODE:
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 dataif (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 nothingbreak;}} catch( exception& e) {if (pSerialOutModule != NULL)pSerialOutModule->trace("CallBack()","exception=", (PCHAR)e.what());}}Statistics: Posted by hesspet — 09 Dec 2012, 01:40
CODE:
SerialBasics(const char *dev_name, TUserModule* pTUserModule) : m_io_service(), // build instance of IO_SERVICEm_serial_port(m_io_service, dev_name), // initialize the COM Portm_work(m_io_service) // bind IO_SERIVCE to a worker thread pattern, so the run() method is repeated endless { // must be set before any trace output! No tracing before this point! m_p_user_module = pTUserModule; // start the endless running worker thread to process the async data. boost::thread t(boost::bind(&boost::asio::io_service::run, &m_io_service)); m_tWorker = &t; trace("SerialBasics","constructed"); }; void runner() { trace("SerialBasics","before run"); m_io_service.run(); trace("SerialBasics","after run"); }CODE:
/*Tries to send all async data available in the streambuffer.*/inline void write_start(void){// compute the data length to send in the streamint iTxDataLen = prepareSendBuffer();trace("write_start()","iTxDataLen", iTxDataLen);// try to send data much as possibleboost::asio::async_write(m_serial_port,boost::asio::buffer(m_TxBuffer, iTxDataLen ),//m_buff,boost::bind(&SerialBasics::write_complete, // called when all data was send.this,boost::asio::placeholders::error));}Statistics: Posted by hesspet — 09 Dec 2012, 15:10
Statistics: Posted by headphoner — 09 Dec 2012, 15:00
yep, it's a good way to have feedback and in this area, more is better.The raw output module works. Should I post it here as a "alpha" version?Testing serial is allways a little bit difficult, so feedback may help to make it bulletprove.
seem's the good choice for Hollyhock and mac compatibility.I used the boost libary als underlying framework and I had a lot of problems to solve, but this may help to port the serial module to the upcomming new Usine (mac) version.
Statistics: Posted by martignasse — 09 Dec 2012, 14:35
Maybe this could also be an alternative for sending slow data, e.g. to an arduino. Depends on what should be solved with an Arduino. If the Arduino is driven with 9600 baud e.g. to send a command to switch on a led or a motor, it's so slow that this mode is ok.ctAsynchronous :
Usine event are injected in a complete separate thread event loop
it's not fast, it's asynchronous but ideal, for example, to an open file popup or to write to a file.
The raw output module works. Should I post it here as a "alpha" version?great, can't wait to test your module
my arduino is hot and ready
Statistics: Posted by hesspet — 09 Dec 2012, 13:46
Statistics: Posted by martignasse — 09 Dec 2012, 13:12
Statistics: Posted by hesspet — 09 Dec 2012, 12:32
CODE:
pParamInfo->CallBackType = ctImmediate;Statistics: Posted by martignasse — 09 Dec 2012, 12:07
Statistics: Posted by hesspet — 09 Dec 2012, 12:06

CODE:
[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 = => 5CODE:
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 dataif (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 nothingbreak;}} catch( exception& e) {if (pSerialOutModule != NULL)pSerialOutModule->trace("CallBack()","exception=", (PCHAR)e.what());}}Statistics: Posted by hesspet — 09 Dec 2012, 01:40