Skip to content

Commit db2141f

Browse files
committed
inline debug statements
1 parent d1b31e2 commit db2141f

2 files changed

Lines changed: 11 additions & 9 deletions

File tree

src/AppleMIDI_Debug.h

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,31 @@
11
#pragma once
22

33
#ifdef SerialMon
4-
namespace {
5-
static void AM_DBG_SETUP(unsigned long baud) {
4+
static inline void AM_DBG_SETUP(unsigned long baud) {
65
SerialMon.begin(baud);
7-
while (!SerialMon);
6+
const unsigned long timeout_ms = 2000;
7+
const unsigned long start_ms = millis();
8+
while (!SerialMon && (millis() - start_ms) < timeout_ms) {
9+
// Avoid hard lock on boards without native USB or no host.
10+
}
811
}
912

1013
template <typename T>
11-
static void AM_DBG_PLAIN(T last) {
14+
static inline void AM_DBG_PLAIN(T last) {
1215
SerialMon.println(last);
1316
}
1417

1518
template <typename T, typename... Args>
16-
static void AM_DBG_PLAIN(T head, Args... tail) {
19+
static inline void AM_DBG_PLAIN(T head, Args... tail) {
1720
SerialMon.print(head);
1821
SerialMon.print(' ');
1922
AM_DBG_PLAIN(tail...);
2023
}
2124

2225
template <typename... Args>
23-
static void AM_DBG(Args... args) {
26+
static inline void AM_DBG(Args... args) {
2427
AM_DBG_PLAIN(args...);
2528
}
26-
} // namespace
2729
#else
2830
#define AM_DBG_SETUP(...)
2931
#define AM_DBG_PLAIN(...)

src/rtp_Defs.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ BEGIN_APPLEMIDI_NAMESPACE
1515
// first octet
1616
#define RTP_P_FIELD 0x20
1717
#define RTP_X_FIELD 0x10
18-
#define RTP_CC_FIELD 0xF
18+
#define RTP_CC_FIELD 0x0F
1919

2020
// second octet
2121
#define RTP_M_FIELD 0x80
@@ -25,7 +25,7 @@ BEGIN_APPLEMIDI_NAMESPACE
2525
#define PAYLOADTYPE_RTPMIDI 97
2626

2727
/* Version is the first 2 bits of the first octet*/
28-
#define RTP_VERSION(octet) ((octet) >> 6)
28+
#define RTP_VERSION(octet) (((octet) >> 6) & 0x03)
2929

3030
/* Padding is the third bit; No need to shift, because true is any value
3131
other than 0! */

0 commit comments

Comments
 (0)