sdWrite behavoir

Discussions and support about ChibiOS/HAL, the MCU Hardware Abstraction Layer.
Post Reply
neums
Posts: 137
Joined: Fri May 08, 2015 1:09 pm
Has thanked: 10 times
Been thanked: 5 times

sdWrite behavoir

Post by neums »

Hi,
is the sdWrite function blocking until the data is transferred? In my application it does not block.

I use my own task scheduler and the osless-osal. When i get a task overrun the software shall lead into an endless loop until the watchdog gets active. Before entering this loop i want to disable the interrupts globally by osalSysDisable().

Before disabling the interrupt i want to send an error message via the serial driver. But i just get a few letters...

Thanks
User avatar
Giovanni
Site Admin
Posts: 14893
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 997 times

Re: sdWrite behavoir

Post by Giovanni »

Hi,

sdWrite() blocks until all the data has been written on the output buffer, this does not mean actually transmitted.

If you need to synchronize with the physical transmission look for the serial driver events, there is an event signalling that

Giovanni
neums
Posts: 137
Joined: Fri May 08, 2015 1:09 pm
Has thanked: 10 times
Been thanked: 5 times

Re: sdWrite behavoir

Post by neums »

Hi,
thanks. I wrote a little helper for this usecase:

Code: Select all

#define sdBlockingWrite(sdp, b, n)                       \
  sdp->event.flags &= ~CHN_TRANSMISSION_END;             \
  oqWriteTimeout(&(sdp)->oqueue, b, n, TIME_INFINITE);   \
  while((sdp->event.flags & CHN_TRANSMISSION_END) == 0)


Maybe it is interesting.
User avatar
Giovanni
Site Admin
Posts: 14893
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 997 times

Re: sdWrite behavoir

Post by Giovanni »

Hi,

There is no need to poll for the event, you could use event wait functions for this.

Giovanni
neums
Posts: 137
Joined: Fri May 08, 2015 1:09 pm
Has thanked: 10 times
Been thanked: 5 times

Re: sdWrite behavoir

Post by neums »

Which is the function without RT? I just use the os-less osal. Is there a function like chEvtWaitOne without RT?
User avatar
Giovanni
Site Admin
Posts: 14893
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 997 times

Re: sdWrite behavoir

Post by Giovanni »

There is no such function, without OS events are implemented as callbacks. See the details in OSAL.

Giovanni
Post Reply