Serial Driver Input Queue Reset
- RoccoMarco
- Posts: 655
- Joined: Wed Apr 24, 2013 4:11 pm
- Location: Munich (Germany)
- Has thanked: 83 times
- Been thanked: 67 times
- Contact:
Re: Serial Driver Input Queue Reset
iqResetI must be called from an interrupt context. Enabling state checker in chconf.h system should halts itself.
Check for a function without I. I am from mobile. I'll provide a better answer later.
Ciao
Check for a function without I. I am from mobile. I'll provide a better answer later.
Ciao
Ciao,
RM
RM
- RoccoMarco
- Posts: 655
- Joined: Wed Apr 24, 2013 4:11 pm
- Location: Munich (Germany)
- Has thanked: 83 times
- Been thanked: 67 times
- Contact:
Re: Serial Driver Input Queue Reset
Ok,
so quoting documentation
This mean, unless you are in an interrupt context, you have to enter in S-Locked state
so your code should be
so quoting documentation
API Name Suffixes
The suffix can be one of the following:
None, APIs without any suffix can be invoked only from the user code in the Normal state unless differently specified. See System States.
"I", I-Class APIs are invokable only from the I-Locked or S-Locked states. See System States.
"S", S-Class APIs are invokable only from the S-Locked state. See System States.
This mean, unless you are in an interrupt context, you have to enter in S-Locked state
so your code should be
Code: Select all
chSysLock();
iqResetI(&SD2.iqueue);
chSysUnlock();
Ciao,
RM
RM
Re: Serial Driver Input Queue Reset
RoccoMarco wrote:Ok,
so quoting documentationAPI Name Suffixes
The suffix can be one of the following:
None, APIs without any suffix can be invoked only from the user code in the Normal state unless differently specified. See System States.
"I", I-Class APIs are invokable only from the I-Locked or S-Locked states. See System States.
"S", S-Class APIs are invokable only from the S-Locked state. See System States.
This mean, unless you are in an interrupt context, you have to enter in S-Locked state
so your code should beCode: Select all
chSysLock();
iqResetI(&SD2.iqueue);
chSysUnlock();
Thanks for the response, did do the same with the locks.
Might be nice to add this feature to the sd driver ?
I dont mind doing the changes, and submitting it to you.
- RoccoMarco
- Posts: 655
- Joined: Wed Apr 24, 2013 4:11 pm
- Location: Munich (Germany)
- Has thanked: 83 times
- Been thanked: 67 times
- Contact:
Re: Serial Driver Input Queue Reset
For me, hard to tell. The APIs design is up to Giovanni.
Maybe it could be helpful to propose a scenario in which this API could be useful.
Maybe it could be helpful to propose a scenario in which this API could be useful.
Ciao,
RM
RM
- Giovanni
- Site Admin
- Posts: 14457
- Joined: Wed May 27, 2009 8:48 am
- Location: Salerno, Italy
- Has thanked: 1076 times
- Been thanked: 922 times
- Contact:
Re: Serial Driver Input Queue Reset
Resetting a queue is usually done from ISR context, this is why there is only the I function. I will add it as an inline function.
Giovanni
Giovanni
Re: Serial Driver Input Queue Reset
RoccoMarco wrote:For me, hard to tell. The APIs design is up to Giovanni.
Maybe it could be helpful to propose a scenario in which this API could be useful.
If you start a serial driver with say gps reciever connected, but dont start the thread that removes data from the queue for some seconds after the start of the driver, you will end up with buffer overruns as the queue if full. Hence why reseting the input queue was needed.
This happens as I use 1 uart for two things
1 the tx is used for debug ouput and thus I need this running right at the start of the application.
2 the rx is used to receive the gps nmea stings. This is done in a thread but starts maybe a second after the application debug is started.
Normally I would not have this situation, but hardware constraints dictated.
Who is online
Users browsing this forum: No registered users and 29 guests