今日時間があったので環境を修正しました。なにせ、作った日付を見ると2008年になっていましたので、まったく環境を思い出さないのでソースを読むことに。
設定ファイルをサーバーから読み込んでいるようで、まず、そのサーバー名を修正しました。
それでも動かないのでおかしいなと思っていたら、プログラムはサーバーからダウンロードして実行する環境にしていたのを思い出し、こっちのサーバー名を修正して完了です。どっちもIPアドレスにしておけばよかったよ。
また、忘れると悪いので、ここに書いておきます。
環境はMESを使用しています。
ディスクイメージの作成
C:\Users\mack\Documents\MES\20130622 のディレクトリ
2013/06/22 12:09
2013/06/22 12:09
2013/06/22 10:57 195 autoexec.bat
2008/08/31 09:59 263 config.sys
2008/08/31 09:59 45 module.sys
2008/08/31 09:59 15,122 sci.exe
2008/08/31 09:58 76,649 shell.exe
6 個のファイル 92,274 バイト
2 個のディレクトリ 40,749,297,664 バイトの空き領域
type autoexec.bat
ifconfig ne0 192.168.1.10 255.255.255.0
dns 192.168.1.15
gateway 192.168.1.253
tftp cmd.txt www.XXX.com
tftp date_now.txt www.XXX.com
tftp rlc.exe www.XXX.com
rlc.exe &
rlc.c
/* 2009/05/16 */
#include <h8/reg770x.h>
#include <ctype.h>
#include <string.h>
#include <stdlib.h>
#include <mes2.h>
#define IP "192.168.1.3"
#define PORT 11000
#define IPRA_TMU0_MASK 0xf000
#define IPRA_TMU1_MASK 0x0f00
#define IPRA_TMU2_MASK 0x00f0
#define IPRA_TMU0_1 0x1000
#define IPRA_TMU1_1 0x0100
#define IPRA_TMU2_1 0x0010
#define TSTR_TMU0 0x01
#define TSTR_TMU1 0x02
#define TSTR_TMU2 0x04
#define TCR_UNF 0x0100
#define VECTOR_TUNI0 0x400
#define VECTOR_TUNI1 0x420
#define VECTOR_TUNI2 0x440
#define SEC 60
#define MIN 60
#define HOUR 24
#define FALSE 0
#define TRUE 1
#define TABLE 0
#define PT 1
#define ORD 2
#define PORT0 0x01
#define PORT1 0x02
#define PORT2 0x04
#define PORT3 0x08
#define PORT4 0x10
#define PORT5 0x20
#define PORT6 0x40
#define PORT7 0x80
#define RLY0 0
#define RLY1 1
#define RLY2 2
#define RLY3 3
#define RLY4 4
#define MAXRELAY 8
#define ON 1
#define OF 2
#define OFF 2
#define AUTO 0
#define HI 1
#define LOW 0
#define SHOR 0
#define SMIN 1
#define EHOR 2
#define EMIN 3
#define SETC 4
#define DISP 0
#define DISP2 0
#define DISP3 0
int gCounter, exgCounter, gTimer, t, interval = 1000;
int excom;
unsigned int year, month, day, hour, min, sec, msec;
unsigned char TBL_Pass_Flag = FALSE;
int RELAY[MAXRELAY], ONOFF[MAXRELAY];
double recv_ip;
int RelayFlag = FALSE;
unsigned char PassMidnight = FALSE;
int st1, et1,ot1;
int c_time;
// 割り込みハンドラ
void int_timer(void) __attribute__((interrupt_handler, nosave_low_regs));
void int_timer(void) {
// SCPDR ^= 0x10;
// MTUチャネルxのステータスクリア
TCR_2 &= ~TCR_UNF;
gCounter++;
gTimer--;
gTimer--;
if(gTimer < 0) gTimer = 0;
msec = msec +1;
if(msec > 999)
{
msec = 0;
sec = sec +1;
// PEDR ^= PORT0;
if(sec > 59)
{
sec = 0;
min = min +1 ;
if(min> 59)
{
min =0;
hour = hour +1;
// system("tftp date_now.txt www.xxx.com");
if(hour > 23)
{
hour = 0;
day = day +1;
// system("tftp date_now.txt www.xxx.com");
if(day > 30)
{
day = 0;
month = month +1;
}
}
}
}
}
}
/* UDPクライアントプログラム*/
#define ERROR(x) {\
fprintf(stderr, "client - ");\
perror(x);\
exit(1);\
}
/* int udp_client(char data[]); */
int main()
{
int err, len, com, cont,tft_flag = OFF;
int y,m,d,h,mi,s;
int sec1, sec10;
int i, j, k, f;
char Cyear[] = "0000";
char Cmonth[] = "00";
char Cday[] = "00";
char Chour[] = "00";
char Cmin[] = "00";
char Csec[] = "00";
unsigned char pre_pt[32], res[MAXRELAY][5];
unsigned char StartMin[10],StartSec[10],EndMin[10],EndSec[10],command[10];
int sk, size, port;
char date[64], data[128], data2[128],buff[128];
struct sockaddr myaddr, recv;
int fp, cmd_size;
int getf;
int pbdr_status, padr_status;
char mes[64];
// ベクタ4x0番の割り込みハンドラを登録
set_handler(VECTOR_TUNI2, int_timer);
// TMUチャネルx割り込みの優先順位を1に設定
IPRA &= ~IPRA_TMU2_MASK;
IPRA |= IPRA_TMU2_1;
// システムクロック256分周でカウント/TMUチャネルxの割り込み許可
TCR_2 = 0x0023;
// 1秒周期 0.00000003125秒(32MHz) X 256分周 X 125000 = 1秒
// TCOR_2 = 125000;
// TCNT_2 = 125000;
//1秒周期 0.00000003125秒(32MHz) X 256分周 X 125 = 1ミリ秒
TCOR_2 = 125;
TCNT_2 = 125;
/*
TCOR_2 = 50; // 1msec 128MHz CLK
TCNT_2 = 50;
*/
//WDT
// WTCNT_WR = 0x5A01;
// WTCSR_WR = 0xA5F7;
// TMUチャネルxを起動
TSTR |= TSTR_TMU2;
PBCR = 0xAAAA; // PBPORT 0-7 input with pull-up
PACR = 0xAAAA; // PAPORT 0-7 input with pull-up
PECR = 0x5555; // PEPORT 0-7 output
PEDR = 0; // ALL OFF
port = 11000;
sk = udp_socket();
if(sk == -1) {
printf("open failed.\r");
return 0;
}
myaddr.sin_port = port;
myaddr.sin_addr = 0;
udp_bind(sk, &myaddr);
for(i=0;i<MAXRELAY;i++)
{
RELAY[i]== FALSE;
}
len = 0;
fp = open( "/ram0/date_now.txt", OptRead ) ; // File must be downloaded from tftp server before program starts.
sleep(1000);
if(fp == -1)
{
printf("Can not read the file.r");
}
else
{
// printf("End read the file.r");
len = read( fp, data, sizeof(data) ) ;
close(fp);
if(len > 10)
{
date_former(data, Cyear, Cmonth, Cday, Chour, Cmin, Csec);
printf("%s/%s/%s %s:%s:%s\r",Cyear,Cmonth,Cday,Chour,Cmin,Csec);
year = atoi(Cyear);
month =atoi(Cmonth);
day = atoi(Cday);
hour = atoi(Chour);
min = atoi(Cmin);
sec = atoi(Csec);
//For Test
/*
hour = 23;
min = 59;
sec = 00;
printf("Time %s/%s/%s %d:%d:%d\r",Cyear,Cmonth,Cday,hour,min,sec);
*/
}
}
fp = open( "/ram0/cmd.txt", OptRead ) ;
sleep(1000);
if(fp == -1)
{
printf("Can not read the file.\r");
}
else
{
// printf("End read the file.\r");
len = read( fp, buff, sizeof(buff) ) ;
close(fp);
if(len > 70){
k = 0;
j = 1;
for(i=0;i<len;i++)
{
if(buff[i] ==0xA) continue;
data[k] = buff[i];
if(j%2 ==0)
{
k++;
data[k] = ',';
}
k++;
j++;
}
if((len != -1) && (DISP2))
{
printf("len : %d data:%sr",len,data);
}
table_former(data, res);
}
}
/*
while(1)
{
sleep(1000);
printf("WTCNT : %fr",WTCNT);
}
*/
while(1)
{
system("tftp date_now.txt www.xxx.com");
if((( 0 == hour) && ( 0 == min)) && (tft_flag == ON))
{
printf("Get timer");
system("tftp date_now.txt www.xxx.com");
tft_flag = OFF;
}
if(1 == hour)
{
tft_flag = ON;
}
// printf("CT %d/%d/%d %d:%d:%d %dr",year,month,day,hour,min,sec,msec);
size = recvfrom(sk, data, 256, &recv);
/*
for(i=0;i<size;i++)
{
tmp[i] = data[i];
}
tmp[i+1] = '�';
*/
if(size != -1)
{
// printf("size : %d data:%sr",size,data);
// printf("sin_addr:%x sin_port:%xr",recv.sin_addr,recv.sin_port);
recv_ip = recv.sin_addr;
}
if(size > 30) // Table
{
rejectCamma(data,data2, sizeof(data));
/*
for(i =0;i<88;i++)
{
printf("%d:%cr",i,data2[i]);
}
data2[88] = '�';
printf("data: %sr",data2);
*/
fp = open( "/ram0/cmd.txt", OptWrite ) ;
if(fp == -1)
{
printf("Can not write the file.r");
}
else
{
err = write(fp, data2, 88);
close(fp);
// printf("err:%d",err);
}
table_former(data, res);
err = message("STSn");
sprintf(data,"%02d%02d%02d%02d%d%d%dn"
,res[0][0],res[0][1],res[0][2],res[0][3],res[0][4],0,(PEDR & PORT0) >> 0);
err = message(data);
sprintf(data,"%02d%02d%02d%02d%d%d%d\n"
,res[1][0],res[1][1],res[1][2],res[1][3],res[1][4],0,(PEDR & PORT1) >> 1);
err = message(data);
sprintf(data,"%02d%02d%02d%02d%d%d%d\n"
,res[2][0],res[2][1],res[2][2],res[2][3],res[2][4],0,(PEDR & PORT2) >> 2);
err = message(data);
sprintf(data,"%02d%02d%02d%02d%d%d%d\n"
,res[3][0],res[3][1],res[3][2],res[3][3],res[3][4],0,(PEDR & PORT3) >> 3);
err = message(data);
sprintf(data,"%02d%02d%02d%02d%d%d%d\n"
,res[4][0],res[4][1],res[4][2],res[4][3],res[4][4],0,(PEDR & PORT4) >> 4);
err = message(data);
sprintf(data,"%02d%02d%02d%02d%d%d%d\n"
,res[5][0],res[5][1],res[5][2],res[5][3],res[5][4],0,(PEDR & PORT5) >> 5);
err = message(data);
sprintf(data,"%02d%02d%02d%02d%d%d%d\n"
,res[6][0],res[6][1],res[6][2],res[6][3],res[6][4],0,(PEDR & PORT6) >> 6);
err = message(data);
sprintf(data,"%02d%02d%02d%02d%d%d%d\n"
,res[7][0],res[7][1],res[7][2],res[7][3],res[7][4],0,(PEDR & PORT7) >> 7);
err = message(data);
TBL_Pass_Flag = TRUE;
}
else if(size > 10) { //時刻
/* printf("date:%s\r",buff); */
date_former(data, Cyear, Cmonth, Cday, Chour, Cmin, Csec);
printf("%s/%s/%s %s:%s:%s\r",Cyear,Cmonth,Cday,Chour,Cmin,Csec);
year = atoi(Cyear);
month = atoi(Cmonth);
day = atoi(Cday);
hour = atoi(Chour);
min = atoi(Cmin);
sec = atoi(Csec);
}
else if(size > 0) // 強制コマンド
{
data[size] = '\0';
// printf("data; %s\r",data);
// printf("strcmp: %d\r",strcmp(data,"REQUEST"));
if(strcmp(data,"REQUEST"))
{
com = atoi(data);
for(i = 0; i< 256;i++)
{
// printf("%2x ",data[i]);
}
if((size != -1) && (DISP2))
{
printf(" In size : %d data:%s %02x r",size,data, com);
}
switch(com)
{
case 0 : func(0,AUTO,res); break;
case 1 : func(0,OF,res); break;
case 2 : func(0,ON,res); break;
case 10 : func(1,AUTO,res); break;
case 11 : func(1,OF,res); break;
case 12 : func(1,ON,res); break;
case 20 : func(2,AUTO,res); break;
case 21 : func(2,OF,res); break;
case 22 : func(2,ON,res); break;
case 30 : func(3,AUTO,res); break;
case 31 : func(3,OF,res); break;
case 32 : func(3,ON,res); break;
case 40 : func(4,AUTO,res); break;
case 41 : func(4,OF,res); break;
case 42 : func(4,ON,res); break;
case 50 : func(5,AUTO,res); break;
case 51 : func(5,OF,res); break;
case 52 : func(5,ON,res); break;
case 60 : func(6,AUTO,res); break;
case 61 : func(6,OF,res); break;
case 62 : func(6,ON,res); break;
case 70 : func(7,AUTO,res); break;
case 71 : func(7,OF,res); break;
case 72 : func(7,ON,res); break;
default : printf("Not match n");
}
}else // REQUEST for resonce of current Status
{
printf("REQUESTr");
// sleep(5000);
fp = open( "/ram0/cmd.txt", OptRead ) ;
sleep(1000);
if(fp == -1)
{
printf("Can not read the file.r");
}
else
{
// printf("End read the file.r");
len = read( fp, buff, sizeof(buff) ) ;
close(fp);
if(len > 70){
k = 0;
j = 1;
for(i=0;i<len;i++)
{
if(buff[i] ==0xA) continue;
data[k] = buff[i];
if(j%2 ==0)
{
k++;
data[k] = ',';
}
k++;
j++;
}
if((len != -1) && (DISP2))
{
printf("len : %d data:%sr",len,data);
}
table_former(data, res);
/*
sprintf(date,"%04d/%02d/%02d %02d:%02d:%02dn",year,month,day,hour,min,sec);
err = message(date);
err = message("STSn");
*/
sprintf(data,"STS %02d:%02d:%02d ct:%d st:%d et:%dn"
,hour,min,sec, c_time, st1,et1);
err = message(data);
sprintf(data,"%02d%02d%02d%02d%d%d%dn"
,res[0][0],res[0][1],res[0][2],res[0][3],res[0][4],0,(PEDR & PORT0) >> 0);
err = message(data);
sprintf(data,"%02d%02d%02d%02d%d%d%d\n"
,res[1][0],res[1][1],res[1][2],res[1][3],res[1][4],0,(PEDR & PORT1) >> 1);
err = message(data);
sprintf(data,"%02d%02d%02d%02d%d%d%d\n"
,res[2][0],res[2][1],res[2][2],res[2][3],res[2][4],0,(PEDR & PORT2) >> 2);
err = message(data);
sprintf(data,"%02d%02d%02d%02d%d%d%d\n"
,res[3][0],res[3][1],res[3][2],res[3][3],res[3][4],0,(PEDR & PORT3) >> 3);
err = message(data);
sprintf(data,"%02d%02d%02d%02d%d%d%d\n"
,res[4][0],res[4][1],res[4][2],res[4][3],res[4][4],0,(PEDR & PORT4) >> 4);
err = message(data);
sprintf(data,"%02d%02d%02d%02d%d%d%d\n"
,res[5][0],res[5][1],res[5][2],res[5][3],res[5][4],0,(PEDR & PORT5) >> 5);
err = message(data);
sprintf(data,"%02d%02d%02d%02d%d%d%d\n"
,res[6][0],res[6][1],res[6][2],res[6][3],res[6][4],0,(PEDR & PORT6) >> 6);
err = message(data);
sprintf(data,"%02d%02d%02d%02d%d%d%d\n"
,res[7][0],res[7][1],res[7][2],res[7][3],res[7][4],0,(PEDR & PORT7) >> 7);
err = message(data);
}
}
}
}
chk_control(res);
// printf("Setime:%d\r",interval);
// printf("%04d/%02d/%02d %02d:%02d:%02d\r",year,month,day,hour,min,sec);
}
udp_free(sk);
}
int set_timer(int t)
{
gTimer = t;
}
int chk_timer()
{
/* printf("%d\r",gTimer); */
return gTimer;
}
int message(char mesdata[])
{
int sk, n, ret, err, port;
unsigned int ip;
struct sockaddr target;
int sockfd, len, result;
ip = strtoip(IP, &err);
port = PORT;
/*UDP クライアント用ソケット作成*/
sk = udp_socket();
if(sk == -1)
{
__write(0, "open failed.\n", 13);
return -1;
}
if(err == -1)
{
printf("Illegal format\r");
return -1;
}
target.sin_port = port;
// target.sin_addr = ip;
target.sin_addr = recv_ip;
sendto(sk, mesdata, strlen(mesdata), &target);
udp_free(sk);
return 0;
}
int func(int port, int cont, char res[][5])
{
if(cont == ON)
{
printf("set port%d to ON\r",port);
res[port][SETC] = ON;
}else if(cont == OF)
{
res[port][SETC] = OF;
printf("set port%d to OFF\r",port);
}else // AUTO
{
res[port][SETC] = AUTO;
printf("set port%d to AUTO\r",port);
}
}
table_former(char buf[], char res[][5])
{
int len, i, j, k, sm, ss, em, es, cm;
unsigned char buff[MAXRELAY * 5* 2 * 2];
/*
printf("%s\r",buf);
for(i = 0; i<5*15; i++) printf("%d:%02xr",i,buf[i]);
*/
for(i=0;i< MAXRELAY;i++)
{
k =0;
for(j=0;j<15;j+=3)
{
buff[0] = buf[i*15 + j];
buff[1] = buf[i*15 + j+1];
buff[2] = buf[i*15 + j+2];
res[i][k] = (char)atoi(buff);
if(DISP3) printf("%d %d %02dr",i,k,res[i][k]);
k++;
}
}
}
chk_control(char res[][5])
{
int i,err;
char mes[64];
// int start_time, c_time, end_time, org_end_time;
int start_time, end_time, org_end_time;
for(i=0;i < MAXRELAY;i++)
{
if(DISP) printf("[%d] H:%d M:%d SH:%d SM:%d EH:%d EM:%d SETC:%dr"
,i,hour,min,res[i][SHOR],res[i][SMIN],res[i][EHOR],res[i][EMIN],res[i][SETC]);
// printf("Ar");
c_time = hour * 60 + min;
/*
if(i == 0)
{
printf("%04d/%02d/%02d %02d:%02d:%02dr",year,month,day,hour,min,sec);
}
*/
//リレーの制御
// printf("i;%d -> res[i][SHOR]:%d res[i][SMIN]:%d res[i][EHOR]:%d res[i][EMIN]:%d \r",i,res[i][SHOR],res[i][SMIN],res[i][EHOR],res[i][EMIN]);
start_time = (int)res[i][SHOR] * 60;
start_time = start_time + (int)res[i][SMIN];
end_time = (int)res[i][EHOR] * 60;
end_time =end_time + (int)res[i][EMIN];
/*
if(c_time == 0)
{
PassMidnight = TRUE;
}
*/
if((start_time >= end_time) && (start_time >=c_time))
{
PassMidnight = TRUE;
}
else
{
PassMidnight = FALSE;
}
if((start_time >= end_time) && (PassMidnight == TRUE))
{
start_time = 0;
}
if((start_time >= end_time) && (PassMidnight == FALSE))
{
end_time = end_time + 24 * 60;
}
if(i == 0)
{
// printf("c_time:%d start_time:%d end_time:%d\r",c_time,start_time,end_time);
st1 = start_time;
et1 = end_time;
ot1 = org_end_time;
}
/*
printf("i;%d -> start_time %d: end_time %d: c_time %d: s-c %d: RELAY[i] %d\r",
i,start_time,end_time,c_time,start_time-c_time,RELAY[i]);
*/
// Check Time
// if(1) printf("i : %d c_time : %d start_time : %d end_time : %d \r",i, c_time, start_time, end_time);
if((start_time <= c_time) && (end_time > c_time))
{
RELAY[i] = TRUE;
// if(i==0) printf("ON\r");
}else
{
RELAY[i] = FALSE;
// if(i==0) printf("OFF\r");
}
if(end_time == c_time)
{
RELAY[i] = FALSE;
// if(i==0) printf("OFF\r");
PassMidnight = FALSE;
}
if(res[i][SETC] == ON)
{
ONOFF[i] = ON;
}else if(res[i][SETC] == OF)
{
ONOFF[i] = OF;
}else
{
ONOFF[i] = AUTO;
}
}
// RELY 0 CHECK
if(ONOFF[0] == ON)
{
PEDR |= PORT0; // ON
// printf("00.ON\r");
}else if(ONOFF[0] == OF)
{
PEDR &= ~PORT0; //OFF
// printf("00.OFF\r");
}else if(RELAY[0] == TRUE) // AUTO
{
PEDR |= PORT0; // ON
// printf("01.ON\r");
}else
{
PEDR &= ~PORT0; //OFF
// printf("01.OFF\r");
}
// RELY 1 CHECK
if(ONOFF[1] == ON)
{
PEDR |= PORT1; // ON
// printf("10.ON\r");
}else if(ONOFF[1] == OF)
{
PEDR &= ~PORT1; //OFF
// printf("10.OFF\r");
}else // AUTO
{
if(RELAY[1] == TRUE)
{
PEDR |= PORT1; // ON
// printf("11.ON\r");
}else
{
PEDR &= ~PORT1; //OFF
// printf("11.OFF\r");
}
}
// RELY 2 CHECK
if(ONOFF[2] == ON)
{
PEDR |= PORT2; // ON
// printf("20.ON\r");
}else if(ONOFF[2] == OF)
{
PEDR &= ~PORT2; //OFF
// printf("20.OFF\r");
}else // AUTO
{
if(RELAY[2] == TRUE)
{
PEDR |= PORT2; // ON
// printf("21.ON\r");
}else
{
PEDR &= ~PORT2; //OFF
// printf("21.OFF\r");
}
}
// RELY 3 CHECK
if(ONOFF[3] == ON)
{
PEDR |= PORT3; // ON
// printf("30.ON\r");
}else if(ONOFF[3] == OF)
{
PEDR &= ~PORT3; //OFF
// printf("30.OFF\r");
}else // AUTO
{
if(RELAY[3] == TRUE)
{
PEDR |= PORT3; // ON
// printf("31.ON\r");
}else
{
PEDR &= ~PORT3; //OFF
if(DISP) printf("31.OFF\r");
}
}
// RELY 4 CHECK
if(ONOFF[4] == ON)
{
PEDR |= PORT4; // ON
// printf("40.ON\r");
}else if(ONOFF[4] == OF)
{
PEDR &= ~PORT4; //OFF
// printf("40.OFF\r");
}else // AUTO
{
if(RELAY[4] == TRUE)
{
PEDR |= PORT4; // ON
// printf("41.ON\r");
}else
{
PEDR &= ~PORT4; //OFF
// printf("41.OFF\r");
}
}
// RELY 5 CHECK
if(ONOFF[5] == ON)
{
PEDR |= PORT5; // ON
// printf("50.ON\r");
}else if(ONOFF[5] == OF)
{
PEDR &= ~PORT5; //OFF
// printf("50.OFF\r");
}else // AUTO
{
if(RELAY[5] == TRUE)
{
PEDR |= PORT5; // ON
// printf("51.ON\r");
}else
{
PEDR &= ~PORT5; //OFF
// printf("51.OFF\r");
}
}
// RELY 6 CHECK
if(ONOFF[6] == ON)
{
PEDR |= PORT6; // ON
// printf("60.ON\r");
}else if(ONOFF[6] == OF)
{
PEDR &= ~PORT6; //OFF
// printf("60.OFF\r");
}else // AUTO
{
if(RELAY[6] == TRUE)
{
PEDR |= PORT6; // ON
// printf("61.ON\r");
}else
{
PEDR &= ~PORT6; //OFF
// printf("61.OFF\r");
}
}
// RELY 7 CHECK
if(ONOFF[7] == ON)
{
PEDR |= PORT7; // ON
// printf("70.ON\r");
}else if(ONOFF[7] == OF)
{
PEDR &= ~PORT7; //OFF
// printf("70.OFF\r");
}else // AUTO
{
if(RELAY[7] == TRUE)
{
PEDR |= PORT7; // ON
// printf("71.ON\r");
}else
{
PEDR &= ~PORT7; //OFF
// printf("71.OFF\r");
}
}
}
date_former(char buff[], char Cyear[], char Cmonth[], char Cday[], char Chour[], char Cmin[], char Csec[])
{
int size,i,j=0,f=0;
/*
printf("%d\n",strlen(buff));
printf("%s\n",buff);
*/
for(i=0;i< 4;i++)
{
Cyear[j] = buff[i];
j++;
}
j = 0;
for(i=5;i< 7;i++)
{
Cmonth[j] = buff[i];
j++;
}
j = 0;
for(i=8;i< 10;i++)
{
Cday[j] = buff[i];
j++;
}
j = 0;
for(i=11;i< 13;i++)
{
Chour[j] = buff[i];
j++;
}
j = 0;
for(i=14;i< 16;i++)
{
Cmin[j] = buff[i];
j++;
}
j = 0;
for(i=17;i< 19;i++)
{
Csec[j] = buff[i];
j++;
}
/*
printf("%s/%s/%s %s:%s:%sn",Cyear,Cmonth,Cday,Chour,Cmin,Csec);
printf("Cyear:%dn",strlen(Cyear));
for(j=0;j<strlen(Cyear);j++)
{
printf("%c",Cyear[j]);
}
*/
}
int rejectCamma(char data[], char data2[], int size)
{
int i,j = 0;
for(i = 0; i< size; i++)
{
// printf("%x ",data[i]);
if((data[i] >= 0x30) && (data[i] <= 0x39))
{
data2[j] = data[i];
// printf("%d: %x\r",j,data2[j]);
j++;
}
}
return j-1;
}