Trying to do a CAN test from : My own ECU simulator - Car Hacking - Carloop Community
The code turns out error 'stray '#' in program' , what's wrong?
7 #pragma once
8 #include "application.h"
9 #include "TinyGPS++.h"
10
11 enum CarloopFeatures_e
12 {
13 CARLOOP_CAN = 1,
14 CARLOOP_GPS = 2,
15 CARLOOP_BATTERY = 4,
16 CARLOOP_ALL_FEATURES = CARLOOP_CAN | CARLOOP_GPS | CARLOOP_BATTERY
17 };
18
19 struct CarloopRevision2
20 {
21 static constexpr auto CAN_PINS = CAN_D1_D2;
22 static constexpr uint32_t CAN_DEFAULT_SPEED = 500000;
23
24 static constexpr auto BATTERY_PIN = A1;
25 static constexpr auto BATTERY_FACTOR = 7.2f;
26
27 static constexpr auto CAN_ENABLE_PIN = D0;
28 static constexpr auto CAN_ENABLE_ACTIVE = LOW;
29 static constexpr auto CAN_ENABLE_INACTIVE = HIGH;
30
31 static constexpr auto GPS_BAUD_RATE = 9600;
32 static constexpr auto GPS_ENABLE_PIN = A0;
33 static constexpr auto GPS_ENABLE_ACTIVE = HIGH;
34 static constexpr auto GPS_ENABLE_INACTIVE = LOW;
35
36 static constexpr auto FEATURES = CARLOOP_CAN | CARLOOP_GPS | CARLOOP_BATTERY;
37 };
38
39 template <typename Config>
40 class Carloop
41 {
42 public:
43 Carloop();
44
45 void setCANSpeed(uint32_t canSpeed);
46 void begin(CarloopFeatures_e features = CARLOOP_ALL_FEATURES);
47
48 void update();
49
50 CANChannel &can();
51 TinyGPSPlus &gps();
52 float battery();
53
54 void enableCAN();
55 void disableCAN();
56 void enableGPS();
57 void disableGPS();
58 void enableBattery();
59
60 float readBattery();
61
62 bool hasCAN();
63 bool hasGPS();
64 bool hasBattery();
65
66 private:
67 void receiveSerialChars();
68
69 CANChannel canDriver;
70 uint32_t canSpeed;
71
72 Thread *gpsSerialThread;
73 TinyGPSPlus gpsDriver;
74
75 float batteryVoltage;
76
77 CarloopFeatures_e features;
78 };
error:
carloop.h:7:3: error: stray '#' in program
7 #pragma once
^
carloop.h:8:3: error: stray '#' in program
8 #include "application.h"
^
carloop.h:9:3: error: stray '#' in program
9 #include "TinyGPS++.h"
^
carloop.h:1:1: error: expected unqualified-id before numeric constant
1 /* Library for the Carloop connected car device
^
carloop.h:19:1: error: expected unqualified-id before numeric constant
18
^
carloop.h:44:1: error: expected unqualified-id before numeric constant
38
^
My_own_ECU_simulator_a:7:14: error: expected constructor, destructor, or type conversion before '(' token
SYSTEM_THREAD(ENABLED); // To not block the main program while searching for WiFi
^
My_own_ECU_simulator_a:8:1: error: 'Carloop' does not name a type
Carloop carloop; // Instantiate Carloop Object
^
My_own_ECU_simulator_a:10:12: error: expected constructor, destructor, or type conversion before '(' token
SYSTEM_MODE(SEMI_AUTOMATIC);
^
E:\design_info\DIY\ARDUINO\0_CAN\My own ECU simulator\My_own_ECU_simulator_a\My_own_ECU_simulator_a.ino: In function 'void setup()':
My_own_ECU_simulator_a:19:5: error: 'carloop' was not declared in this scope
carloop.begin(); // Creates the appropriate CANChannel
^
My_own_ECU_simulator_a:23:5: error: 'WiFi' was not declared in this scope
WiFi.connect();
^
E:\design_info\DIY\ARDUINO\0_CAN\My own ECU simulator\My_own_ECU_simulator_a\My_own_ECU_simulator_a.ino: In function 'void loop()':
My_own_ECU_simulator_a:26:5: error: 'CANMessage' was not declared in this scope
CANMessage message;
^
My_own_ECU_simulator_a:28:11: error: 'carloop' was not declared in this scope
while(carloop.can().receive(message)) {
^
My_own_ECU_simulator_a:28:33: error: 'message' was not declared in this scope
while(carloop.can().receive(message)) {
^
E:\design_info\DIY\ARDUINO\0_CAN\My own ECU simulator\My_own_ECU_simulator_a\My_own_ECU_simulator_a.ino: In function 'void processMode1(int)':
My_own_ECU_simulator_a:44:5: error: 'CANMessage' was not declared in this scope
CANMessage message;
^
My_own_ECU_simulator_a:45:5: error: 'message' was not declared in this scope
message.id = 0x7E8;
^
My_own_ECU_simulator_a:68:5: error: 'carloop' was not declared in this scope
carloop.can().transmit(message);
^
Using library carloop.h in folder: C:\Program Files (x86)\Arduino\libraries\carloop.h (legacy)
exit status 1
stray '#' in program