Arduino uno + eV1527 解碼

主旨: Arduino uno + eV1527 解碼

說明:

  1. ESP-12F + mpy 解碼失敗, 而後,改用 arduino 解ev1527 碼, 使用arduino ide 所附範例, 實測成功。
  2. 今, 2020/01/04 將以前8051C 改寫為 arduino uno , 用sloeber ide, 實測成功, 正確率, 再現性100%
  3. 這意味著,目前arduino 的功力, 可以改寫 ecu vsm ecv esv ....., 都沒有技術上的問題。


int gPos=0;
#define BufMax 66
#define T_HI_OK 2 // kearn key
#define T_START 28 // 為快速訊訊號

uc gBuf[BufMax];
uc giLen=0;
uc gbNwprt=0;


void nw_2_str(unsigned char *c);

void gPos_66(void)
{
uc i;
//#define _NW_PRT

#ifdef _NW_PRT
xdata int len;
xdata char str[20];
xdata uc  j;
#endif
int iMin=0,iMax=0,iLen=0;
uc  t_start;

// Serial.print("gPos="); Serial.println(gPos);
t_start=T_START;
if(gPos>=66)
{
for(i=0;i< 66;i++) { if(gBuf[i]>t_start) t_start=gBuf[i]; }
t_start-=5;
for(i=0;i< 66;i++) { if(gBuf[i]>t_start) {iMin=i+1;break;} }
for(i=iMin;i< 66;i++){ if(gBuf[i]>t_start) {iMax=i-1;break;} }
iLen=iMax-iMin+1;
giLen=iLen;

if((iLen==32)||(iLen==24))
{
#ifdef _NW_PRT
len=sprintf(str,"len=%03d:",iLen);PrtStr(str,len);
// for(i=iMin;i<= iMax;i++)
for(i=0;i< 66;i++)
{
len=sprintf(str,"%02X ",(int)gBuf[i]); PrtStr(str,len);
if((i%10)==9){len=sprintf(str," "); PrtStr(str,len);
}
}
len=sprintf(str,"\r"); PrtStr(str,len);
j=0;
for(i=(iMin-1);i<=  (iMax+1);i++)
{
len=sprintf(str,"%02X ",(int)gBuf[i]); PrtStr(str,len);
if((j%10)==9){len=sprintf(str," "); PrtStr(str,len);}
j++;

}
len=sprintf(str,"\r"); PrtStr(str,len);
len=sprintf(str,"\r"); PrtStr(str,len);
// len=sprintf(str,"ValMax=%d\r",(int)j);PrtStr(str,len);
#endif
nw_2_str(gBuf+iMin);
}
for(i=0;i< BufMax;i++) gBuf[i]=0;//test 時 註記, 正式拿掉€
gPos=0;
}
}

void nw_work(void)
{
// if(gPos>=66) gPos_66();// 正常模式使用
if(gPos>=66) return;
if(digitalRead(PIN_NW))
{
if(gBuf[gPos]>T_HI_OK) gPos++;
gBuf[gPos]=0;
}
else gBuf[gPos]++;
}
void ecv_nw()
{

if(gPos>=66)
{
// Serial.print("gPos : "); Serial.println(gPos);
gPos_66();// 正常模式使用
}
nw_work(); delayMicroseconds(50);

static int gPos_old=0;
if(gPos_old!=gPos)
{
// Serial.print("gPos="); Serial.println(gPos);
gPos_old=gPos;
}

}
void nw_2_str(unsigned char *c)
{
uc i;
uc cc[4];

for(i=0;i< 4;i++)cc[i]=0;
for(i=0;i< 32;i++){if (c[i]>9) cc[i/8] |=    (0x80>>(i%8)); }
if ((giLen==24)||(giLen==32))
{
for(i=0;i< giLen/8;i++){Serial.print(cc[i],HEX); Serial.print(" ");}
Serial.print("==>"); Serial.println(giLen);
}
}
l           工作: esp-01 治具
n           畫電路

n           不要led


留言

這個網誌中的熱門文章

無效的努力

股市-華頓S&P黃豆(00693U) 操作法