?? fx1n.lst
字號:
319 5 ReadLen = UartReceiveBuffer[8]*16+UartReceiveBuffer[9];
320 5 UartSendchar(STX);
321 5 // 計算 sumdata 并發送讀取字節
322 5 sumdata=0;
323 5 for(i=1;i<=ReadLen;i++)
324 5 {
325 6 if(ReadAddr==0x01c0)Readdat=0x0a; // 此地址,目前只見過讀,沒有見過寫.
326 6 else
327 6 {
328 7 Readdat=IAPFlashReadMode(ReadAddr+i-1); // 讀FlashData
329 7 }
330 6 tempascdata=hextoasc(Readdat);
331 6 ucdata=tempascdata>>8;
332 6 sumdata = sumdata + ucdata;
333 6 UartSendchar(ucdata);
334 6 ucdata=tempascdata&0xff;
335 6 sumdata = sumdata + ucdata;
336 6 UartSendchar(ucdata);
337 6 }
338 5 UartSendchar(ETX);
339 5 sumdata = sumdata + ETX;
340 5 usum=sumdata&0x0f;
341 5 tempsum=(usum<10)?(usum+0x30):(usum+0x41-0x0a);
342 5 sumdata>>=4;
343 5 usum=sumdata&0x0f;
344 5 Readdat=(usum<10)?(usum+0x30):(usum+0x41-0x0a);
345 5 UartSendchar(Readdat);
346 5 UartSendchar(tempsum); // 注意此處sum 發送順序
347 5 }
348 4 //============================= Write Code ==============================
349 4 else if((UartReceiveBuffer[1]==0x45)\
350 4 &&(UartReceiveBuffer[2] ==0x31)\
351 4 &&(UartReceiveBuffer[3] ==0x31))
352 4 /*&&(UartReceiveBuffer[7] ==0x43))*/
353 4 {
354 5 // 計算得到寫入字節數:
C51 COMPILER V8.16 FX1N 10/10/2009 14:43:37 PAGE 7
355 5 for(i=8;i<10;i++)UartReceiveBuffer[i]=ascto0F(UartReceiveBuffer[i]);
356 5 UartReceiveBuffer[8]<<=4;
357 5 WriteLen=(UartReceiveBuffer[8]+UartReceiveBuffer[9]);
358 5 // 計算得到寫入地址:
359 5 for(i=4;i<8;i++)UartReceiveBuffer[i]=ascto0F(UartReceiveBuffer[i]);
360 5 WriteAddr =UartReceiveBuffer[4]<<12;
361 5 WriteAddr+=UartReceiveBuffer[5]<<8;
362 5 WriteAddr+=UartReceiveBuffer[6]<<4;
363 5 WriteAddr+=UartReceiveBuffer[7];
364 5 if(WriteAddr==0x8000)ErasurePLC(ErasureCODE); // 擦除PLC程序區
365 5 WriteFlash(WriteAddr,(unsigned char *)(UartReceiveBuffer+10),(unsigned char)WriteLen); // 寫 flash
366 5 UartSendchar(ACK);
367 5 }
368 4 //PC :02 30 30 45 30 32 30 32 03 36 43 ==== 2. 6.
369 4 //MCU :02 36 32 36 36 03 44 37
370 4 else if((UartReceiveBuffer[1]==0x30)\
371 4 &&(UartReceiveBuffer[2] ==0x30)\
372 4 &&(UartReceiveBuffer[3] ==0x45)\
373 4 &&(UartReceiveBuffer[4] ==0x30)\
374 4 &&(UartReceiveBuffer[5] ==0x32)\
375 4 &&(UartReceiveBuffer[6] ==0x30)\
376 4 &&(UartReceiveBuffer[7] ==0x32)) // 查詢PLC 類型:FX1N\FX1S
377 4 {
378 5 UartSendByte((unsigned char *)OrderSend1,8);
379 5 }
380 4 //PC :02 45 30 30 30 31 43 30 30 31 03 44 44 ==== 4.
381 4 //MCU :02 30 41 03 37 34
382 4 else if((UartReceiveBuffer[1]==0x45)\
383 4 &&(UartReceiveBuffer[2] ==0x30)\
384 4 &&(UartReceiveBuffer[3] ==0x30)\
385 4 &&(UartReceiveBuffer[4] ==0x30)\
386 4 &&(UartReceiveBuffer[5] ==0x31)\
387 4 &&(UartReceiveBuffer[6] ==0x43)\
388 4 &&(UartReceiveBuffer[7] ==0x30)\
389 4 &&(UartReceiveBuffer[8] ==0x30)\
390 4 &&(UartReceiveBuffer[9] ==0x31)) // 查詢PLC 當前狀態:暫停\運行
391 4 {
392 5 UartSendByte((unsigned char *)OrderSend2,6);
393 5 }
394 4 //PC :02 45 30 30 30 45 30 36 30 32 03 45 35 ==== 11.
395 4 //MCU :02 31 30 30 30 03 43 34
396 4 else if((UartReceiveBuffer[1]==0x45)\
397 4 &&(UartReceiveBuffer[2] ==0x30)\
398 4 &&(UartReceiveBuffer[3] ==0x30)\
399 4 &&(UartReceiveBuffer[4] ==0x30)\
400 4 &&(UartReceiveBuffer[5] ==0x45)\
401 4 &&(UartReceiveBuffer[6] ==0x30)\
402 4 &&(UartReceiveBuffer[7] ==0x36)\
403 4 &&(UartReceiveBuffer[8] ==0x30)\
404 4 &&(UartReceiveBuffer[9] ==0x32))
405 4 {
406 5 UartSendByte((unsigned char *)OrderSend5,8);
407 5 }
408 4 //PC :02 45 30 30 30 45 43 43 30 32 03 30 35 ==== 13.
409 4 //MCU :02 30 38 30 30 03 43 42
410 4 else if((UartReceiveBuffer[1]==0x45)\
411 4 &&(UartReceiveBuffer[2] ==0x30)\
412 4 &&(UartReceiveBuffer[3] ==0x30)\
413 4 &&(UartReceiveBuffer[4] ==0x30)\
414 4 &&(UartReceiveBuffer[5] ==0x45)\
415 4 &&(UartReceiveBuffer[6] ==0x43)\
416 4 &&(UartReceiveBuffer[7] ==0x43)\
C51 COMPILER V8.16 FX1N 10/10/2009 14:43:37 PAGE 8
417 4 &&(UartReceiveBuffer[8] ==0x30)\
418 4 &&(UartReceiveBuffer[9] ==0x32))
419 4 {
420 5 UartSendByte((unsigned char *)OrderSend6,8);
421 5 }
422 4
423 4 //PC :02 45 37 37 36 30 45 03 36 31
424 4 //MCU :06
425 4 else if((UartReceiveBuffer[1]==0x45)\
426 4 &&(UartReceiveBuffer[2] ==0x37)\
427 4 &&(UartReceiveBuffer[3] ==0x37)\
428 4 &&(UartReceiveBuffer[4] ==0x36)\
429 4 &&(UartReceiveBuffer[5] ==0x30)\
430 4 &&(UartReceiveBuffer[6] ==0x45))
431 4 {
432 5 UartSendchar(ACK);
433 5 }
434 4 //PC :02 45 38 37 36 30 45 03 36 32
435 4 //MCU :06
436 4 else if((UartReceiveBuffer[1]==0x45)\
437 4 &&(UartReceiveBuffer[2] ==0x38)\
438 4 &&(UartReceiveBuffer[3] ==0x37)\
439 4 &&(UartReceiveBuffer[4] ==0x36)\
440 4 &&(UartReceiveBuffer[5] ==0x30)\
441 4 &&(UartReceiveBuffer[6] ==0x45))
442 4 {
443 5 UartSendchar(ACK);
444 5 }
445 4 //PC :02 42 03 34 35
446 4 //MCU :06
447 4 else if((UartReceiveBuffer[1]==0x42))
448 4 {
449 5 UartSendchar(ACK);
450 5 }
451 4 //PC :02 45 36 31 03 41 46 ;02 45 36 30 03 41 45 ;02 45 36 33 03 42 31 ;02 45 36 32 03 42 30 ---清除PL
-C存儲空間[順序]
452 4 //MCU :06
453 4 else if((UartReceiveBuffer[1]==0x45)\
454 4 &&(UartReceiveBuffer[2] ==0x36)\
455 4 &&(UartReceiveBuffer[3] <0x34)) // 暫定,可以實現目的,但是有待于進一步討論.
456 4 {
457 5 ErasurePLC(ErasureCODE); // 擦除PLC程序
458 5 UartSendchar(ACK);
459 5 }
460 4 //************* 有待于加入運行\中止相關代碼 *******************
461 4 //************* 有待于加入監控測試 相關代碼 *******************
462 4 }
463 3 else UartSendchar(NACK);
464 3 }
465 2 else UartSendchar(NACK);
466 2 UartReceiveCounter=0;
467 2 REN=1; // 使能接收
468 2 }
469 1 }
470
MODULE INFORMATION: STATIC OVERLAYABLE
CODE SIZE = 1972 ----
CONSTANT SIZE = 122 ----
XDATA SIZE = ---- 36
PDATA SIZE = ---- ----
C51 COMPILER V8.16 FX1N 10/10/2009 14:43:37 PAGE 9
DATA SIZE = ---- ----
IDATA SIZE = ---- ----
BIT SIZE = ---- ----
END OF MODULE INFORMATION.
C51 COMPILATION COMPLETE. 0 WARNING(S), 0 ERROR(S)
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -