2,586
社区成员
发帖
与我相关
我的任务
分享
UCHAR LinBuf[100] ;
int i ;
int Lcnt ;
int HexBase ;
int a ;
int endf ;
UCHAR *p1 ;
int HexLen ;
int nResult = 0;
CFile file;
int flag = 0;
if(!file.Open(strPath,CFile::modeRead)){
return (-1);
}
//初始化数组
for ( Lcnt = 0 ; Lcnt < MAX_SIZE ; Lcnt ++ ) {
m_bufFlash[Lcnt] = 0xFF ;
}
HexBase = 0 ;
endf = 0 ;
while ( endf == 0 ) {
flag++;
LinBuf[0] = 0 ;
GetHexLine(LinBuf,90,&file) ;
if ( LinBuf[0] == 0 ) {
endf = 1 ;
continue ;
}
p1 = LinBuf ;
if ( LinBuf[0] == '#' ) {
a = ParaSet(LinBuf + 1) ;
if ( a < 0 ) {
nResult = -1;
endf = 1;
continue;
}
}
else {
a = CheckHexLin(p1) ;
if ( a < 0 ) {
nResult = -1;
endf = 1;
continue;
}
if ( m_bufHex[3] != 0 ) {
if ( m_bufHex[3] == 2 ) {
HexBase = m_bufHex[4] * 256 + m_bufHex[5] ;
HexBase *= 0x10 ;
}
else {
endf = 1 ;
}
continue ;
}
HexLen = m_bufHex[0] ;
if ( HexLen == 0 ) {
endf = 1 ;
continue ;
}
m_nHexAddr = HexBase + m_bufHex[1] * 256 + m_bufHex[2] ;
for ( i = 0 ; i < HexLen ; i ++ ) {
if ( m_nHexAddr > m_nMaxAddr ) {
m_nMaxAddr = m_nHexAddr ;
}
if ( m_nHexAddr >= m_nCodeLength ) {
nResult = -1;
endf = 1;
continue;
}
m_bufFlash[m_nHexAddr++] = m_bufHex[4+i] ;
}
}
}
file.Close();