src/libYARP_dev/esdcan/linux/yarp/YARPEsdCanDeviceDriver.cpp
int YARPEsdCanDeviceDriver::setPosition (void *cmd)
{
	/// prepare can message.
	EsdCanResources& r = RES(system_resources);
	SingleAxisParameters *tmp = (SingleAxisParameters *) cmd;
	const int axis = tmp->axis;
	ACE_ASSERT (axis >= 0 && axis <= (ESD_MAX_CARDS-1)*2);

	if (!ENABLED (axis))
	{
		// still fills the _ref_position structure.
		_ref_positions[axis] = *((double *)tmp->parameters);
		return YARP_OK;
	}

	_mutex.Wait();

	r.startPacket();
	r.addMessage (CAN_POSITION_MOVE, axis);

	_ref_positions[axis] = *((double *)tmp->parameters);
	*((int*)(r._writeBuffer[0].data+1)) = S_32(_ref_positions[axis]);		/// pos
	*((short*)(r._writeBuffer[0].data+5)) = S_16(_ref_speeds[axis]);			/// speed
	r._writeBuffer[0].len = 7;
		
	_writerequested = true;
	_noreply = true;
	
	_mutex.Post();

	/// syncing.
	_done.Wait();

	return YARP_OK;
}
///
///
/// cmd is a SingleAxisParameters pointer to a double argument
cmd is a SingleAxisParameters pointer to a double argument
cmd is a SingleAxisParameters pointer to a double argument
int YARPEsdCanDeviceDriver::setPosition (void *cmd)
{
	EsdCanResources& r = RES(system_resources);
	SingleAxisParameters *tmp = (SingleAxisParameters *) cmd;
	const int axis = tmp->axis;
	ACE_ASSERT (axis >= 0 && axis <= (ESD_MAX_CARDS-1)*2);
	if (!ENABLED (axis))
	{
		_ref_positions[axis] = *((double *)tmp->parameters);
		return YARP_OK;
	}
	_mutex.Wait();
	r.startPacket();
	r.addMessage (CAN_POSITION_MOVE, axis);
	_ref_positions[axis] = *((double *)tmp->parameters);
	*((int*)(r._writeBuffer[0].data+1)) = S_32(_ref_positions[axis]);		
	*((short*)(r._writeBuffer[0].data+5)) = S_16(_ref_speeds[axis]);			
	r._writeBuffer[0].len = 7;
	_writerequested = true;
	_noreply = true;
	_mutex.Post();
	_done.Wait();
	return YARP_OK;
}
int YARPEsdCanDeviceDriver :: setPosition ( void * cmd ) { EsdCanResources & r = RES ( system_resources ) ; SingleAxisParameters * tmp = ( SingleAxisParameters * ) cmd ; const int axis = tmp -> axis ; ACE_ASSERT ( axis >= 0 && axis <= ( ESD_MAX_CARDS - 1 ) * 2 ) ; if ( ! ENABLED ( axis ) ) { _ref_positions [ axis ] = * ( ( double * ) tmp -> parameters ) ; return YARP_OK ; } _mutex . Wait ( ) ; r . startPacket ( ) ; r . addMessage ( CAN_POSITION_MOVE , axis ) ; _ref_positions [ axis ] = * ( ( double * ) tmp -> parameters ) ; * ( ( int * ) ( r . _writeBuffer [ 0 ] . data + 1 ) ) = S_32 ( _ref_positions [ axis ] ) ; * ( ( short * ) ( r . _writeBuffer [ 0 ] . data + 5 ) ) = S_16 ( _ref_speeds [ axis ] ) ; r . _writeBuffer [ 0 ] . len = 7 ; _writerequested = true ; _noreply = true ; _mutex . Post ( ) ; _done . Wait ( ) ; return YARP_OK ; }
cmd is a SingleAxisParameters pointer to a double argument
cmd is a SingleAxisParameters pointer to a double argument
/// prepare can message. // still fills the _ref_position structure. /// pos /// speed /// syncing.