From 5904a3045a8c4f591c32a131779eeb3648f9c317 Mon Sep 17 00:00:00 2001 From: Alex Warm Date: Tue, 12 Feb 2019 17:25:44 +0300 Subject: [PATCH] =?UTF-8?q?=D0=A2=D0=B5=D1=81=D1=82=D0=BE=D0=B2=D0=B0?= =?UTF-8?q?=D1=8F=20=D1=81=D0=B1=D0=BE=D1=80=D0=BA=D0=B0=20=D1=81=20=D1=81?= =?UTF-8?q?=D0=BE=D1=85=D1=80=D0=B0=D0=BD=D0=B5=D0=BD=D0=B8=D0=B5=D0=BC=20?= =?UTF-8?q?=D0=BF=D0=B0=D1=80=D0=B0=D0=BC=D0=B5=D1=82=D1=80=D0=BE=D0=B2=20?= =?UTF-8?q?1902121725?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- KSM-Line-2.2.tpr | 2 +- braker.tc | 4 +- command.tc | 314 +++++++++++++++++++++++++++++++---------------- command.th | 15 +-- common.tc | 88 ++++++------- common.th | 10 ++ config_work.tc | 194 ++++++++++++++++++++--------- config_work.th | 3 +- encoder.tc | 15 +-- global.th | 5 +- main.tc | 42 ++++++- net.tc | 3 +- relay.tc | 3 +- 13 files changed, 467 insertions(+), 231 deletions(-) diff --git a/KSM-Line-2.2.tpr b/KSM-Line-2.2.tpr index 4df3015..4d04cf7 100644 --- a/KSM-Line-2.2.tpr +++ b/KSM-Line-2.2.tpr @@ -10,7 +10,7 @@ transport=udp_broadcast [address1] platform=SIMULATOR transport=udp_broadcast -address=0.36.119.82.182.139 +address=0.48.72.100.118.81 [address2] platform=TPP3W(G2) transport=udp_broadcast diff --git a/braker.tc b/braker.tc index 655d703..348af86 100644 --- a/braker.tc +++ b/braker.tc @@ -8,10 +8,11 @@ extern Configuration config; BrakerProcess brakers[BRAKER_COUNT]; void brakers_init(){ - + config.STORE_BRAKER = false; for (int num = 0;num 0; - return "Debug sensors SET="+(config.debug.SensorsLook? "TRUE":"FALSE"); +string cmd_system(){ + string result; + bool save = true; + int i = indexOfArray(sys_commands,cmd); + if (i >= 0){ + switch (i){ + case 0: // systeminfo + result = cmd_systeminfo(); + save = false; + break; + case 1: // ip + result = cmd_ip(params); + break; + case 2: // reset + case 3: // reboot + cmd_replay("{cmd} Rebooting..."); + cmd_reset(); + save = false; + break; + case 4: // setbraker + result = cmd_setbraker(); + break; + case 5: // setencoder + result = cmd_setencoder(); + break; + case 6: // setconfig + string r; + string s; + unsigned char x; + string p = toLower1(pars[0]); + if (p=="off"||p=="none"){ + s=chr(255); + stor.setdata(s,5); + config.STORE_LOCATON = NONE; + save=false; + fd.mount(); + fd.delete("config"); + }else if(p=="flash"){ + s=chr(3); + stor.setdata(s,5); + config.STORE_LOCATON = FLASH; + config.FLASH_SIZE = 1024; + config.FLASH_FILES = 10; + + }else if(p=="eprom"){ + s=chr(6); + stor.setdata(s,5); + config.STORE_LOCATON = EEPROM; + + } + + break; + case 7: // getconfig + save = false; + char strconfig[1000]; + char *ptr = get_config(strconfig); + char *out = strconfig; + int length = ptr - out; + d(str(length)); + while (out < ptr){ + string s; + char *ss = s; + if (out+100 0; - return "Debug relay reply SET="+(config.debug.RelayReply? "TRUE":"FALSE"); -} -string cmd_debug_relay_show(string params){ - getParams(params); - config.debug.RelayShow = val(pars[0])>0; - return "Debug relay show SET="+(config.debug.RelayShow? "TRUE":"FALSE"); -} -string cmd_debug_enc_level(string params){ - getParams(params); - config.debug.EncoderDebug= val(pars[0]); - return "Debug encoder level SET="+str(config.debug.EncoderDebug); -} -string cmd_debug_enc_state(string params){ - getParams(params); - config.debug.EncoderStateMode= val(pars[0]); - return "Debug encoder work with state SET="+str(config.debug.EncoderStateMode); -} -string cmd_debug_showtime(string params){ - getParams(params); - config.debug.ShowTime = val(pars[0])>0; - return "Debug show time SET="+(config.debug.ShowTime? "TRUE":"FALSE"); +string cmd_debug(){ + string result; + int i = indexOfArray(debug_commands,cmd); + if (i >= 0){ + switch (i){ + case 0: // debug_enc_level + config.debug.EncoderDebug= val(pars[0]); + result = "Debug encoder level SET="+str(config.debug.EncoderDebug); + break; + case 1: // debug_enc_state + config.debug.EncoderStateMode= val(pars[0]); + result = "Debug encoder work with state SET="+str(config.debug.EncoderStateMode); + break; + case 2: // debug_relay_reply + config.debug.RelayReply = val(pars[0])>0; + result = "Debug relay reply SET="+(config.debug.RelayReply? "TRUE":"FALSE"); + break; + case 3: // debug_relay_show + config.debug.RelayShow = val(pars[0])>0; + result = "Debug relay show SET="+(config.debug.RelayShow? "TRUE":"FALSE"); + break; + case 4: // debug_sensors + config.debug.SensorsLook = val(pars[0])>0; + result = "Debug sensors SET="+(config.debug.SensorsLook? "TRUE":"FALSE"); + break; + case 5: // debug_showtime + config.debug.ShowTime = val(pars[0])>0; + result = "Debug show time SET="+(config.debug.ShowTime? "TRUE":"FALSE"); + break; + default: + result = "{cmd}: Unknown command: "+cmd; + } + }else + result = "{cmd}: Unknown command: "+cmd; + + return result; } -string cmd_enc_set_windows(string params){ - getParams(params); - config.EncoderCfg.windowWidth = val(pars[0]); - return "Encoder window SET="+str(config.EncoderCfg.windowWidth); +string cmd_encoder(){ + string result; + bool save = true; + int i = indexOfArray(enc_commands,cmd); + if (i >= 0){ + switch (i){ + case 0: // enc_set_window + config.EncoderCfg.windowWidth = val(pars[0]); + result = "Encoder window SET="+str(config.EncoderCfg.windowWidth); + save = true; + break; + case 1: // "enc_calibrate_start", // 1 + case 2: // "enc_calibrate_end", // 2 + result = cmd_enc_calibre(); + break; + default: + result = "{cmd}: Unknown command: "+cmd; + break; + } + }else + result = "{cmd}: Unknown command: "+cmd; + if (save) config_save(); + return result; } + void cmd_replay(string message){ d(message); sock.setsendinband(chr(sock.escchar)+" "+message+chr(sock.endchar)+chr(13)+chr(10)); } -string cmd_setencoder(string params){ +string cmd_setencoder(){ string message; - // setencoder=encoderpin,mode,interval,sensorspinoverdot - // setencoder=4,1,50,1.2 - d("params: "+params); - unsigned char n, p, num ; - unsigned long t; - string vals = ""; - n = 1; - p = instr(1,params,",",1); - while (p>0){ - vals+=chr(val(mid(params,n,n-p))); - n = p+1; - p = instr(n,params,",",1); - } - string port = mid(params,n,len(params)-n+1); - d("port: "+port); - string ports; - n = 1; - p = instr(1,port,".",1); - while (p>0){ - ports+=chr(val(mid(port,n,n-p))); - n = p+1; - p = instr(n,port,".",1); - } - ports += chr(val(mid(port,n,len(port)-n+1))); - config.EncoderCfg.encoderPort = vals[0]; - config.EncoderCfg.encoderMode = vals[1]; - config.EncoderCfg.encoderInterval = vals[2]; - config.EncoderCfg.workedPorts = ports; - message = "Энкодер настроен: Порт: "+str(vals[0])+ ", Режим: "+str(vals[1])+ ", Интервал: "+str(vals[2])+ ", Рабочие порты: "+port; + config.EncoderCfg.encoderPort = pars[0]; + config.EncoderCfg.encoderMode = pars[1]; + config.EncoderCfg.encoderInterval = pars[2]; + config.EncoderCfg.workedPorts = pars[par_num]; + config_save(); encoder_init(); - return message; + return "Энкодер настроен: Порт: "+str(pars[0])+ ", Режим: "+str(pars[1])+ ", Интервал: "+str(pars[2])+ ", Рабочие порты: "+pars[par_num]; } -string cmd_enc_calibre(string params){ - int mode = val(left(params,1)); +string cmd_enc_calibre(){ + int mode = val(pars[0]); enc_calibrate_mode(mode); if (mode >0){ return "Запушена калибровка энкодера в режиме "+str(mode); @@ -157,7 +257,7 @@ string cmd_enc_calibre(string params){ return "Остановлен режим калибровки энкодера. Среднее значение: " + str(enc_calibrate_result()); } string cmd_systeminfo(){ - return "{ platform='"+ PLATFORM+"', version='" + VERSION + "', uptime=" + str(sys.timercountms)+" }"; + return "platform='"+ PLATFORM+"', version='" + VERSION + "', uptime=" + str(sys.timercountms)+""; } void cmd_reset() @@ -198,7 +298,7 @@ string cmd_ip(string params) } return result; } -string cmd_setbraker(string params) +string cmd_setbraker() { unsigned char n, p, num ; unsigned long t; @@ -210,9 +310,12 @@ string cmd_setbraker(string params) n = p+1; p = instr(n,params,",",1); } - num = vals[0]; -// BrakerConfig c = config.BRAKERS[num-1]; -// c.Enable = val(vals[1]) > 0; + num = pars[0]; + if (toLower1(pars[1])=="off"){ + config.BRAKERS[num-1].Enable = false; + brakers_init(); + return "OK: Braker "+str(num)+" now OFF"; + } // string rrrr = right(params,len(params)-n+1); // if (c.Enable){ // c.Relay= vals[1]; @@ -221,11 +324,11 @@ string cmd_setbraker(string params) // c.Timeout= (strtof(right(params,len(params)-n+1))*1000); // } // //braker_init(unsigned char number, unsigned char sensor, unsigned char drop, unsigned char relay, unsigned long timeout); - unsigned long timeout = (strtof(right(params,len(params)-n+1))*1000); - braker_init(num,vals[2],vals[3],vals[1],timeout); + float timeout = (strtof(pars[par_num])*1000); + braker_init(num,val(pars[2]),val(vals[3]),val(vals[1]),timeout); string message; - if (vals[1]>0){ - message = "OK: Num="+str(num)+", Rel="+str(vals[1])+", Sens="+str(vals[2])+", Drop="+str(vals[3])+", Timeout="+ ftostr(timeout,FTOSTR_MODE_PLAIN,4)+" sec."; + if (val(pars[1])>0){ + message = "OK: Num="+str(num)+", Rel="+pars[1]+", Sens="+pars[2]+", Drop="+pars[3]+", Timeout="+ ftostr(timeout/1000,FTOSTR_MODE_PLAIN,4)+" sec."; }else{ message = "OK: Num="+str(num)+" DISABLED"; } @@ -236,6 +339,9 @@ string cmd_setbraker(string params) void getParams(string params){ //d("params: "+params); + for (int i=0;i<10;i++){ + pars[i]=""; + } unsigned char n, p, num ; unsigned long t; string vals = ""; @@ -243,7 +349,7 @@ void getParams(string params){ n = 1; p = instr(1,params,",",1); while (p>0){ - pars[par_num] = mid(params,n,n-p); + pars[par_num] = mid(params,n,p-n); n = p+1; par_num++; p = instr(n,params,",",1); diff --git a/command.th b/command.th index 3743d19..ea5189a 100644 --- a/command.th +++ b/command.th @@ -1,16 +1,13 @@ void on_sock_inband(); void cmd_replay(string message); +string cmd_debug(); +string cmd_system(); +string cmd_encoder(); string cmd_systeminfo(); void cmd_reset(); string cmd_ip(string params); -string cmd_setbraker(string params); -string cmd_setencoder(string params); -string cmd_enc_calibre(string params); +string cmd_setbraker(); +string cmd_setencoder(); +string cmd_enc_calibre(); string cmd_enc_set_windows(string params); -string cmd_debug_enc_level(string params); -string cmd_debug_enc_state(string params); -string cmd_debug_sensors(string params); -string cmd_debug_showtime(string params); void getParams(string params); -string cmd_debug_relay_reply(string params); -string cmd_debug_relay_show(string params); diff --git a/common.tc b/common.tc index f6f9481..4631b4b 100644 --- a/common.tc +++ b/common.tc @@ -1,46 +1,52 @@ -//// You must free the result if result is non-NULL. -//char *str_replace(char *orig, char *rep, char *with) { -// char *result; // the return string -// char *ins; // the next insert point -// char *tmp; // varies -// int len_rep; // length of rep (the string to remove) -// int len_with; // length of with (the string to replace rep with) -// int len_front; // distance between rep and end of last rep -// int count; // number of replacements +#include "global.th"; -// // sanity checks and initialization -// if (!orig || !rep) -// return null; -// len_rep = len(rep); -// if (len_rep == 0) -// return null; // empty rep causes infinite loop during count -// if (!with) -// with = ""; -// len_with = len(with); +int arrayLength(string *a){ + int i=0; + for (i=0;i<255;i++){ + if (len(a[i])==0) + break; + } + return i-1; +} -// // count the number of replacements needed -// ins = orig; -// for (count = 0; tmp = instr(ins, rep); ++count) { -// ins = tmp + len_rep; -// } +int indexOfArray(string *a,string search){ + int r = -1; + int i=0; + for (i=0;i<255;i++){ + if (len(a[i])==0){ + r=-1; + break; + } + else{ + if (a[i] == search){ + r = i; + break; + } + } + } + return r; +} -// tmp = result = malloc(len(orig) + (len_with - len_rep) * count + 1); +void *memcpy(void *dst,void *src,char n){ + int i; + for( i = 0; i < n; i++ ) + ((unsigned char*)dst)[i] = ((unsigned char*)src)[i]; + return dst; +} -// if (!result) -// return null; +char tolower(char c){ + char o = c; + if(c>=65 && c<=90){ + c=c+32 ; + o =(char) c; + } + return (char) o; +} +string toLower1(string st){ + for (int i=0;i0){ + d(s); + s=fd.getdata(200); } + //d("config file size:" +str(fd.filesize)); + fd.close(); + config.IP= get_parameter_from_file("ip","config"); + //config.STORE_LOCATON = get_parameter_from_file("STORE_LOCATON","config"); + //config.FLASH_SIZE = get_parameter_from_file("FLASH_SIZE","config"); + //config.FLASH_FILES = get_parameter_from_file("FLASH_FILES","config"); + config.STORE_BRAKER = get_parameter_from_file("sb","config"); + config.STORE_ENCODER = get_parameter_from_file("se","config"); + if (config.STORE_ENCODER){ + config.EncoderCfg.encoderPort = get_parameter_from_file("en.p","config"); + config.EncoderCfg.encoderMode = get_parameter_from_file("en.m","config"); + config.EncoderCfg.encoderInterval= get_parameter_from_file("en.int","config"); + config.EncoderCfg.workedPorts = get_parameter_from_file("en.wp","config"); + config.EncoderCfg.windowWidth = get_parameter_from_file("en.wn","config"); + config.EncoderCfg.reinitInterval = get_parameter_from_file("en.ri","config"); + } + //if (config.STORE_BRAKER){ + for (int i = 0; i0){ + c.Enable = get_parameter_from_file("br["+str(i)+"].e","config"); + c.SensPort= get_parameter_from_file("br["+str(i)+"].s","config"); + c.DropPort=get_parameter_from_file("br["+str(i)+"].d","config"); + c.Relay=get_parameter_from_file("br["+str(i)+"].r","config"); + c.Timeout=get_parameter_from_file("br["+str(i)+"].t","config"); + } + } + //} + char arr[1024]; + get_config(arr); + } } -void config_write(Configuration conf){ - if (conf.STORE_LOCATON == FLASH){ - fd.filenum = 1; - fd.open("config"); - d("before write:file size:" +str(fd.filesize)); - fd.setpointer(1); +char *get_config( char *array){ string sb=""; - string r = chr(13); - sb += "IP="+conf.IP+r; - string t[] = {"NONE","EEPROM","FLASH"}; - sb += "STORE_LOCATON="+ t[conf.STORE_LOCATON]+r; - sb += "FLASH_SIZE=" + str(conf.FLASH_SIZE)+r; - sb += "FLASH_FILES=" + str(conf.FLASH_FILES)+r; - sb += "STORE_BRAKER=" + str(conf.STORE_BRAKER)+r; - fd.filenum = 1; - fd.setdata(sb); - d("|>>>"+sb); + string r = chr(13)+chr(10); + sb += "ip="+config.IP+r; + string t[] = {"none","eeprom","flash"}; + sb += "store="+ t[config.STORE_LOCATON]+r; + if (config.STORE_LOCATON == FLASH){ + sb += "fs=" + str(config.FLASH_SIZE)+r; + sb += "ff=" + str(config.FLASH_FILES)+r; + } + //d("|>>>"+sb); + memcpy(array,sb,len(sb)); + array+=len(sb); + sb=""; + if (config.EncoderCfg.encoderPort>0){ + config.STORE_ENCODER = true; + sb += "en.p="+str(config.EncoderCfg.encoderPort)+r; + sb += "en.m="+str(config.EncoderCfg.encoderMode)+r; + sb += "en.int="+str(config.EncoderCfg.encoderInterval)+r; + sb += "en.wp="+config.EncoderCfg.workedPorts+r; + sb += "en.wn="+str(config.EncoderCfg.windowWidth)+r; + sb += "en.ri="+str(config.EncoderCfg.reinitInterval)+r; + + } + sb += "se=" + str(config.STORE_ENCODER)+r; + d(sb); + memcpy(array,sb,len(sb)); + array+=len(sb); + sb=""; for (int i = 0; i0){ - BrakerConfig c = conf.BRAKERS[i]; - b+="BRAKER["+str(i)+"].ENABLE=" +str(c.Enable)+r; - b+="BRAKER["+str(i)+"].SENSPORT=" +str(c.SensPort)+r; - b+="BRAKER["+str(i)+"].DROPPORT=" +str(c.DropPort)+r; - b+="BRAKER["+str(i)+"].RELAY=" +str(c.Relay)+r; - b+="BRAKER["+str(i)+"].TIMEOUT=" +str(c.Timeout)+r; - fd.filenum = 1; - fd.setdata(b); - d("|>>>"+b); + if (config.BRAKERS[i].Enable){ + config.STORE_BRAKER = true; + BrakerConfig c = config.BRAKERS[i]; + b+="br["+str(i)+"].e=" +str(c.Enable)+r; + b+="br["+str(i)+"].s=" +str(c.SensPort)+r; + b+="br["+str(i)+"].d=" +str(c.DropPort)+r; + b+="br["+str(i)+"].r=" +str(c.Relay)+r; + b+="br["+str(i)+"].t=" +str(c.Timeout)+r; + //d("|>>>"+b); } + sb+=b; } - for (int i=0;i0){ - b+="BOUNCE["+str(i)+"].ENABLE="+ str(conf.BOUNCE[i].Enable); - b+="BOUNCE["+str(i)+"].PORT="+ str(conf.BOUNCE[i].Port); - b+="BOUNCE["+str(i)+"].TIMEOUT="+ str(conf.BOUNCE[i].Timeout); - fd.filenum = 1; - fd.setdata(b); - d("|>>>"+b); + sb += "sb=" + str(config.STORE_BRAKER)+r; + d(sb); + memcpy(array,sb,len(sb)); + array+=len(sb); + return array; - } +} + + +void config_write(){ + if (config.STORE_LOCATON == NONE){ + fd.filenum = 1; + fd.delete("config"); + } + if (config.STORE_LOCATON == FLASH){ + fd.mount(); + fd.filenum = 1; + //d("flash size = "+ stri(fd.capacity)); + if (fd.open("config") == PL_FD_STATUS_NOT_FOUND) + fd.create("config"); + if (fd.open("config") == PL_FD_STATUS_OK){ + //d("before write:file size:" +str(fd.filesize)); + fd.setpointer(0); + char prep[1000]; + char *ptr = get_config(prep); + char *out = prep; + int length = ptr - out; + while (out < ptr){ + string s; + char *ss = s; + if (out+100 encoderInterval; long diff = interval * config.EncoderCfg.windowWidth / 200; @@ -86,24 +87,26 @@ bool getEncEnabled(unsigned char port,bool value){ }else{ if (config.debug.EncoderDebug>2) d(str(port)+" не попал о окно "+str(works[portVector[port]].Count)); } + t("enc_end"); return works[portVector[port]].State; } else{ if (works[portVector[port]].Enabled && works[portVector[port]].State == true && value){ if (config.debug.EncoderDebug>1) d(str(port)+" Повторное срабатывание "+str(works[portVector[port]].Count)); } + t("enc_end"); return false; } } void on_io_int(unsigned char linestate){ + t("enc_int_start"); string workers = vector[linestate-1]; if(calibrate_mode>0){ for (int i=0;i=0) { calibrate_buff[i][z[i]]=calibrate_count[i]; @@ -114,12 +117,10 @@ void on_io_int(unsigned char linestate){ calibrate_count[i]=0; if (z[i]>9) z[i]=0; - } else calibrate_count[i]++; } - return; } else{ for (int i = 0; i < ENCWORKER;i++){ @@ -138,6 +139,7 @@ void on_io_int(unsigned char linestate){ } } } + t("enc_int_end"); } /// Блок калибровки @@ -152,7 +154,6 @@ void enc_calibrate_mode(int mode){ case 2: // Калибровка интервала датчиков calibrate_mode = 2; break; - default: calibrate_mode = 0; d("Установка режима калибровки энкодера - неверный режим: "+ str(mode)); diff --git a/global.th b/global.th index 75d20c9..97caf5a 100644 --- a/global.th +++ b/global.th @@ -9,7 +9,7 @@ #message "link global not defined" #endif -#define VERSION "2.0b_1902011712" +#define VERSION "2.0b_1902121725" #define MAX_FIFO_SIZE 20 #define BRAKER_COUNT 3 @@ -26,6 +26,7 @@ #endif void d(string mess); +void t(string mess); @@ -91,6 +92,7 @@ typedef struct Configuration{ unsigned int FLASH_SIZE; unsigned char FLASH_FILES; bool STORE_BRAKER; + bool STORE_ENCODER; BrakerConfig BRAKERS[BRAKER_COUNT]; BounceConfig BOUNCE[SENSORS]; EncoderConfig EncoderCfg; @@ -122,3 +124,4 @@ extern BrakerProcess brakers[BRAKER_COUNT]; + diff --git a/main.tc b/main.tc index b6cb0b6..dadd43c 100644 --- a/main.tc +++ b/main.tc @@ -3,7 +3,18 @@ #include "relay.th" #include "net.th" #include "encoder.th" +#include "common.th" +static string debug_commands[]= { + "debug_enc_level", + "debug_enc_state", + "debug_relay_reply", + "debug_relay_show", + "debug_sensors", + "debug_showtime", + "" // Разделитель. не удалять + }; + //==================================================================== void d(string mess){ if (config.debug.ShowTime) @@ -19,6 +30,18 @@ void d(string mess){ } + +void t(string mess){ + mess = lstr(sys.timercountms)+":\t"+mess; + int c = sock.num; + sock.num = 4; + if (sock.statesimple == PL_SSTS_EST){ + sock.setdata(mess+chr(13)+chr(10)); + sock.send(); + } + sock.num =c; +} + #include "config_work.th" #include "braker.th" @@ -27,12 +50,24 @@ void on_sys_init(){ pat.play("RG~",PL_PAT_CANINT); +d(arrayLength(debug_commands)); + +// for (int i=0;i<255;i++){ +// if (len(debug_commands[i])>0){ +// d(str(i)+" - "+debug_commands[i]); +// }else{ +// break; +// } + + +// } + config_init(); net_init(); sensor_init(); relay_init(); brakers_init(); -// encoder_init(); + encoder_init(); // fd.filenum = 2; @@ -80,13 +115,14 @@ pat.play("RG~",PL_PAT_CANINT); // } sys.onsystimerperiod = 1 ; net_start(); - +#if PLATFORM_ID != SIMULATOR io.num=PL_IO_NUM_46; io.enabled=YES; io.num=PL_IO_NUM_47; io.enabled=YES; io.num=PL_IO_NUM_48; io.enabled=YES; +#endif pat.play("---G-R-R~",PL_PAT_CANINT); } @@ -94,6 +130,7 @@ pat.play("RG~",PL_PAT_CANINT); void on_sys_timer() { +t("sys_start"); if (!inEncCalibrate()){ for (int i=1; i<=3; i++){ braker_proc(i); @@ -141,4 +178,5 @@ if (!inEncCalibrate()){ io.state=LOW; io.state=HIGH; #endif + t("sys_end"); } \ No newline at end of file diff --git a/net.tc b/net.tc index ec3eeba..a669e4f 100644 --- a/net.tc +++ b/net.tc @@ -4,7 +4,7 @@ #include "braker.th" int num_sdf = 0; -#define IP_STR "IP=" +#define IP_STR "ip=" string buff[4]; @@ -45,6 +45,7 @@ void net_start(){ net_openSocket(1,999,false);//, &net_relay_handle); // relay net_openSocket(2,998,true);//, &net_diag_handle); // diag net_openSocket(3,997,true);//, &net_config_handle); // config + net_openSocket(4,996,false);//, &net_config_handle); // config } string validate_id(string ip){ diff --git a/relay.tc b/relay.tc index e27b197..647c352 100644 --- a/relay.tc +++ b/relay.tc @@ -7,8 +7,7 @@ void relay_init(){ io.enabled = true; } d("Relays initialized"); -#endif - +#endif } void relay_set(int number, bool state)