main.c
上传用户:xhjmsc
上传日期:2019-09-13
资源大小:389k
文件大小:24k
- /************************************************
- Network 3G Fax
- Copyright 2006 by Vson. All rights reserved.
- Author: Bryan Cai
- Date: 2006.09.04
- Description: Carry out a Network 3G Fax with Conexant CX06833.
- Note:
- Identifier abbreviation:
- c-const
- a-array
- p-pointer
- g-global
- uc-unsigned char
- w-unsigned int
- cnt-count
- pnt-point
- Update:
- 2007.04.12 Bryan Concise the FaxManager program
- 2007.03.20 Bryan Complete all DTE command function
- 2007.03.16 Bryan Fast exit RxProcess when error occur.
- 2007.01.03 Bryan Add Modem RX parameter set
- 2006.12.27 Bryan add RX multi imagepages
- 2006.12.22 Bryan Flash I/O changed
- 2006.11.02 Bryan program header
- ************************************************/
- #include "includeH.h"
- //interrupt [USART0TX_VECTOR] void intUartTx(void);
- //interrupt [USART0RX_VECTOR] void intUartRx(void);
- /* AT command Set
- unsigned char ATcmdPrefix[]={0x41,0x54}, ATcmdSuffix[]={0x0D},
- //ATFS0[]={0x26,0x46,0x53,0x30,0x3d,0x30,0x45,0x31,0x56,0x31,0x51,0x30},
- //ATS7[]={0x53,0x37,0x3d,0x36,0x30,0x26,0x44,0x33,0x26,0x4b,0x34},
- //ATX4M1L0[]={0x58,0x34,0x4d,0x31,0x4c,0x30},
- //FCLASS[]={0x2b,0x46,0x43,0x4c,0x41,0x53,0x53,0x3d,0x31},
- //FCLASS0[]={0x2b,0x46,0x43,0x4c,0x41,0x53,0x53,0x3d,0x30},
-
-
- ATS0RX[]={0x53,0x30,0x3d,0x30},
- DT[]={0x44,0x54,0x39,0x36,0x31,0x31,0x33,0x39,0x35,0x30,0x39},
- A[]={0x41},
- //DT[]={0x44,0x54,0x39,0x30,0x37,0x39,0x37,0x36,0x39,0x30,0x35,0x31,0x39,0x31},
- FRH[]={0x2b,0x46,0x52,0x48,0x3d,0x33,0x0d},
- FTH[]={0x2b,0x46,0x54,0x48,0x3d,0x33,0x0d},
- //FTHNSF[]={0xff,0x03,0x54,0x47,0x46,0x33,0x36,0x36,0x43,0x00,0x77,0x9C,0x10,0x03},
- //for TX
- FTHTSI[]={0xff,0x03,0x43,0x78,0x61,0x46,0x10,0x03},
- FTHDCS[]={0xff,0x13,0x83,0x00,0x46,0x78,0x10,0x03},//for TX
- //for RX
- //FTHCSI[]={0xff,0x03,0x40,0x78,0x61,0x46,0x10,0x03},//@Fax
- FTHCSI[]={0xff,0x03,0x40,0x36,0x33,0x38,0x10,0x03},//@836
- FTHDIS[]={0xff,0x13,0x80,0x00,0xee,0x78,0x10,0x03},//for RX ee 78
- //FTHDIS[]={0xff,0x13,0x80,0x00,0x46,0x70,0x10,0x03},//for RX ee 78
- //FTHCSI[]={0xff,0x03,0x40,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x36,0x33,0x38,0x10,0x03},//@Fax
- //FTHDIS[]={0xff,0x13,0x80,0x00,0xee,0x78,0x10,0x03},//for RX ee 78
- FTHCFR[]={0xff,0x13,0x84,0x10,0x03},// Confirmation to receive MSB 21H LSB 83H
- FTHMCF[]={0xff,0x13,0x8C,0x10,0x03},// Message Confirmation MSB 31H LSB 8CH
- FTHEOP[]={0xff,0x13,0x2f,0x10,0x03},
- FTHDNC[]={0xff,0x13,0xfb,0x10,0x03},
- FTHEOM[]={0xff,0x03,0x43,0x78,0x61,0x46,0x10,0x03},
- FTS[]={0x2b,0x46,0x54,0x53,0x3d,0x38},
- FTM[]={0x2b,0x46,0x54,0x4d,0x3d,0x39,0x36},
- //FRM[]={0x2b,0x46,0x52,0x4d,0x3d,0x31,0x34,0x35},
- FRM[]={0x2b,0x46,0x52,0x4d,0x3d,0x39,0x36},
- H0[]={0x48,0x00},
- TerminalFlag[]={0x10,0x03};
- */
-
- void main(void)
- {
-
- unsigned int wGeneralCount = 0,
- wOKcount=0,
- wNotOKcount=0,
- wOneFaxHead=0,
- wOneFaxRear=0,
- wGeneralVar=0;
- unsigned char
- ucRxIndex3=0,ucRxIndex2=0,
- ucRxIndex1=0,ucRxIndex0=0,
- ucSoftUartRxCnt=0;
- //unsigned char ucGeneralCount=1;
- unsigned char ucGeneralCnt=0;
- unsigned char ucRingNum=0;
- unsigned char ucRxIndex=0;
- //unsigned char ucSoftUartRxData=0;
- //unsigned char ucFlashWriteData;
- //unsigned char ucFlashColumnAddCnt;
- //unsigned int wGeneralCnt;
- //unsigned int wBlockAddress=0,wPageAddress=0;
- WDTCTL=WDTPW+WDTHOLD; //close watch dog
-
- /*
- FLASH_CON_PORT_OUT |= CE; //COMMAND_LATCH_INTO_INITAIL all control disable
- FLASH_CON_PORT_OUT &= ~CE;
- FLASH_CON_PORT_OUT |= WE;
- FLASH_CON_PORT_OUT &= ~WE;
- FLASH_CON_PORT_OUT |= RE;
- FLASH_CON_PORT_OUT &= ~RE;
- FLASH_CON_PORT_OUT |= CLE;
- FLASH_CON_PORT_OUT &= ~CLE;
- FLASH_CON_PORT_OUT |= ALE;
- FLASH_CON_PORT_OUT &= ~ALE;
- */
- //while (1) _NOP();
- IoInitial();
- InitUART();
- Flash_Reset();
- FLASH_READ_ID();
- //while (0) aucUartRxBuf[ucRxIndex++]=SoftUartRxOneFrame();
- SOFTUART_PORT_DIRECTION |= bitSOFTUARTTX;
- /*
- while (0)
- {
- SOFTUART_PORT_OUT |= bitSOFTUARTTX;
- delay1us(20);
- SOFTUART_PORT_OUT &= ~bitSOFTUARTTX;
- delay1us(8);
- SOFTUART_PORT_OUT |= bitSOFTUARTTX;
- for (ucGeneralCnt=0;ucGeneralCnt<8;ucGeneralCnt++)
- {
- delay1us(2);//SoftUartDelayHalf();
- ucSoftUartRxData=ucSoftUartRxData>>1;
- //if ((SOFTUART_PORT_IN & bitSOFTUARTRX) == bitSOFTUARTRX)
- //ucSoftUartRxData |= BIT7;//BIT7;//(1<<ucGeneralCount);//set Rx bit
- //else
- //{ucSoftUartRxData &= ~BIT7;__no_operation();__no_operation();__no_operation();}//~BIT7;//~(1<<ucGeneralCount);//set Rx bit
- if ((SOFTUART_PORT_OUT & bitSOFTUARTTX) != bitSOFTUARTTX)
- {SOFTUART_PORT_OUT |= bitSOFTUARTTX;} //set Tx bit
- else
- {SOFTUART_PORT_OUT &= ~bitSOFTUARTTX;__no_operation();__no_operation();}
- delay1us(2);//SoftUartDelayHalf();
- __no_operation();
- __no_operation();
- __no_operation();
- __no_operation();
- __no_operation();
-
- }
-
- SOFTUART_PORT_OUT &= ~bitSOFTUARTTX;
- delay1us(8);
- SOFTUART_PORT_OUT |= bitSOFTUARTTX;
- }
- */
- Delay2000ms();
-
- ReadLastViewData();
- //ReadLast16BytesFromFlashMemoryArea(cstViewDataAreaStartBlockNum,cstViewDataAreaOverBlockNum);
-
- ucRxIndex=gucUartRxCnt;
- if ((gucGeneralStatus & bitReadFlashMemoryOK) == bitReadFlashMemoryOK)
- {
- gucViewRingNum = aucUartRxBuf[ucRxIndex++];
- gucViewStaticStatus = aucUartRxBuf[ucRxIndex++];
- gucViewDynamicStatus = aucUartRxBuf[ucRxIndex++];
- gucViewDceNewFaxNum = aucUartRxBuf[ucRxIndex++];
- }
- ViewCommunicationTX(0);
-
- //while (1) wGeneralCount = gwGeneralPageAddress>>6;
- //while (1) _NOP();
- /*
- while (1)
- {
- ViewCommunicationTX(1);
- ViewCommunicationRX();
- }
- */
-
-
-
- //while (1)
- //{
- //Initial Device Reset Modem
- ModemResetPortDir |= bitModemHardwareReset;
- ModemResetCon &= ~bitModemHardwareReset;
- ATcmdDelay();
- ModemResetPortDir &= ~bitModemHardwareReset;
- ModemResetCon |= bitModemHardwareReset;
- while (1)
- {
-
- ATcmdDelay();
- SendATcmd();
- ATcmdDelay();
- ATcmdDelay();
- if ((0x0d!=aucUartRxBuf[ucRxIndex0])&&(0x4B!=aucUartRxBuf[ucRxIndex1]))
- {
- SendATcmdModemSoftReset();
- ATcmdDelay();
- ATcmdDelay();
-
- ucRxIndex1=gucUartRxCnt-3;
- ucRxIndex0=gucUartRxCnt-2;
- if ((0x0d==aucUartRxBuf[ucRxIndex0])&&(0x4B==aucUartRxBuf[ucRxIndex1]))
- {break;}
- }
- }//while
- while (1)
- {
- ATcmdDelay();
- SendATcmd(); //a bug of Sep.22 If this AT is not added, the ring can't receive sometimes.
- ATcmdDelay();
- ATcmdDelay();
-
- while (wGeneralCount++<0xffff)
- {
- ucRxIndex1=gucUartRxCnt-3;
- ucRxIndex0=gucUartRxCnt-2;
- if ((0x0d==aucUartRxBuf[ucRxIndex0])&&(0x4B==aucUartRxBuf[ucRxIndex1]))
- {wOKcount++;break;}
- if (wGeneralCount==0xffff)
- {
- //wGeneralCount=0;
- wNotOKcount++;
- SendATcmdModemSoftReset();
- ATcmdDelay();
- ATcmdDelay();
- }//if
- }//while
- ucRxIndex1=gucUartRxCnt-3;
- ucRxIndex0=gucUartRxCnt-2;
- if ((0x0d==aucUartRxBuf[ucRxIndex0])&&(0x4B==aucUartRxBuf[ucRxIndex1]))
- {wOKcount++;break;}
- }//while
- _NOP();
- gucGeneralStatus &= ~bitModemActive;
-
- //gucUartRxCnt++;
- //}//while
-
- //Main Circle
- while (1)
- {
- //Key Scan and Set Parameters
-
- KeyScan();
- //}// test keyscan
- //while (1)//test keyscan
- //{//test keyscan
-
- //if Modem active(bitModemActive=0X0002)
- //detect modem
- //else
- //detect PC command through SoftUart
- ucRingNum=0;
- if ((gucGeneralStatus & bitModemActive) == bitModemActive)
- {
- while (wGeneralCount++<0xffff)
- {
- ucRxIndex3=gucUartRxCnt-6;
- ucRxIndex2=gucUartRxCnt-5;
- ucRxIndex1=gucUartRxCnt-4;
- ucRxIndex0=gucUartRxCnt-3;
- if ((aucUartRxBuf[ucRxIndex0]==0x47)&&(aucUartRxBuf[ucRxIndex1]==0x4e)&&
- (aucUartRxBuf[ucRxIndex2]==0x49)&&(aucUartRxBuf[ucRxIndex3]==0x52))
- {
- gucUartRxCnt+=1;
- ucRingNum++;
- //if AutoMode
- //{
- //if Ring Num < Ring Num Max
- //gucUartRxCnt++; RingNumCnt++;
- //else
- //break;
- //}
- //else (Manual Mode)
- //if Receive Start Key Switch On
- // break;
- if ((gucViewStaticStatus & bitViewAutoMode) == bitViewAutoMode) //auto mode
- {
- while (1)
- {
-
- ucRxIndex3=gucUartRxCnt-6;
- ucRxIndex2=gucUartRxCnt-5;
- ucRxIndex1=gucUartRxCnt-4;
- ucRxIndex0=gucUartRxCnt-3;
- if ((aucUartRxBuf[ucRxIndex0]==0x47)&&(aucUartRxBuf[ucRxIndex1]==0x4e)&&
- (aucUartRxBuf[ucRxIndex2]==0x49)&&(aucUartRxBuf[ucRxIndex3]==0x52))
- {ucRingNum++;gucUartRxCnt++;}// pointer to next imcoming RING
- if (ucRingNum>=gucViewRingNum)
- {gucGeneralStatus |= bitSendFaxSignalOK;break;}//OK
- //time overflow quit
- if (gwTimeOverflowCount++ == 0xffff)
- gucTimeOverflowCount++;
- if (gucTimeOverflowCount == 20)
- {gucGeneralStatus &= ~bitSendFaxSignalOK;gucTimeOverflowCount=0;gwTimeOverflowCount=0;break;}
- }
-
- }//if auto mode end
- else //manual mode
- {
- while (1)
- {
- gucUartRxCnt++;// pointer to next imcoming RING
- ucRxIndex3=gucUartRxCnt-6;
- ucRxIndex2=gucUartRxCnt-5;
- ucRxIndex1=gucUartRxCnt-4;
- ucRxIndex0=gucUartRxCnt-3;
- if ((aucUartRxBuf[ucRxIndex0]==0x47)&&(aucUartRxBuf[ucRxIndex1]==0x4e)&&
- (aucUartRxBuf[ucRxIndex2]==0x49)&&(aucUartRxBuf[ucRxIndex3]==0x52))
- ucRingNum++;
- if (ucRingNum>10)//if RING is over 10, error
- {gucGeneralStatus &= ~bitSendFaxSignalOK;break;}//Not OK
- if ((KEY_PORT_IN & bitKeySendFaxSignal) != bitKeySendFaxSignal)
- {gucGeneralStatus |= bitSendFaxSignalOK;break;}//OK
- }
- }//else manual mode end
- break;
- }//if
- }//while
-
- //receive fax
- if ((gucGeneralStatus & bitSendFaxSignalOK) == bitSendFaxSignalOK)
- {
- gucGeneralStatus &= ~bitSendFaxSignalOK;
- //Driver Screen Flash Receiving
-
- gucViewDynamicStatus |= bitViewReceiving;
-
- ViewCommunicationTX(0x01);
- //ViewCommunicationRX();
-
- gucUartRxCnt=0;//
- gucFrhErrorStatus=0x00;
- FaxRXProcess();
-
- //Off Screen Flash Receiving
- gucViewDynamicStatus &= ~bitViewReceiving;
- ViewCommunicationTX(0x01);
- //if receive is OK
- //write data to flash
- //FaxRawDataBuf2Flash();
- //gucRxTxFlag = DTERX;
-
-
- if (gucFrhErrorStatus!=3)
- {
- FaxRxBufRawdata2PCFromSoftUart();
- //FaxRxBufRawdata2PCFromUart();
- FaxRxBufRawdata2Flash();
- //FaxData2PCFromSoftUart();
- gucViewStaticStatus |= bitViewNewFax;
- gucViewDynamicStatus |= bitViewNewFax;
- gucViewDceNewFaxNum++;
- ViewCommunicationTX(0x01);
- ReadAndWriteViewDataMemory();
-
- }//if
- else
- {
- ModemResetPortDir |= bitModemHardwareReset;
- ModemResetCon &= ~bitModemHardwareReset;
- ATcmdDelay();
- ModemResetPortDir &= ~bitModemHardwareReset;
- ModemResetCon |= bitModemHardwareReset;
- //InitUART();
- while (1) //add at Apr. 13, 2007 can't receive RS232 Data
- {
- SendATcmdModemSoftReset();
- ATcmdDelay();
- ATcmdDelay();
-
- ucRxIndex1=gucUartRxCnt-3;
- ucRxIndex0=gucUartRxCnt-2;
- if ((0x0d==aucUartRxBuf[ucRxIndex0])&&(0x4B==aucUartRxBuf[ucRxIndex1]))
- {break;}
- }
- }//else Rx error
- //break; //Cant's delete it should be over this while circle //break; //delete at Mar. 16, 2007
- }//if fax receive end
- //Fax receive over, reset bitModemActive for PC detect the new fax
- gucGeneralStatus &= ~bitModemActive; //fax receiving over
- }//if modem active end
- else
- {
- //receive data from SoftUart
- ucSoftUartRxCnt=0;
- gucSoftUartRxCnt=0;
- //ucGeneralCnt=0;
- while (1)
- {
- aucSoftUartRxBuf[ucSoftUartRxCnt++]=SoftUartRxOneFrame();//receive one Byte Data
- if (ucSoftUartRxCnt>19)//17)//
- ucSoftUartRxCnt=0;//gucSoftUartRxCnt=0; 2-2=0
- if (aucSoftUartRxBuf[ucSoftUartRxCnt-1]==0x03 && aucSoftUartRxBuf[ucSoftUartRxCnt-2]==0x10)
- {gucSoftUartRxCnt=ucSoftUartRxCnt;ucSoftUartRxCnt=0; break;}//{gucSoftUartRxCnt=0; break;} //bug of Apr. 03, 20007
- if ((gucGeneralStatus & bitModemActive) == bitModemActive)//if modem active, over this while function
- break;
- if (((KEY_PORT_IN & bitKeyRingNumDec) != bitKeyRingNumDec) ||
- ((KEY_PORT_IN & bitKeyRingNumAdd) != bitKeyRingNumAdd) ||
- ((KEY_PORT_IN & bitKeyAutoMode) != bitKeyAutoMode) ||
- ((KEY_PORT_IN & bitKeyManualMode) != bitKeyManualMode)) //||
- //((KEY_PORT_IN & bitKeySendFaxSignal) != bitKeySendFaxSignal))
- break;
- }
-
- //Judge the received data
-
- //PC get Modem Bus command:ba 23 00 01 10 03
- if ((aucSoftUartRxBuf[gucSoftUartRxCnt-1]==0x03) && (aucSoftUartRxBuf[gucSoftUartRxCnt-2]==0x10)&&
- (aucSoftUartRxBuf[gucSoftUartRxCnt-3]==0x01) && (aucSoftUartRxBuf[gucSoftUartRxCnt-4]==0x00)&&
- (aucSoftUartRxBuf[gucSoftUartRxCnt-5]==0x23) && (aucSoftUartRxBuf[gucSoftUartRxCnt-6]==0xba))
- {
- DteGetModemBus();
- SoftUartTxOneFrame(0xff);
- }
-
- //PC return Modem Bus command:ba 23 00 02 10 03
- if ((aucSoftUartRxBuf[gucSoftUartRxCnt-1]==0x03) && (aucSoftUartRxBuf[gucSoftUartRxCnt-2]==0x10)&&
- (aucSoftUartRxBuf[gucSoftUartRxCnt-3]==0x02) && (aucSoftUartRxBuf[gucSoftUartRxCnt-4]==0x00)&&
- (aucSoftUartRxBuf[gucSoftUartRxCnt-5]==0x23) && (aucSoftUartRxBuf[gucSoftUartRxCnt-6]==0xba))
- {
- DteReturnModemBus();
- SoftUartTxOneFrame(0xff);
- }
-
- //PC get Fax List command:ba 23 00 03 10 03
- if ((aucSoftUartRxBuf[gucSoftUartRxCnt-1]==0x03)&&(aucSoftUartRxBuf[gucSoftUartRxCnt-2]==0x10)&&
- (aucSoftUartRxBuf[gucSoftUartRxCnt-3]==0x03)&&(aucSoftUartRxBuf[gucSoftUartRxCnt-4]==0x00)&&
- (aucSoftUartRxBuf[gucSoftUartRxCnt-5]==0x23)&&(aucSoftUartRxBuf[gucSoftUartRxCnt-6]==0xba))
- {
- DteGetFaxList();
- }
-
- //PC get One Fax command:ba 23 00 04 HeadLow HeadHigh RearLow RearHigh 10 03
- if ((aucSoftUartRxBuf[gucSoftUartRxCnt-1]==0x03)&&(aucSoftUartRxBuf[gucSoftUartRxCnt-2]==0x10)&&
- (aucSoftUartRxBuf[gucSoftUartRxCnt-7]==0x04)&&(aucSoftUartRxBuf[gucSoftUartRxCnt-8]==0x00)&&
- (aucSoftUartRxBuf[gucSoftUartRxCnt-9]==0x23)&&(aucSoftUartRxBuf[gucSoftUartRxCnt-10]==0xba))
- {
-
- if (gucFrhErrorStatus==0)
- {
- ucRxIndex1=gucSoftUartRxCnt-6;//Low Byte
- ucRxIndex0=gucSoftUartRxCnt-5;//High Byte
- wGeneralVar=aucSoftUartRxBuf[ucRxIndex0];
- wOneFaxHead=(wGeneralVar<<8) | aucSoftUartRxBuf[ucRxIndex1];
-
- ucRxIndex1=gucSoftUartRxCnt-4;//Low Byte
- ucRxIndex0=gucSoftUartRxCnt-3;//High Byte
- wGeneralVar=aucSoftUartRxBuf[ucRxIndex0];
- wOneFaxRear=(wGeneralVar<<8) | aucSoftUartRxBuf[ucRxIndex1];
-
- DteGetOneFax(wOneFaxHead, wOneFaxRear);
- if (gucViewDceNewFaxNum>0)
- {
- gucViewDceNewFaxNum--;// for DCE check the new fax
- gucViewStaticStatus |= bitViewNewFax;
- gucViewDynamicStatus |= bitViewNewFax;
- }
- else
- {gucViewStaticStatus &= ~bitViewNewFax;}
-
- ViewCommunicationTX(0x01);
- ReadAndWriteViewDataMemory();
- }
- }
-
- //PC delete One Fax command:ba 23 00 05 HeadLow HeadHigh RearLow RearHigh 10 03
- if ((aucSoftUartRxBuf[gucSoftUartRxCnt-1]==0x03)&&(aucSoftUartRxBuf[gucSoftUartRxCnt-2]==0x10)&&
- (aucSoftUartRxBuf[gucSoftUartRxCnt-7]==0x05)&&(aucSoftUartRxBuf[gucSoftUartRxCnt-8]==0x00)&&
- (aucSoftUartRxBuf[gucSoftUartRxCnt-9]==0x23)&&(aucSoftUartRxBuf[gucSoftUartRxCnt-10]==0xba))
- {
-
- if (gucFrhErrorStatus==0)
- {
- ucRxIndex1=gucSoftUartRxCnt-6;//Low Byte
- ucRxIndex0=gucSoftUartRxCnt-5;//High Byte
- wGeneralVar=aucSoftUartRxBuf[ucRxIndex0];
- wOneFaxHead=(wGeneralVar<<8) | aucSoftUartRxBuf[ucRxIndex1];
-
- ucRxIndex1=gucSoftUartRxCnt-4;//Low Byte
- ucRxIndex0=gucSoftUartRxCnt-3;//High Byte
- wGeneralVar=aucSoftUartRxBuf[ucRxIndex0];
- wOneFaxRear=(wGeneralVar<<8) | aucSoftUartRxBuf[ucRxIndex1];
-
- //DteDelOneFax(wOneFaxHead, wOneFaxRear);
- }
- }
-
- //PC delete all fax command:ba 23 00 05 10 03
- if ((aucSoftUartRxBuf[gucSoftUartRxCnt-1]==0x03)&&(aucSoftUartRxBuf[gucSoftUartRxCnt-2]==0x10)&&
- (aucSoftUartRxBuf[gucSoftUartRxCnt-3]==0x06)&&(aucSoftUartRxBuf[gucSoftUartRxCnt-4]==0x00)&&
- (aucSoftUartRxBuf[gucSoftUartRxCnt-5]==0x23)&&(aucSoftUartRxBuf[gucSoftUartRxCnt-6]==0xba))
- {
- ;//DteDelAllFax();
- }
-
- //PC send the system time to Dce command:ba 23 00 0b YearLow YearHigh Month Day Hour Minute Second 10 03
- if ((aucSoftUartRxBuf[gucSoftUartRxCnt-1]==0x03)&&(aucSoftUartRxBuf[gucSoftUartRxCnt-2]==0x10)&&
- (aucSoftUartRxBuf[gucSoftUartRxCnt-10]==0x0b)&&(aucSoftUartRxBuf[gucSoftUartRxCnt-11]==0x00)&&
- (aucSoftUartRxBuf[gucSoftUartRxCnt-12]==0x23)&&(aucSoftUartRxBuf[gucSoftUartRxCnt-13]==0xba))
- {
-
- if (gucFrhErrorStatus==0)
- {
- /*
- SetSystemTime(aucSoftUartRxBuf[gucSoftUartRxCnt-9], aucSoftUartRxBuf[gucSoftUartRxCnt-8],
- aucSoftUartRxBuf[gucSoftUartRxCnt-7], aucSoftUartRxBuf[gucSoftUartRxCnt-6],
- aucSoftUartRxBuf[gucSoftUartRxCnt-5], aucSoftUartRxBuf[gucSoftUartRxCnt-4],
- aucSoftUartRxBuf[gucSoftUartRxCnt-3]);
- */
- ucRxIndex=gucSoftUartRxCnt-8;
- for (ucGeneralCnt = 0; ucGeneralCnt < 6; ucGeneralCnt++)
- {
- aucViewData[cstViewSecondIndex] = aucUartRxBuf[ucRxIndex++];//second
- aucViewData[cstViewMinuteIndex] = aucUartRxBuf[ucRxIndex++];//minute
- aucViewData[cstViewHourIndex] = aucUartRxBuf[ucRxIndex++];//hour
- aucViewData[cstViewDateIndex] = aucUartRxBuf[ucRxIndex++];//date
- aucViewData[cstViewMonthIndex] = aucUartRxBuf[ucRxIndex++];//month
- aucViewData[cstViewYearIndex] = aucUartRxBuf[ucRxIndex++];//Year
- }
- ViewCommunicationTX(0x00);
- }
- }
-
- //format flash
- if ((aucSoftUartRxBuf[gucSoftUartRxCnt-1]==0x03)&&(aucSoftUartRxBuf[gucSoftUartRxCnt-2]==0x10)&&
- (aucSoftUartRxBuf[gucSoftUartRxCnt-3]==0x0c)&&(aucSoftUartRxBuf[gucSoftUartRxCnt-4]==0x00)&&
- (aucSoftUartRxBuf[gucSoftUartRxCnt-5]==0x23)&&(aucSoftUartRxBuf[gucSoftUartRxCnt-6]==0xba))
- {
- FlashFormat();
- }
-
- //Flash bad block process
- if ((aucSoftUartRxBuf[gucSoftUartRxCnt-1]==0x03)&&(aucSoftUartRxBuf[gucSoftUartRxCnt-2]==0x10)&&
- (aucSoftUartRxBuf[gucSoftUartRxCnt-3]==0x0d)&&(aucSoftUartRxBuf[gucSoftUartRxCnt-4]==0x00)&&
- (aucSoftUartRxBuf[gucSoftUartRxCnt-5]==0x23)&&(aucSoftUartRxBuf[gucSoftUartRxCnt-6]==0xba))
- {
- CheckInvalidBlock();
- SoftUartTxOneFrame(0xff);
- }
-
- //PC set CSI and DIS
- if ((aucSoftUartRxBuf[gucSoftUartRxCnt-1]==0x03)&&(aucSoftUartRxBuf[gucSoftUartRxCnt-2]==0x10)&&
- (aucSoftUartRxBuf[gucSoftUartRxCnt-7]==0x0e)&&(aucSoftUartRxBuf[gucSoftUartRxCnt-8]==0x00)&&
- (aucSoftUartRxBuf[gucSoftUartRxCnt-9]==0x23)&&(aucSoftUartRxBuf[gucSoftUartRxCnt-10]==0xba))
- {
- SetCSIandDIS();
- DceResponsePc();
-
- }
- /* get new fax
- if ((aucUartRxBuf[gucUartRxCnt-1]==0x03)&&(aucUartRxBuf[gucUartRxCnt-2]==0x10)&&
- (aucUartRxBuf[gucUartRxCnt-3]==0x01)&&(aucUartRxBuf[gucUartRxCnt-4]==0x00)&&
- (aucUartRxBuf[gucUartRxCnt-5]==0x23)&&(aucUartRxBuf[gucUartRxCnt-6]==0xba))
- //;
- //if (gucRxTxFlag == DTERX)
- {
- FaxData2PCFromSoftUart();//FaxRXProcess();//FaxData2PC(); //FaxTXProcess();
- gucRxTxFlag = DTETX;
- }
- */
- }//else over Modem active not active
- }//while end Main circle over
- }//main function over
-
- /***************************************************************************
-
- ***************************************************************************/
- /***************************************************************************/