Skip to content

Commit 01c1a3b

Browse files
author
Quantum Leaps
committed
5.8.2
1 parent 28144af commit 01c1a3b

File tree

6 files changed

+108
-120
lines changed

6 files changed

+108
-120
lines changed

README-MacOS.txt

Lines changed: 0 additions & 52 deletions
This file was deleted.

README.txt

Lines changed: 51 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ Please refer to the companion webiste to this project at:
44
http://www.state-machine.com/arduino
55

66

7-
Software Installation
8-
=====================
7+
Software Installation on Windows
8+
================================
99
The QP-nano adaptation for Arduino is distributed in a single ZIP
1010
archive qpn-<ver>_arduino-1.6.x.zip, where <ver> stands for version of
1111
the QP-nano framework.
@@ -18,11 +18,55 @@ sketchbook location will be shown at the top of the Preferences dialog
1818
box. Once you identify the Sketchbook folder, you simply unzip the whole
1919
archive to your Sketchbook.
2020

21-
****
22-
NOTE: Currently, the QP-nano for Arduino project is available only
23-
on Windows. If you are interested in other platforms, such as Linux
24-
or MacOS, please consider contribuing a tested port.
25-
****
21+
22+
Software Installation on MacOS
23+
==============================
24+
The Mac funtionality has been tested, but other users will likely find
25+
issues. Please submit issues at https://sourceforge.net/p/qpc/bugs/ and
26+
submit questions and suggestions at
27+
https://sourceforge.net/p/qpc/discussion/668726/
28+
29+
Install Dependencies
30+
--------------------
31+
1. Install the AVR-GCC tooltrain for Mac OS X. Following are the commands
32+
to install using Homebrew (must have Homebrew installed):
33+
34+
> ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
35+
> brew tap osx-cross/avr
36+
> brew install avr-libc
37+
> brew install avrdude --with-usb
38+
39+
2. Install Arduino for Mac OS X by placing the Arduino application in the
40+
Applications folder. Open the application at least one time to overcome
41+
security warnings.
42+
43+
3. Install Install QP-nano for Arduino into your Documents/Arduino folder
44+
(documentation refers to this as the Arduino Sketchbook folder).
45+
46+
4. Install QM.
47+
48+
Instructions for Configuring External Tools for a Model
49+
50+
1. Ensure the model is not open in QM.
51+
52+
2. Copy the Blinky model's settings
53+
(libraries/qpn_avr/examples/blinky/.blinky.macos) from your Arduino
54+
Sketchbook folder to the model's folder.
55+
56+
3. Rename the settings file to your model's name (i.e., .mymodel).
57+
58+
4. Open QM and edit the settings from External Tools.
59+
60+
Once you have a working .model file, copy it to other models and use it as
61+
a starting point.
62+
63+
Known Issues
64+
------------
65+
1. The serialterm External Tool is working by opening a Terminal window.
66+
An additional Terminal window also appears and can be safely closed. When
67+
the Terminal window displaying the Arduino's output is closed, the port is
68+
busy and can no longer be accessed. Work-around is to unplug and
69+
re-connect the Arduino from the Mac's USB port.
2670

2771

2872
Building the Examples in the QM Modeling Tool

libraries/qpn_avr/qepn.c

Lines changed: 41 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@
44
* @ingroup qep
55
* @cond
66
******************************************************************************
7-
* Last updated for version 5.8.1
8-
* Last updated on 2017-02-19
7+
* Last updated for version 5.8.2
8+
* Last updated on 2017-02-22
99
*
1010
* Q u a n t u m L e a P s
1111
* ---------------------------
1212
* innovating embedded systems
1313
*
14-
* Copyright (C) Quantum Leaps, www.state-machine.com.
14+
* Copyright (C) Quantum Leaps, LLC. All rights reserved.
1515
*
1616
* This program is open source software: you can redistribute it and/or
1717
* modify it under the terms of the GNU General Public License as published
@@ -32,7 +32,7 @@
3232
* along with this program. If not, see <http://www.gnu.org/licenses/>.
3333
*
3434
* Contact information:
35-
* http:www.state-machine.com
35+
* http://www.state-machine.com
3636
* mailto:info@state-machine.com
3737
******************************************************************************
3838
* @endcond
@@ -73,14 +73,6 @@ static int_fast8_t QHsm_tran_(QHsm * const me,
7373
*
7474
* @note Must be called only ONCE before QHSM_INIT().
7575
*
76-
* @note
77-
* QHsm inherits QHsm, so by the @ref oop convention it should call the
78-
* constructor of the superclass, i.e., QHsm_ctor(). However, this would pull
79-
* in the QHsmVtbl, which in turn will pull in the code for QHsm_init_() and
80-
* QHsm_dispatch_() implemetations. To avoid this code size penalty, in case
81-
* ::QHsm is not used in a given project, the QHsm_ctor() performs direct
82-
* intitialization of the Vtbl, which avoids pulling in the code for QHsm.
83-
*
8476
* @usage
8577
* The following example illustrates how to invoke QHsm_ctor() in the
8678
* "constructor" of a derived state machine:
@@ -91,31 +83,11 @@ void QHsm_ctor(QHsm * const me, QStateHandler initial) {
9183
&QHsm_init_,
9284
&QHsm_dispatch_
9385
};
94-
/* do not call the QHsm_ctor() here */
95-
me->vptr = &vtbl;
86+
me->vptr = &vtbl;
9687
me->state = Q_STATE_CAST(&QHsm_top);
9788
me->temp = initial;
9889
}
9990

100-
/****************************************************************************/
101-
/**
102-
* @description
103-
* QHsm_top() is the ultimate root of state hierarchy in all HSMs derived
104-
* from ::QHsm.
105-
*
106-
* @param[in] me pointer (see @ref oop)
107-
*
108-
* @returns Always returns #Q_RET_IGNORED, which means that the top state
109-
* ignores all events.
110-
*
111-
* @note The parameter @p me to this state handler is not used. It is provided
112-
* for conformance with the state-handler function signature ::QStateHandler.
113-
*/
114-
QState QHsm_top(void const * const me) {
115-
(void)me; /* suppress the "unused parameter" compiler warning */
116-
return (QState)Q_RET_IGNORED; /* the top state ignores all events */
117-
}
118-
11991
/****************************************************************************/
12092
/**
12193
* @description
@@ -133,14 +105,14 @@ void QHsm_init_(QHsm * const me) {
133105
* transition must be initialized, and the initial transition must not
134106
* be taken yet.
135107
*/
136-
Q_REQUIRE_ID(600, (me->vptr != (QHsmVtbl const *)0)
108+
Q_REQUIRE_ID(200, (me->vptr != (QHsmVtbl const *)0)
137109
&& (me->temp != Q_STATE_CAST(0))
138110
&& (t == Q_STATE_CAST(&QHsm_top)));
139111

140112
r = (*me->temp)(me); /* execute the top-most initial transition */
141113

142114
/* the top-most initial transition must be taken */
143-
Q_ASSERT_ID(610, r == (QState)Q_RET_TRAN);
115+
Q_ASSERT_ID(210, r == (QState)Q_RET_TRAN);
144116

145117
/* drill down into the state hierarchy with initial transitions... */
146118
do {
@@ -152,7 +124,7 @@ void QHsm_init_(QHsm * const me) {
152124
(void)(*me->temp)(me);
153125
while (me->temp != t) {
154126
++ip;
155-
Q_ASSERT_ID(620, ip < (int_fast8_t)Q_DIM(path));
127+
Q_ASSERT_ID(220, ip < (int_fast8_t)Q_DIM(path));
156128
path[ip] = me->temp;
157129
(void)(*me->temp)(me);
158130
}
@@ -175,6 +147,25 @@ void QHsm_init_(QHsm * const me) {
175147
me->temp = t; /* mark the configuration as stable */
176148
}
177149

150+
/****************************************************************************/
151+
/**
152+
* @description
153+
* QHsm_top() is the ultimate root of state hierarchy in all HSMs derived
154+
* from ::QHsm.
155+
*
156+
* @param[in] me pointer (see @ref oop)
157+
*
158+
* @returns Always returns #Q_RET_IGNORED, which means that the top state
159+
* ignores all events.
160+
*
161+
* @note The parameter @p me to this state handler is not used. It is provided
162+
* for conformance with the state-handler function signature ::QStateHandler.
163+
*/
164+
QState QHsm_top(void const * const me) {
165+
(void)me; /* suppress the "unused parameter" compiler warning */
166+
return (QState)Q_RET_IGNORED; /* the top state ignores all events */
167+
}
168+
178169
/****************************************************************************/
179170
/**
180171
* @description
@@ -193,16 +184,18 @@ void QHsm_dispatch_(QHsm * const me) {
193184
QState r;
194185
int_fast8_t iq; /* helper transition entry path index */
195186

196-
/** @pre the state configuration must be stable */
197-
Q_REQUIRE_ID(700, t == me->temp);
187+
/** @pre the current state must be initialized and
188+
* the state configuration must be stable
189+
*/
190+
Q_REQUIRE_ID(400, (t != Q_STATE_CAST(0))
191+
&& (t == me->temp));
198192

199193
/* process the event hierarchically... */
200194
do {
201195
s = me->temp;
202196
r = (*s)(me); /* invoke state handler s */
203197

204-
/* unhandled due to a guard? */
205-
if (r == (QState)Q_RET_UNHANDLED) {
198+
if (r == (QState)Q_RET_UNHANDLED) { /* unhandled due to a guard? */
206199
iq = (int_fast8_t)Q_SIG(me); /* save the original signal */
207200
Q_SIG(me) = (QSignal)QEP_EMPTY_SIG_; /* find the superstate */
208201
r = (*s)(me); /* invoke state handler s */
@@ -256,7 +249,7 @@ void QHsm_dispatch_(QHsm * const me) {
256249
me->temp = path[0];
257250

258251
/* entry path must not overflow */
259-
Q_ASSERT_ID(710, ip < QHSM_MAX_NEST_DEPTH_);
252+
Q_ASSERT_ID(410, ip < QHSM_MAX_NEST_DEPTH_);
260253

261254
/* retrace the entry path in reverse (correct) order... */
262255
Q_SIG(me) = (QSignal)Q_ENTRY_SIG;
@@ -344,7 +337,7 @@ static int_fast8_t QHsm_tran_(QHsm * const me,
344337
iq = (int_fast8_t)1; /* indicate that LCA found */
345338

346339
/* entry path must not overflow */
347-
Q_ASSERT_ID(810, ip < QHSM_MAX_NEST_DEPTH_);
340+
Q_ASSERT_ID(510, ip < QHSM_MAX_NEST_DEPTH_);
348341
--ip; /* do not enter the source */
349342
r = (QState)Q_RET_HANDLED; /* terminate loop */
350343
}
@@ -358,7 +351,7 @@ static int_fast8_t QHsm_tran_(QHsm * const me,
358351
if (iq == (int_fast8_t)0) {
359352

360353
/* entry path must not overflow */
361-
Q_ASSERT_ID(820, ip < QHSM_MAX_NEST_DEPTH_);
354+
Q_ASSERT_ID(520, ip < QHSM_MAX_NEST_DEPTH_);
362355

363356
Q_SIG(me) = (QSignal)Q_EXIT_SIG;
364357
(void)(*s)(me); /* exit the source */
@@ -369,9 +362,7 @@ static int_fast8_t QHsm_tran_(QHsm * const me,
369362
iq = ip;
370363
r = (QState)Q_RET_IGNORED; /* LCA NOT found */
371364
do {
372-
s = path[iq];
373-
/* is this the LCA? */
374-
if (t == s) {
365+
if (t == path[iq]) { /* is this the LCA? */
375366
r = (QState)Q_RET_HANDLED; /* LCA found */
376367

377368
/* do not enter LCA */
@@ -383,7 +374,7 @@ static int_fast8_t QHsm_tran_(QHsm * const me,
383374
}
384375
} while (iq >= (int_fast8_t)0);
385376

386-
/* LCAnot found? */
377+
/* LCA not found? */
387378
if (r != (QState)Q_RET_HANDLED) {
388379
/* (g) check each source->super->...
389380
* for each target->super...
@@ -396,12 +387,11 @@ static int_fast8_t QHsm_tran_(QHsm * const me,
396387
Q_SIG(me) = (QSignal)QEP_EMPTY_SIG_;
397388
(void)(*t)(me); /* find super of t */
398389
}
399-
t = me->temp; /* set to super of t */
390+
t = me->temp; /* set to super of t */
400391
iq = ip;
401392
do {
402-
s = path[iq];
403393
/* is this LCA? */
404-
if (t == s) {
394+
if (t == path[iq]) {
405395
/* do not enter LCA */
406396
ip = (int_fast8_t)(iq-(int_fast8_t)1);
407397
/* cause breaking out of inner loop */
@@ -466,7 +456,7 @@ QStateHandler QHsm_childState_(QHsm * const me,
466456
me->temp = me->state; /* establish stable state configuration */
467457

468458
/** @post the child must be confirmed */
469-
Q_ENSURE_ID(910, isConfirmed != false);
459+
Q_ENSURE_ID(710, isConfirmed != false);
470460

471461
return child; /* return the child */
472462
}

libraries/qpn_avr/qfn.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
* @ingroup qfn
55
* @cond
66
******************************************************************************
7-
* Last updated for version 5.8.0
8-
* Last updated on 2016-11-18
7+
* Last updated for version 5.8.1
8+
* Last updated on 2016-12-16
99
*
1010
* Q u a n t u m L e a P s
1111
* ---------------------------
@@ -343,6 +343,12 @@ void QF_init(uint_fast8_t maxActive) {
343343
}
344344
#endif /* (QF_TIMEEVT_CTR_SIZE != 0) */
345345
}
346+
347+
#ifdef QV_INIT /* initialization of the QV-nano kernel defined? */
348+
QV_INIT(); /* port-specific initialization of the QV-nano kernel */
349+
#elif defined QK_INIT /* initialization of the QK-nano kernel defined? */
350+
QK_INIT(); /* port-specific initialization of the QK-nano kernel */
351+
#endif
346352
}
347353

348354
/****************************************************************************/

0 commit comments

Comments
 (0)