<commit_before>

#ifndef DYNAMIXEL_INTERFACE_H
#define DYNAMIXEL_INTERFACE_H

#include <Arduino.h>
#include "Dynamixel.h"


template<class T>
static void setReadMode(T &aStream);

template<class T>
static void setWriteMode(T &mStream);


template<class T>
class DynamixelInterfaceImpl:public DynamixelInterface
{
	private:
	/** \brief Switch stream to read (receive)) mode */
	void readMode()
	{
		if(mDirectionPin==NO_DIR_PORT)
		{
			digitalWrite(mDirectionPin, LOW);
		}
		else
		{
			setReadMode(mStream);
		}
	}
	
	/** \brief Switch stream to write (send) mode */
	void writeMode()
	{
		if(mDirectionPin==NO_DIR_PORT)
		{
			digitalWrite(mDirectionPin, HIGH);
		}
		else
		{
			setWriteMode(mStream);
		}
	}
	
	public:
	
	/**
	 * \brief Constructor
	 * \param[in] aStreamController : stream controller that abstract real stream
	 * \param[in] aDirectionPin : direction pin, use NO_DIR_PORT if you do not one (default)
	 * \param[in] aTranferOwnership : if true, the stream will be deleted in the destructor
	*/
	DynamixelInterfaceImpl(T &aStream, uint8_t aDirectionPin=NO_DIR_PORT, bool aTranferOwnership=false):
		mStream(aStream), mDirectionPin(aDirectionPin), mStreamOwner(aTranferOwnership)
	{
		if(mDirectionPin!=NO_DIR_PORT)
		{
			digitalWrite(mDirectionPin, LOW);
			pinMode(mDirectionPin, OUTPUT);
		}
	}
	<commit_msg>fix bug in read/write mode<commit_after>

#ifndef DYNAMIXEL_INTERFACE_H
#define DYNAMIXEL_INTERFACE_H

#include <Arduino.h>
#include "Dynamixel.h"


template<class T>
static void setReadMode(T &aStream);

template<class T>
static void setWriteMode(T &mStream);


template<class T>
class DynamixelInterfaceImpl:public DynamixelInterface
{
	private:
	/** \brief Switch stream to read (receive)) mode */
	void readMode()
	{
		if(mDirectionPin!=NO_DIR_PORT)
		{
			digitalWrite(mDirectionPin, LOW);
		}
		else
		{
			setReadMode(mStream);
		}
	}
	
	/** \brief Switch stream to write (send) mode */
	void writeMode()
	{
		if(mDirectionPin!=NO_DIR_PORT)
		{
			digitalWrite(mDirectionPin, HIGH);
		}
		else
		{
			setWriteMode(mStream);
		}
	}
	
	public:
	
	/**
	 * \brief Constructor
	 * \param[in] aStreamController : stream controller that abstract real stream
	 * \param[in] aDirectionPin : direction pin, use NO_DIR_PORT if you do not one (default)
	 * \param[in] aTranferOwnership : if true, the stream will be deleted in the destructor
	*/
	DynamixelInterfaceImpl(T &aStream, uint8_t aDirectionPin=NO_DIR_PORT, bool aTranferOwnership=false):
		mStream(aStream), mDirectionPin(aDirectionPin), mStreamOwner(aTranferOwnership)
	{
		if(mDirectionPin!=NO_DIR_PORT)
		{
			digitalWrite(mDirectionPin, LOW);
			pinMode(mDirectionPin, OUTPUT);
		}
	}
	
{'fraction_non_alphanumeric': 0.10795666791184161, 'fraction_numerical': 0.0007471049682480389, 'mean_word_length': 4.626050420168068, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4519940', 'n_tokens_mistral': 1045, 'n_tokens_neox': 949, 'n_words': 212}