Hi!
Does it possible to flush serial driver buffer?
Thanks in advance!
Serial Driver flush buffer
- Giovanni
- Site Admin
- Posts: 14444
- Joined: Wed May 27, 2009 8:48 am
- Location: Salerno, Italy
- Has thanked: 1074 times
- Been thanked: 921 times
- Contact:
Re: Serial Driver flush buffer
Hi,
If you want to erase all the buffered content there are two ways:
1) Read and discard all content using TIME_IMMEDIATE, you get MSG_TIMEOUT when the queue is empty.
2) Reset the queue directly using iqResetI().
osalSysLock();
isResetI();
osalOsRescheduleS();
osalSysUnlock();
You may use "ch" function instead of "osal" functions, it is the same.
Giovanni
If you want to erase all the buffered content there are two ways:
1) Read and discard all content using TIME_IMMEDIATE, you get MSG_TIMEOUT when the queue is empty.
2) Reset the queue directly using iqResetI().
osalSysLock();
isResetI();
osalOsRescheduleS();
osalSysUnlock();
You may use "ch" function instead of "osal" functions, it is the same.
Giovanni
Re: Serial Driver flush buffer
Hi,
I mean output buffer, is there any method to force driver process all output buffer to implement this scenario:
sdStart();
chprintf("log message");
// force driver to process log message before stop it
sdStop();
I mean output buffer, is there any method to force driver process all output buffer to implement this scenario:
sdStart();
chprintf("log message");
// force driver to process log message before stop it
sdStop();
Vitaly
- Giovanni
- Site Admin
- Posts: 14444
- Joined: Wed May 27, 2009 8:48 am
- Location: Salerno, Italy
- Has thanked: 1074 times
- Been thanked: 921 times
- Contact:
Re: Serial Driver flush buffer
Hi,
There is a specific event flag for transmission complete, you need to wait for that.
Giovanni
There is a specific event flag for transmission complete, you need to wait for that.
Giovanni
Re: Serial Driver flush buffer
Hi, Giovanni!
Is this right way to wait transmission complete:
event_listener_t serial_listener;
chEvtRegisterMaskWithFlags(&(SD2.event), &serial_listener, EVENT_MASK(0), CHN_TRANSMISSION_END);
sdStart(&STDOUT_SD, &SD2Config);
<write to STDOUT_SD>
while (true) {
chEvtWaitAny(EVENT_MASK(0));
if (chEvtGetAndClearFlags(&serial_listener) & CHN_TRANSMISSION_END) {
break;
}
}
sdStop(&STDOUT_SD);
Is this right way to wait transmission complete:
event_listener_t serial_listener;
chEvtRegisterMaskWithFlags(&(SD2.event), &serial_listener, EVENT_MASK(0), CHN_TRANSMISSION_END);
sdStart(&STDOUT_SD, &SD2Config);
<write to STDOUT_SD>
while (true) {
chEvtWaitAny(EVENT_MASK(0));
if (chEvtGetAndClearFlags(&serial_listener) & CHN_TRANSMISSION_END) {
break;
}
}
sdStop(&STDOUT_SD);
Vitaly
- Giovanni
- Site Admin
- Posts: 14444
- Joined: Wed May 27, 2009 8:48 am
- Location: Salerno, Italy
- Has thanked: 1074 times
- Been thanked: 921 times
- Contact:
Re: Serial Driver flush buffer
At risk of stating the obvious, dependent on your application you may need to check that there is a transmission in progress before waiting for it to complete. Or just add a timeout into the event wait.
Re: Serial Driver flush buffer
Hi,
is there no queue for events? In this case you are right, there is a chance to wait forever.
Can not figure out how to check that transmission is in progress....
is there no queue for events? In this case you are right, there is a chance to wait forever.
Can not figure out how to check that transmission is in progress....
Vitaly
- Giovanni
- Site Admin
- Posts: 14444
- Joined: Wed May 27, 2009 8:48 am
- Location: Salerno, Italy
- Has thanked: 1074 times
- Been thanked: 921 times
- Contact:
Re: Serial Driver flush buffer
Hi,
Events are bit masks, there is no queuing. You need to make sure there are no events pending before starting transmission.
Giovanni
Events are bit masks, there is no queuing. You need to make sure there are no events pending before starting transmission.
Giovanni
Who is online
Users browsing this forum: No registered users and 8 guests