I am sending some data to a logger, ( all sent as bytes ) , and have just got a testing code at the receive end, with the results monitored with Terminal on the PC.
If I just send all the data and time/date with the code below it logs fine :-
}
void checkprinter () { //check and see if a data packet has come in.
if(ET.receiveData()){
int(PIN ) = mydata.PIN ; // PIN 33 for Radiant
if(PIN == 33 ){
Serial.print (" PIN OK = " );
Serial.println (PIN );
int( qgps) = mydata.qgps;
if ( qgps == 0 ){
searching = 1;
queuetype = 1;
}
if ( qgps == 1 ){
searching = 0;
queuetype = 0;
}
if ( qgps == 2 ){
searching = 1;
queuetype = 1;
}
if ( qgps == 3 ){
searching = 0;
queuetype = 0;
}
int (number) = mydata.number;
// if (searching == 0 ) { // only update realtime clock if gps locked
int( clockyear) = mydata.clockyear ;
clockyear = clockyear + 2000 ;
int( clockmonth ) = mydata.clockmonth;
int ( clockday) = mydata.clockday;
int ( clockhours) = mydata.clockhours;
int ( clockmins) = mydata.clockmins;
// } // end of if seraching - 0
Serial.print (" qgps = " ) ;
Serial.println (qgps);
Serial.print (" number = " ) ;
Serial.println (number);
Serial.print (" searching = " ) ;
Serial.println (searching);
Serial.print (" queuetype = " ) ;
Serial.println (queuetype);
Serial.print (" clockmins = " ) ;
Serial.println (clockmins);
Serial.print (" clockhours = " );
Serial.println (clockhours);
Serial.print (" clockday = " ) ;
Serial.println (clockday);
Serial.print (" clockmonth = " );
Serial.println (clockmonth);
Serial.print (" clockyear = " ) ;
Serial.println (clockyear);
} // end of if pin =33
} // end of if any rx
//you should make this delay shorter then your transmit delay or else messages could be lost
delay(250);
}
The result is PIN OK = 33
qgps = 3
number = 2
searching = 0
queuetype = 0
clockmins = 35
clockhours = 8
clockday = 15
clockmonth = 4
clockyear = 2013
If I include the if statement that I commented out , as I only want to update the loggers clock if the GPS time coming in as right ie the remote GPS is locked, I lose the time and get as below
void checkprinter () { //check and see if a data packet has come in.
if(ET.receiveData()){
int(PIN ) = mydata.PIN ; // PIN 33 for Radiant
if(PIN == 33 ){
Serial.print (" PIN OK = " );
Serial.println (PIN );
int( qgps) = mydata.qgps;
if ( qgps == 0 ){
searching = 1;
queuetype = 1;
}
if ( qgps == 1 ){
searching = 0;
queuetype = 0;
}
if ( qgps == 2 ){
searching = 1;
queuetype = 1;
}
if ( qgps == 3 ){
searching = 0;
queuetype = 0;
}
int (number) = mydata.number;
if (searching == 0 ) { // only update realtime clock if gps locked
int( clockyear) = mydata.clockyear ;
clockyear = clockyear + 2000 ;
int( clockmonth ) = mydata.clockmonth;
int ( clockday) = mydata.clockday;
int ( clockhours) = mydata.clockhours;
int ( clockmins) = mydata.clockmins;
} // end of if seraching - 0
Serial.print (" qgps = " ) ;
Serial.println (qgps);
Serial.print (" number = " ) ;
Serial.println (number);
Serial.print (" searching = " ) ;
Serial.println (searching);
Serial.print (" queuetype = " ) ;
Serial.println (queuetype);
Serial.print (" clockmins = " ) ;
Serial.println (clockmins);
Serial.print (" clockhours = " );
Serial.println (clockhours);
Serial.print (" clockday = " ) ;
Serial.println (clockday);
Serial.print (" clockmonth = " );
Serial.println (clockmonth);
Serial.print (" clockyear = " ) ;
Serial.println (clockyear);
} // end of if pin =33
} // end of if any rx
//you should make this delay shorter then your transmit delay or else messages could be lost
delay(250);
}
I get the times as below
PIN OK = 33
qgps = 3
number = 2
searching = 0
queuetype = 0
clockmins = <0>
clockhours = <0>
clockday = <0>
clockmonth = <0>
clockyear = <0>
the declared variables are
#include <EasyTransfer.h>
//create object
EasyTransfer ET;
int ledPin = 10;
int searching;
int queuetype;
byte number;
byte clockyear;
byte clockmonth;
byte clockday;
byte clockhours;
byte clockmins;
byte qgps;
struct RECEIVE_DATA_STRUCTURE{
//put your variable definitions here for the data you want to receive
//THIS MUST BE EXACTLY THE SAME ON THE OTHER ARDUINO
// int blinks;
// int pause;
byte PIN; // PIN 33 for Radiant
// byte searching; // gps locked = 1
byte number; // broken down for old system and eeprom?
// byte numremainder;
byte clockyear;
byte clockmonth;
byte clockday;
byte clockhours;
byte clockmins;
byte qgps; // 0 for no lock normal ,1 for lock normal , 2 for no lock express, 3 for lock express
// byte clocksecs;
};
//give a name to the group of data
RECEIVE_DATA_STRUCTURE mydata;
//*************************************************************************
void setup(){
Serial.begin(9600);
Serial.println("setup");
//start the library, pass in the data details and the name of the serial port. Can be Serial, Serial1, Serial2, etc.
ET.begin(details(mydata), &Serial);
pinMode(ledPin, OUTPUT);
}
void loop()
checkprinter ();
}