Hello,
I have a few questions about using the Serial over USB Driver (SDU1 on STM32F072B).
If I may ask:
1. How thread safe is it?
a. Is it safe to have a writer thread (chnWriteTimeout) and a reader thread (chnReadTimeout) running at the same time?
b. Is it safe to have multiple writer threads doing chnWriteTimeout or will messages intermingle/corrupt?
2. Does the chnWrite/chnRead function return once the data in place into the appropriate buffer or does it wait until the data actually sent?
a. Would it be an acceptable pattern to have multiple threads do blocking writes or would this result in very long waits because it has to be sent over the wire before the functions returns?
3. How big is the efficiency difference of calling chnWriteTimeout vs repeated calls of chnPutTimeout?
Thanks!
chnWriteTimeout with USB Serial - finish on buffer write or device write?
-
- Posts: 38
- Joined: Sat Jan 10, 2015 10:12 pm
- Has thanked: 1 time
- Been thanked: 1 time
- 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: chnWriteTimeout with USB Serial - finish on buffer write or device write?
Hi,
1) Both are thread safe but operation atomicity is not assured. You need an external mutex/semaphore for that.
2) Data has been sent because it returns when USB completes the transaction.
Giovanni
1) Both are thread safe but operation atomicity is not assured. You need an external mutex/semaphore for that.
2) Data has been sent because it returns when USB completes the transaction.
Giovanni
- 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: chnWriteTimeout with USB Serial - finish on buffer write or device write?
Correction on point 2:
The function can return after simply writing in the buffer. If you need control over this then you may consider using the "raw" USB API without buffering, there is a demo about this: /testhal/STM32/STM32F7xx/USB_RAW
Giovanni
The function can return after simply writing in the buffer. If you need control over this then you may consider using the "raw" USB API without buffering, there is a demo about this: /testhal/STM32/STM32F7xx/USB_RAW
Giovanni
Who is online
Users browsing this forum: No registered users and 23 guests