Skip to content

Commit 4b150cc

Browse files
Merge tag '1.5.0' into feature/fromUtf8ToEAscii-method-in-String
2 parents 8e3d27a + 0c853c5 commit 4b150cc

File tree

99 files changed

+1184
-122
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

99 files changed

+1184
-122
lines changed

Diff for: .github/ISSUE_TEMPLATE/api-deprecation.md

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
---
2+
name: API deprecation
3+
about: Suggest the deprecation of an API component defined by ArduinoCore-API.
4+
title: ""
5+
labels: enhancement
6+
assignees: ""
7+
---
8+
9+
### API component
10+
11+
<!-- Tell us which API component the deprecation applies to. -->
12+
13+
### Description
14+
15+
<!-- A clear and concise description of the suggestion. -->
16+
<!-- What is the reason for the deprecation? -->
17+
18+
### Replacement API component
19+
20+
<!-- What should be used instead of the deprecated API component? -->
21+
<!-- Is this replacement available to all users (e.g., is it provided by the C++ standard version used in major boards platforms)? -->
22+
23+
### Additional information
24+
25+
<!-- Add any other context for the suggestion here. -->

Diff for: .github/ISSUE_TEMPLATE/api-improvement.md

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
---
2+
name: API improvement
3+
about: Suggest an improvement to an existing API component.
4+
title: ""
5+
labels: enhancement
6+
assignees: ""
7+
---
8+
9+
### API component
10+
11+
<!-- Tell us which API component the improvement applies to. -->
12+
13+
### Description
14+
15+
<!-- A clear and concise description of the suggestion. -->
16+
17+
### Is this a breaking change?
18+
19+
<!-- Would this change require any users to change their code? -->
20+
<!-- Would this change require any boards platform authors to change their configuration files or release system? -->
21+
22+
### Additional information
23+
24+
<!-- Add any other context for the request here. -->

Diff for: .github/ISSUE_TEMPLATE/bug_report.md

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
---
2+
name: Bug report
3+
about: Report problems with the code in this repository.
4+
title: ""
5+
labels: bug
6+
assignees: ""
7+
---
8+
9+
### Description
10+
11+
<!-- A clear and concise description of the bug. -->
12+
13+
### Environment
14+
15+
- Boards platform name:
16+
- Boards platform version (as shown in Boards Manager):
17+
- ArduinoCore-API version (if you manually installed it):
18+
19+
### Current behavior
20+
21+
<!-- Provide a minimal sketch that demonstrates the issue. -->
22+
23+
### Expected behavior
24+
25+
<!-- Describe what you expect to happen when the demonstration sketch is run. -->
26+
27+
### Additional information
28+
29+
<!-- Add any other context about the problem here. -->

Diff for: .github/ISSUE_TEMPLATE/config.yml

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
contact_links:
2+
- name: Learn about the Arduino language
3+
url: https://www.arduino.cc/reference/en
4+
about: User documentation is available at the Arduino language reference.
5+
- name: Support request
6+
url: https://forum.arduino.cc/
7+
about: We can help you out on the Arduino Forum!
8+
- name: Discuss ArduinoCore-API development
9+
url: https://groups.google.com/a/arduino.cc/g/developers
10+
about: Arduino Developers Mailing List

Diff for: .github/ISSUE_TEMPLATE/new-api-component.md

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
---
2+
name: New API component
3+
about: Suggest the addition of a new API component to ArduinoCore-API.
4+
title: ""
5+
labels: enhancement
6+
assignees: ""
7+
---
8+
9+
### Description
10+
11+
<!-- A clear and concise description of the API component you want added. -->
12+
13+
### Additional information
14+
15+
<!-- Add any other context for the request here. -->

Diff for: .github/ISSUE_TEMPLATE/other-enhancement.md

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
---
2+
name: Other enhancement
3+
about:
4+
Suggest an improvement for this project that doesn't fit in the specific categories
5+
above.
6+
title: ""
7+
labels: enhancement
8+
assignees: ""
9+
---
10+
11+
### Description
12+
13+
<!-- A clear and concise description of the enhancement. -->
14+
15+
### Is this a breaking change?
16+
17+
<!-- Would this change require any users to change their code? -->
18+
<!-- Would this change require any boards platform authors to change their configuration files or release system? -->
19+
20+
### Additional information
21+
22+
<!-- Add any other context for the request here. -->

Diff for: .github/workflows/unit-tests.yml

+4-3
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,9 @@ jobs:
3838
coverage-data-path: ${{ env.COVERAGE_DATA_PATH }}
3939

4040
# See: https://github.com/codecov/codecov-action/blob/master/README.md
41-
- name: Upload coverage report to Codecov
42-
uses: codecov/codecov-action@v1
41+
- name: Code coverage
42+
uses: codecov/codecov-action@v3
4343
with:
44-
file: ${{ env.COVERAGE_DATA_PATH }}
44+
token: ${{ secrets.CODECOV_TOKEN }}
45+
files: ${{ env.COVERAGE_DATA_PATH }}
4546
fail_ci_if_error: true

Diff for: .gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
.vscode/
2+
.idea/

Diff for: README.md

+3
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ As of now, the following official cores are utilising ArduinoCore-API:
1313
* [megaavr](https://github.com/arduino/ArduinoCore-megaAVR)
1414
* [mbed](https://github.com/arduino/ArduinoCore-mbed)
1515
* [samd](https://github.com/arduino/ArduinoCore-samd)
16+
* [renesas](https://github.com/arduino/ArduinoCore-renesas)
1617

1718
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.
1819

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

81+
The API is coded to the C++11 standard and the core's compiler must be able to support that version of the language.
82+
8083
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:
8184
* [ArduinoCore-megaavr](https://github.com/arduino/ArduinoCore-megaavr#developing)
8285
* [ArduinoCore-mbed](https://github.com/arduino/ArduinoCore-mbed#clone-the-repository-in-sketchbookhardwarearduino-git)

Diff for: api/ArduinoAPI.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@
2020
#ifndef ARDUINO_API_H
2121
#define ARDUINO_API_H
2222

23-
// version 1.4.0
24-
#define ARDUINO_API_VERSION 10400
23+
// version 1.5.0
24+
#define ARDUINO_API_VERSION 10500
2525

2626
#include "Binary.h"
2727

Diff for: api/CanMsg.cpp

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
/*
2+
* This file is free software; you can redistribute it and/or modify
3+
* it under the terms of either the GNU General Public License version 2
4+
* or the GNU Lesser General Public License version 2.1, both as
5+
* published by the Free Software Foundation.
6+
*/
7+
8+
/**************************************************************************************
9+
* INCLUDE
10+
**************************************************************************************/
11+
12+
#include "CanMsg.h"
13+
14+
/**************************************************************************************
15+
* NAMESPACE
16+
**************************************************************************************/
17+
18+
namespace arduino
19+
{
20+
21+
/**************************************************************************************
22+
* STATIC CONST DEFINITION
23+
**************************************************************************************/
24+
25+
uint8_t const CanMsg::MAX_DATA_LENGTH;
26+
uint32_t const CanMsg::CAN_EFF_FLAG;
27+
uint32_t const CanMsg::CAN_SFF_MASK;
28+
uint32_t const CanMsg::CAN_EFF_MASK;
29+
30+
/**************************************************************************************
31+
* NAMESPACE
32+
**************************************************************************************/
33+
34+
} /* arduino */

Diff for: api/CanMsg.h

+144
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,144 @@
1+
/*
2+
* This file is free software; you can redistribute it and/or modify
3+
* it under the terms of either the GNU General Public License version 2
4+
* or the GNU Lesser General Public License version 2.1, both as
5+
* published by the Free Software Foundation.
6+
*/
7+
8+
#ifndef ARDUINOCORE_API_CAN_MSG_H_
9+
#define ARDUINOCORE_API_CAN_MSG_H_
10+
11+
/**************************************************************************************
12+
* INCLUDE
13+
**************************************************************************************/
14+
15+
#include <inttypes.h>
16+
#include <string.h>
17+
18+
#include "Print.h"
19+
#include "Printable.h"
20+
#include "Common.h"
21+
22+
/**************************************************************************************
23+
* NAMESPACE
24+
**************************************************************************************/
25+
26+
namespace arduino
27+
{
28+
29+
/**************************************************************************************
30+
* CLASS DECLARATION
31+
**************************************************************************************/
32+
33+
class CanMsg : public Printable
34+
{
35+
public:
36+
static uint8_t constexpr MAX_DATA_LENGTH = 8;
37+
38+
static uint32_t constexpr CAN_EFF_FLAG = 0x80000000U;
39+
static uint32_t constexpr CAN_SFF_MASK = 0x000007FFU; /* standard frame format (SFF) */
40+
static uint32_t constexpr CAN_EFF_MASK = 0x1FFFFFFFU; /* extended frame format (EFF) */
41+
42+
43+
CanMsg(uint32_t const can_id, uint8_t const can_data_len, uint8_t const * can_data_ptr)
44+
: id{can_id}
45+
, data_length{min(can_data_len, MAX_DATA_LENGTH)}
46+
, data{0}
47+
{
48+
if (data_length && can_data_ptr)
49+
memcpy(data, can_data_ptr, data_length);
50+
}
51+
52+
CanMsg() : CanMsg(0, 0, nullptr) { }
53+
54+
CanMsg(CanMsg const & other)
55+
{
56+
id = other.id;
57+
data_length = other.data_length;
58+
if (data_length > 0)
59+
memcpy(data, other.data, data_length);
60+
}
61+
62+
virtual ~CanMsg() { }
63+
64+
CanMsg & operator = (CanMsg const & other)
65+
{
66+
if (this != &other)
67+
{
68+
id = other.id;
69+
data_length = other.data_length;
70+
if (data_length > 0)
71+
memcpy(data, other.data, data_length);
72+
}
73+
return (*this);
74+
}
75+
76+
virtual size_t printTo(Print & p) const override
77+
{
78+
char buf[20] = {0};
79+
size_t len = 0;
80+
81+
/* Print the header. */
82+
if (isStandardId())
83+
len = snprintf(buf, sizeof(buf), "[%03" PRIX32 "] (%d) : ", getStandardId(), data_length);
84+
else
85+
len = snprintf(buf, sizeof(buf), "[%08" PRIX32 "] (%d) : ", getExtendedId(), data_length);
86+
size_t n = p.write(buf, len);
87+
88+
/* Print the data. */
89+
for (size_t d = 0; d < data_length; d++)
90+
{
91+
len = snprintf(buf, sizeof(buf), "%02X", data[d]);
92+
n += p.write(buf, len);
93+
}
94+
95+
/* Wrap up. */
96+
return n;
97+
}
98+
99+
100+
uint32_t getStandardId() const {
101+
return (id & CAN_SFF_MASK);
102+
}
103+
uint32_t getExtendedId() const {
104+
return (id & CAN_EFF_MASK);
105+
}
106+
bool isStandardId() const {
107+
return ((id & CAN_EFF_FLAG) == 0);
108+
}
109+
bool isExtendedId() const {
110+
return ((id & CAN_EFF_FLAG) == CAN_EFF_FLAG);
111+
}
112+
113+
114+
/*
115+
* CAN ID semantics (mirroring definition by linux/can.h):
116+
* |- Bit 31 : frame format flag (0 = standard 11 bit, 1 = extended 29 bit)
117+
* |- Bit 30 : reserved (future remote transmission request flag)
118+
* |- Bit 29 : reserved (future error frame flag)
119+
* |- Bit 0-28 : CAN identifier (11/29 bit)
120+
*/
121+
uint32_t id;
122+
uint8_t data_length;
123+
uint8_t data[MAX_DATA_LENGTH];
124+
};
125+
126+
/**************************************************************************************
127+
* FREE FUNCTIONS
128+
**************************************************************************************/
129+
130+
inline uint32_t CanStandardId(uint32_t const id) {
131+
return (id & CanMsg::CAN_SFF_MASK);
132+
}
133+
134+
inline uint32_t CanExtendedId(uint32_t const id) {
135+
return (CanMsg::CAN_EFF_FLAG | (id & CanMsg::CAN_EFF_MASK));
136+
}
137+
138+
/**************************************************************************************
139+
* NAMESPACE
140+
**************************************************************************************/
141+
142+
} /* arduino */
143+
144+
#endif /* ARDUINOCORE_API_CAN_MSG_H_ */

0 commit comments

Comments
 (0)