Skip to content

Update RS485.h #58

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

bohnelang
Copy link

@bohnelang bohnelang commented Apr 23, 2025

Compilation of the library for an ESP32 board fails:

c:\Users\foo\Documents\Arduino\libraries\ArduinoRS485\src\RS485.cpp:209:18: error: 'SERIAL_PORT_HARDWARE' was not declared in this scope
  209 | RS485Class RS485(SERIAL_PORT_HARDWARE, RS485_DEFAULT_TX_PIN, RS485_DEFAULT_DE_PIN, RS485_DEFAULT_RE_PIN);
      |                  ^~~~~~~~~~~~~~~~~~~~

The library only provides a definition of the SERIAL_PORT_HARDWARE macro when compiling for the UNO R4 Minima or UNO R4 WiFi boards:

ArduinoRS485/src/RS485.h

Lines 42 to 43 in 22829af

#elif defined(ARDUINO_UNOR4_WIFI) || defined(ARDUINO_UNOR4_MINIMA)
#define SERIAL_PORT_HARDWARE Serial1

It is expected that the core variant of all other boards will provide a definition of the macro. This is the case for all boards which the library explicitly supports, but not so for some other boards.

I propose to hardcode a definition of SERIAL_PORT_HARDWARE into the library, to allow it to compile for all boards.

Compiling ModbusLib on an ESP32 board stopp compiling on an compiling error RS485.cpp with  SERIAL_PORT_HARDWARE is not defined.

Here in RS485.cpp is:
#ifdef RS485_SERIAL_PORT
RS485Class RS485(RS485_SERIAL_PORT, RS485_DEFAULT_TX_PIN, RS485_DEFAULT_DE_PIN, RS485_DEFAULT_RE_PIN);
#else
RS485Class RS485(SERIAL_PORT_HARDWARE, RS485_DEFAULT_TX_PIN, RS485_DEFAULT_DE_PIN, RS485_DEFAULT_RE_PIN);
#endif

Thus SERIAL_PORT_HARDWARE should be defined anyhow independently in RS485.h .
@CLAassistant
Copy link

CLAassistant commented Apr 23, 2025

CLA assistant check
All committers have signed the CLA.

Copy link

Memory usage change @ 612ab7d

Board flash % RAM for global variables %
arduino:mbed_portenta:envie_m7 N/A N/A N/A N/A
arduino:samd:mkr1000 0 - 0 0.0 - 0.0 0 - 0 0.0 - 0.0
arduino:samd:mkrfox1200 0 - 0 0.0 - 0.0 0 - 0 0.0 - 0.0
arduino:samd:mkrgsm1400 0 - 0 0.0 - 0.0 0 - 0 0.0 - 0.0
arduino:samd:mkrnb1500 0 - 0 0.0 - 0.0 0 - 0 0.0 - 0.0
arduino:samd:mkrvidor4000 0 - 0 0.0 - 0.0 0 - 0 0.0 - 0.0
arduino:samd:mkrwan1300 0 - 0 0.0 - 0.0 0 - 0 0.0 - 0.0
arduino:samd:mkrwan1310 0 - 0 0.0 - 0.0 0 - 0 0.0 - 0.0
arduino:samd:mkrwifi1010 0 - 0 0.0 - 0.0 0 - 0 0.0 - 0.0
arduino:samd:mkrzero 0 - 0 0.0 - 0.0 0 - 0 0.0 - 0.0
arduino:mbed_opta:opta 0 - 0 0.0 - 0.0 0 - 0 0.0 - 0.0
Click for full report table
Board examples/RS485Passthrough
flash
% examples/RS485Passthrough
RAM for global variables
% examples/RS485Receiver
flash
% examples/RS485Receiver
RAM for global variables
% examples/RS485Sender
flash
% examples/RS485Sender
RAM for global variables
%
arduino:mbed_portenta:envie_m7 N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A
arduino:samd:mkr1000 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0
arduino:samd:mkrfox1200 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0
arduino:samd:mkrgsm1400 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0
arduino:samd:mkrnb1500 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0
arduino:samd:mkrvidor4000 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0
arduino:samd:mkrwan1300 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0
arduino:samd:mkrwan1310 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0
arduino:samd:mkrwifi1010 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0
arduino:samd:mkrzero 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0
arduino:mbed_opta:opta 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0
Click for full report CSV
Board,examples/RS485Passthrough<br>flash,%,examples/RS485Passthrough<br>RAM for global variables,%,examples/RS485Receiver<br>flash,%,examples/RS485Receiver<br>RAM for global variables,%,examples/RS485Sender<br>flash,%,examples/RS485Sender<br>RAM for global variables,%
arduino:mbed_portenta:envie_m7,N/A,N/A,N/A,N/A,N/A,N/A,N/A,N/A,N/A,N/A,N/A,N/A
arduino:samd:mkr1000,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0
arduino:samd:mkrfox1200,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0
arduino:samd:mkrgsm1400,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0
arduino:samd:mkrnb1500,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0
arduino:samd:mkrvidor4000,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0
arduino:samd:mkrwan1300,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0
arduino:samd:mkrwan1310,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0
arduino:samd:mkrwifi1010,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0
arduino:samd:mkrzero,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0
arduino:mbed_opta:opta,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0

@per1234 per1234 added type: enhancement Proposed improvement topic: code Related to content of the project itself labels Apr 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic: code Related to content of the project itself type: enhancement Proposed improvement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants