Hi all,
I'm a big noob when it comes to arduino and I'm having a hard time getting my code to compile. After commenting irrelevant parts that worked fine, I only left code related to the time library and giving errors. Here is my code:
#include <Arduino.h>
#include <stdio.h>
#include </home/user/Desktop/solarfurnace/asm/unistd.h>
#include <math.h>
#include </home/user/Desktop/solarfurnace/Time/Time/Time.h>
#include </home/user/Desktop/solarfurnace/Helios/Helios.h>
#include </home/user/Desktop/solarfurnace/AccelStepper/AccelStepper.h>
#define TIME_MSG_LEN 11 // time sync to PC is HEADER followed by unix time_t as ten ascii digits
#define TIME_HEADER 'T' // Header tag for serial time sync message
#define TIME_REQUEST 7 // ASCII bell character requests a time sync message
void setup ()
{
Serial.begin(9600);
setSyncProvider(requestSync); //set function to call when sync required
Serial.println("Waiting for sync message");
}
void loop ()
{
if(Serial.available() )
{
processSyncMessage();
}
}
void processSyncMessage() {
// if time sync available from serial port, update time and return true
while(Serial.available() >= TIME_MSG_LEN ){ // time message consists of a header and ten ascii digits
char c = Serial.read() ;
Serial.print(c);
if( c == TIME_HEADER ) {
time_t pctime = 0;
for(int i=0; i < TIME_MSG_LEN -1; i++){
c = Serial.read();
if( c >= '0' && c <= '9'){
pctime = (10 * pctime) + (c - '0') ; // convert digits to a number
}
}
setTime(pctime); // Sync Arduino clock to the time received on the serial port
}
}
}
time_t requestSync()
{
Serial.print(TIME_REQUEST,byte(0));
return 0; // the time will be sent later in response to serial mesg
}
When i try to compile it, I get the following error:
_L_control.cpp.o: In function `loop':
/usr/share/arduino/O_L_control.ino:87: undefined reference to `setSyncProvider(unsigned long (*)())'
/usr/share/arduino/O_L_control.ino:87: undefined reference to `setTime(unsigned long)'
collect2: error: ld returned 1 exit status
Can you help me figure it out?
I'm a big noob when it comes to arduino and I'm having a hard time getting my code to compile. After commenting irrelevant parts that worked fine, I only left code related to the time library and giving errors. Here is my code:
#include <Arduino.h>
#include <stdio.h>
#include </home/user/Desktop/solarfurnace/asm/unistd.h>
#include <math.h>
#include </home/user/Desktop/solarfurnace/Time/Time/Time.h>
#include </home/user/Desktop/solarfurnace/Helios/Helios.h>
#include </home/user/Desktop/solarfurnace/AccelStepper/AccelStepper.h>
#define TIME_MSG_LEN 11 // time sync to PC is HEADER followed by unix time_t as ten ascii digits
#define TIME_HEADER 'T' // Header tag for serial time sync message
#define TIME_REQUEST 7 // ASCII bell character requests a time sync message
void setup ()
{
Serial.begin(9600);
setSyncProvider(requestSync); //set function to call when sync required
Serial.println("Waiting for sync message");
}
void loop ()
{
if(Serial.available() )
{
processSyncMessage();
}
}
void processSyncMessage() {
// if time sync available from serial port, update time and return true
while(Serial.available() >= TIME_MSG_LEN ){ // time message consists of a header and ten ascii digits
char c = Serial.read() ;
Serial.print(c);
if( c == TIME_HEADER ) {
time_t pctime = 0;
for(int i=0; i < TIME_MSG_LEN -1; i++){
c = Serial.read();
if( c >= '0' && c <= '9'){
pctime = (10 * pctime) + (c - '0') ; // convert digits to a number
}
}
setTime(pctime); // Sync Arduino clock to the time received on the serial port
}
}
}
time_t requestSync()
{
Serial.print(TIME_REQUEST,byte(0));
return 0; // the time will be sent later in response to serial mesg
}
When i try to compile it, I get the following error:
_L_control.cpp.o: In function `loop':
/usr/share/arduino/O_L_control.ino:87: undefined reference to `setSyncProvider(unsigned long (*)())'
/usr/share/arduino/O_L_control.ino:87: undefined reference to `setTime(unsigned long)'
collect2: error: ld returned 1 exit status
Can you help me figure it out?