It is currently Wed Aug 23, 2017 11:51 am

All times are UTC




Post new topic Reply to topic  [ 1 post ] 
Author Message
PostPosted: Sun May 14, 2017 5:14 am 
Offline
Member
Member

Joined: Sun May 14, 2017 4:56 am
Posts: 1
Complex multi-gates system with several Arduino boards and radios communicating with a "central" unit.
When a gate is activated (open, stop, close), the gate controller sends a message to the central, where date, time, operation, user etc are logged on an SD high volume card. The central adds date and time to the log before writing it to the SD card, reading time and date from the Velleman RTC.
Problem:
When connecting the PC to the controller (USB), using Serial.xxx functions, I want to reset the date/time on the RTC, reading the PC date/time.
How could I do that?
(I can set the RTC manually, but I want it automatic, each time I connect the USB)
partial code:
Code:
void USB_command()
{
  char msg[100];
  int i;
  // execute a command from Arduino monitor
  // Read the header byte to determine the type of command
  msg[0] = Serial.read();
  while (!Serial.available());
  switch (msg[0])
  {
    case 0x01:  // Central request for log
      send_log_to_central();
      break;
    case 0x02:  // Write dummy log to SD card
      write_dummy_log();   
      break;
....
}
void loop()
{
  if (key_check() > -1) // any key gets the menu (options such as download and erase LOGs from SD card)
    menu();
  if (Serial.available()) // USB MESSAGE FROM MONITOR
    USB_command();        // execute the command, ie reset the clock
  if (ZetaSerial.available())  // ZETAPLUS MESSAGE FROM GATES
    ZetaMessage();
}


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group