Jp3141
Well-known member
My simple programs work OK, and this one works on my Mac, but on my PCs (both Win7 and XP), I get this error:
c:/projects/arduino-1.0.2/hardware/tools/arm-none-eabi/bin/../lib/gcc/arm-none-eabi/4.4.1/../../../../arm-none-eabi/lib/thumb2\libc.a(lib_a-closer.o): In function `_close_r':
closer.c.text+0x12): undefined reference to `_close'
c:/projects/arduino-1.0.2/hardware/tools/arm-none-eabi/bin/../lib/gcc/arm-none-eabi/4.4.1/../../../../arm-none-eabi/lib/thumb2\libc.a(lib_a-lseekr.o): In function `_lseek_r':
lseekr.c.text+0x16): undefined reference to `_lseek'
collect2: ld returned 1 exit status
Any ideas ?
My code is:
c:/projects/arduino-1.0.2/hardware/tools/arm-none-eabi/bin/../lib/gcc/arm-none-eabi/4.4.1/../../../../arm-none-eabi/lib/thumb2\libc.a(lib_a-closer.o): In function `_close_r':
closer.c.text+0x12): undefined reference to `_close'
c:/projects/arduino-1.0.2/hardware/tools/arm-none-eabi/bin/../lib/gcc/arm-none-eabi/4.4.1/../../../../arm-none-eabi/lib/thumb2\libc.a(lib_a-lseekr.o): In function `_lseek_r':
lseekr.c.text+0x16): undefined reference to `_lseek'
collect2: ld returned 1 exit status
Any ideas ?
My code is:
Code:
#include <stdio.h>
#include <stdlib.h>
#define D(line) Serial.println(line);
#define RTCget() Teensy3Clock.get()
#define RTCget() (millis()/1000+RTCoffset) // Use this one if no 32768 installed
#define RTCset(t) Teensy3clock.set(t)
#define RTCset(t) RTCoffset=(t-millis()/1000) // can't reset millis().
#define analogpin 10
#define LED 13
#define temperatureChannel 0x26
#define TEMPERATURE_AVERAGES 4
#define bandgapChannel 0x27
#define TemperatureOffset 432
#define TemperatureScale -0.02936
long rollingCounter=1L, PseudoTimer=0L;
char DataLine[82], InputLine[82];
char CRLF[2]={'\0', '\0'}; // Prepare null-terminated string
byte index=0;
int SetD, SetH, SetM, SetS;
int Set6Y, Set6Month, Set6D, Set6H, Set6M, Set6S;
char *Month[]={"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"};
char *DOW[]={"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"};
int MonthL[]={31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
int iLeapDay=0;
float temperatureC;
//elapsedMillis milli_s_timer; //seems to initialize at 0
int iLastTime=0;
int DateMode=1; // 0 ==> D, H:M:S; 1 ==> DOW, Year, Month, Date, H:M:S
long RTCoffset=0L;
// the setup routine runs once when you press reset:
void setup() {
// initialize the digital pin as an output.
pinMode(LED, OUTPUT);
digitalWrite(LED, HIGH);
Serial.begin(9600);
analogReference(INTERNAL);
analogReadRes(16);
while (!Serial && 0) { // skip this
digitalWrite(LED, HIGH);
delay(50);
digitalWrite(LED, LOW);
delay(100); } // Wait for Arduino Serial Monitor to open
RTCset(3600*24+1); // Gnuplot likes to plot from day #1
Serial.println("# Serial Temperature Logger; Dec 3, 2012");
//Serial.setTimeout(0);
//InputLine[0]='\0';
}
void loop() {
long TemperatureADC=0L;
int nLoops = 0;
digitalWrite(LED, HIGH);
//delay(20);
do {
TemperatureADC += analogRead(temperatureChannel);
delay(20);
digitalWrite(LED, LOW);
nLoops++; } // gets about 2400 measurements without delays, this gives ~ 49
while (RTCget()==iLastTime);
iLastTime = RTCget();
if (iLastTime % (3600*24)==0) {
RTCset(iLastTime+3600*24-1); // 5 s short of a day
Set6D++;
iLeapDay = (isLeapYear(Set6Y) && Set6Month==2) ? 1 : 0;
if (Set6D > (MonthL[Set6Month-1]+iLeapDay)){
Set6D=1; Set6Month++;
if (Set6Month==13) {Set6Month=1; Set6Y++;}
}
}
temperatureC = (TemperatureADC*TemperatureScale)/nLoops + TemperatureOffset;
// sprintf(DataLine, "%4i d %2d:%02d:%02d Internal Temp #%6d = %5.2f deg.C\n", iLastTime/(24*3600), (iLastTime/3600) % 24, (iLastTime/60) % 60, iLastTime % 60, rollingCounter++, temperatureC);
if (DateMode==0) sprintf(DataLine, "%4i %2d:%02d:%02d Internal Temp # %9ld = %6.2f deg.C%s\n", iLastTime/(24*3600), (iLastTime/3600) % 24, (iLastTime/60) % 60, iLastTime % 60, rollingCounter++, temperatureC, CRLF);
else sprintf(DataLine, "%4i %3s %3s %2i %2d:%02d:%02d Internal Temp # %9ld = %6.2f deg.C%s\n", Set6Y, DOW[dayofweek(Set6Y, Set6Month, Set6D)], Month[Set6Month-1], Set6D, (iLastTime/3600) % 24, (iLastTime/60) % 60, iLastTime % 60, rollingCounter++, temperatureC, CRLF);
Serial.print(DataLine);
// D(iLastTime)
while (Serial.available() && (index < sizeof(InputLine))) {
InputLine[index] = Serial.read();
if (InputLine[index]=='R') DateMode=1;
if (InputLine[index]=='r') CRLF[0]='\r'; // [1] is '\0'
if (InputLine[index]=='n') CRLF[0]='\0'; // append or not a CRLF or just LF
if (InputLine[index]=='\n') { // if there is a whole line in the buffer
// only process this code if there is a line
InputLine[index] = '\0'; // Mark as end of a string
if (DateMode==0 && sscanf(InputLine, "%d %d %d %d", &SetD, &SetH, &SetM, &SetS)==4) { // only accept 4 numbers
if (SetD < 0) { Serial.println(((String) "# Date set.").concat(CRLF)); SetD = -SetD; }
RTCset(SetS+60L*(SetM+60L*(SetH+24L*SetD))); }
if (DateMode==1 && sscanf(InputLine, "%d %d %d %d %d %d", &Set6Y, &Set6Month, &Set6D, &Set6H, &Set6M, &Set6S)==6) { // only accept 6 numbers
if (Set6Y < 0) { Serial.println(((String) "# Calendar date set.").concat(CRLF)); Set6Y = -Set6Y; }
RTCset(Set6S+60L*(Set6M+60L*(Set6H+24L*Set6D))); } // Is Set6D important ?
index=0; } else index++; // Note InputLine[0] is not reset
} // while
}
int dayofweek(int y, int m, int d) { /* 0 = Sunday */
static int t[] = {0, 3, 2, 5, 0, 3, 5, 1, 4, 6, 2, 4};
y -= m < 3;
return (y + y/4 - y/100 + y/400 + t[m-1] + d) % 7;}
int isLeapYear(int year) {
return ((year % 4 == 0) && (year % 100 != 0) || (year % 400 == 0));}