Skip to content

Commit 4c409c4

Browse files
author
camilo
committed
bump to 1.8.0
1 parent ca0b45c commit 4c409c4

File tree

19 files changed

+404
-151
lines changed

19 files changed

+404
-151
lines changed

check/main.cpp

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,22 @@ using namespace qOS;
55

66

77
void idleTask_Callback( event_t e ) {
8+
e.self().setTime( 5_sec );
89
if ( e.firstCall() ) {
9-
10+
logger::out() << "first call";
1011
}
11-
12+
int x = 0;
1213
co::reenter() {
1314
co::delay( 500 );
1415
co::restart();
16+
co::waitUntil( false );
17+
co::perform(2.5_sec) {
18+
logger::out() << "hello world";
19+
} co::until( false );
1520
}
1621
}
1722

1823
int main() {
19-
os.init( nullptr, idleTask_Callback );
24+
(void)os.init( nullptr, idleTask_Callback );
2025
return 0;
2126
}

check/simple_dry_test.cpp

Lines changed: 30 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -69,11 +69,8 @@ unsigned long sysClock( void );
6969

7070
void idleTask_callback( event_t e )
7171
{
72-
unsigned int a;
73-
7472
if ( e.firstCall() ) {
75-
logger::out() << "idle task" << a;;
76-
logger::out() << e.thisTask();
73+
logger::out() << e;
7774
}
7875
co::reenter() {
7976
for(;;) {
@@ -106,7 +103,7 @@ co::semaphore sem(1);
106103
void otherTask( event_t e )
107104
{
108105
if ( e.firstCall() ) {
109-
logger::out() << e.thisTask();
106+
logger::out() << e;
110107
}
111108
co::reenter( otherTaskCrHandle ) {
112109
co::restart();
@@ -117,10 +114,13 @@ void otherTask( event_t e )
117114

118115
sm::status s1_callback( sm::handler_t h )
119116
{
117+
logger::out() << h;
120118
switch ( h.signal() ) {
121119
case sm::SIGNAL_ENTRY:
122120
logger::out() << logger::cyn << h.thisMachine() << h.thisState() << "s1_callback";
123121
h.thisMachine().timeoutSet( 0, 5_sec );
122+
h.thisMachine().timeoutSet( 1, 3_sec );
123+
h.thisMachine().timeoutSet( 2, 2_sec );
124124
break;
125125
case sm::SIGNAL_TIMEOUT( 0 ):
126126
h.nextState( s2 );
@@ -134,11 +134,13 @@ sm::status s1_callback( sm::handler_t h )
134134
sm::status s2_callback( sm::handler_t h )
135135
{
136136
static timer tmr;
137-
137+
logger::out() << h;
138138
logger::out() << logger::var(tmr);
139+
logger::out() << h.signal();
139140

140141
switch ( h.signal() ) {
141142
case sm::SIGNAL_ENTRY:
143+
142144
logger::out() << logger::cyn << h.thisMachine() << h.thisState() << "s2_callback";
143145
tmr( 5_sec );
144146
break;
@@ -153,19 +155,8 @@ sm::status s2_callback( sm::handler_t h )
153155

154156
void task_callback( event_t e )
155157
{
156-
logger::out() << e.self();
157-
158-
if ( e.firstCall() ) {
159-
logger::out() << logger::grn << "first call "<< e.thisTask();
160-
}
161-
162-
if( trigger::byNotificationSimple == e.getTrigger() ) {
163-
logger::out() << "notified(SIMPLE)! " << e.thisTask();
164-
}
165-
166-
if( trigger::byNotificationQueued == e.getTrigger() ) {
167-
logger::out() << "notified(QUEUED)! " << e.thisTask();
168-
}
158+
logger::out() << e;
159+
logger::out() << LEDsigqueue.q;
169160

170161
if ( e.lastIteration() ) {
171162
os.notify( notifyMode::QUEUED, t1, nullptr );
@@ -177,7 +168,7 @@ void task_callback( event_t e )
177168

178169
int someValue = 457;
179170
int *ptr = &someValue;
180-
logger::out() << logger::red <<"test trace "<< logger::dec << logger::var(someValue)<< " " << ptr;
171+
logger::out() << logger::red <<"test trace "<< logger::dec << logger::var(someValue)<< ptr;
181172

182173
}
183174

@@ -211,15 +202,33 @@ input::digitalChannel pinD3( 3, true );
211202
input::digitalChannel pinD4( 4, true );
212203
input::watcher pinWatcher( digitalRead, analogRead, 50_ms );
213204

205+
void pinEvent( input::channel& c ) {
206+
logger::out() << c;
207+
}
214208

215209
int main()
216210
{
217211

218212
uint32_t x = 0xFFAA2211;
219213
double y = -3.1416;
220214
logger::setOutputFcn( &putCharFcn );
215+
uint8_t area[ 256 ];
216+
mem::pool mypool( area, sizeof(area) );
217+
218+
pinWatcher.add( pinD2, pinEvent );
219+
pinWatcher.add( pinD3, pinEvent );
220+
pinWatcher.add( pinD4, pinEvent );
221+
pinWatcher.add( pinA0, pinEvent );
222+
223+
void *ptrx = nullptr;
224+
225+
226+
logger::out() << pinWatcher;
221227
logger::out() << logger::pre(8) << logger::var(y);
222228
logger::out() << logger::var(x) << logger::mem( sizeof(x) ) << &x;
229+
logger::out() << logger::var(y) << logger::mem( sizeof(y) ) << &y;
230+
logger::out() << ptrx;
231+
logger::out() << mypool;
223232
logger::out(logger::info) << "info message";
224233
logger::out(logger::error) << "error message";
225234
logger::out(logger::debug) << "debug message";
@@ -245,7 +254,7 @@ int main()
245254
os.add( t5, nullptr, core::MEDIUM_PRIORITY, 1_sec, task::PERIODIC );
246255

247256
t1.setName( "t1" );
248-
t2.setName( "t2" );
257+
//t2.setName( "t2" );
249258
t3.setName( "t3" );
250259
t4.setName( "t4" );
251260
t5.setName( "t5" );

src/QuarkTS.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*!
22
* @file QuarkTS.h
33
* @author J. Camilo Gomez C.
4-
* @version 1.7.9
4+
* @version 1.8.0
55
* @note This file is part of the QuarkTS++ distribution.
66
* @brief Global inclusion header
77
**/
@@ -41,8 +41,8 @@ This file is part of the QuarkTS++ OS distribution.
4141
#ifndef QOS_CPP_H
4242
#define QOS_CPP_H
4343

44-
#define QUARKTS_CPP_VERSION "1.7.9"
45-
#define QUARKTS_CPP_VERNUM ( 179u )
44+
#define QUARKTS_CPP_VERSION "1.8.0"
45+
#define QUARKTS_CPP_VERNUM ( 180u )
4646
#define QUARKTS_CPP_CAPTION "QuarkTS++ OS " QUARKTS_CPP_VERSION
4747

4848
#include "config/config.h"
@@ -67,7 +67,7 @@ This file is part of the QuarkTS++ OS distribution.
6767
namespace qOS {
6868
/*cstat -MISRAC++2008-0-1-4_b*/
6969
namespace build {
70-
constexpr const uint32_t number = 4238;
70+
constexpr const uint32_t number = 4367;
7171
constexpr const char* date = __DATE__;
7272
constexpr const char* time = __TIME__;
7373
constexpr const char* std = "c++11";
@@ -76,8 +76,8 @@ namespace qOS {
7676
constexpr const char* str = QUARKTS_CPP_VERSION;
7777
constexpr const uint8_t number = QUARKTS_CPP_VERNUM;
7878
constexpr const uint8_t mayor = 1U;
79-
constexpr const uint8_t minor = 7U;
80-
constexpr const uint8_t rev = 9U;
79+
constexpr const uint8_t minor = 8U;
80+
constexpr const uint8_t rev = 0U;
8181
}
8282
namespace product {
8383
constexpr const char* author = "J. Camilo Gomez C.";

src/critical.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
using namespace qOS;
44

55
/*! @cond */
6-
int_disabler_t critical::lock::disable = nullptr; /*< Point to the user-supplied function used to disable the hardware interrupts. */
7-
int_restorer_t critical::lock::restore = nullptr; /*< Point to the user-supplied function used to restore the hardware interrupts. */
8-
volatile uint32_t critical::lock::flags = 0UL; /*< To save the current interrupt flags before the disable action is performed. */
9-
volatile int critical::lock::nestingLevel = 0;
6+
int_disabler_t critical::lock::disable = nullptr; // skipcq: CXX-W2009 /*< Point to the user-supplied function used to disable the hardware interrupts. */
7+
int_restorer_t critical::lock::restore = nullptr; // skipcq: CXX-W2009 /*< Point to the user-supplied function used to restore the hardware interrupts. */
8+
volatile uint32_t critical::lock::flags = 0UL; // skipcq: CXX-W2009 /*< To save the current interrupt flags before the disable action is performed. */
9+
volatile int critical::lock::nestingLevel = 0; // skipcq: CXX-W2009
1010
/*! @endcond */
1111

1212
/*============================================================================*/

src/fsm.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,13 @@ const sm::timeoutSpecOption_t sm::TIMEOUT_RST_EXIT = 0x08000000UL;
1111
const sm::timeoutSpecOption_t sm::TIMEOUT_KEEP_IF_SET = 0x10000000UL;
1212
const sm::timeoutSpecOption_t sm::TIMEOUT_PERIODIC = 0x20000000UL;
1313

14+
/*cstat -MISRAC++2008-8-5-2*/
1415
/*============================================================================*/
1516
sm::signalPublisher::signalPublisher()
1617
{
1718
unsubscribeAll();
1819
}
20+
/*cstat +MISRAC++2008-8-5-2*/
1921
/*============================================================================*/
2022
void sm::signalPublisher::unsubscribeAll( void ) noexcept
2123
{

src/include/coroutine.hpp

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -126,11 +126,13 @@ namespace qOS {
126126
co::state label{ co::BEGINNING };
127127
qOS::timer tm;
128128
public:
129+
/*cstat -CERT-MSC40-C_a*/
129130
coContext() = default;
130131
inline void saveHandle( co::handle& h ) noexcept
131132
{
132133
h.ctx = this;
133134
}
135+
/*cstat +CERT-MSC40-C_a*/
134136
inline static void saveHandle( void ) noexcept {}
135137
inline static void semSignal( semaphore& s ) noexcept
136138
{
@@ -140,11 +142,13 @@ namespace qOS {
140142
{
141143
return s.tryLock();
142144
}
145+
/*cstat -COP-member-uninit*/
143146
inline coContext& operator=( co::state l )
144147
{
145148
label = l;
146149
return *this;
147150
}
151+
/*cstat +COP-member-uninit*/
148152
inline operator co::state() const
149153
{
150154
return label;
@@ -321,6 +325,7 @@ namespace qOS {
321325
* @note Must be used together with a matching co::until() statement.
322326
* @warning Co-routines statements are not allowed within the job segment.
323327
* and can produce undefined behavior.
328+
*
324329
* Example:
325330
* @code{.c}
326331
* co::perform() {
@@ -337,6 +342,7 @@ namespace qOS {
337342
* @warning Co-routines statements are not allowed within the job segment.
338343
* and can produce undefined behavior.
339344
* @param[in] t The timeout for the specified job segment.
345+
*
340346
* Example:
341347
* @code{.c}
342348
* co::perform( timeout ) {
@@ -362,6 +368,10 @@ namespace qOS {
362368
* @endcode
363369
*/
364370
inline void until( bool condition ) noexcept { Q_UNUSED(condition); }
371+
372+
373+
374+
inline void until( bool condition, qOS::duration_t timeout ) noexcept { Q_UNUSED(condition); Q_UNUSED(timeout); }
365375
/*cstat +MISRAC++2008-0-1-11 +MISRAC++2008-7-1-2*/
366376

367377
/** @}*/
@@ -383,12 +393,12 @@ reenter(); \
383393
static qOS::co::coContext co_ctx; \
384394
co_ctx.saveHandle( h ); \
385395
for ( ; co_ctx != qOS::co::SUSPENDED ; co_ctx = qOS::co::SUSPENDED ) \
386-
if ( 0 ) { \
396+
if ( false ) { \
387397
goto q_co_continue; \
388398
q_co_continue: \
389399
continue; \
390400
} \
391-
else if ( 0 ) { \
401+
else if ( false ) { \
392402
goto q_co_break; \
393403
q_co_break: \
394404
break; \
@@ -401,7 +411,7 @@ for ( ; co_ctx != qOS::co::SUSPENDED ; co_ctx = qOS::co::SUSPENDED ) \
401411
#define q_co_SaveRestore( label, init_action, pos_label_action ) \
402412
init_action; \
403413
for ( co_ctx = (label) ;; ) \
404-
if ( 0 ) { \
414+
if ( false ) { \
405415
case ( label ) : { \
406416
pos_label_action \
407417
break; \
@@ -431,7 +441,7 @@ q_co_SaveRestore( label, qOS::co::crNOP(), Q_NONE ) \
431441
#define delay( t ) q_co_delay( q_co_label , t)
432442
#define q_co_delay( label, t ) \
433443
delay( t ); \
434-
q_co_SaveRestore( label, co_ctx(t) , q_co_t_cond(0) ) \
444+
q_co_SaveRestore( label, co_ctx(t) , q_co_t_cond(false) ) \
435445

436446
/*============================================================================*/
437447
#define q_co_wu_1( c ) q_co_waitUntil( q_co_label , c )
@@ -493,6 +503,8 @@ q_co_SaveRestore( q_co_label, co_ctx(t), Q_NONE ); \
493503
until( c ); \
494504
q_co_cond( ( c ) || co_ctx.timeout() ) \
495505
/*============================================================================*/
506+
507+
496508
/*! @endcond */
497509

498510
#endif /*QOS_CPP_CO*/

src/include/critical.hpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -95,10 +95,10 @@ namespace qOS {
9595
private:
9696
static void enter( void ) noexcept;
9797
static void exit( void ) noexcept;
98-
static int_disabler_t disable;
99-
static int_restorer_t restore;
100-
static volatile uint32_t flags;
101-
static volatile int nestingLevel;
98+
static int_disabler_t disable; // skipcq: CXX-W2009
99+
static int_restorer_t restore; // skipcq: CXX-W2009
100+
static volatile uint32_t flags; // skipcq: CXX-W2009
101+
static volatile int nestingLevel; // skipcq: CXX-W2009
102102
bool entered{ true };
103103
friend bool setInterruptsED( const int_restorer_t rFcn, const int_disabler_t dFcn ) noexcept;
104104
public:

src/include/fsm.hpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -383,10 +383,18 @@ namespace qOS {
383383
{
384384
return *State;
385385
}
386+
inline const state& thisState( void ) const noexcept
387+
{
388+
return *State;
389+
}
386390
inline stateMachine& thisMachine( void ) noexcept
387391
{
388392
return *Machine;
389393
}
394+
inline const stateMachine& thisMachine( void ) const noexcept
395+
{
396+
return *Machine;
397+
}
390398
inline signalID signal( void ) const noexcept
391399
{
392400
return Signal;

src/include/input.hpp

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -449,7 +449,7 @@ namespace qOS {
449449
friend class watcher;
450450
};
451451

452-
452+
/*cstat -MISRAC++2008-2-13-3*/
453453
/**
454454
* @brief The digital input-channel watcher class.
455455
*/
@@ -545,13 +545,32 @@ namespace qOS {
545545
* updated cycle. Otherwise @c false.
546546
*/
547547
bool watch( void ) noexcept;
548-
/*! @cond */
548+
/**
549+
* @brief Watch for the state and events for all channels
550+
* registered inside the watcher instance (Non-Blocking call).
551+
* @return @c true when the input channels have been completed an
552+
* updated cycle. Otherwise @c false.
553+
*/
549554
inline bool operator()( void )
550555
{
551556
return watch();
552557
}
553-
/*! @endcond */
558+
/**
559+
* @brief Returns the number of analog channels monitored by
560+
* this instance.
561+
* @return The number of analog channels managed by the watcher
562+
* instance.
563+
*/
564+
size_t getAnalogChannelsCount( void ) const noexcept;
565+
/**
566+
* @brief Returns the number of digital channels monitored by
567+
* this instance.
568+
* @return The number of digital channels managed by the watcher
569+
* instance.
570+
*/
571+
size_t getDigitalChannelsCount( void ) const noexcept;
554572
};
573+
/*cstat +MISRAC++2008-2-13-3*/
555574
/** @}*/
556575
}
557576

0 commit comments

Comments
 (0)