Skip to content

Commit

Permalink
started using pyserial
Browse files Browse the repository at this point in the history
  • Loading branch information
marco committed Sep 16, 2016
1 parent a151586 commit 1367392
Show file tree
Hide file tree
Showing 23 changed files with 1,519 additions and 476 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
#include <RFM69.h> //get it here: https://www.github.com/lowpowerlab/rfm69
#include <SPI.h>
#include <RFM69_ATC.h>
#include "onos_message_decode.h"
#include "onos_message_decode.cpp"

//*********************************************************************************************
// *********** IMPORTANT SETTINGS - YOU MUST CHANGE/CONFIGURE TO FIT YOUR HARDWARE *************
Expand Down
20 changes: 20 additions & 0 deletions arduino_code/onos_lamp_node_WLightSS/onos_message_decode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,26 @@
#include "onos_message_decode.h"
#include "Arduino.h"

char received_serial_number[13];


//////////////////////////////////Start of Standard part to run decodeOnosCmd()//////////////////////////////////
#define rx_msg_lenght 61
int onos_cmd_start_position=-99;
int onos_cmd_end_position=-99;
char received_message_type_of_onos_cmd[3];
uint8_t received_message_first_pin_used;
uint8_t received_message_second_pin_used;
int received_message_value;
char received_message_answer[rx_msg_lenght+6]="er00_#]";
int received_message_address=0; //must be int..
char filtered_onos_message[rx_msg_lenght+3];
char syncMessage[28];
char str_this_node_address[4];
//////////////////////////////////End of Standard part to run decodeOnosCmd()//////////////////////////////////




void decodeOnosCmd(const char *received_message,int this_node_address,char serial_number[13]){
/*
Expand Down
22 changes: 1 addition & 21 deletions arduino_code/onos_lamp_node_WLightSS/onos_message_decode.h
Original file line number Diff line number Diff line change
@@ -1,28 +1,8 @@
#include <Arduino.h>
#ifdef HEADER_HELPERFUNC
#define HEADER_HELPERFUNC

//////////////////////////////////Start of Standard part to run decodeOnosCmd()//////////////////////////////////
#define rx_msg_lenght 61
int onos_cmd_start_position=-99;
int onos_cmd_end_position=-99;
char received_message_type_of_onos_cmd[3];
uint8_t received_message_first_pin_used;
uint8_t received_message_second_pin_used;
int received_message_value;
char received_message_answer[rx_msg_lenght+6]="er00_#]";
int received_message_address=0; //must be int..
char filtered_onos_message[rx_msg_lenght+3];
char syncMessage[28];
char str_this_node_address[4];
//////////////////////////////////End of Standard part to run decodeOnosCmd()//////////////////////////////////
char received_serial_number[13];




#define rx_msg_lenght 61


///////////////////////////////////////

void decodeOnosCmd(const char *received_message,int this_node_address ,char serial_number[13]);
12 changes: 6 additions & 6 deletions arduino_code/onos_rf69_serial_transponder.ino
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@
#define IS_RFM69HCW false // set to 'true' if you are using an RFM69HCW module

//*********************************************************************************************
#define SERIAL_BAUD 115200
#define SERIAL_BAUD 57600

#define RFM69_CS 10
#define RFM69_IRQ 2
Expand Down Expand Up @@ -511,7 +511,7 @@ void setup() {
Serial.println(" MHz");
*/
Serial.println(F("arduino_ready_#]"));
Serial.println(F("[S_arduino_ready_#]"));
radio_enabled=1;


Expand Down Expand Up @@ -557,20 +557,20 @@ void loop()
//Serial.println(counter);
// read the incoming byte:
//if (counter==0){
delayMicroseconds(110); //the serial doesnt work without this delay...
delayMicroseconds(210);//the serial doesnt work without this delay... to change if you change baud rate (increase with lower baud rate)
//}
data_from_serial[counter] = Serial.read();

if ( millis()>timeout){
Serial.println(F("serial_timeout---------------------------------"));
Serial.println(F("[S_serial_timeout---------------------------------_#]"));
break;
}




if (counter>rx_msg_lenght){ //prevent overflow
Serial.println(F("array_overflow prevented---"));
Serial.println(F("[S_array_overflow prevented---_#]"));
Serial.println(counter);
Serial.println(F("end"));
counter=0;
Expand Down Expand Up @@ -646,7 +646,7 @@ void loop()

if (strcmp(received_message_answer,"[S_remote_#]")!=0) {//onos command for this arduino node
//Serial.print("ok_local");
strcpy(received_message_answer,"[S_ok_local_#]");
strcpy(received_message_answer,"ok_#]");
counter=0;
}
else{ //onos command to send to a remote node
Expand Down

0 comments on commit 1367392

Please sign in to comment.