Pages: [1]   Go Down
Author Topic: Stray characters error  (Read 3872 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
God Member
*****
Karma: 1
Posts: 547
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I'm getting the following compiler complaints but the referenced strays cannot be found. Arduino version 1.0.
Project files accompany post.

Code:
C:\arduino-1.0\hardware\tools\avr\bin\avr-g++ -c -g -Os -Wall -fno-exceptions -ffunction-sections -fdata-sections -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=100 -IC:\arduino-1.0\hardware\arduino\cores\arduino -IC:\arduino-1.0\hardware\arduino\variants\standard -IC:\arduino-1.0\libraries\FastADC C:\Users\AARONJ~1.SCO\AppData\Local\Temp\build5886924818106296315.tmp\FastDAC_ino.cpp -oC:\Users\AARONJ~1.SCO\AppData\Local\Temp\build5886924818106296315.tmp\FastDAC_ino.cpp.o
In file included from FastDAC_ino.cpp:1:
C:\arduino-1.0\libraries\FastADC/FastADC.h:1: error: stray '\357' in program
C:\arduino-1.0\libraries\FastADC/FastADC.h:1: error: stray '\273' in program
C:\arduino-1.0\libraries\FastADC/FastADC.h:1: error: stray '\277' in progra

* FastADC.cpp (1.58 KB - downloaded 26 times.)
* FastADC.h (0.52 KB - downloaded 26 times.)
* FastDAC_ino.ino (0.44 KB - downloaded 20 times.)
Logged

West Des Moines, Iowa USA
Offline Offline
Sr. Member
****
Karma: 2
Posts: 428
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Just for grins, try opening FastDAC_ino.ino in your favorite program editor and removing everything after the final brace...
Logged

There's always a better way!

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 601
Posts: 48543
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I don't get those errors, but I do get lots of others. Your cpp is missing plenty of includes.
Logged

Offline Offline
God Member
*****
Karma: 1
Posts: 547
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Deleting the last 3 lines in FastADC_ino had no effect, and in respect to includes here is the post preprocess file:
Code:
#include "FastADC.h"
#include "Arduino.h"
void setup();
void loop();
FastADC Conv1;
void setup()
  {
    Serial.begin(9600);
    Conv1.Resolution(8);
    Conv1.Comparator = 0;
  }
void loop()
  {

    if (!Conv1.InProgress())
      {
        Serial.println(Conv1.Output());
        Serial.println(Conv1.Resolution());
        Serial.println(Conv1.InProgress());
        Serial.println(Conv1.ApproxMask());
        Conv1.Start();
      }
     Serial.println(Conv1.InProgress());
       
   }


So I don't see anything not included that should be.
Logged

Offline Offline
God Member
*****
Karma: 1
Posts: 547
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I found a missing closing parenthesis in FastADC.cpp @ line 81 but it didn't resolve the strays error, the compiler didn't get that far apparently.
Logged

Offline Offline
God Member
*****
Karma: 1
Posts: 547
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

The issue was my code editor saved the file in UTF8 format, not ANSI.
Logged

Offline Offline
God Member
*****
Karma: 1
Posts: 547
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

It is a a mu point in the end. It would seem I can't use 'attachInterrupt()' from within a class.
Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 601
Posts: 48543
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
It would seem I can't use 'attachInterrupt()' from within a class.
Sure, you can. You just can't attach a non-static method. How would the Arduino know which instance to call the handler for?
Logged

Offline Offline
God Member
*****
Karma: 1
Posts: 547
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

So how do I make one function shared uniquely to all instances of the class?
Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 601
Posts: 48543
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
So how do I make one function shared uniquely to all instances of the class?
Declare it static.
Logged

Offline Offline
God Member
*****
Karma: 1
Posts: 547
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I see I will have to handle the interrupt externally and ping the function from the ISR or make a copy of the attachInterrupt function and make it local to the class. The reasoning for the class was not for multiple instances, but for ease of use...or so I thought. The easiest for me is to just call CompareShift from the main body.
Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 601
Posts: 48543
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
The reasoning for the class was not for multiple instances, but for ease of use..
Perhaps, but the compiler has no way of knowing that you will only make one instance of the class.

There are ways of making a copy of the this pointer in the constructor, and then using that copy in the static method to access the non-static members of the class IF you do only create one instance.

I do that all the time at work, when the class is a dialog class, and I want to use a progress bar dialog class. The progress bar class requires a static method, just like attachInterrupt, for very similar reasons. Each class that uses the progress bar class is a singleton (only one instance at a time), so I register a static method for the progress bar class to call, and in that static method I call the real class member function using the static copy of the pointer to this that the constructor of the singleton made.
Logged

Pages: [1]   Go Up
Jump to: