📄 comm.lst
字号:
222 1 COMMEN = COMMEN_ON;
223 1 os_wait(K_TMO,20/OS_MSEL_PER_TICKS,0);
224 1 SBUF = 0xEB;//启动发送
225 1 }
226 /*********************************************************************************************************
227 ** 函数名称: CommSendParaInfo
228 ** 功能描述: 发送参数报文
229 ** 输 入: 无
230 ** 输 出: 无
231 ** 全局变量: address CommCid ReturnCode outchk
232 ** 调用模块: OSQCreate PutCharWithCheck PutChar
233 **
234 ** 作 者: 刘宝贵
235 ** 日 期: 2004年4月25日
236 **-------------------------------------------------------------------------------------------------------
237 ** 修改人:
238 ** 日 期:
239 **------------------------------------------------------------------------------------------------------
240 ********************************************************************************************************/
C51 COMPILER V7.06 COMM 01/22/2007 09:50:04 PAGE 5
241 void CommSendParaInfo(void)
242 {
243 1 uint16 idata address_temp;
244 1 CommTxPointer = 0;
245 1 CommTxLength = 12;
246 1 CommChkOut = 0xEB;
247 1 PutCharWithCheck(0x90);
248 1 PutCharWithCheck(0xEB);
249 1 PutCharWithCheck(0x90);
250 1 PutCharWithCheck(Address);
251 1 PutCharWithCheck(CommCid);
252 1 PutCharWithCheck(4);
253 1 PutCharWithCheck(ReturnCode);
254 1 PutCharWithCheck(CommRxBuf[0]);//CommRxBuf[0]内容为参数序号
255 1 switch(CommRxBuf[0])
256 1 {
257 2 case 0:address_temp = E2Uk ;break;
258 2 case 1:address_temp = E2Ub ;break;
259 2 case 2:address_temp = E2Ik ;break;
260 2 case 3:address_temp = E2Ib ;break;
261 2 case 4:address_temp = E2DAk;break;
262 2 case 5:address_temp = E2DAb;break;
263 2 case 6:address_temp = E2Tk ;break;
264 2 case 7:address_temp = E2Tb ;break;
265 2 default:address_temp = 0;
266 2 }
267 1 PutCharWithCheck( EepromReadByteA(address_temp) );
268 1 PutCharWithCheck( EepromReadByteA(address_temp+1) );
269 1 PutChar(CommChkOut);
270 1 PutChar(0x0D);
271 1 CommTxPointer = 0;
272 1 COMMEN = COMMEN_ON;
273 1 os_wait(K_TMO,20/OS_MSEL_PER_TICKS,0);
274 1 SBUF = 0xEB;//启动发送
275 1 }
276 /*********************************************************************************************************
277 ** 函数名称: CommSendParaInfo
278 ** 功能描述: 发送指定工步信息报文
279 ** 输 入: 无
280 ** 输 出: 无
281 ** 全局变量: address CommCid ReturnCode outchk
282 ** 调用模块: OSQCreate PutCharWithCheck PutChar
283 **
284 ** 作 者: 刘宝贵
285 ** 日 期: 2006年10月25日
286 **-------------------------------------------------------------------------------------------------------
287 ** 修改人:
288 ** 日 期:
289 **------------------------------------------------------------------------------------------------------
290 ********************************************************************************************************/
291 void CommSendWorkStepInfo(void)
292 {
293 1 uint8 idata ProgramNoTemp;
294 1 uint8 idata StepTemp;
295 1 uint8 xdata ModeTemp;
296 1 uint16 xdata SetupITemp;
297 1 uint16 xdata SetupUTemp;
298 1 uint16 xdata JumpTimeMTemp;
299 1 uint16 xdata JumpUTemp;
300 1 uint16 xdata JumpITemp;
301 1 uint16 xdata JumpQTemp;
302 1
C51 COMPILER V7.06 COMM 01/22/2007 09:50:04 PAGE 6
303 1 ProgramNoTemp = CommRxBuf[0];
304 1 StepTemp = CommRxBuf[1];
305 1 ModeTemp = EepromReadByte(ProgramNoTemp*600 + StepTemp*20 + 2*0);
306 1 // LoopTimes = EepromReadByte(ProgramNoTemp*600 + StepTemp*20 + 2*1);
307 1 SetupITemp = EepromReadWord(ProgramNoTemp*600 + StepTemp*20 + 2*2);
308 1 SetupUTemp = EepromReadWord(ProgramNoTemp*600 + StepTemp*20 + 2*3);
309 1 JumpTimeMTemp = EepromReadWord(ProgramNoTemp*600 + StepTemp*20 + 2*5);
310 1 JumpUTemp = EepromReadWord(ProgramNoTemp*600 + StepTemp*20 + 2*6);
311 1 JumpQTemp = EepromReadWord(ProgramNoTemp*600 + StepTemp*20 + 2*7);
312 1
313 1 CommTxPointer = 0;
314 1 CommTxLength = 24;
315 1 CommChkOut = 0xEB;
316 1 PutCharWithCheck(0x90);
317 1 PutCharWithCheck(0xEB);
318 1 PutCharWithCheck(0x90);
319 1 PutCharWithCheck(Address);
320 1 PutCharWithCheck(CommCid);
321 1 PutCharWithCheck(16);
322 1 PutCharWithCheck(ReturnCode);
323 1
324 1 PutCharWithCheck(ProgramNoTemp);
325 1 PutCharWithCheck(StepTemp);
326 1 PutCharWithCheck(ModeTemp);
327 1 PutCharWithCheck((unsigned char)(SetupUTemp>>8));PutCharWithCheck((unsigned char)SetupUTemp);
328 1 PutCharWithCheck((unsigned char)(SetupITemp>>8));PutCharWithCheck((unsigned char)SetupITemp);
329 1 PutCharWithCheck((unsigned char)(JumpTimeMTemp>>8));PutCharWithCheck((unsigned char)JumpTimeMTemp);
330 1 PutCharWithCheck((unsigned char)(JumpUTemp>>8));PutCharWithCheck((unsigned char)JumpUTemp);
331 1 PutCharWithCheck((unsigned char)(JumpITemp>>8));PutCharWithCheck((unsigned char)JumpITemp);
332 1 PutCharWithCheck((unsigned char)(JumpQTemp>>8));PutCharWithCheck((unsigned char)JumpQTemp);
333 1
334 1 PutChar(CommChkOut);
335 1 PutChar(0x0D);
336 1 CommTxPointer = 0;
337 1 COMMEN = COMMEN_ON;
338 1 os_wait(K_TMO,20/OS_MSEL_PER_TICKS,0);
339 1 SBUF = 0xEB;//启动发送
340 1 }
341 /*********************************************************************************************************
342 ** 函数名称: CommSendCellDataInfo
343 ** 功能描述: 发送电池数据报文
344 ** 输 入: 无
345 ** 输 出: 无
346 ** 全局变量: address CommCid ReturnCode outchk cell.u cell.i cell.c cell.s
347 ** 调用模块: OSQCreate PutCharWithCheck PutChar
348 **
349 ** 作 者: 刘宝贵
350 ** 日 期: 2004年4月27日
351 **-------------------------------------------------------------------------------------------------------
352 ** 修改人: 刘宝贵
353 ** 日 期: 2004年4月29日22:17
354 **-------------------------------------------------------------------------------------------------------
355 ** 修改人:
356 ** 日 期:
357 **------------------------------------------------------------------------------------------------------
358 ********************************************************************************************************/
359 void CommSendCellDataInfo (void)
360 {
361 1 uint8 data temp8;
362 1 temp8 = 0;
363 1 CommTxPointer = 0;
364 1 CommTxLength = 35;
C51 COMPILER V7.06 COMM 01/22/2007 09:50:04 PAGE 7
365 1 CommChkOut = 0xEB;
366 1 PutCharWithCheck(0x90);
367 1 PutCharWithCheck(0xEB);
368 1 PutCharWithCheck(0x90);
369 1 PutCharWithCheck(Address);
370 1 PutCharWithCheck(CommCid);
371 1 PutCharWithCheck(27);
372 1 PutCharWithCheck(ReturnCode);
373 1
374 1 PutCharWithCheck((uint8)(MeasureU>>8));
375 1 PutCharWithCheck((uint8)(MeasureU));
376 1 PutCharWithCheck((uint8)(MeasureI>>8));
377 1 PutCharWithCheck((uint8)(MeasureI));
378 1 PutCharWithCheck((uint8)(MeasureT>>8));
379 1 PutCharWithCheck((uint8)(MeasureT));
380 1 PutCharWithCheck((uint8)(LastTimeS>>24));
381 1 PutCharWithCheck((uint8)(LastTimeS>>16));
382 1 PutCharWithCheck((uint8)(LastTimeS>>8));
383 1 PutCharWithCheck((uint8)(LastTimeS));
384 1 PutCharWithCheck((uint8)((AmountQ10S/36000)>>8));
385 1 PutCharWithCheck((uint8)( AmountQ10S/36000));
386 1 PutCharWithCheck(State);
387 1 PutCharWithCheck(ProgramNo);
388 1 PutCharWithCheck(Step);
389 1 PutCharWithCheck(RemainLoopTimes);
390 1 PutCharWithCheck(Mode);
391 1 PutCharWithCheck(LoopTimes);
392 1 PutCharWithCheck((uint8)(SetupU>>8));
393 1 PutCharWithCheck((uint8)(SetupU));
394 1 PutCharWithCheck((uint8)(SetupI>>8));
395 1 PutCharWithCheck((uint8)(SetupI));
396 1
397 1 PutCharWithCheck(ErrorType);//告警信息
398 1 if(ChangeStateFlag)
399 1 {
400 2 temp8 = temp8 |1;
401 2 }
402 1 else
403 1 {
404 2 temp8 = temp8 & 0xFE;
405 2 }
406 1 PutCharWithCheck(temp8);
407 1 PutCharWithCheck(0);
408 1 PutCharWithCheck(0);
409 1
410 1 PutChar(CommChkOut);
411 1 PutChar(0x0D);
412 1 CommTxPointer = 0;
413 1 COMMEN = COMMEN_ON;
414 1 os_wait(K_TMO,20/OS_MSEL_PER_TICKS,0);
415 1 SBUF = 0xEB;//启动发送
416 1 }
417 /*********************************************************************************************************
418 ** 函数名称: void TaskComm (void) _task_ 5
419 ** 功能描述: 对所接收的数据包进行异或效验
420 ** 输 入: 接收数据数据包
421 ** 输 出: 效验通过返回1 ,否则返回0
422 ** 全局变量:
423 ** 调用模块:
424 **
425 ** 作 者: 刘宝贵
426 ** 日 期: 2006年4月26日
C51 COMPILER V7.06 COMM 01/22/2007 09:50:04 PAGE 8
427 **-------------------------------------------------------------------------------------------------------
428 ** 修改人:
429 ** 日 期:
430 **------------------------------------------------------------------------------------------------------
431 ********************************************************************************************************/
432 bit XorCheck(void)
433 {
434 1 uint8 idata checktemp;
435 1 uint8 idata i;
436 1 checktemp = 0xeb^0x90^0xeb^0x90;
437 1 checktemp^= Address;
438 1 checktemp^= CommCid;
439 1 checktemp^= CommRxLength;
440 1 for(i=0;i<CommRxLength;i++)
441 1 {
442 2 checktemp ^= CommRxBuf[i];
443 2 }
444 1 if(checktemp == CommChkIn || CommChkIn==0x55)
445 1 {//如果接收的校验和为0x55则不校验
446 2 return 1;
447 2 }
448 1 else
449 1 {
450 2 return 0;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -