Pages: [1]   Go Down
Author Topic: time stamp  (Read 498 times)
0 Members and 4 Guests are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 3
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hello guys!!!
I'm using Mega 2560 for my little project and I try to read my bluetooth data from serial and send  that to other device by getting request. I have problem about adding my time stamp. The receiving sync request  string is like "ST,SYNC,Unix time  "
here is part of my code:
char check = Serial2.read();   
   inString += check;
   if(check == '\0'){
      count_check = 0;
      inString= "";
      digitalClockDisplay();
   }
   checkCommand[count_check] = check ;
   count_check++;
 for (int j = 0; j < sizeof(check_ST1); j++){
      check_ST1[j] = checkCommand[j];
   }
     if(strcmp(check_ST1,ST1)==0){
        allow = 1;
     }
if(strcmp(check_SYNC,SYNC)==0 && allow == 1){
    processSyncMessage();
    allow = 0;
            }
void digitalClockDisplay(){  // digital clock display of the time
   Serial.print(hour());
   printDigits(minute());
   printDigits(second());
   Serial.print("-");
   Serial.print(day());
   Serial.print("/");
   Serial.print(month());
   Serial.print("/");
   Serial.print(year());
   Serial.print(",");
}
void printDigits(int digits){
  Serial.print(":");
  if(digits < 10)
    Serial.print('0');
  Serial.print(digits);
}
void processSyncMessage() {
    char check = Serial.read() ;
      time_t pctime = 0;
      for(int i=0; i < TIME_MSG_LEN -1; i++){
        check = Serial.read();
        if( isDigit(check)) {
          pctime = (10 * pctime) + (check - '0') ; // convert digits to a number
        }
      }
      setTime(pctime);   // Sync clock to the time received on serial port
  }
 /
Quote


your help be appreciate !!
Logged

Miers 46500 France
Offline Offline
Sr. Member
****
Karma: 14
Posts: 306
EmbeddedAT .. From Concept to Prototype to Production
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

yes but what is the problem you are having ?
Logged

EmbeddedAT .. From Concept to Prototype to Production

Electronics and firmware design and project mentoring

Pages: [1]   Go Up
Jump to: