Skip to content

Commit f953240

Browse files
committed
v1.0.13
* Fixed Mega 2560 compatibility issue.
1 parent e44a944 commit f953240

File tree

8 files changed

+58
-19
lines changed

8 files changed

+58
-19
lines changed

Changes.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,13 @@
33

44
Changelog for the `CSE_ArduinoRS485` library. Latest entries are at the top.
55

6+
#
7+
### **+05:30 08:31:31 PM 30-06-2024, Sunday**
8+
9+
* Added new platform/board checking preprocessor section to enable the SoftrwareSerial library. Some AVR boards like Mega 2560 have multiple harware serial ports and therefore shouldn't be using the SoftwareSerial library. The new changes fix this issue.
10+
* The examples are compiling for Uno, Mega 2560 and ESP32 DevKit.
11+
* New Revision `v1.0.13`.
12+
613
#
714
### **+05:30 12:34:00 AM 21-05-2024, Tuesday**
815

README.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
:repository-owner: CIRCUITSTATE
22
:repository-name: CSE_ArduinoRS485
3-
:repository-version: 1.0.12
3+
:repository-version: 1.0.13
44

55
image::https://socialify.git.ci/CIRCUITSTATE/CSE_ArduinoRS485/image?description=1&font=KoHo&forks=1&issues=1&logo=https%3A%2F%2Fwww.circuitstate.com%2Fwp-content%2Fuploads%2F2024%2F05%2FCIRCUITSTATE-R-Emblem-20052024-2.svg&name=1&pattern=Circuit%20Board&pulls=1&stargazers=1&theme=Auto[CSE_ArduinoRS485]
66

examples/RS485_Receiver/RS485_Receiver.ino

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,10 @@
1111

1212
#include <CSE_ArduinoRS485.h>
1313

14-
// Declare the RS485 interface here with a hardware serial port.
15-
// RS485Class RS485 (Serial1, 2, 3, 4); // DE, RE, TX
14+
// If you want to use a software serial port, uncomment the following line.
15+
// SoftwareSerial Serial1 (10, 11); // RX, TX
1616

17-
// If you want to use a software serial port, declare it here,
18-
// comment out the previous declaration, and uncomment this section.
19-
SoftwareSerial Serial1 (10, 11); // RX, TX
17+
// For using Hardware serial ports, the following line is enough.
2018
RS485Class RS485 (Serial1, 2, 3, 4); // DE, RE, TX
2119

2220
void setup() {

examples/RS485_Sender/RS485_Sender.ino

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,10 @@
1313

1414
int counter = 0;
1515

16-
// Declare the RS485 interface here with a hardware serial port.
17-
// RS485Class RS485 (Serial1, 2, 3, 4); // DE, RE, TX
18-
19-
// If you want to use a software serial port, declare it here,
20-
// comment out the previous declaration, and uncomment this section.
16+
// If you want to use a software serial port, uncomment the following line.
2117
SoftwareSerial Serial1 (10, 11); // RX, TX
18+
19+
// For using Hardware serial ports, the following line is enough.
2220
RS485Class RS485 (Serial1, 2, 3, 4); // DE, RE, TX
2321

2422
void setup() {

library.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"url": "https://github.com/CIRCUITSTATE",
1414
"maintainer": true
1515
},
16-
"version": "1.0.12",
16+
"version": "1.0.13",
1717
"license": "LGPL-2.1",
1818
"frameworks": "arduino",
1919
"platforms": "*"

library.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name=CSE_ArduinoRS485
2-
version=1.0.12
2+
version=1.0.13
33
author=CIRCUITSTATE
44
maintainer=CIRCUITSTATE <@circuitstate>
55
sentence=Allows sending and receiving data through the RS-485 interface, using any Arduino-compatible boards.

src/CSE_RS485.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@
2020
*/
2121
//===================================================================================//
2222

23-
// Version: 1.0.12
24-
// Last modified: +05:30 15:08:03 PM 28-01-2024, Sunday
23+
// Version: 1.0.13
24+
// Last modified: +05:30 21:11:24 PM 30-06-2024, Sunday
2525
// Source: https://github.com/CIRCUITSTATE/CSE_ArduinoRS485
2626

2727
//===================================================================================//

src/CSE_RS485.h

Lines changed: 40 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@
2020
*/
2121
//===================================================================================//
2222

23-
// Version: 1.0.12
24-
// Last modified: +05:30 15:03:34 PM 28-01-2024, Sunday
23+
// Version: 1.0.13
24+
// Last modified: +05:30 21:11:21 PM 30-06-2024, Sunday
2525
// Source: https://github.com/CIRCUITSTATE/CSE_ArduinoRS485
2626

2727
//===================================================================================//
@@ -41,10 +41,46 @@
4141
// You can expand the software serial support here.
4242
// SoftwareSerial is required by boards like Arduino Uno and Nano which don't have a
4343
// dedicated secondary hardware serial port.
44-
#define SOFTWARE_SERIAL_REQUIRED defined(__AVR__) || defined(ARDUINO_ARCH_AVR) || defined(ESP8266)
44+
// #define SOFTWARE_SERIAL_REQUIRED defined(__AVR__) || defined(ARDUINO_ARCH_AVR) || defined(ESP8266)
45+
46+
// #if !defined(HAVE_HWSERIAL1) && !defined(HAVE_HWSERIAL2) && !defined(HAVE_HWSERIAL3) && !defined(HAVE_HWSERIAL4)
47+
// #define SOFTWARE_SERIAL_REQUIRED 1
48+
// #endif
49+
50+
// // Check if the user has defined the macro to control SoftwareSerial inclusion
51+
// #ifdef DISABLE_SOFTWARE_SERIAL
52+
// #define SOFTWARE_SERIAL_REQUIRED 0
53+
// #else
54+
// #define SOFTWARE_SERIAL_REQUIRED 1
55+
// #endif
56+
57+
// Define default values
58+
#define _HAVE_HWSERIAL1
59+
60+
// Check for specific architectures and boards
61+
#if defined(ARDUINO_AVR_UNO) || defined(ARDUINO_AVR_NANO)
62+
// Arduino Uno and Nano have only one hardware serial port
63+
#define _HAVE_HWSERIAL1
64+
#elif defined(ARDUINO_AVR_MEGA2560)
65+
// Arduino Mega has four hardware serial ports
66+
#define _HAVE_HWSERIAL1
67+
#define _HAVE_HWSERIAL2
68+
#define _HAVE_HWSERIAL3
69+
#define _HAVE_HWSERIAL4
70+
#elif defined(ARDUINO_ARCH_ESP32)
71+
// ESP32 typically has three hardware serial ports
72+
#define _HAVE_HWSERIAL1
73+
#define _HAVE_HWSERIAL2
74+
#define _HAVE_HWSERIAL3
75+
#endif
76+
77+
// Define a flag to include SoftwareSerial if no additional UARTs are available
78+
#if !defined(_HAVE_HWSERIAL2) && !defined(_HAVE_HWSERIAL3) && !defined(_HAVE_HWSERIAL4)
79+
#define SOFTWARE_SERIAL_REQUIRED 1
80+
#endif
4581

4682
// The SoftwareSerial is loaded automatically when required.
47-
#if SOFTWARE_SERIAL_REQUIRED
83+
#ifdef SOFTWARE_SERIAL_REQUIRED
4884
#include <SoftwareSerial.h>
4985
#endif
5086

0 commit comments

Comments
 (0)