]> rtime.felk.cvut.cz Git - eurobot/public.git/commitdiff
Merge branch 'maint-demo'
authorMichal Sojka <sojkam1@fel.cvut.cz>
Thu, 24 Oct 2013 05:24:29 +0000 (07:24 +0200)
committerMichal Sojka <sojkam1@fel.cvut.cz>
Thu, 24 Oct 2013 05:24:29 +0000 (07:24 +0200)
Conflicts:
src/hokuyo/lib/serial_ctrl_lin.c

1  2 
src/hokuyo/lib/serial_ctrl_lin.c

index d698bbc531f31f8ff1aac77cdc1267fac7674d8a,ac595fa5b0ee5ff3dac8af920c69da64372e288d..212ccd5b0178d64d74f5a26f7fe817cb76cbef1b
@@@ -1,8 -1,8 +1,8 @@@
  /*!
    \file
--  \brief \83V\83\8a\83A\83\8b\92Ê\90M (Linux, Mac \8eÀ\91\95)
++  \brief �V���A���ʐM (Linux, Mac ���)
  
--  Serial Communication Interface \90§\8cä
++  Serial Communication Interface ����
  
  
    \author Satofumi KAMIMURA
  #include <fcntl.h>
  #include <errno.h>
  #include <string.h>
 +#include <sys/select.h>
+ #include <time.h>
+ #include <sys/types.h>
 +
  //#include <ctype.h>
  
  enum {
@@@ -42,7 -43,7 +45,7 @@@ void serial_initialize(serial_t *serial
  }
  
  
--/* \90Ú\91± */
++/* �ڑ� */
  int serial_connect(serial_t *serial, const char *device, long baudrate)
  {
    int flags = 0;
    serial_initialize(serial);
  
  #ifndef MAC_OS
--  enum { O_EXLOCK = 0x0 }; /* Linux \82Å\82Í\8eg\82¦\82È\82¢\82Ì\82Å\83_\83~\81[\82ð\8dì\90¬\82µ\82Ä\82¨\82­ */
++  enum { O_EXLOCK = 0x0 }; /* Linux �ł͎g���Ȃ��̂Ń_�~�[���쐬���Ă��� */
  #endif
    serial->fd_ = open(device, O_RDWR | O_EXLOCK | O_NONBLOCK | O_NOCTTY);
    if (serial->fd_ < 0) {
--    /* \90Ú\91±\82É\8e¸\94s */
++    /* �ڑ��Ɏ��s */
      strerror_r(errno, serial->error_string_, SerialErrorStringSize);
      return SerialConnectionFail;
    }
@@@ -63,7 -64,7 +66,7 @@@
    flags = fcntl(serial->fd_, F_GETFL, 0);
    fcntl(serial->fd_, F_SETFL, flags & ~O_NONBLOCK);
  
--  /* \83V\83\8a\83A\83\8b\92Ê\90M\82Ì\8f\89\8aú\89» */
++  /* �V���A���ʐM�̏����� */
    tcgetattr(serial->fd_, &serial->sio_);
    serial->sio_.c_iflag = 0;
    serial->sio_.c_oflag = 0;
    serial->sio_.c_cc[VMIN] = 0;
    serial->sio_.c_cc[VTIME] = 0;
  
--  /* \83{\81[\83\8c\81[\83g\82̕ύX */
++  /* �{�[���[�g�̕ύX */
    ret = serial_setBaudrate(serial, baudrate);
    if (ret < 0) {
      return ret;
    }
  
--  /* \83V\83\8a\83A\83\8b\90§\8cä\8d\\91¢\91Ì\82Ì\8f\89\8aú\89» */
++  /* �V���A�������\���̂̏����� */
    serial->has_last_ch_ = False;
  
    return 0;
  }
  
  
--/* \90ؒf */
++/* ؒf */
  void serial_disconnect(serial_t *serial)
  {
    if (serial->fd_ >= 0) {
@@@ -103,7 -104,7 +106,7 @@@ int serial_isConnected(const serial_t *
  }
  
  
--/* \83{\81[\83\8c\81[\83g\82Ì\90Ý\92è */
++/* �{�[���[�g�̐ݒ� */
  int serial_setBaudrate(serial_t *serial, long baudrate)
  {
    long baudrate_value = -1;
      return SerialSetBaudrateFail;
    }
  
--  /* \83{\81[\83\8c\81[\83g\95ύX */
++  /* �{�[���[�g�ύX */
    cfsetospeed(&serial->sio_, baudrate_value);
    cfsetispeed(&serial->sio_, baudrate_value);
    tcsetattr(serial->fd_, TCSADRAIN, &serial->sio_);
  }
  
  
--/* \91\97\90M */
++/* ���M */
  int serial_send(serial_t *serial, const char *data, int data_size)
  {
    if (! serial_isConnected(serial)) {
@@@ -162,7 -163,7 +165,7 @@@ static int waitReceive(serial_t* serial
    fd_set rfds;
    struct timeval tv;
  
--  // \83^\83C\83\80\83A\83E\83g\90Ý\92è
++  // �^�C���A�E�g�ݒ�
    FD_ZERO(&rfds);
    FD_SET(serial->fd_, &rfds);
  
  
    if (select(serial->fd_ + 1, &rfds, NULL, NULL,
               (timeout < 0) ? NULL : &tv) <= 0) {
--    /* \83^\83C\83\80\83A\83E\83g\94­\90 */
++    /* �^�C���A�E�g���� */
      return 0;
    }
    return 1;
@@@ -198,7 -199,7 +201,7 @@@ static int internal_receive(char data[]
      require_n = data_size_max - filled;
      read_n = read(serial->fd_, &data[filled], require_n);
      if (read_n <= 0) {
--      /* \93Ç\82Ý\8fo\82µ\83G\83\89\81[\81B\8c»\8dÝ\82Ü\82Å\82Ì\8eó\90M\93à\97e\82Å\96ß\82é */
++      /* �ǂݏo���G���[�B���݂܂ł̎��M���e�Ŗ߂� */
        break;
      }
      filled += read_n;
  }
  
  
--/* \8eó\90M */
++/* ���M */
  int serial_recv(serial_t *serial, char* data, int data_size_max, int timeout)
  {
    int filled;
      return 0;
    }
  
--  /* \8f\91\82«\96ß\82µ\82½\82P\95\8e\9a\82ª\82 \82ê\82Î\81A\8f\91\82«\8fo\82· */
++  /* �����߂����P�����������΁A�����o�� */
    filled = 0;
    if (serial->has_last_ch_ != False) {
      data[0] = serial->last_ch_;
    buffer_size = ring_size(&serial->ring_);
    read_n = data_size_max - filled;
    if (buffer_size < read_n) {
--    // \83\8a\83\93\83O\83o\83b\83t\83@\93à\82Ì\83f\81[\83^\82Å\91«\82è\82È\82¯\82ê\82Î\81A\83f\81[\83^\82ð\93Ç\82Ý\91«\82·
++    // �����O�o�b�t�@���̃f�[�^�ő����Ȃ����΁A�f�[�^���ǂݑ���
      char buffer[RingBufferSize];
      int n = internal_receive(buffer,
                               ring_capacity(&serial->ring_) - buffer_size,
    }
    buffer_size = ring_size(&serial->ring_);
  
--  // \83\8a\83\93\83O\83o\83b\83t\83@\93à\82Ì\83f\81[\83^\82ð\95Ô\82·
++  // �����O�o�b�t�@���̃f�[�^���Ԃ�
    if (read_n > buffer_size) {
      read_n = buffer_size;
    }
      filled += read_n;
    }
  
--  // \83f\81[\83^\82ð\83^\83C\83\80\83A\83E\83g\95t\82«\82Å\93Ç\82Ý\8fo\82·
++  // �f�[�^���^�C���A�E�g�t���œǂݏo��
    filled += internal_receive(&data[filled],
                               data_size_max - filled, serial, timeout);
    return filled;
  }
  
  
--/* \82P\95\8e\9a\8f\91\82«\96ß\82· */
++/* �P���������߂� */
  void serial_ungetc(serial_t *serial, char ch)
  {
    serial->has_last_ch_ = True;