QuakeGod
2022-10-17 d69aae90ede578aaebc355dafd3496993ccea126
提交 | 用户 | age
bfc108 1 /**
Q 2   ******************************************************************************
3   * @file           : KBus.c
4   * @brief          : K-Bus Protocol program body
5   ******************************************************************************
6     */
7 #include "KBus.h"
8 #include "functions.h"
9 #include "string.h"
d69aae 10 #include "stm32f0xx.h"
bfc108 11
d69aae 12 unsigned char bMaster=0,bSlave=0,bRepeater=0;;
bfc108 13
Q 14 unsigned char PacketBuf1[128];
15 unsigned char PacketBuf2[128];
16
17 unsigned char BufferIn[16]={0};
18 unsigned char BufferOut[16]={0};
19
d69aae 20 stChnStat ChnStats[9];
e1f350 21 unsigned char nAddr=0;
Q 22 unsigned char nChilds;
bfc108 23 int ChildStat[16];
e1f350 24 unsigned char nCurPollId=0;
Q 25 unsigned char nSeq=0;
bfc108 26
d69aae 27 volatile unsigned char MasterRecved=1;
Q 28 volatile unsigned char MasterRecvOK=1;
e1f350 29
d69aae 30 volatile unsigned char SlaveRecved=1;
bfc108 31 unsigned int SendTimeuS=0;
Q 32 volatile int RecvTimeuS=0;
33
34 int DelayuS=0;
35 int MaxDelayuS=0;
36 int ThisuS;
37 volatile unsigned int nSlaveTick=0;
d69aae 38
Q 39 int Clk3=0;
40 int SendTime,Latancy,LatancyClk,SendClk;    
41
42 volatile int nCount2=0;
43 int TimeOutCount=0;
44 int LastCircleStartTime=0;
45 int CircleTime=0;
46
47 unsigned char Datas[128];        
48 volatile int PacketLength = 0;
bfc108 49
Q 50 unsigned char BCC(void * pData, int nSize)
51 {
52     unsigned char k;
53     k=0;
54     for (int i=0;i<nSize;i++)
55     {
56         k^=((unsigned char *)pData)[i];
57     }
58     return k;    
59 }
d69aae 60
Q 61 int RepeaterFunc(int nChn)
62 {
63         KMem.WY[0]=KMem.WX[0];
64         if ((KMem.nRunCount &0x7f) == 88) 
65         { 
66             nCount2++;    
67             ToggleRunLed();
68 //        int len1=sprintf(str1,"%d %d Cfg %02X  Input %02X  \r\n",nCount,nCount2,EffJumperSW,MyKeyStat1);
69 //        PutStr(str1,len1);
70         }                
71     return 0;
72 }
73
74 int MasterFunc(int nChn)
75 {
76         uint32_t tick1=HAL_GetTick();
77         uint32_t thisuS=GetuS();
78     
79             int len1=0;
80
81             if ((MasterRecved && MasterRecvOK && thisuS-SendTimeuS>50) || thisuS-SendTimeuS>1500u)
82             {
83                 if (!MasterRecvOK) 
84                 {
85                     TimeOutCount++;
86                     Uart2Stat.TimeOutErr++; 
87                     ChnStats[nCurPollId].LostPackets++;
88                     ChnStats[nCurPollId].CtnLstPkts++;
89                     if (!MasterRecved) {ChnStats[nCurPollId].TimeOutErr++;}
90                     if (ChnStats[nCurPollId].CtnLstPkts>ChnStats[nCurPollId].MaxCtnLstPkts)
91                     {ChnStats[nCurPollId].MaxCtnLstPkts=ChnStats[nCurPollId].CtnLstPkts;}
92                     if (ChnStats[nCurPollId].CtnLstPkts>3)
93                     {
94                         ChnStats[nCurPollId].Stat=0;
95                         KMem.ErrStat=200;
96                          
97                         {BufferIn[nCurPollId]=0;}
98                     }
99                 //    LL_GPIO_SetOutputPin(GPIOA,LL_GPIO_PIN_7);
100                 }else
101                 {
102                     ChnStats[nCurPollId].Stat=1;
103                     
104                     KMem.RunStat=100;
105                 }
106                 nCurPollId ++;
107                 if (nCurPollId > nChilds)
108                 {
109                     CircleTime=thisuS-LastCircleStartTime;
110                     LastCircleStartTime=thisuS;
111                     nSeq++;
112                     nCurPollId=1;
113                 }
114 #if (BOARD_TYPE == 12)
115                 if (KMRunStat.WorkMode==0)
116                 {
117                 //    KMem.WX[0]= GetInput();
118                 //    KMem.WY[1]=KMem.WX[0]&0xff;
119                 //    KMem.WY[2]=(KMem.WX[0]>>8)&0xff;        
120                 }
121             //    BufferOut[1]=KMem.WY[1];
122             //    BufferOut[2]=KMem.WY[2];        
123 #else
124                 if (KMRunStat.WorkMode==0)
125                 {
126                     KMem.WX[0]= GetInput();
127                     KMem.WY[1]=KMem.WX[0]&0xff;
128                     KMem.WY[2]=(KMem.WX[0]>>8)&0xff;        
129                 }
130                 BufferOut[1]=KMem.WY[1];
131                 BufferOut[2]=KMem.WY[2];        
132 #endif
133
134                 Datas[0]=BufferOut[nCurPollId];
135                 Datas[1]=BufferOut[nCurPollId+1];;
136                 Datas[2]=ChnStats[nCurPollId].Stat;
137                 Datas[3]=0;
138                 Datas[4]=tick1&0xff;
139                 Datas[5]=(tick1>>8)&0xff;
140                 Datas[6]=(tick1>>16)&0xff;
141                 Datas[7]=(tick1>>24)&0xff;
142                 
143                 SendTimeuS=thisuS;                
144                 len1=MakePacket((pPacket)PacketBuf1,0,nCurPollId,cmdExChgData,nSeq,8,Datas);
145                 SendPacket(nChn, (pPacket)PacketBuf1, len1);
146                 ChnStats[nCurPollId].SendPackets++;
147                 ChnStats[nCurPollId].SendTimeInterval=SendTimeuS-ChnStats[nCurPollId].LastSentTimeuS;
148                 ChnStats[nCurPollId].LastSentTimeuS=SendTimeuS;
149                 PacketLength = len1;
150                 SendTime=tick1;
151
152                 MasterRecved=0;
153                 MasterRecvOK=0;
154             //    LL_GPIO_TogglePin(GPIOA,LL_GPIO_PIN_5);        
155                 //ToggleErrLed();
156 //                ToggleOut8();
157
158             }
159         
160             Clk3=SysTick->VAL;
161         //    LL_GPIO_TogglePin(GPIOA,LL_GPIO_PIN_4);
162     //    HAL_Delay(1);                
163     return 0;
164 }
165
166 int SlaveFunc(int nChn)
167 {
168         int ThisuS=GetuS();
169         int thisRecvTime=RecvTimeuS;
170         if (SlaveRecved)
171         {
172             KMem.RunStat=8000;
173             SlaveRecved=0;
174         }else if ((ThisuS - thisRecvTime) >12000u)
175         {
176             KMem.ErrStat=8000;
177             KMem.SDD[17]=1;
178             KMem.SDD[18]=ThisuS;
179             KMem.SDD[19]=RecvTimeuS;
180         }else if ( ThisuS > (thisRecvTime + 12000u))
181         {
182             KMem.ErrStat=8000;
183             KMem.SDD[17]=2;
184             KMem.SDD[18]=ThisuS;
185             KMem.SDD[19]=RecvTimeuS;
186         }
187         
188     return 0;
189 }
190
bfc108 191 int MakePacket(pPacket p1,unsigned char src, uchar dst, uchar nType,unsigned char nSEQ, unsigned char DataLen,void * pData )
Q 192 {
193     p1->Sign=StartSign;
e1f350 194     p1->DstHost=dst;
bfc108 195     p1->SrcAddr=src;
Q 196     p1->nCMD=nType;
197     p1->nSEQ=nSEQ;
198     int PacketLenth=0;
199     switch (nType)
200     {
201         case cmdNone:
202             break;
203         case cmdPing:
204             p1->PacketLen=DataLen;
205             memcpy(p1->data,pData,DataLen);
206             p1->data[DataLen]=BCC(p1,sizeof(stPacket)+DataLen-1);
207             p1->data[DataLen+1]=EndSign;
208         
209             PacketLenth=sizeof(stPacket)+DataLen+1;
210             break;
211         case cmdPingReply:
212             p1->PacketLen=DataLen;
213             memcpy(p1->data,pData,DataLen);
214             p1->data[DataLen]=BCC(p1,sizeof(stPacket)+DataLen-1);
215             p1->data[DataLen+1]=EndSign;        
216             PacketLenth=sizeof(stPacket)+DataLen+1;        
217             break;
218         case cmdRead:
219             break;
220         case cmdReadReply:
221             break;
222         case cmdWrite:
223             break;
224         case cmdWriteReply:
225             p1->PacketLen=DataLen;
226          if (DataLen !=0 )    memcpy(p1->data,pData,DataLen);
227             p1->data[DataLen]=BCC(p1,sizeof(stPacket)+DataLen-1);
228             p1->data[DataLen+1]=EndSign;
229             PacketLenth=sizeof(stPacket)+DataLen+1;                    
230             break;
231         case cmdGetVersion:
232             p1->PacketLen=DataLen;
233             memcpy(p1->data,pData,DataLen);
234             p1->data[DataLen]=BCC(p1,sizeof(stPacket)+DataLen-1);
235             p1->data[DataLen+1]=EndSign;
236             PacketLenth=sizeof(stPacket)+DataLen+1;            
237             break;
238         case cmdVerInfo:
239             p1->PacketLen=DataLen;
240             memcpy(p1->data,pData,DataLen);
241             p1->data[DataLen]=BCC(p1,sizeof(stPacket)+DataLen-1);
242             p1->data[DataLen+1]=EndSign;
243             PacketLenth=sizeof(stPacket)+DataLen+1;            
244             break;
245         case cmdExChgData:
246             p1->PacketLen=DataLen;
247             memcpy(p1->data,pData,DataLen);
248             p1->data[DataLen]=BCC(p1,sizeof(stPacket)+DataLen-1);
249             p1->data[DataLen+1]=EndSign;
250             PacketLenth=sizeof(stPacket)+DataLen+1;
251             break;
252         case cmdExChgDataReply:
253             p1->PacketLen=DataLen;
254             memcpy(p1->data,pData,DataLen);
255             p1->data[DataLen]=BCC(p1,sizeof(stPacket)+DataLen-1);
256             p1->data[DataLen+1]=EndSign;        
257             PacketLenth=sizeof(stPacket)+DataLen+1;        
258             break;
259                 
260         case cmdSyncRead:
261             p1->PacketLen=DataLen;
262             memcpy(p1->data,pData,DataLen);
263             p1->data[DataLen]=BCC(p1,sizeof(stPacket)+DataLen-1);
264             p1->data[DataLen+1]=EndSign;        
265             PacketLenth=sizeof(stPacket)+DataLen+1;        
266             break;
267         case cmdSyncWrite:
268             p1->PacketLen=DataLen;
269             memcpy(p1->data,pData,DataLen);
270             p1->data[DataLen]=BCC(p1,sizeof(stPacket)+DataLen-1);
271             p1->data[DataLen+1]=EndSign;        
272             PacketLenth=sizeof(stPacket)+DataLen+1;        
273             break;
274         case cmdSequenRead:
275             p1->PacketLen=DataLen;
276             memcpy(p1->data,pData,DataLen);
277             p1->data[DataLen]=BCC(p1,sizeof(stPacket)+DataLen-1);
278             p1->data[DataLen+1]=EndSign;        
279             PacketLenth=sizeof(stPacket)+DataLen+1;        
280             break;        
281         
282         case cmdSyncTime:
283             p1->PacketLen=DataLen;
284             memcpy(p1->data,pData,DataLen);
285             p1->data[DataLen]=BCC(p1,sizeof(stPacket)+DataLen-1);
286             p1->data[DataLen+1]=EndSign;        
287             PacketLenth=sizeof(stPacket)+DataLen+1;        
288             break;
289         
290         default:
291             break;
292     }
293     
294     return PacketLenth;
295 }
296
d69aae 297 int CheckPacket(int nChn, pPacket p1, int nLen1)
bfc108 298 {
Q 299     if (p1->Sign != StartSign)
300     {
301         Uart2Stat.NotPacketErr++;
302         ChnStats[nCurPollId].NotPkgErr++;
303         return -1;
304     }
305     int DataLen=p1->PacketLen;
306     if (DataLen>MaxPacketLength) 
307     {
308         Uart2Stat.LengthErr++;
309         ChnStats[nCurPollId].PkgLenErr++;
310         return -1;
311     }
312     if (nLen1<DataLen+sizeof(stPacket)+1)
313     {
314         //len4=sprintf(str3,"%d < %d + %d \r\n",len2,DataLen,sizeof(stPacket));
315         //PutStr(str3,len4);
316         ChnStats[nCurPollId].PkgLenErr++;
317         Uart2Stat.LengthErr++;
318         return -3;    //not long enough                    
319     }
320 //    if (p1->data[DataLen+1] != EndSign)
321 //    {
322 //        ChnStats[nCurPollId].NoEndErr++;
323 //        Uart2Stat.LengthErr++;        
324 //        return -2;
325 //    }
326     unsigned char thisBCC=BCC(p1,sizeof(stPacket)+DataLen-1);
327     if (thisBCC != p1->data[DataLen]) 
328     {//BCC Error;
329         Uart2Stat.BCCerr++;
e1f350 330         ChnStats[nCurPollId].BCCErr++;
bfc108 331         return -4;
Q 332     }         
333     return 0;
334 }
335
d69aae 336 int SlaveCheckPacket(int nChn, pPacket p1, int nLen1)
bfc108 337 {
Q 338     if (p1->Sign != StartSign)
339     {
340         Uart2Stat.NotPacketErr++;
e1f350 341         ChnStats[0].ClientNotPktErr++;
bfc108 342         return -1;
Q 343     }
344     int DataLen=p1->PacketLen;
345     if (DataLen>MaxPacketLength) 
346     {
347         Uart2Stat.LengthErr++;
e1f350 348         ChnStats[0].ClientPkgLenErr++;
bfc108 349         return -1;
Q 350     }
351     if (nLen1<DataLen+sizeof(stPacket)+1)
352     {
353         //len4=sprintf(str3,"%d < %d + %d \r\n",len2,DataLen,sizeof(stPacket));
354         //PutStr(str3,len4);
e1f350 355         ChnStats[0].ClientPkgLenErr++;
bfc108 356         Uart2Stat.LengthErr++;
Q 357         return -3;    //not long enough                    
358     }
359 //    if (p1->data[DataLen+1] != EndSign)
360 //    {
361 //        ChnStats[nCurPollId].NoEndErr++;
362 //        Uart2Stat.LengthErr++;        
363 //        return -2;
364 //    }
365     unsigned char thisBCC=BCC(p1,sizeof(stPacket)+DataLen-1);
366     if (thisBCC != p1->data[DataLen]) 
367     {//BCC Error;
368         Uart2Stat.BCCerr++;
e1f350 369         ChnStats[0].ClientBccErr++;
bfc108 370         return -4;
Q 371     }         
372     return 0;
373 }
374
d69aae 375 int MasterParsePacket(int nChn, pPacket p1, int Len1)
bfc108 376 {
Q 377
378         int DataLen=p1->PacketLen;
379         ChnStats[nCurPollId].RecvPackets++;    
380         pPacket p2=(pPacket)PacketBuf2;        
381         int PacketLen=0;
382         //LL_GPIO_TogglePin(GPIOA,LL_GPIO_PIN_6);
383         int ChildId=p1->SrcAddr;
384         unsigned char nIndex;
385         switch (p1->nCMD)
386         {
387             
388             case cmdNone:
389                 break;
390             case cmdPing:
391                 BufferIn[ChildId]=p1->data[0];
392                 PacketLen=MakePacket(p2,0,nCurPollId,cmdPingReply,p1->nSEQ,DataLen,p1->data);
d69aae 393                 SendPacket(nChn, p2, PacketLen);
bfc108 394                 break;
Q 395             case cmdPingReply:
396                 DelayuS=ThisuS-SendTimeuS;
397                 if (DelayuS > MaxDelayuS) MaxDelayuS = DelayuS;
398                 
399                 BufferIn[ChildId]=p1->data[0];
400                 
401                 //RunStat=100;
402                 ChnStats[nCurPollId].CtnLstPkts=0;
403                 ChnStats[nCurPollId].Delay=DelayuS;
404             if (DelayuS > ChnStats[nCurPollId].MaxDelay) 
405                 ChnStats[nCurPollId].MaxDelay=DelayuS;
406                 //PutOutput(outputvalue);
e1f350 407                 MasterRecvOK=1;
bfc108 408                 break;
Q 409             case cmdRead:
410                 break;
411             case cmdReadReply:
412                 break;
413             case cmdWrite:
414                 break;
415             case cmdWriteReply:
416                 MasterRecved=1;
417                 break;
418             case cmdGetVersion:
419                 break;
420             case cmdVerInfo:
421                 break;
422             case cmdExChgData:
423                 BufferIn[0]=p1->data[0];
424                 //PutOutput(outputvalue);
425                 //memcpy(DispBuf,p1->data+2,8);
426                 p1->data[0]=BufferOut[0];
427                 PacketLen=MakePacket(p2,nAddr,0,cmdExChgDataReply,p1->nSEQ,DataLen,p1->data);
d69aae 428                 SendPacket(nChn, p2, PacketLen);
bfc108 429                 break;
Q 430             case cmdExChgDataReply:
431                 DelayuS=ThisuS-SendTimeuS;
432                 if (DelayuS > MaxDelayuS) MaxDelayuS = DelayuS;
d69aae 433
Q 434 #if (BOARD_TYPE==12)                
435                 BufferIn[ChildId]=p1->data[0];
436                 KMem.WXB[ChildId-1]=BufferIn[ChildId];
437                 if (KMRunStat.WorkMode==0) {    
438                 //    KMem.WY[0]= KMem.WX[1]+(KMem.WX[2]<<8)    ;
439                 //    PutOutput (KMem.WY[0]);
440                 }
441 #else
bfc108 442                 BufferIn[ChildId]=p1->data[0];
e1f350 443                 KMem.WX[ChildId]=BufferIn[ChildId];
Q 444                 if (KMRunStat.WorkMode==0) {    
445                     KMem.WY[0]= KMem.WX[1]+(KMem.WX[2]<<8)    ;
446                     PutOutput (KMem.WY[0]);
447                 }
d69aae 448 #endif
Q 449
bfc108 450                 //RunStat=100;
Q 451                 ChnStats[nCurPollId].CtnLstPkts=0;
452                 ChnStats[nCurPollId].Delay=DelayuS;
453             if (DelayuS > ChnStats[nCurPollId].MaxDelay) 
454                 ChnStats[nCurPollId].MaxDelay=DelayuS;
455                 //PutOutput(outputvalue);
456                 
457             
458                 nIndex=p1->data[3];
459                 ChnStats[nCurPollId].ClientDatas[nIndex]=p1->data[4]|(p1->data[5]<<8)|(p1->data[6]<<16)|(p1->data[7]<<24);
460             
e1f350 461                 MasterRecvOK=1;
bfc108 462                 
Q 463                 break;
464                     
465             default:
466                 break;        
467         }
468     //    nCurPollId ++;
469     //    if (nCurPollId > nChilds)
470     //    {
471     //        nCurPollId=1;
472     //    }    
473     return 0;
474 }
e1f350 475 unsigned char nClientDataIndex=0;
d69aae 476 int SlaveParsePacket(int nChn, pPacket p1, int Len1)
bfc108 477 {
Q 478     Uart2Stat.OKPacket++;                
479     int DataLen=p1->PacketLen;    
480 //int nSrcAddr=p1->SrcAddr;
e1f350 481     int nDstHost=p1->DstHost;
bfc108 482         
Q 483 //    RecvTimeuS=ThisuS;
484 //    SlaveRecved=1;
485     
486     pPacket p2=(pPacket)PacketBuf2;
487     int PacketLen=0;
488     unsigned char nIndex = p1->nSEQ & 0x07;
e1f350 489     if (nDstHost!=nAddr && nDstHost != 0xff)
bfc108 490     {
Q 491         ChnStats[0].ClientMisIdPkts++;
492         return -1;
493     }
e1f350 494     if (nDstHost==nAddr || nDstHost==0xff)
bfc108 495     {
Q 496         RecvTimeuS=ThisuS;
497         SlaveRecved=1;
498         switch (p1->nCMD)
499         {
500             case cmdNone:
501                 break;
502             case cmdPing:
503                 BufferIn[0]=p1->data[0];
504                 //PutOutput(outputvalue);
505                 //memcpy(DispBuf,p1->data+2,8);
506                 p1->data[0]=BufferOut[0];
507                 RecvTimeuS=ThisuS;
508                 PacketLen=MakePacket(p2,nAddr,0,cmdPingReply,p1->nSEQ,DataLen,p1->data);
509                 ChnStats[0].ClientSendPkts++;
d69aae 510                 SendPacket(nChn, p2, PacketLen);
bfc108 511                 break;
Q 512             case cmdPingReply:
513                 break;
514             case cmdRead:
515                 break;
516             case cmdReadReply:
517                 break;
518             case cmdWrite:
519                 //memcpy(DispBuf,p1->data,DataLen);
520                 PacketLen=MakePacket(p2,1,0,cmdWriteReply,p1->nSEQ,0,0);
521                 ChnStats[0].ClientSendPkts++;
d69aae 522                 SendPacket(nChn, p2, PacketLen);                    
bfc108 523                 break;
Q 524             case cmdWriteReply:
525                 break;
526             case cmdGetVersion:
527                 break;
528             case cmdVerInfo:
529                 break;
530             case cmdExChgData:
531                 BufferIn[0]=p1->data[0];
532                 nSlaveTick=p1->data[4]+(p1->data[5]<<8);//+(p1->data[6]<<16)+(p1->data[7]<<24);
d69aae 533 #if (BOARD_TYPE == 12)
Q 534             //    PutOutput(BufferIn[0]);
bfc108 535                 //PutOutput(outputvalue);
Q 536                 //memcpy(DispBuf,p1->data+2,8);
e1f350 537                 nIndex=nClientDataIndex;
Q 538         //        ChnStats[0].ClientDatas[7]++;
539 //                BufferOut[0]=GetInput();
d69aae 540         //        BufferOut[0]=GetInput();
Q 541 #else
542                 PutOutput(BufferIn[0]);
543                 //PutOutput(outputvalue);
544                 //memcpy(DispBuf,p1->data+2,8);
545                 nIndex=nClientDataIndex;
546         //        ChnStats[0].ClientDatas[7]++;
e1f350 547 //                BufferOut[0]=GetInput();
Q 548                 BufferOut[0]=GetInput();
d69aae 549 #endif
bfc108 550                 p1->data[0]=BufferOut[0];
Q 551                 p1->data[3]=nIndex;
552                 p1->data[4]=ChnStats[0].ClientDatas[nIndex];
553                 p1->data[5]=ChnStats[0].ClientDatas[nIndex]>>8;
554                 p1->data[6]=ChnStats[0].ClientDatas[nIndex]>>16;
555                 p1->data[7]=ChnStats[0].ClientDatas[nIndex]>>24;
e1f350 556                 nClientDataIndex++;
Q 557                 if (nClientDataIndex >= 10) { nClientDataIndex=0;}
bfc108 558                 PacketLen=MakePacket(p2,nAddr,0,cmdExChgDataReply,p1->nSEQ,DataLen,p1->data);
Q 559                 ChnStats[0].ClientSendPkts++;
d69aae 560                 SendPacket(nChn, p2, PacketLen);
bfc108 561                 break;
Q 562             case cmdExChgDataReply:
563                 break;
564             
565             
566             case cmdSyncRead:
567                 break;
568             case cmdSyncWrite:
569                 break;
570             case cmdSequenRead:
571                 break;
572             case cmdSyncTime:
573                 nSlaveTick=p1->data[0]+(p1->data[1]<<8)+(p1->data[2]<<16)+(p1->data[3]<<24);
574                 break;
575             default:
576                 break;        
577         }
578     }    
579     return 0;
580 }
d69aae 581 int ParsePacket(int nChn, pPacket p1, int Len1)
bfc108 582 {
Q 583     ThisuS=GetuS();
584     int Result=0;
585     if (bMaster)
586     {
e1f350 587             MasterRecved=1;
d69aae 588             Result=CheckPacket(nChn, p1, Len1);
bfc108 589             if (Result != S_OK)
Q 590             {
591                 return Result;
592             }
e1f350 593             MasterRecvOK=1;
d69aae 594             Result=MasterParsePacket(nChn, p1, Len1);            
bfc108 595             return Result;
Q 596     }
597     if (bSlave)
598     {
599             ChnStats[0].ClientRecvPkts++;
d69aae 600             Result=SlaveCheckPacket(nChn, p1, Len1);
bfc108 601             if (Result != S_OK)
Q 602             {
603                 return Result;
604             }
e1f350 605             ChnStats[0].ClientTimeOutErr=KMem.RunStat;
d69aae 606             Result=SlaveParsePacket(nChn, p1, Len1);
bfc108 607             return Result;
Q 608     }
609     //int len1=p1->PacketLen;
e1f350 610 //    if (p1->DstHost!=255&&p1->DstHost!=2) return -3;
bfc108 611 //    pPacket p2=(pPacket)PacketBuf2;
Q 612 //            Uart2Stat.OKPacket++;
613
614     return Result;
615 }
616
617 int InitMachine(stMachineConfig * pConfig)
618 {
619     return S_OK;
620 }
621
622 int SetConfig(void)
623 {
624     return S_OK;
625 }
626
627 int StartConfig(void)
628 {
629     return S_OK;
630 }
631     
632 int SetMasterConfig(void)
633 {
634     return S_OK;
635 }
636
637 int StartPolling(void)
638 {
639     return S_OK;
640 }
641
642 int ReadData(void)
643 {
644     return S_OK;
645 }
646
647 int WriteData(void)
648 {
649     return S_OK;
650 }
651
652 int GetStat(void)
653 {
654     return S_OK;
655 }
656