Skip to content

Commit

Permalink
Merge branch 'arduino:master' into Feat/more-string-functions
Browse files Browse the repository at this point in the history
  • Loading branch information
PiotrekB416 authored Oct 1, 2023
2 parents 66ea405 + 65633ce commit 829215a
Show file tree
Hide file tree
Showing 87 changed files with 287 additions and 113 deletions.
25 changes: 25 additions & 0 deletions .github/ISSUE_TEMPLATE/api-deprecation.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
---
name: API deprecation
about: Suggest the deprecation of an API component defined by ArduinoCore-API.
title: ""
labels: enhancement
assignees: ""
---

### API component

<!-- Tell us which API component the deprecation applies to. -->

### Description

<!-- A clear and concise description of the suggestion. -->
<!-- What is the reason for the deprecation? -->

### Replacement API component

<!-- What should be used instead of the deprecated API component? -->
<!-- Is this replacement available to all users (e.g., is it provided by the C++ standard version used in major boards platforms)? -->

### Additional information

<!-- Add any other context for the suggestion here. -->
24 changes: 24 additions & 0 deletions .github/ISSUE_TEMPLATE/api-improvement.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
---
name: API improvement
about: Suggest an improvement to an existing API component.
title: ""
labels: enhancement
assignees: ""
---

### API component

<!-- Tell us which API component the improvement applies to. -->

### Description

<!-- A clear and concise description of the suggestion. -->

### Is this a breaking change?

<!-- Would this change require any users to change their code? -->
<!-- Would this change require any boards platform authors to change their configuration files or release system? -->

### Additional information

<!-- Add any other context for the request here. -->
29 changes: 29 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
---
name: Bug report
about: Report problems with the code in this repository.
title: ""
labels: bug
assignees: ""
---

### Description

<!-- A clear and concise description of the bug. -->

### Environment

- Boards platform name:
- Boards platform version (as shown in Boards Manager):
- ArduinoCore-API version (if you manually installed it):

### Current behavior

<!-- Provide a minimal sketch that demonstrates the issue. -->

### Expected behavior

<!-- Describe what you expect to happen when the demonstration sketch is run. -->

### Additional information

<!-- Add any other context about the problem here. -->
10 changes: 10 additions & 0 deletions .github/ISSUE_TEMPLATE/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
contact_links:
- name: Learn about the Arduino language
url: https://www.arduino.cc/reference/en
about: User documentation is available at the Arduino language reference.
- name: Support request
url: https://forum.arduino.cc/
about: We can help you out on the Arduino Forum!
- name: Discuss ArduinoCore-API development
url: https://groups.google.com/a/arduino.cc/g/developers
about: Arduino Developers Mailing List
15 changes: 15 additions & 0 deletions .github/ISSUE_TEMPLATE/new-api-component.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
name: New API component
about: Suggest the addition of a new API component to ArduinoCore-API.
title: ""
labels: enhancement
assignees: ""
---

### Description

<!-- A clear and concise description of the API component you want added. -->

### Additional information

<!-- Add any other context for the request here. -->
22 changes: 22 additions & 0 deletions .github/ISSUE_TEMPLATE/other-enhancement.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
---
name: Other enhancement
about:
Suggest an improvement for this project that doesn't fit in the specific categories
above.
title: ""
labels: enhancement
assignees: ""
---

### Description

<!-- A clear and concise description of the enhancement. -->

### Is this a breaking change?

<!-- Would this change require any users to change their code? -->
<!-- Would this change require any boards platform authors to change their configuration files or release system? -->

### Additional information

<!-- Add any other context for the request here. -->
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ As of now, the following official cores are utilising ArduinoCore-API:
* [megaavr](https://github.com/arduino/ArduinoCore-megaAVR)
* [mbed](https://github.com/arduino/ArduinoCore-mbed)
* [samd](https://github.com/arduino/ArduinoCore-samd)
* [renesas](https://github.com/arduino/ArduinoCore-renesas)

There's an ongoing effort to port the others, while maintainers of third-party cores are strongly invited to follow the same route in order to stay up-to-date with the new language features. For backwards compatibility, every revision of this repo will increase the `ARDUINO_API_VERSION` define.

Expand Down Expand Up @@ -77,6 +78,8 @@ In order to compile a core which is implementing ArduinoCore-API you'll need to
tar --exclude='*.git*' -cjhvf $yourcore-$version.tar.bz2 $yourcore/
```

The API is coded to the C++11 standard and the core's compiler must be able to support that version of the language.

Documentation for how to integrate with a Arduino core (which is necessary if you do not download the Arduino core via the Boards Manager) can be found here:
* [ArduinoCore-megaavr](https://github.com/arduino/ArduinoCore-megaavr#developing)
* [ArduinoCore-mbed](https://github.com/arduino/ArduinoCore-mbed#clone-the-repository-in-sketchbookhardwarearduino-git)
Expand Down
9 changes: 6 additions & 3 deletions api/CanMsg.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ class CanMsg : public Printable
, data_length{min(can_data_len, MAX_DATA_LENGTH)}
, data{0}
{
memcpy(data, can_data_ptr, data_length);
if (data_length && can_data_ptr)
memcpy(data, can_data_ptr, data_length);
}

CanMsg() : CanMsg(0, 0, nullptr) { }
Expand All @@ -54,7 +55,8 @@ class CanMsg : public Printable
{
this->id = other.id;
this->data_length = other.data_length;
memcpy(this->data, other.data, this->data_length);
if (this->data_length && other.data)
memcpy(this->data, other.data, this->data_length);
}

virtual ~CanMsg() { }
Expand All @@ -65,7 +67,8 @@ class CanMsg : public Printable
{
this->id = other.id;
this->data_length = other.data_length;
memcpy(this->data, other.data, this->data_length);
if (this->data_length && other.data)
memcpy(this->data, other.data, this->data_length);
}
return (*this);
}
Expand Down
4 changes: 2 additions & 2 deletions api/CanMsgRingbuffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ void CanMsgRingbuffer::enqueue(CanMsg const & msg)

_buf[_head] = msg;
_head = next(_head);
_num_elems++;
_num_elems = _num_elems + 1;
}

CanMsg CanMsgRingbuffer::dequeue()
Expand All @@ -50,7 +50,7 @@ CanMsg CanMsgRingbuffer::dequeue()

CanMsg const msg = _buf[_tail];
_tail = next(_tail);
_num_elems--;
_num_elems = _num_elems - 1;

return msg;
}
Expand Down
4 changes: 2 additions & 2 deletions api/IPAddress.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,14 +97,14 @@ IPAddress::IPAddress(const char *address)
String IPAddress::toString4() const
{
char szRet[16];
sprintf(szRet,"%u.%u.%u.%u", _address.bytes[IPADDRESS_V4_BYTES_INDEX], _address.bytes[IPADDRESS_V4_BYTES_INDEX + 1], _address.bytes[IPADDRESS_V4_BYTES_INDEX + 2], _address.bytes[IPADDRESS_V4_BYTES_INDEX + 3]);
snprintf(szRet, sizeof(szRet), "%u.%u.%u.%u", _address.bytes[IPADDRESS_V4_BYTES_INDEX], _address.bytes[IPADDRESS_V4_BYTES_INDEX + 1], _address.bytes[IPADDRESS_V4_BYTES_INDEX + 2], _address.bytes[IPADDRESS_V4_BYTES_INDEX + 3]);
return String(szRet);
}

String IPAddress::toString6() const
{
char szRet[40];
sprintf(szRet,"%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x",
snprintf(szRet, sizeof(szRet), "%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x",
_address.bytes[0], _address.bytes[1], _address.bytes[2], _address.bytes[3],
_address.bytes[4], _address.bytes[5], _address.bytes[6], _address.bytes[7],
_address.bytes[8], _address.bytes[9], _address.bytes[10], _address.bytes[11],
Expand Down
6 changes: 0 additions & 6 deletions api/String.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ String::String(const __FlashStringHelper *pstr)
*this = pstr;
}

#if __cplusplus >= 201103L || defined(__GXX_EXPERIMENTAL_CXX0X__)
String::String(String &&rval)
: buffer(rval.buffer)
, capacity(rval.capacity)
Expand All @@ -73,7 +72,6 @@ String::String(String &&rval)
rval.capacity = 0;
rval.len = 0;
}
#endif

String::String(char c)
{
Expand Down Expand Up @@ -213,7 +211,6 @@ String & String::copy(const __FlashStringHelper *pstr, unsigned int length)
return *this;
}

#if __cplusplus >= 201103L || defined(__GXX_EXPERIMENTAL_CXX0X__)
void String::move(String &rhs)
{
if (this != &rhs)
Expand All @@ -229,7 +226,6 @@ void String::move(String &rhs)
rhs.capacity = 0;
}
}
#endif

String & String::operator = (const String &rhs)
{
Expand All @@ -241,13 +237,11 @@ String & String::operator = (const String &rhs)
return *this;
}

#if __cplusplus >= 201103L || defined(__GXX_EXPERIMENTAL_CXX0X__)
String & String::operator = (String &&rval)
{
move(rval);
return *this;
}
#endif

String & String::operator = (const char *cstr)
{
Expand Down
6 changes: 0 additions & 6 deletions api/String.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,7 @@ class String
String(const uint8_t *cstr, unsigned int length) : String((const char*)cstr, length) {}
String(const String &str);
String(const __FlashStringHelper *str);
#if __cplusplus >= 201103L || defined(__GXX_EXPERIMENTAL_CXX0X__)
String(String &&rval);
#endif
explicit String(char c);
explicit String(unsigned char, unsigned char base=10);
explicit String(int, unsigned char base=10);
Expand All @@ -98,9 +96,7 @@ class String
String & operator = (const String &rhs);
String & operator = (const char *cstr);
String & operator = (const __FlashStringHelper *str);
#if __cplusplus >= 201103L || defined(__GXX_EXPERIMENTAL_CXX0X__)
String & operator = (String &&rval);
#endif

// concatenate (works w/ built-in types)

Expand Down Expand Up @@ -233,9 +229,7 @@ class String
// copy and move
String & copy(const char *cstr, unsigned int length);
String & copy(const __FlashStringHelper *pstr, unsigned int length);
#if __cplusplus >= 201103L || defined(__GXX_EXPERIMENTAL_CXX0X__)
void move(String &rhs);
#endif
};

class StringSumHelper : public String
Expand Down
3 changes: 3 additions & 0 deletions api/deprecated-avr-comp/avr/dtostrf.c.impl
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,12 @@
char *dtostrf (double val, signed char width, unsigned char prec, char *sout) {
asm(".global _printf_float");

#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
char fmt[20];
sprintf(fmt, "%%%d.%df", width, prec);
sprintf(sout, fmt, val);
return sout;
#pragma GCC diagnostic pop
}

4 changes: 3 additions & 1 deletion test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ project(test-ArduinoCore-API)

##########################################################################

include_directories(../api)
include_directories(..)
include_directories(include)
include_directories(external/catch/v2.13.9/include)

Expand All @@ -33,6 +33,7 @@ set(TEST_SRCS
src/CanMsg/test_isStandardId.cpp
src/CanMsg/test_operator_assignment.cpp
src/CanMsg/test_printTo.cpp
src/CanMsgRingbuffer/test_available.cpp
src/Common/test_makeWord.cpp
src/Common/test_map.cpp
src/Common/test_max.cpp
Expand Down Expand Up @@ -106,6 +107,7 @@ set(TEST_SRCS

set(TEST_DUT_SRCS
../api/CanMsg.cpp
../api/CanMsgRingbuffer.cpp
../api/Common.cpp
../api/IPAddress.cpp
../api/String.cpp
Expand Down
2 changes: 1 addition & 1 deletion test/include/MillisFake.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* INCLUDE
**************************************************************************************/

#include <Common.h>
#include <api/Common.h>

/**************************************************************************************
* FUNCTION DECLARATION
Expand Down
2 changes: 1 addition & 1 deletion test/include/PrintMock.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

#include <string>

#include <Print.h>
#include <api/Print.h>

/**************************************************************************************
* CLASS DECLARATION
Expand Down
2 changes: 1 addition & 1 deletion test/include/PrintableMock.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

#include <string>

#include <Printable.h>
#include <api/Printable.h>

/**************************************************************************************
* CLASS DECLARATION
Expand Down
2 changes: 1 addition & 1 deletion test/include/StreamMock.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

#include <deque>

#include <Stream.h>
#include <api/Stream.h>

/**************************************************************************************
* CLASS DECLARATION
Expand Down
2 changes: 1 addition & 1 deletion test/src/CanMsg/test_CanExtendedId.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

#include <catch.hpp>

#include <CanMsg.h>
#include <api/CanMsg.h>

/**************************************************************************************
* NAMESPACE
Expand Down
2 changes: 1 addition & 1 deletion test/src/CanMsg/test_CanMsg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

#include <catch.hpp>

#include <CanMsg.h>
#include <api/CanMsg.h>

/**************************************************************************************
* NAMESPACE
Expand Down
2 changes: 1 addition & 1 deletion test/src/CanMsg/test_CanMsg_CopyCtor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

#include <catch.hpp>

#include <CanMsg.h>
#include <api/CanMsg.h>

/**************************************************************************************
* NAMESPACE
Expand Down
2 changes: 1 addition & 1 deletion test/src/CanMsg/test_CanStandardId.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

#include <catch.hpp>

#include <CanMsg.h>
#include <api/CanMsg.h>

/**************************************************************************************
* NAMESPACE
Expand Down
Loading

0 comments on commit 829215a

Please sign in to comment.