Skip to content

Commit

Permalink
solved import config options bug, now the config are saved correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
marco committed Sep 11, 2016
1 parent 0c90533 commit 75965d0
Show file tree
Hide file tree
Showing 19 changed files with 402 additions and 210 deletions.
32 changes: 16 additions & 16 deletions arduino_code/onos_rf69_serial_transponder.ino
Original file line number Diff line number Diff line change
Expand Up @@ -246,15 +246,15 @@ void decodeOnosCmd(const char *received_message){
*/

strcpy(received_message_answer,"err01_#]");
strcpy(received_message_answer,"[S_err01_#]");



if ((received_message[0]=='[')&&(received_message[1]=='S')&&(received_message[2]=='_') ) {
// the onos cmd was found [S_001dw06001_#]


strcpy(received_message_answer,"cmdRx_#]");
strcpy(received_message_answer,"[S_cmdRx_#]");


received_message_type_of_onos_cmd[0]=received_message[6];
Expand All @@ -266,7 +266,7 @@ void decodeOnosCmd(const char *received_message){


if (received_message_address!=this_node_address) {//onos command for a remote arduino node
strcpy(received_message_answer,"remote_#]");
strcpy(received_message_answer,"[S_remote_#]");

/*
Expand All @@ -284,7 +284,7 @@ void decodeOnosCmd(const char *received_message){

received_message_value=received_message[12]-48;
if (received_message_value>1){
strcpy(received_message_answer,"er0_status_#]");
strcpy(received_message_answer,"[S_er0_status_#]");
return;
}

Expand All @@ -304,7 +304,7 @@ void decodeOnosCmd(const char *received_message){
if ((received_message_value<0)||(received_message_value>255)){ //status check
received_message_value=0;
//Serial.println(F("onos_cmd_value_error"));
strcpy(received_message_answer,"er0_status_#]");
strcpy(received_message_answer,"[S_er0_status_#]");
return;
}

Expand All @@ -321,7 +321,7 @@ void decodeOnosCmd(const char *received_message){
received_message_value=received_message[12]-48;

if (received_message_value>1){
strcpy(received_message_answer,"er0_status_#]");
strcpy(received_message_answer,"[S_er0_status_#]");
return;
}

Expand Down Expand Up @@ -640,13 +640,13 @@ void loop()



if(((received_message_answer[0]=='o')&&(received_message_answer[1]=='k'))||(strcmp(received_message_answer,"remote_#]")==0)){
if(((received_message_answer[0]=='o')&&(received_message_answer[1]=='k'))||(strcmp(received_message_answer,"[S_remote_#]")==0)){



if (strcmp(received_message_answer,"remote_#]")!=0) {//onos command for this arduino node
if (strcmp(received_message_answer,"[S_remote_#]")!=0) {//onos command for this arduino node
//Serial.print("ok_local");
strcpy(received_message_answer,"ok_local_#]");
strcpy(received_message_answer,"[S_ok_local_#]");
counter=0;
}
else{ //onos command to send to a remote node
Expand Down Expand Up @@ -692,7 +692,7 @@ void loop()

else{
// Serial.println("sendtoWait failed");
strcpy(received_message_answer,"ertx1_#]");
strcpy(received_message_answer,"[S_ertx1_#]");
radio.receiveDone(); //put radio in RX mode
}

Expand All @@ -701,7 +701,7 @@ void loop()

}
else {//radio is disabled
strcpy(received_message_answer,"ertx3_#]");
strcpy(received_message_answer,"[S_ertx3_#]");

}

Expand All @@ -724,7 +724,7 @@ void loop()
}
else{

strcpy(received_message_answer,"nocmd0_#]");
strcpy(received_message_answer,"[S_nocmd0_#]");


}
Expand Down Expand Up @@ -764,7 +764,7 @@ void loop()
}


strcpy(received_message_answer,"VOID");
strcpy(received_message_answer,"[S_nocmd2_#]");
strcpy(filtered_onos_message,"");

Serial.flush(); //make sure all serial data is clocked out before sleeping the
Expand Down Expand Up @@ -830,7 +830,7 @@ void loop()
// Serial.println("onos cmd found-------------------------------");
decodeOnosCmd(filtered_onos_message);

if( (received_message_answer[0]=='o')&&(received_message_answer[1]=='k')||(strcmp(received_message_answer,"remote_#]")==0)){//if the message was ok...
if( (received_message_answer[0]=='o')&&(received_message_answer[1]=='k')||(strcmp(received_message_answer,"[S_remote_#]")==0)){//if the message was ok...
//check if sender wanted an ACK
if (radio.ACKRequested()){
radio.sendACK();
Expand All @@ -846,7 +846,7 @@ void loop()

}
else{
strcpy(received_message_answer,"nocmd0_#]");
strcpy(received_message_answer,"[S_nocmd0_#]");
Serial.println("error in message nocmd0_#]");
}

Expand All @@ -859,7 +859,7 @@ void loop()
}


if(strcmp(received_message_answer,"remote_#]")==0){ //transmit the received data from the node to the serial port
if(strcmp(received_message_answer,"[S_remote_#]")==0){ //transmit the received data from the node to the serial port


for (uint8_t pointer = 0; pointer <= rx_msg_lenght; pointer++) {
Expand Down
7 changes: 5 additions & 2 deletions scripts_folder/arduinoserial.py
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,7 @@ def waitForData(self,timeout):
self.disable_uart_queue=1 # I disable the auto queue add because I want to read the data directly
start_time=time.time()
while self.dataAvaible==0:
if (time.time>(start_time+timeout) ): #timeout to exit the loop
if (time.time()>(start_time+timeout) ): #timeout to exit the loop
return(-1)
time.sleep(0.001)
return(1)
Expand All @@ -408,6 +408,8 @@ def write(self, data):
while waitTowriteUntilIReceive==1 : #wait because there are half packet in serial receiving
time.sleep(0.001)
if (time.time>(timeout+10) ): #timeout to exit the loop
print "timeout in write() to serial port, the query was:"+data
errorQueue.put("timeout in write() to serial port, the query was:"+data)
break


Expand All @@ -421,7 +423,7 @@ def write(self, data):

tmp="void"
self.usbW.write(data+'\n')
if self.waitForData(10)==1:
if self.waitForData(2)==1: # wait for incoming message for 10 ms
#tmp=serial_incomingBuffer
#self.removeFromInBuffer=tmp

Expand All @@ -434,6 +436,7 @@ def write(self, data):

else:
print "rx timeout0"
waitToReceiveUntilIRead=0

return(tmp)

Expand Down
Binary file modified scripts_folder/arduinoserial.pyc
Binary file not shown.
5 changes: 4 additions & 1 deletion scripts_folder/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ def importConfig():
"""

global zoneDict
global nodeDicts
global nodeDict
global scenarioDict
global scenarios_enable
global accept_only_from_white_list
Expand All @@ -180,6 +180,7 @@ def importConfig():
global online_usersDict
global timezone
global enable_onos_auto_update
global conf_options

accept_only_from_white_list=readConfigurationsFromSavedFile(u"accept_only_from_white_list")
enable_mail_service=readConfigurationsFromSavedFile(u"enable_mail_service")
Expand All @@ -197,6 +198,8 @@ def importConfig():
scenarioDict.update(readDictionaryFromSavedFile(u"scenarioDictionary"))
tmp_obj_dict=readDictionaryFromSavedFile(u"objectDictionary")

conf_options={u"online_server_enable":online_server_enable,u"enable_mail_output_service":enable_mail_output_service,u"enable_mail_service":enable_mail_service,u"accept_only_from_white_list":accept_only_from_white_list,u"mail_whiteList":mail_whiteList,u"timezone":timezone,u"login_required":login_required,u"logTimeout":logTimeout,"online_usersDict":online_usersDict,"enable_onos_auto_update":enable_onos_auto_update,"scenarios_enable":scenarios_enable}

for a in tmp_obj_dict.keys(): #for each object in the file
object_html_name=a
object_type=tmp_obj_dict[a][u"type"]
Expand Down
Binary file modified scripts_folder/conf.pyc
Binary file not shown.
4 changes: 2 additions & 2 deletions scripts_folder/config_files/cfg.json
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
"enable_mail_service": 1,
"enable_onos_auto_update": "yes",
"logTimeout": 15,
"login_required": 1,
"login_required": 0,
"mail_whiteList": [
"elettronicaopensource@gmail.com",
"electronicflame@gmail.com",
"marco_righe@yahoo.it"
],
"online_server_enable": 1,
"online_server_enable": 0,
"online_usersDict": {
"RouterGA0000": {
"mail_control_password": "1234",
Expand Down
54 changes: 49 additions & 5 deletions scripts_folder/config_files/data.json
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@
],
"priority": 0,
"scenarios": [],
"status": 0,
"status": 1,
"styleDict": {
"0": "background-color:#A9E2F3;",
"1": "background-color:#8181F7;",
Expand Down Expand Up @@ -441,7 +441,7 @@
],
"priority": 0,
"scenarios": [],
"status": 0,
"status": 1,
"styleDict": {
"0": "background-color:#A9E2F3;",
"1": "background-color:#8181F7;",
Expand Down Expand Up @@ -648,7 +648,7 @@
],
"priority": 0,
"scenarios": [],
"status": 235,
"status": 799,
"styleDict": {
"0": "background-color:green;",
"1": "background-color:red;",
Expand Down Expand Up @@ -736,7 +736,7 @@
"scenario4",
"scenario8"
],
"status": 55,
"status": 19,
"styleDict": {
"0": "background-color:green;",
"1": "background-color:red;",
Expand Down Expand Up @@ -816,6 +816,40 @@
},
"type": "b"
},
"prova1_body": {
"cmdDict": {
"0": "",
"1": "",
"s_cmd": ""
},
"grp": [
"web_interface",
"onos_mail_guest"
],
"htmlDict": {
"0": "prova1_body=0",
"1": "prova1_body=1"
},
"mail_l": [],
"node_sn": 9999,
"notes": " ",
"objname": "prova1_body",
"own": "onos_admin",
"perm": "111111111",
"pins": [
9999
],
"priority": 0,
"scenarios": [],
"status": 0,
"styleDict": {
"0": "background-color:#A9E2F3;",
"1": "background-color:#8181F7;",
"default_s": "background-color:red ;color black",
"onoswait": "background-color:grey ;color black"
},
"type": "b"
},
"rergswgeg": {
"cmdDict": {
"0": "",
Expand Down Expand Up @@ -1055,7 +1089,7 @@
],
"priority": 0,
"scenarios": [],
"status": 0,
"status": 1,
"styleDict": {
"0": "background-color:#A9E2F3;",
"1": "background-color:#8181F7;",
Expand Down Expand Up @@ -1790,6 +1824,16 @@
"order": 5,
"owner": "onos_sys",
"permissions": "777"
},
"prova1": {
"group": [],
"hidden": 0,
"objects": [
"prova1_body"
],
"order": 7,
"owner": "onos_sys",
"permissions": "777"
}
}
}

0 comments on commit 75965d0

Please sign in to comment.