kevinl95 / KeychainSkimmerScanner

A compact keychain device powered by M5CoreInk that detects and alerts you to potential credit card skimmers at payment terminals.
MIT License
4 stars 3 forks source link

Code won't compile #4

Open johnwargo opened 3 weeks ago

johnwargo commented 3 weeks ago

@kevinl95 I purchased a new M5Stack CoreInk device, downloaded the code, and tried to compile it with no success..

The code generates some warnings, but I assume the sketch will compile even with those warnings. Did you see those warnings when you worked on the code?

D:\dev\hardware\M5Stack\KeychainSkimmerScanner\main\main.ino: In function 'void Scan()':
D:\dev\hardware\M5Stack\KeychainSkimmerScanner\main\main.ino:76:34: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
   76 |         if (StrContains(success, "HC-05") == 1) {
      |                                  ^~~~~~~
D:\dev\hardware\M5Stack\KeychainSkimmerScanner\main\main.ino:78:41: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
   78 |         } else if (StrContains(success, "HC-06") == 1) {
      |                                         ^~~~~~~
D:\dev\hardware\M5Stack\KeychainSkimmerScanner\main\main.ino:80:41: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
   80 |         } else if (StrContains(success, "Name: , ") == 1) {
      |                                         ^~~~~~~~~~

The IDE also generates a bunch of errors based on issues it sees with the M5Stack M5Core-Ink library (listed below). But looking at the M5Core-Ink project I do see that ledcSetup and ledcAttachPin aren't in the library (as I expected based on the error). So I'm trying to understand how you were able to compile the code. I tried compiling this with the M5Stack libraries installed in the Arduino IDE then deleted them and installed just the M5StackCore-Ink libraries.

c:\Users\john\Documents\Arduino\libraries\M5Core-Ink\src\utility\Speaker.cpp: In member function 'void SPEAKER::begin()':
c:\Users\john\Documents\Arduino\libraries\M5Core-Ink\src\utility\Speaker.cpp:10:5: error: 'ledcSetup' was not declared in this scope
   10 |     ledcSetup(TONE_PIN_CHANNEL, 0, 13);
      |     ^~~~~~~~~
c:\Users\john\Documents\Arduino\libraries\M5Core-Ink\src\utility\Speaker.cpp:11:5: error: 'ledcAttachPin' was not declared in this scope; did you mean 'ledcAttach'?
   11 |     ledcAttachPin(SPEAKER_PIN, TONE_PIN_CHANNEL);
      |     ^~~~~~~~~~~~~
      |     ledcAttach
c:\Users\john\Documents\Arduino\libraries\M5Core-Ink\src\utility\Speaker.cpp: In member function 'void SPEAKER::end()':
c:\Users\john\Documents\Arduino\libraries\M5Core-Ink\src\utility\Speaker.cpp:17:5: error: 'ledcDetachPin' was not declared in this scope; did you mean 'ledcDetach'?
   17 |     ledcDetachPin(SPEAKER_PIN);
      |     ^~~~~~~~~~~~~
      |     ledcDetach
c:\Users\john\Documents\Arduino\libraries\M5Core-Ink\src\utility\Speaker.cpp: In member function 'void SPEAKER::playMusic(const uint8_t*, uint16_t)':
c:\Users\john\Documents\Arduino\libraries\M5Core-Ink\src\utility\Speaker.cpp:79:5: error: 'ledcAttachPin' was not declared in this scope; did you mean 'ledcAttach'?
   79 |     ledcAttachPin(SPEAKER_PIN, TONE_PIN_CHANNEL);
      |     ^~~~~~~~~~~~~
      |     ledcAttach
c:\Users\john\Documents\Arduino\libraries\M5Core-Ink\src\utility\BM8563.cpp: In member function 'uint8_t RTC::byteToBcd2(uint8_t)':
c:\Users\john\Documents\Arduino\libraries\M5Core-Ink\src\utility\BM8563.cpp:66:10: error: 'uint_fast8_t' is not a member of 'std'; did you mean 'uint_fast8_t'?
   66 |     std::uint_fast8_t bcdhigh = value / 10;
      |          ^~~~~~~~~~~~
In file included from c:\users\john\appdata\local\arduino15\packages\esp32\tools\esp-x32\2302\lib\gcc\xtensa-esp32-elf\12.2.0\include\stdint.h:9,
                 from C:\Users\john\AppData\Local\Arduino15\packages\esp32\hardware\esp32\3.0.7\cores\esp32/esp32-hal.h:23,
                 from C:\Users\john\AppData\Local\Arduino15\packages\esp32\hardware\esp32\3.0.7\libraries\Wire\src/Wire.h:32,
                 from c:\Users\john\Documents\Arduino\libraries\M5Core-Ink\src\utility\BM8563.h:4,
                 from c:\Users\john\Documents\Arduino\libraries\M5Core-Ink\src\utility\BM8563.cpp:1:
c:\users\john\appdata\local\arduino15\packages\esp32\tools\esp-x32\2302\xtensa-esp32-elf\sys-include\stdint.h:52:31: note: 'uint_fast8_t' declared here
   52 |   typedef __UINT_FAST8_TYPE__ uint_fast8_t;
      |                               ^~~~~~~~~~~~
c:\Users\john\Documents\Arduino\libraries\M5Core-Ink\src\utility\BM8563.cpp:67:13: error: 'bcdhigh' was not declared in this scope
   67 |     return (bcdhigh << 4) | (value - (bcdhigh * 10));
      |             ^~~~~~~
c:\Users\john\Documents\Arduino\libraries\M5Core-Ink\src\utility\BM8563.cpp: In member function 'void RTC::SetDate(RTC_DateTypeDef*)':
c:\Users\john\Documents\Arduino\libraries\M5Core-Ink\src\utility\BM8563.cpp:105:28: error: 'uint8_t' is not a member of 'std'; did you mean 'uint8_t'?
  105 |                      (std::uint8_t)(byteToBcd2(RTC_DateStruct->Month) +
      |                            ^~~~~~~
In file included from c:\users\john\appdata\local\arduino15\packages\esp32\tools\esp-x32\2302\xtensa-esp32-elf\sys-include\stdint.h:14:
c:\users\john\appdata\local\arduino15\packages\esp32\tools\esp-x32\2302\xtensa-esp32-elf\sys-include\sys\_stdint.h:24:19: note: 'uint8_t' declared here
   24 | typedef __uint8_t uint8_t ;
      |                   ^~~~~~~
c:\Users\john\Documents\Arduino\libraries\M5Core-Ink\src\utility\BM8563.cpp: In member function 'int RTC::SetAlarmIRQ(int)':
c:\Users\john\Documents\Arduino\libraries\M5Core-Ink\src\utility\BM8563.cpp:113:10: error: 'uint8_t' is not a member of 'std'; did you mean 'uint8_t'?
  113 |     std::uint8_t reg_value = _i2c.readByte(BM8563_I2C_ADDR, 0x01) & ~0x0C;
      |          ^~~~~~~
c:\users\john\appdata\local\arduino15\packages\esp32\tools\esp-x32\2302\xtensa-esp32-elf\sys-include\sys\_stdint.h:24:19: note: 'uint8_t' declared here
   24 | typedef __uint8_t uint8_t ;
      |                   ^~~~~~~
c:\Users\john\Documents\Arduino\libraries\M5Core-Ink\src\utility\BM8563.cpp:116:47: error: 'reg_value' was not declared in this scope
  116 |         _i2c.writeByte(BM8563_I2C_ADDR, 0x01, reg_value & ~0x01);
      |                                               ^~~~~~~~~
c:\Users\john\Documents\Arduino\libraries\M5Core-Ink\src\utility\BM8563.cpp:122:10: error: 'uint8_t' is not a member of 'std'; did you mean 'uint8_t'?
  122 |     std::uint8_t type_value = 0x82;
      |          ^~~~~~~
c:\users\john\appdata\local\arduino15\packages\esp32\tools\esp-x32\2302\xtensa-esp32-elf\sys-include\sys\_stdint.h:24:19: note: 'uint8_t' declared here
   24 | typedef __uint8_t uint8_t ;
      |                   ^~~~~~~
c:\Users\john\Documents\Arduino\libraries\M5Core-Ink\src\utility\BM8563.cpp:133:9: error: 'type_value' was not declared in this scope; did you mean 'typename'?
  133 |         type_value = 0x83;
      |         ^~~~~~~~~~
      |         typename
c:\Users\john\Documents\Arduino\libraries\M5Core-Ink\src\utility\BM8563.cpp:136:43: error: 'type_value' was not declared in this scope; did you mean 'typename'?
  136 |     _i2c.writeByte(BM8563_I2C_ADDR, 0x0E, type_value);
      |                                           ^~~~~~~~~~
      |                                           typename
c:\Users\john\Documents\Arduino\libraries\M5Core-Ink\src\utility\BM8563.cpp:138:44: error: 'reg_value' was not declared in this scope
  138 |     _i2c.writeByte(BM8563_I2C_ADDR, 0x01, (reg_value | 0x01) & ~0x80);
      |                                            ^~~~~~~~~
c:\Users\john\Documents\Arduino\libraries\M5Core-Ink\src\utility\BM8563.cpp: In member function 'void RTC::disableIRQ()':
c:\Users\john\Documents\Arduino\libraries\M5Core-Ink\src\utility\BM8563.cpp:222:33: error: 'uint8_t' in namespace 'std' does not name a type
  222 |     static constexpr const std::uint8_t buf[4] = {0x80, 0x80, 0x80, 0x80};
      |                                 ^~~~~~~
c:\Users\john\Documents\Arduino\libraries\M5Core-Ink\src\utility\BM8563.cpp:223:55: error: 'buf' was not declared in this scope
  223 |     _i2c.writeBytes(BM8563_I2C_ADDR, 0x09, (uint8_t *)buf, 4);
      |                                                       ^~~

exit status 1

Compilation error: exit status 1
johnwargo commented 3 weeks ago

I decided to start over from scratch and deleted all of the M5Stack libraries from the IDE. Next, I restated the Arduino IDE and installed the M5Stack library as you described in the instructions. When I compile the sketch after the library installation, I get the following error:

D:\dev\hardware\M5Stack\KeychainSkimmerScanner\main\main.ino:9:10: fatal error: M5CoreInk.h: No such file or directory
    9 | #include "M5CoreInk.h"
      |          ^~~~~~~~~~~~~
compilation terminated.
exit status 1

Compilation error: M5CoreInk.h: No such file or directory

So I added the M5Core-Ink library to my Arduino IDE configuration and got the error messages shown above.

Can you please share how you were able to compile this sketch?

b-morgan commented 2 weeks ago

I'm having the exact same problem.

F:\KeychainSkimmerScanner\KeychainSkimmerScanner.ino:10:10: fatal error: M5CoreInk.h: No such file or directory
 #include "M5CoreInk.h"
          ^~~~~~~~~~~~~
compilation terminated.
exit status 1

Compilation error: M5CoreInk.h: No such file or directory
b-morgan commented 2 weeks ago

I believe there is a missing step in the README posted here. Go to the Library Manager and install the M5Core-Ink library.

I found https://docs.m5stack.com/en/arduino/m5coreink/program which lays out the process in more detail.

johnwargo commented 2 weeks ago

@b-morgan if you read my notes you'll see that I've already tried installing the M5Core-Ink library.

https://github.com/kevinl95/KeychainSkimmerScanner/issues/4#issuecomment-2439668427

I tried it with just the M5 libraries, just the M5Core-Ink, and with both installed. I doesn't compile in any of those scenarios.

Which libraries did you install? You can get it to compile fully and deploy?

In my comment here: https://github.com/kevinl95/KeychainSkimmerScanner/issues/4#issue-2616013195 I see a bunch of errors in the M5Core-Ink library which is what's causing my compilation errors. IT's like there are missing functions in the code and it hasn't been touched in two months.

b-morgan commented 2 weeks ago

Sorry, I missed that you already tried M5-CoreInk.

Using this document, I installed M5Core-Ink, M5GFX, and M5Unified.

The Git repository for M5Core-Ink has comments on the library.json and library.properties that say "release 1.0.0 depends M5GFX" so I installed it manually.

In the Arduino IDE (2.3.3) File, Examples I can scroll (way) down under "Examples from Custom Libraries" and find "M5-Core-Ink" as shown below. I compiled and uploaded a few of the basic examples and when they all worked, I compiled and uploaded this sketch (after renaming main.ino).

I also purchased the HC-05 and HC-06 Bluetooth modules and used an existing 5V source to test the code and it works.

image

johnwargo commented 1 week ago

M5GFX is already part of the M5Core-Ink Library (See screenshot) image

johnwargo commented 1 week ago

After deleting all M5Stack libraries from the libraries folder then launching the Arduino IDE, I installed the M5Core-Ink library again and it still fails with the same errors even though the M5GFX library is installed and is at the latest version.

There's functions missing from Speaker.cpp and I assume they're now in M5GFX, but @b-morgan what's different in your config and mine? I can't even compile the Factory Test sketch.

Installed are:

image

D:\dev\hardware\M5Stack\KeychainSkimmerScanner\KeychainSkimmerScanner.ino: In function 'void Scan()':
D:\dev\hardware\M5Stack\KeychainSkimmerScanner\KeychainSkimmerScanner.ino:76:34: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
   76 |         if (StrContains(success, "HC-05") == 1) {
      |                                  ^~~~~~~
D:\dev\hardware\M5Stack\KeychainSkimmerScanner\KeychainSkimmerScanner.ino:78:41: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
   78 |         } else if (StrContains(success, "HC-06") == 1) {
      |                                         ^~~~~~~
D:\dev\hardware\M5Stack\KeychainSkimmerScanner\KeychainSkimmerScanner.ino:80:41: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
   80 |         } else if (StrContains(success, "Name: , ") == 1) {
      |                                         ^~~~~~~~~~
c:\Users\john\Documents\Arduino\libraries\M5Core-Ink\src\utility\Speaker.cpp: In member function 'void SPEAKER::begin()':
c:\Users\john\Documents\Arduino\libraries\M5Core-Ink\src\utility\Speaker.cpp:10:5: error: 'ledcSetup' was not declared in this scope
   10 |     ledcSetup(TONE_PIN_CHANNEL, 0, 13);
      |     ^~~~~~~~~
c:\Users\john\Documents\Arduino\libraries\M5Core-Ink\src\utility\Speaker.cpp:11:5: error: 'ledcAttachPin' was not declared in this scope; did you mean 'ledcAttach'?
   11 |     ledcAttachPin(SPEAKER_PIN, TONE_PIN_CHANNEL);
      |     ^~~~~~~~~~~~~
      |     ledcAttach
c:\Users\john\Documents\Arduino\libraries\M5Core-Ink\src\utility\Speaker.cpp: In member function 'void SPEAKER::end()':
c:\Users\john\Documents\Arduino\libraries\M5Core-Ink\src\utility\Speaker.cpp:17:5: error: 'ledcDetachPin' was not declared in this scope; did you mean 'ledcDetach'?
   17 |     ledcDetachPin(SPEAKER_PIN);
      |     ^~~~~~~~~~~~~
      |     ledcDetach
c:\Users\john\Documents\Arduino\libraries\M5Core-Ink\src\utility\Speaker.cpp: In member function 'void SPEAKER::playMusic(const uint8_t*, uint16_t)':
c:\Users\john\Documents\Arduino\libraries\M5Core-Ink\src\utility\Speaker.cpp:79:5: error: 'ledcAttachPin' was not declared in this scope; did you mean 'ledcAttach'?
   79 |     ledcAttachPin(SPEAKER_PIN, TONE_PIN_CHANNEL);
      |     ^~~~~~~~~~~~~
      |     ledcAttach
c:\Users\john\Documents\Arduino\libraries\M5Core-Ink\src\utility\BM8563.cpp: In member function 'uint8_t RTC::byteToBcd2(uint8_t)':
c:\Users\john\Documents\Arduino\libraries\M5Core-Ink\src\utility\BM8563.cpp:66:10: error: 'uint_fast8_t' is not a member of 'std'; did you mean 'uint_fast8_t'?
   66 |     std::uint_fast8_t bcdhigh = value / 10;
      |          ^~~~~~~~~~~~
In file included from c:\users\john\appdata\local\arduino15\packages\esp32\tools\esp-x32\2302\lib\gcc\xtensa-esp32-elf\12.2.0\include\stdint.h:9,
                 from C:\Users\john\AppData\Local\Arduino15\packages\esp32\hardware\esp32\3.0.7\cores\esp32/esp32-hal.h:23,
                 from C:\Users\john\AppData\Local\Arduino15\packages\esp32\hardware\esp32\3.0.7\libraries\Wire\src/Wire.h:32,
                 from c:\Users\john\Documents\Arduino\libraries\M5Core-Ink\src\utility\BM8563.h:4,
                 from c:\Users\john\Documents\Arduino\libraries\M5Core-Ink\src\utility\BM8563.cpp:1:
c:\users\john\appdata\local\arduino15\packages\esp32\tools\esp-x32\2302\xtensa-esp32-elf\sys-include\stdint.h:52:31: note: 'uint_fast8_t' declared here
   52 |   typedef __UINT_FAST8_TYPE__ uint_fast8_t;
      |                               ^~~~~~~~~~~~
c:\Users\john\Documents\Arduino\libraries\M5Core-Ink\src\utility\BM8563.cpp:67:13: error: 'bcdhigh' was not declared in this scope
   67 |     return (bcdhigh << 4) | (value - (bcdhigh * 10));
      |             ^~~~~~~
c:\Users\john\Documents\Arduino\libraries\M5Core-Ink\src\utility\BM8563.cpp: In member function 'void RTC::SetDate(RTC_DateTypeDef*)':
c:\Users\john\Documents\Arduino\libraries\M5Core-Ink\src\utility\BM8563.cpp:105:28: error: 'uint8_t' is not a member of 'std'; did you mean 'uint8_t'?
  105 |                      (std::uint8_t)(byteToBcd2(RTC_DateStruct->Month) +
      |                            ^~~~~~~
In file included from c:\users\john\appdata\local\arduino15\packages\esp32\tools\esp-x32\2302\xtensa-esp32-elf\sys-include\stdint.h:14:
c:\users\john\appdata\local\arduino15\packages\esp32\tools\esp-x32\2302\xtensa-esp32-elf\sys-include\sys\_stdint.h:24:19: note: 'uint8_t' declared here
   24 | typedef __uint8_t uint8_t ;
      |                   ^~~~~~~
c:\Users\john\Documents\Arduino\libraries\M5Core-Ink\src\utility\BM8563.cpp: In member function 'int RTC::SetAlarmIRQ(int)':
c:\Users\john\Documents\Arduino\libraries\M5Core-Ink\src\utility\BM8563.cpp:113:10: error: 'uint8_t' is not a member of 'std'; did you mean 'uint8_t'?
  113 |     std::uint8_t reg_value = _i2c.readByte(BM8563_I2C_ADDR, 0x01) & ~0x0C;
      |          ^~~~~~~
c:\users\john\appdata\local\arduino15\packages\esp32\tools\esp-x32\2302\xtensa-esp32-elf\sys-include\sys\_stdint.h:24:19: note: 'uint8_t' declared here
   24 | typedef __uint8_t uint8_t ;
      |                   ^~~~~~~
c:\Users\john\Documents\Arduino\libraries\M5Core-Ink\src\utility\BM8563.cpp:116:47: error: 'reg_value' was not declared in this scope
  116 |         _i2c.writeByte(BM8563_I2C_ADDR, 0x01, reg_value & ~0x01);
      |                                               ^~~~~~~~~
c:\Users\john\Documents\Arduino\libraries\M5Core-Ink\src\utility\BM8563.cpp:122:10: error: 'uint8_t' is not a member of 'std'; did you mean 'uint8_t'?
  122 |     std::uint8_t type_value = 0x82;
      |          ^~~~~~~
c:\users\john\appdata\local\arduino15\packages\esp32\tools\esp-x32\2302\xtensa-esp32-elf\sys-include\sys\_stdint.h:24:19: note: 'uint8_t' declared here
   24 | typedef __uint8_t uint8_t ;
      |                   ^~~~~~~
c:\Users\john\Documents\Arduino\libraries\M5Core-Ink\src\utility\BM8563.cpp:133:9: error: 'type_value' was not declared in this scope; did you mean 'typename'?
  133 |         type_value = 0x83;
      |         ^~~~~~~~~~
      |         typename
c:\Users\john\Documents\Arduino\libraries\M5Core-Ink\src\utility\BM8563.cpp:136:43: error: 'type_value' was not declared in this scope; did you mean 'typename'?
  136 |     _i2c.writeByte(BM8563_I2C_ADDR, 0x0E, type_value);
      |                                           ^~~~~~~~~~
      |                                           typename
c:\Users\john\Documents\Arduino\libraries\M5Core-Ink\src\utility\BM8563.cpp:138:44: error: 'reg_value' was not declared in this scope
  138 |     _i2c.writeByte(BM8563_I2C_ADDR, 0x01, (reg_value | 0x01) & ~0x80);
      |                                            ^~~~~~~~~
c:\Users\john\Documents\Arduino\libraries\M5Core-Ink\src\utility\BM8563.cpp: In member function 'void RTC::disableIRQ()':
c:\Users\john\Documents\Arduino\libraries\M5Core-Ink\src\utility\BM8563.cpp:222:33: error: 'uint8_t' in namespace 'std' does not name a type
  222 |     static constexpr const std::uint8_t buf[4] = {0x80, 0x80, 0x80, 0x80};
      |                                 ^~~~~~~
c:\Users\john\Documents\Arduino\libraries\M5Core-Ink\src\utility\BM8563.cpp:223:55: error: 'buf' was not declared in this scope
  223 |     _i2c.writeBytes(BM8563_I2C_ADDR, 0x09, (uint8_t *)buf, 4);
      |                                                       ^~~

exit status 1

Compilation error: exit status 1
b-morgan commented 1 week ago

The M5Core-Ink is not my first ESP32 device. I added the two URLs "https://dl.espressif.com/dl/package_esp32_index.json" and "https://static-cdn.m5stack.com/resource/arduino/package_m5stack_index.json" to the end of my string.

I started over on a different computer, installed Arduino IDE 2.3.3, and followed the instructions in the README.md. I didn't have to manually install any additional libraries or boards. I have the same versions of M5Core-Ink, M5Unified, and M5GFX as you have.

I successfully compiled and uploaded both my KeychainSkimmerScanner and the FactoryTest example.

Obviously, there's something different between your system and mine (both of them). I'm not sure how to proceed from here.

Here is a zip of my Documents\Arduino folder from the fresh install I did today.

kevinl95 commented 1 week ago

Good morning, Sorry for not seeing this when you first posted and thanks a ton to you both for the debugging you've done here. I am spinning up a VM with a clean install of the Arduino IDE and will be going over the steps from the beginning to see where things may have diverged. Sorry for the trouble!

kevinl95 commented 1 week ago

The instructions were definitely missing the installation step for M5Core-Ink- I must have had it from a previous project and I have updated the README and Instructable accordingly.

As for the issue at hand, one thing I have been able to figure out is that there were breaking changes when the esp32 boards platform was updated to 3.0.0. This explains errors like you're seeing in speaker.cpp such as "error: 'ledcAttachPin' was not declared in this scope; did you mean 'ledcAttach'?". See: https://docs.espressif.com/projects/arduino-esp32/en/latest/migration_guides/2.x_to_3.0.html

Do you also have esp32 installed via Board Manager? Could you temporarily remove it or downgrade it to see if maybe conflicting definitions are causing these errors?

kevinl95 commented 1 week ago

Answering your question about the warnings- I did not see those warnings but they are legitimate. StrContains now accepts const char* arguments which resolves the warnings and makes the function more robust.