Skip to content

Commit

Permalink
Merge pull request #987 from mcci-catena/issue968
Browse files Browse the repository at this point in the history
Fix hang after 8 hours with certain compilers
  • Loading branch information
terrillmoore authored Nov 25, 2024
2 parents 40e9714 + 8017555 commit 2e04c8e
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 3 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -999,6 +999,10 @@ function uflt12f(rawUflt12)

## Release History

- HEAD has the following changes.

- Work around different behavior for `int32_t` wrap in newer GCC versions. ([#968](https://github.com/mcci-catena/arduino-lmic/issues/968), `v5.0.1-pre1`)

- v5.0.0 has the following changes.

- Enable device time request by default in config file ([#840](https://github.com/mcci-catena/arduino-lmic/issues/840)).
Expand Down
15 changes: 13 additions & 2 deletions src/lmic/lmic.c
Original file line number Diff line number Diff line change
Expand Up @@ -2597,8 +2597,19 @@ static void engineUpdate_inner (void) {
goto checkrx;
}
#endif // !DISABLE_BEACONS
// Earliest possible time vs overhead to setup radio
if( txbeg - (now + TX_RAMPUP) < 0 ) {

//
// Compare earliest possible time vs overhead to setup radio, and start
// transmit if we can. Otherwise (way below), if we're not tracking a
// beacon, we'll simply queue an osjob for the computed txbeg time.
//
// Per bug #968, the explicit cast to (ostime_t) is needed
// (with some versions of GCC) if txbeg is positive and now + TX_RAMPUP is negative
// otherwise the compiler falsely assumes that the computation
// is positive.
//
volatile ostime_t tdiff = txbeg - (now + TX_RAMPUP);
if( tdiff < 0 ) {
// We could send right now!
txbeg = now;
dr_t txdr = (dr_t)LMIC.datarate;
Expand Down
2 changes: 1 addition & 1 deletion src/lmic/lmic.h
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ extern "C"{
((((major)*UINT32_C(1)) << 24) | (((minor)*UINT32_C(1)) << 16) | (((patch)*UINT32_C(1)) << 8) | (((local)*UINT32_C(1)) << 0))

#define ARDUINO_LMIC_VERSION \
ARDUINO_LMIC_VERSION_CALC(5, 0, 0, 0) /* 5.0.0 */
ARDUINO_LMIC_VERSION_CALC(5, 0, 1, 1) /* 5.0.1-pre1 */

#define ARDUINO_LMIC_VERSION_GET_MAJOR(v) \
((((v)*UINT32_C(1)) >> 24u) & 0xFFu)
Expand Down

0 comments on commit 2e04c8e

Please sign in to comment.