Go to Post In FIRST you have the right to remain silent, anything you say can and will be held against you and your associates in the court of public opinion. - Koko Ed [more]
Home
Go Back   Chief Delphi > Technical > Programming > C/C++
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Reply
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 14-01-2012, 19:04
POSIXGuru POSIXGuru is offline
Registered User
FRC #1389 (The Body Electric)
Team Role: Programmer
 
Join Date: Jan 2012
Rookie Year: 2012
Location: Walt Whitman High School
Posts: 3
POSIXGuru is an unknown quantity at this point
Thread Safety/Reentrancy in WPILib

Hi all,

I was wondering if anyone knew if the the motor output functions in WPILib are thread safe. If they aren't, worst case, I wil just use a binary semaphore to ensure that only one thread is using the motors at the same time.

Thanks.
Reply With Quote
  #2   Spotlight this post!  
Unread 15-01-2012, 11:21
pmalmsten pmalmsten is offline
Registered User
no team
Team Role: Mentor
 
Join Date: Jan 2011
Rookie Year: 2006
Location: United States
Posts: 9
pmalmsten is on a distinguished road
Re: Thread Safety/Reentrancy in WPILib

As far as I know, WPILib speed controller objects are not thread-safe.

I'm curious; why would you want to set the output of a speed controller from more than one thread?
Reply With Quote
  #3   Spotlight this post!  
Unread 15-01-2012, 14:23
POSIXGuru POSIXGuru is offline
Registered User
FRC #1389 (The Body Electric)
Team Role: Programmer
 
Join Date: Jan 2012
Rookie Year: 2012
Location: Walt Whitman High School
Posts: 3
POSIXGuru is an unknown quantity at this point
Re: Thread Safety/Reentrancy in WPILib

It's not that I want to set the speed of the same motor from different threads, but that I want to set the speeds of different motors from different threads. However, depending on how the cRIO communicates with the digital sidecar, it might pose a problem. For example, if it uses a serial command format, and, let's say we want to turn on two motors at the same time from different threads. Usually, it would send the open command followed by the motor ID. However, if we were unlucky, it would send the open command to turn on the first motor, and then it would switch threads to the other motor thread. That thread would then send its open command, which would be interpreted by the digital sidecar as a motor ID, causing sporadic motor movement.
Reply With Quote
  #4   Spotlight this post!  
Unread 15-01-2012, 14:27
pmalmsten pmalmsten is offline
Registered User
no team
Team Role: Mentor
 
Join Date: Jan 2011
Rookie Year: 2006
Location: United States
Posts: 9
pmalmsten is on a distinguished road
Re: Thread Safety/Reentrancy in WPILib

Oh, I see what you mean. In that case, yes, the lower-level implementation is thread-safe.

WPILib has no problem updating unique speed controller objects from within different threads.
__________________
~Paul Malmsten
Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 03:06.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi