Skip to content

Commit b4f88f7

Browse files
katzfeytimzarhansen
authored andcommitted
Serial: removed the validateBaudrate function from nuttx and posix platforms and just send out a warning it baudrate is non-standard (PX4#22969)
- Fix some Qurt platform build issues uncovered when changing the posix version of SerialImpl
1 parent 3af016d commit b4f88f7

File tree

11 files changed

+295
-56
lines changed

11 files changed

+295
-56
lines changed

boards/modalai/fc-v2/default.px4board

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ CONFIG_DRIVERS_PCA9685_PWM_OUT=y
2424
CONFIG_DRIVERS_POWER_MONITOR_INA226=y
2525
CONFIG_DRIVERS_POWER_MONITOR_VOXLPM=y
2626
CONFIG_DRIVERS_PWM_OUT=y
27+
CONFIG_DRIVERS_RC_CRSF_RC=y
2728
CONFIG_DRIVERS_RC_INPUT=y
2829
CONFIG_COMMON_TELEMETRY=y
2930
CONFIG_MODULES_AIRSPEED_SELECTOR=y
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/bin/bash
2+
3+
# Run this from the px4 project top level directory
4+
docker run -it --rm --privileged -v `pwd`:/usr/local/workspace px4io/px4-dev-nuttx-focal:2022-08-12
5+

boards/modalai/voxl2/default.px4board

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ CONFIG_DRIVERS_ACTUATORS_VOXL_ESC=y
66
CONFIG_DRIVERS_GPS=y
77
CONFIG_DRIVERS_OSD_MSP_OSD=y
88
CONFIG_DRIVERS_QSHELL_POSIX=y
9+
CONFIG_DRIVERS_RC_CRSF_RC=y
910
CONFIG_DRIVERS_RC_INPUT=y
1011
CONFIG_DRIVERS_VOXL2_IO=y
1112
CONFIG_MODULES_COMMANDER=y

platforms/nuttx/src/px4/common/SerialImpl.cpp

Lines changed: 3 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -68,28 +68,11 @@ SerialImpl::~SerialImpl()
6868
}
6969
}
7070

71-
bool SerialImpl::validateBaudrate(uint32_t baudrate)
72-
{
73-
return ((baudrate == 9600) ||
74-
(baudrate == 19200) ||
75-
(baudrate == 38400) ||
76-
(baudrate == 57600) ||
77-
(baudrate == 115200) ||
78-
(baudrate == 230400) ||
79-
(baudrate == 460800) ||
80-
(baudrate == 921600));
81-
}
82-
8371
bool SerialImpl::configure()
8472
{
8573
/* process baud rate */
8674
int speed;
8775

88-
if (! validateBaudrate(_baudrate)) {
89-
PX4_ERR("ERR: unknown baudrate: %lu", _baudrate);
90-
return false;
91-
}
92-
9376
switch (_baudrate) {
9477
case 9600: speed = B9600; break;
9578

@@ -116,8 +99,9 @@ bool SerialImpl::configure()
11699
case 921600: speed = B921600; break;
117100

118101
default:
119-
PX4_ERR("ERR: unknown baudrate: %lu", _baudrate);
120-
return false;
102+
speed = _baudrate;
103+
PX4_WARN("Using non-standard baudrate: %lu", _baudrate);
104+
break;
121105
}
122106

123107
struct termios uart_config;
@@ -374,11 +358,6 @@ uint32_t SerialImpl::getBaudrate() const
374358

375359
bool SerialImpl::setBaudrate(uint32_t baudrate)
376360
{
377-
if (! validateBaudrate(baudrate)) {
378-
PX4_ERR("ERR: invalid baudrate: %lu", baudrate);
379-
return false;
380-
}
381-
382361
// check if already configured
383362
if ((baudrate == _baudrate) && _open) {
384363
return true;

platforms/nuttx/src/px4/common/include/SerialImpl.hpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,6 @@ class SerialImpl
109109
StopBits _stopbits{StopBits::One};
110110
FlowControl _flowcontrol{FlowControl::Disabled};
111111

112-
bool validateBaudrate(uint32_t baudrate);
113112
bool configure();
114113

115114
bool _single_wire_mode{false};

platforms/posix/include/SerialImpl.hpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,6 @@ class SerialImpl
109109
StopBits _stopbits{StopBits::One};
110110
FlowControl _flowcontrol{FlowControl::Disabled};
111111

112-
bool validateBaudrate(uint32_t baudrate);
113112
bool configure();
114113

115114
bool _single_wire_mode{false};

platforms/posix/src/px4/common/SerialImpl.cpp

Lines changed: 3 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -66,28 +66,11 @@ SerialImpl::~SerialImpl()
6666
}
6767
}
6868

69-
bool SerialImpl::validateBaudrate(uint32_t baudrate)
70-
{
71-
return ((baudrate == 9600) ||
72-
(baudrate == 19200) ||
73-
(baudrate == 38400) ||
74-
(baudrate == 57600) ||
75-
(baudrate == 115200) ||
76-
(baudrate == 230400) ||
77-
(baudrate == 460800) ||
78-
(baudrate == 921600));
79-
}
80-
8169
bool SerialImpl::configure()
8270
{
8371
/* process baud rate */
8472
int speed;
8573

86-
if (! validateBaudrate(_baudrate)) {
87-
PX4_ERR("ERR: unknown baudrate: %u", _baudrate);
88-
return false;
89-
}
90-
9174
switch (_baudrate) {
9275
case 9600: speed = B9600; break;
9376

@@ -114,8 +97,9 @@ bool SerialImpl::configure()
11497
case 921600: speed = B921600; break;
11598

11699
default:
117-
PX4_ERR("ERR: unknown baudrate: %d", _baudrate);
118-
return false;
100+
speed = _baudrate;
101+
PX4_WARN("Using non-standard baudrate: %u", _baudrate);
102+
break;
119103
}
120104

121105
struct termios uart_config;
@@ -366,11 +350,6 @@ uint32_t SerialImpl::getBaudrate() const
366350

367351
bool SerialImpl::setBaudrate(uint32_t baudrate)
368352
{
369-
if (! validateBaudrate(baudrate)) {
370-
PX4_ERR("ERR: invalid baudrate: %u", baudrate);
371-
return false;
372-
}
373-
374353
// check if already configured
375354
if ((baudrate == _baudrate) && _open) {
376355
return true;

platforms/qurt/cmake/px4_impl_os.cmake

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -124,13 +124,7 @@ endfunction()
124124
#
125125
function(px4_os_add_flags)
126126

127-
set(DSPAL_ROOT platforms/qurt/dspal)
128127
include_directories(
129-
${DSPAL_ROOT}/include
130-
${DSPAL_ROOT}/sys
131-
${DSPAL_ROOT}/sys/sys
132-
133-
platforms/posix/include
134128
platforms/qurt/include
135129
)
136130

platforms/qurt/include/crc32.h

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
/****************************************************************************
2+
* include/crc.h
3+
*
4+
* Copyright (C) 2010 Gregory Nutt. All rights reserved.
5+
* Author: Gregory Nutt <[email protected]>
6+
*
7+
* Redistribution and use in source and binary forms, with or without
8+
* modification, are permitted provided that the following conditions
9+
* are met:
10+
*
11+
* 1. Redistributions of source code must retain the above copyright
12+
* notice, this list of conditions and the following disclaimer.
13+
* 2. Redistributions in binary form must reproduce the above copyright
14+
* notice, this list of conditions and the following disclaimer in
15+
* the documentation and/or other materials provided with the
16+
* distribution.
17+
* 3. Neither the name NuttX nor the names of its contributors may be
18+
* used to endorse or promote products derived from this software
19+
* without specific prior written permission.
20+
*
21+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22+
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23+
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
24+
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
25+
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26+
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
27+
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
28+
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
29+
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30+
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
31+
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32+
* POSSIBILITY OF SUCH DAMAGE.
33+
*
34+
****************************************************************************/
35+
36+
#ifndef __INCLUDE_CRC32_H
37+
#define __INCLUDE_CRC32_H
38+
39+
/****************************************************************************
40+
* Included Files
41+
****************************************************************************/
42+
43+
#include <sys/types.h>
44+
#include <stdint.h>
45+
46+
/****************************************************************************
47+
* Public Function Prototypes
48+
****************************************************************************/
49+
50+
#ifdef __cplusplus
51+
#define EXTERN extern "C"
52+
extern "C" {
53+
#else
54+
#define EXTERN extern
55+
#endif
56+
57+
/****************************************************************************
58+
* Name: crc32part
59+
*
60+
* Description:
61+
* Continue CRC calculation on a part of the buffer.
62+
*
63+
****************************************************************************/
64+
65+
EXTERN uint32_t crc32part(const uint8_t *src, size_t len,
66+
uint32_t crc32val);
67+
68+
/****************************************************************************
69+
* Name: crc32
70+
*
71+
* Description:
72+
* Return a 32-bit CRC of the contents of the 'src' buffer, length 'len'
73+
*
74+
****************************************************************************/
75+
76+
EXTERN uint32_t crc32(const uint8_t *src, size_t len);
77+
78+
#undef EXTERN
79+
#ifdef __cplusplus
80+
}
81+
#endif
82+
83+
#endif /* __INCLUDE_CRC32_H */

platforms/qurt/include/queue.h

Lines changed: 134 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,134 @@
1+
/************************************************************************
2+
* include/queue.h
3+
*
4+
* Copyright (C) 2007-2009 Gregory Nutt. All rights reserved.
5+
* Author: Gregory Nutt <[email protected]>
6+
*
7+
* Redistribution and use in source and binary forms, with or without
8+
* modification, are permitted provided that the following conditions
9+
* are met:
10+
*
11+
* 1. Redistributions of source code must retain the above copyright
12+
* notice, this list of conditions and the following disclaimer.
13+
* 2. Redistributions in binary form must reproduce the above copyright
14+
* notice, this list of conditions and the following disclaimer in
15+
* the documentation and/or other materials provided with the
16+
* distribution.
17+
* 3. Neither the name NuttX nor the names of its contributors may be
18+
* used to endorse or promote products derived from this software
19+
* without specific prior written permission.
20+
*
21+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22+
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23+
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
24+
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
25+
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26+
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
27+
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
28+
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
29+
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30+
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
31+
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32+
* POSSIBILITY OF SUCH DAMAGE.
33+
*
34+
************************************************************************/
35+
36+
#ifndef __INCLUDE_QUEUE_H
37+
#define __INCLUDE_QUEUE_H
38+
39+
/************************************************************************
40+
* Included Files
41+
************************************************************************/
42+
43+
#include <sys/types.h>
44+
45+
#ifdef __cplusplus
46+
#include <cstddef> // NULL
47+
#else
48+
#include <stddef.h> // NULL
49+
#endif
50+
51+
/************************************************************************
52+
* Pre-processor Definitions
53+
************************************************************************/
54+
55+
#define sq_init(q) do { (q)->head = NULL; (q)->tail = NULL; } while (0)
56+
#define dq_init(q) do { (q)->head = NULL; (q)->tail = NULL; } while (0)
57+
58+
#define sq_next(p) ((p)->flink)
59+
#define dq_next(p) ((p)->flink)
60+
#define dq_prev(p) ((p)->blink)
61+
62+
#define sq_empty(q) ((q)->head == NULL)
63+
#define dq_empty(q) ((q)->head == NULL)
64+
65+
#define sq_peek(q) ((q)->head)
66+
#define dq_peek(q) ((q)->head)
67+
68+
// Required for Linux
69+
#define FAR
70+
71+
/************************************************************************
72+
* Global Type Declarations
73+
************************************************************************/
74+
75+
struct sq_entry_s {
76+
FAR struct sq_entry_s *flink;
77+
};
78+
typedef struct sq_entry_s sq_entry_t;
79+
80+
struct dq_entry_s {
81+
FAR struct dq_entry_s *flink;
82+
FAR struct dq_entry_s *blink;
83+
};
84+
typedef struct dq_entry_s dq_entry_t;
85+
86+
struct sq_queue_s {
87+
FAR sq_entry_t *head;
88+
FAR sq_entry_t *tail;
89+
};
90+
typedef struct sq_queue_s sq_queue_t;
91+
92+
struct dq_queue_s {
93+
FAR dq_entry_t *head;
94+
FAR dq_entry_t *tail;
95+
};
96+
typedef struct dq_queue_s dq_queue_t;
97+
98+
/************************************************************************
99+
* Global Function Prototypes
100+
************************************************************************/
101+
102+
#ifdef __cplusplus
103+
#define EXTERN extern "C"
104+
extern "C" {
105+
#else
106+
#define EXTERN extern
107+
#endif
108+
109+
EXTERN void sq_addfirst(FAR sq_entry_t *node, sq_queue_t *queue);
110+
EXTERN void dq_addfirst(FAR dq_entry_t *node, dq_queue_t *queue);
111+
EXTERN void sq_addlast(FAR sq_entry_t *node, sq_queue_t *queue);
112+
EXTERN void dq_addlast(FAR dq_entry_t *node, dq_queue_t *queue);
113+
EXTERN void sq_addafter(FAR sq_entry_t *prev, FAR sq_entry_t *node,
114+
sq_queue_t *queue);
115+
EXTERN void dq_addafter(FAR dq_entry_t *prev, FAR dq_entry_t *node,
116+
dq_queue_t *queue);
117+
EXTERN void dq_addbefore(FAR dq_entry_t *next, FAR dq_entry_t *node,
118+
dq_queue_t *queue);
119+
120+
EXTERN FAR sq_entry_t *sq_remafter(FAR sq_entry_t *node, sq_queue_t *queue);
121+
EXTERN void sq_rem(FAR sq_entry_t *node, sq_queue_t *queue);
122+
EXTERN void dq_rem(FAR dq_entry_t *node, dq_queue_t *queue);
123+
EXTERN FAR sq_entry_t *sq_remlast(sq_queue_t *queue);
124+
EXTERN FAR dq_entry_t *dq_remlast(dq_queue_t *queue);
125+
EXTERN FAR sq_entry_t *sq_remfirst(sq_queue_t *queue);
126+
EXTERN FAR dq_entry_t *dq_remfirst(dq_queue_t *queue);
127+
128+
#undef EXTERN
129+
#ifdef __cplusplus
130+
}
131+
#endif
132+
133+
#endif /* __INCLUDE_QUEUE_H_ */
134+

0 commit comments

Comments
 (0)