Skip to content

Commit 2ed6a28

Browse files
authored
Rpi (#7)
* DRAFT respberry pi support * readme * standardize defines * doxygen * README * Raspberry PI support * RPI Errors * RPI corrections * RPI corrections * RPI corrections * RPI corrections * RPI corrections * RPI: fix blink example * RPI: fix blink.ino * RPI: blink.ino * RPI: fix SPI * RPI: fix SPI * RPI - compile errors * RPI: I2C compile errors * RPI: I2C compile errors * RPI: i2c compile errors * Rasperry PI * blink: add println * RPI: Cleanup * WiFiUDPStream: cleanup * USE_HTTPS * upgrade WolfSSL * Compile errors wifi-secure * examples * README * RPI * cleanup HardwareSetup * Resolve IP addresses * SSL * Unit tests * gitignroe * ArduinoAPI v1.5.2 * wifi-secure.ino * https * README * build.sh success message * RPI corrections * fix misspelled raspberry_pi * RPI: I2C compile errors * RPI: add back uint8_t spi_bits = 8; // Default to 8 bits per word * RPI: link_libraries(gpiod) * gpiod * RPI: add HardwareSetupRPI * Fix RPI * rename examples to rasperry-pi
1 parent 220667e commit 2ed6a28

File tree

254 files changed

+8716
-19666
lines changed

Some content is hidden

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

254 files changed

+8716
-19666
lines changed

.github/workflows/c-cpp-cmake.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
name: C/C++ CI
2+
3+
on:
4+
push:
5+
branches: [ "main" ]
6+
pull_request:
7+
branches: [ "main" ]
8+
9+
jobs:
10+
build:
11+
12+
runs-on: ubuntu-latest
13+
14+
steps:
15+
- uses: actions/checkout@v4
16+
- name: build.sh
17+
run: ./build.sh

.github/workflows/unit-tests.yml

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
name: Unit Tests
2+
3+
on:
4+
pull_request:
5+
# Only run workflow if a file in these paths is modified
6+
paths:
7+
- ".github/workflows/unit-tests.yml"
8+
- "ArduinoCore-API/test/**"
9+
- "ArduinoCore-API/api/**"
10+
11+
push:
12+
paths:
13+
- ".github/workflows/unit-tests.yml"
14+
- "ArduinoCore-API/test/**"
15+
- "ArduinoCore-API/api/**"
16+
17+
jobs:
18+
test:
19+
name: Run unit tests
20+
runs-on: ubuntu-latest
21+
22+
env:
23+
COVERAGE_DATA_PATH: extras/coverage-data/coverage.info
24+
25+
steps:
26+
- name: Checkout repository
27+
uses: actions/checkout@v2
28+
29+
- name: Relax some warings
30+
# run: echo 'add_compile_options(-Wno-unused-function)' >> ArduinoCore-API/test/CMakeLists.txt
31+
# run: echo 'add_compile_options(-Wno-error=all)' >> ArduinoCore-API/test/CMakeLists.txt
32+
# run: echo 'add_compile_options(-Wno-error=unused-function)' >> ArduinoCore-API/test/CMakeLists.txt
33+
run: sed -i 's/-Werror//g' ArduinoCore-API/test/CMakeLists.txt
34+
35+
36+
# See: https://github.com/arduino/cpp-test-action/blob/main/README.md
37+
- uses: arduino/cpp-test-action@main
38+
with:
39+
source-path: ArduinoCore-API/test
40+
build-path: ArduinoCore-API/test/build
41+
runtime-path: ArduinoCore-API/test/build/bin/test-ArduinoCore-API
42+
coverage-exclude-paths: |
43+
- '*/test/*'
44+
- '/usr/*'
45+
coverage-data-path: ${{ env.COVERAGE_DATA_PATH }}
46+
47+
# Temporary excluded to prevent token requirement
48+
# See: https://github.com/codecov/codecov-action/blob/master/README.md
49+
#- name: Code coverage
50+
# uses: codecov/codecov-action@v3
51+
# with:
52+
# token: ${{ secrets.CODECOV_TOKEN }}
53+
# files: ${{ env.COVERAGE_DATA_PATH }}
54+
# fail_ci_if_error: true

.gitignore

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
1-
/build
2-
.*
1+
build/
2+
.vscode
3+

ArduinoCore-API/api/ArduinoAPI.h

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
1010
This library is distributed in the hope that it will be useful,
1111
but WITHOUT ANY WARRANTY; without even the implied warranty of
12-
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
1313
Lesser General Public License for more details.
1414
1515
You should have received a copy of the GNU Lesser General Public
@@ -20,8 +20,8 @@
2020
#ifndef ARDUINO_API_H
2121
#define ARDUINO_API_H
2222

23-
// version 1.2.0
24-
#define ARDUINO_API_VERSION 10200
23+
// version 1.5.2
24+
#define ARDUINO_API_VERSION 10502
2525

2626
#include "Binary.h"
2727

@@ -32,7 +32,7 @@
3232
#include "Printable.h"
3333
#include "PluggableUSB.h"
3434
#include "Server.h"
35-
#include "WString.h"
35+
#include "String.h"
3636
#include "Stream.h"
3737
#include "Udp.h"
3838
#include "USBAPI.h"
@@ -46,9 +46,10 @@
4646
#include <string.h>
4747
#include <math.h>
4848

49-
#ifdef __cplusplus
5049
// Misc Arduino core functions
5150
#include "Common.h"
51+
52+
#ifdef __cplusplus
5253
// Compatibility layer for older code
5354
#include "Compat.h"
5455
#endif

ArduinoCore-API/api/CanMsg.cpp

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
/*
2+
CanMsg.cpp - Library for CAN message handling
3+
Copyright (c) 2023 Arduino. All right reserved.
4+
5+
This library is free software; you can redistribute it and/or
6+
modify it under the terms of the GNU Lesser General Public
7+
License as published by the Free Software Foundation; either
8+
version 2.1 of the License, or (at your option) any later version.
9+
10+
This library is distributed in the hope that it will be useful,
11+
but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13+
Lesser General Public License for more details.
14+
15+
You should have received a copy of the GNU Lesser General Public
16+
License along with this library; if not, write to the Free Software
17+
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18+
*/
19+
20+
/**************************************************************************************
21+
* INCLUDE
22+
**************************************************************************************/
23+
24+
#include "CanMsg.h"
25+
26+
/**************************************************************************************
27+
* NAMESPACE
28+
**************************************************************************************/
29+
30+
namespace arduino
31+
{
32+
33+
/**************************************************************************************
34+
* STATIC CONST DEFINITION
35+
**************************************************************************************/
36+
37+
uint8_t const CanMsg::MAX_DATA_LENGTH;
38+
uint32_t const CanMsg::CAN_EFF_FLAG;
39+
uint32_t const CanMsg::CAN_SFF_MASK;
40+
uint32_t const CanMsg::CAN_EFF_MASK;
41+
42+
/**************************************************************************************
43+
* NAMESPACE
44+
**************************************************************************************/
45+
46+
} /* arduino */

ArduinoCore-API/api/CanMsg.h

Lines changed: 156 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,156 @@
1+
/*
2+
CanMsg.h - Library for CAN message handling
3+
Copyright (c) 2023 Arduino. All right reserved.
4+
5+
This library is free software; you can redistribute it and/or
6+
modify it under the terms of the GNU Lesser General Public
7+
License as published by the Free Software Foundation; either
8+
version 2.1 of the License, or (at your option) any later version.
9+
10+
This library is distributed in the hope that it will be useful,
11+
but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13+
Lesser General Public License for more details.
14+
15+
You should have received a copy of the GNU Lesser General Public
16+
License along with this library; if not, write to the Free Software
17+
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18+
*/
19+
20+
#ifndef ARDUINOCORE_API_CAN_MSG_H_
21+
#define ARDUINOCORE_API_CAN_MSG_H_
22+
23+
/**************************************************************************************
24+
* INCLUDE
25+
**************************************************************************************/
26+
27+
#include <inttypes.h>
28+
#include <string.h>
29+
30+
#include "Print.h"
31+
#include "Printable.h"
32+
#include "Common.h"
33+
34+
/**************************************************************************************
35+
* NAMESPACE
36+
**************************************************************************************/
37+
38+
namespace arduino
39+
{
40+
41+
/**************************************************************************************
42+
* CLASS DECLARATION
43+
**************************************************************************************/
44+
45+
class CanMsg : public Printable
46+
{
47+
public:
48+
static uint8_t constexpr MAX_DATA_LENGTH = 8;
49+
50+
static uint32_t constexpr CAN_EFF_FLAG = 0x80000000U;
51+
static uint32_t constexpr CAN_SFF_MASK = 0x000007FFU; /* standard frame format (SFF) */
52+
static uint32_t constexpr CAN_EFF_MASK = 0x1FFFFFFFU; /* extended frame format (EFF) */
53+
54+
55+
CanMsg(uint32_t const can_id, uint8_t const can_data_len, uint8_t const * can_data_ptr)
56+
: id{can_id}
57+
, data_length{min(can_data_len, MAX_DATA_LENGTH)}
58+
, data{0}
59+
{
60+
if (data_length && can_data_ptr)
61+
memcpy(data, can_data_ptr, data_length);
62+
}
63+
64+
CanMsg() : CanMsg(0, 0, nullptr) { }
65+
66+
CanMsg(CanMsg const & 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+
74+
virtual ~CanMsg() { }
75+
76+
CanMsg & operator = (CanMsg const & other)
77+
{
78+
if (this != &other)
79+
{
80+
id = other.id;
81+
data_length = other.data_length;
82+
if (data_length > 0)
83+
memcpy(data, other.data, data_length);
84+
}
85+
return (*this);
86+
}
87+
88+
virtual size_t printTo(Print & p) const override
89+
{
90+
char buf[20] = {0};
91+
size_t len = 0;
92+
93+
/* Print the header. */
94+
if (isStandardId())
95+
len = snprintf(buf, sizeof(buf), "[%03" PRIX32 "] (%d) : ", getStandardId(), data_length);
96+
else
97+
len = snprintf(buf, sizeof(buf), "[%08" PRIX32 "] (%d) : ", getExtendedId(), data_length);
98+
size_t n = p.write(buf, len);
99+
100+
/* Print the data. */
101+
for (size_t d = 0; d < data_length; d++)
102+
{
103+
len = snprintf(buf, sizeof(buf), "%02X", data[d]);
104+
n += p.write(buf, len);
105+
}
106+
107+
/* Wrap up. */
108+
return n;
109+
}
110+
111+
112+
uint32_t getStandardId() const {
113+
return (id & CAN_SFF_MASK);
114+
}
115+
uint32_t getExtendedId() const {
116+
return (id & CAN_EFF_MASK);
117+
}
118+
bool isStandardId() const {
119+
return ((id & CAN_EFF_FLAG) == 0);
120+
}
121+
bool isExtendedId() const {
122+
return ((id & CAN_EFF_FLAG) == CAN_EFF_FLAG);
123+
}
124+
125+
126+
/*
127+
* CAN ID semantics (mirroring definition by linux/can.h):
128+
* |- Bit 31 : frame format flag (0 = standard 11 bit, 1 = extended 29 bit)
129+
* |- Bit 30 : reserved (future remote transmission request flag)
130+
* |- Bit 29 : reserved (future error frame flag)
131+
* |- Bit 0-28 : CAN identifier (11/29 bit)
132+
*/
133+
uint32_t id;
134+
uint8_t data_length;
135+
uint8_t data[MAX_DATA_LENGTH];
136+
};
137+
138+
/**************************************************************************************
139+
* FREE FUNCTIONS
140+
**************************************************************************************/
141+
142+
inline uint32_t CanStandardId(uint32_t const id) {
143+
return (id & CanMsg::CAN_SFF_MASK);
144+
}
145+
146+
inline uint32_t CanExtendedId(uint32_t const id) {
147+
return (CanMsg::CAN_EFF_FLAG | (id & CanMsg::CAN_EFF_MASK));
148+
}
149+
150+
/**************************************************************************************
151+
* NAMESPACE
152+
**************************************************************************************/
153+
154+
} /* arduino */
155+
156+
#endif /* ARDUINOCORE_API_CAN_MSG_H_ */

0 commit comments

Comments
 (0)