![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
20190816
Diff: main.cpp
- Revision:
- 24:fba9a58e6fbd
- Parent:
- 23:39d96e160cf1
- Child:
- 25:0f1f6687333c
--- a/main.cpp Thu Aug 08 13:24:28 2019 +0000 +++ b/main.cpp Thu Aug 08 17:10:26 2019 +0000 @@ -9,18 +9,14 @@ MsgType _msg; bool tick = 0; +bool SM = 0; uint32_t ctr = 0; // счетчик обменов uint32_t ctro = 0; uint32_t Ectr = 0; // счетчик ошибок -void dpc_func(){ - (void) dpc.getc(); - StartTx(&_msg.cmd); - } +void dpc_func(){ (void) dpc.getc(); SM=1; } -void tickIntrFunc(void){ - tick = 1; - }//tickIntrFunc +void tickIntrFunc(void){ tick = 1; }//tickIntrFunc int main() { @@ -41,20 +37,19 @@ //https://os.mbed.com/forum/bugs-suggestions/topic/4264/ проблема выравнивания данных while(1) { - if ( RxBuffFull == 1 ) { - RxBuffFull = 0; - if(GetCheckSum(&RxBuff.cmd) == RxBuff.cs){ - myled = !myled; - ctr = RxBuff.pars.ui32[0] + 1; - if(tick){ - tick = 0; - dpc.printf("ctr = %d, diff = %d, Ectr = %d\n\r", ctr, ctr - ctro, Ectr); - ctro = ctr; - } - }else Ectr++; - _msg.pars.ui32[0] = ctr; - StartTx(&_msg.cmd); - } + TxRxStates _trs = GetMsg(&_msg.cmd); + if(_trs == RxRcvd){ + myled = !myled; + ctr++; + _msg.pars.ui32[0]++; + if(tick){ + tick = 0; + dpc.printf("ctr = %d, diff = %d, Ectr = %d\n\r", ctr, ctr - ctro, Ectr); + ctro = ctr; + } + SendMsg(&_msg.cmd); + }else if(_trs == RxCS_Err) Ectr++; + if(SM) { SM = 0; SendMsg(&_msg.cmd); } }//while(1) }//main