gicking / LIN_master_portable_Arduino

Portable LIN Master Node Emulation for Arduino
MIT License
10 stars 2 forks source link

ESP32 linker error for LIN_SoftwareSerial_Blocking.ino #4

Open gicking opened 3 weeks ago

gicking commented 3 weeks ago

on behalf of Mario M.

So far, I have successfully tested your LIN_master_HardwareSerial_ESP32 and LIN_SlaveHardwareSerial_ESP32 working together, and both seem to function well as far as I can see. However, I haven't yet adapted them for my application.

Now, I would like to test the LIN server with software serial.

On my ESP32, one serial interface is already occupied, and I want to implement a LIN master and a LIN slave. Although I could reassign Serial Interface 0 to other ports, I would then lose the serial monitor for debugging purposes.

To get straight to the point: unfortunately, I am unable to compile and link LIN_SoftwareSerial_Blocking.ino. The following error message appears:

c:/users/admin/appdata/local/arduino15/packages/esp32/tools/esp-x32/2302/bin/../lib/gcc/xtensa-esp32-elf/12.2.0/../../../../xtensa-esp32-elf/bin/ld.exe: C:\Users\Admin\AppData\Local\Temp\arduino\sketches\0D5AC09792D58F187C9C5846DA3B6AE5\sketch\LIN_SoftwareSerial_Blocking.ino.cpp.o:(.literal.startup._GLOBAL__sub_I_LIN+0x4): undefined reference to `LIN_Master_SoftwareSerial::LIN_Master_SoftwareSerial(unsigned char, unsigned char, bool, char const*)'

c:/users/admin/appdata/local/arduino15/packages/esp32/tools/esp-x32/2302/bin/../lib/gcc/xtensa-esp32-elf/12.2.0/../../../../xtensa-esp32-elf/bin/ld.exe: C:\Users\Admin\AppData\Local\Temp\arduino\sketches\0D5AC09792D58F187C9C5846DA3B6AE5\sketch\LIN_SoftwareSerial_Blocking.ino.cpp.o:(.literal._Z5setupv+0x8): undefined reference to `LIN_Master_SoftwareSerial::begin(unsigned short)'

c:/users/admin/appdata/local/arduino15/packages/esp32/tools/esp-x32/2302/bin/../lib/gcc/xtensa-esp32-elf/12.2.0/../../../../xtensa-esp32-elf/bin/ld.exe: C:\Users\Admin\AppData\Local\Temp\arduino\sketches\0D5AC09792D58F187C9C5846DA3B6AE5\sketch\LIN_SoftwareSerial_Blocking.ino.cpp.o: in function `_GLOBAL__sub_I_LIN':

E:\mdm\Projekte\Arduino\LIN_SoftwareSerial_Blocking/LIN_SoftwareSerial_Blocking.ino:118: undefined reference to `LIN_Master_SoftwareSerial::LIN_Master_SoftwareSerial(unsigned char, unsigned char, bool, char const*)'

c:/users/admin/appdata/local/arduino15/packages/esp32/tools/esp-x32/2302/bin/../lib/gcc/xtensa-esp32-elf/12.2.0/../../../../xtensa-esp32-elf/bin/ld.exe: C:\Users\Admin\AppData\Local\Temp\arduino\sketches\0D5AC09792D58F187C9C5846DA3B6AE5\sketch\LIN_SoftwareSerial_Blocking.ino.cpp.o: in function `setup()':

E:\mdm\Projekte\Arduino\LIN_SoftwareSerial_Blocking/LIN_SoftwareSerial_Blocking.ino:154: undefined reference to `LIN_Master_SoftwareSerial::begin(unsigned short)'

collect2.exe: error: ld returned 1 exit status

exit status 1

Compilation error: exit status 1

I’ve tried many things; it seems there’s some issue with linking. In the lines referenced, LIN_SoftwareSerial_Blocking.ino:118 and LIN_SoftwareSerial_Blocking.ino:154, I don’t see a connection to LIN_Master_SoftwareSerial:: …. I’ve checked the relevant libraries, tried everything on a second Windows machine as well, and used both Arduino IDE versions 2.3.3 and 1.8.19. I also updated the ESP32 libraries. My searches online didn’t yield any helpful information either.

Do you have any ideas on this issue, or have you encountered it yourself? I’d be very grateful for any helpful tips.

gicking commented 3 weeks ago

hello Mario,

thanks for reporting this bug and for using my lib!

Here my status

  1. build LIN_SoftwareSerial_Blocking.ino from this repo for ESP32 -> same linker error
  2. build LIN_SoftwareSerial_Blocking.ino for Mega, ESP8266 and Adafruit Trinket (=all other boards I own) -> no error
  3. build LIN_HardwareSerial_ESP32_Blocking.ino for ESP32 -> no error
  4. SoftwareSerial for ESP is via library EspSoftwareSerial. Re-installed v8.1.0 via IDE library manager -> still linker error for LIN_SoftwareSerial_Blocking.ino
  5. Aaaarrrggghhhh!!!! Found it - stupido! Please check line 10 in src/LIN_master_SoftwareSerial.cpp --> there ESP32 is specifically commented out... Including it solves the problem
  6. As SoftwareSerial is available for most architectures, I have now deleted this line

Ok, I just uploaded the fix to Github. Before I trigger a new release, can you please download and install it manually, and tell me if it solves your issue? Thanks a lot in advance!

Btw, to avoid mixup with my recently started LIN slave repo (not yet ready!), I have renamed all examples to include "master" and "slave" in the filenames, respectively.

Georg

pulmol commented 3 weeks ago

Hello Georg, The speed with which you reacted to the problem and provided a solution is phenomenal. Thank you very much for that! I downloaded your current files and came to the following conclusion:

  1. LIN_master_SWSerial_Blk.ino can now be compiled and linked without any problems. After a small change in line 123 (_error = LIN.receiveSlaveResponseBlocking(LIN_Master::LINV2, 0x05, 6, Data);) the interaction with the LIN slave HWserial also works, because it only sends 6 bytes!
  2. The LIN_master_HWSerial_ESP32_Blk also works with the LIN slave after this change and a slightly shorter pause in line 23 (#define LIN_PAUSE 80)!

Now I will start adapting it for my planned application.

Thank you very much for your excellent work!

Ciao Mario

gicking commented 3 weeks ago

Hi Mario,

ad 1) the examples are not yet synchronized, so the number of data bytes don't match btw. master & slave. As said, the LIN slave library is work in progress and not yet released. Good to hear it works for you!

ad 2) I guess that comes from the overhead by SoftwareSerial. I will look into it when I have sorted out the other issues

Good luck and have fun, Georg