Привет, продолжаю играться с этой штукой: Не могу заставить работать USB <--> RS232 converter
Написал 2 простые программки:
#include <stdio.h>
#include <fcntl.h>
#include <stdlib.h>
#include <unistd.h>
#define OUTPUT "/dev/ttyS0"
int 
main (int argc, char *argv[]) 
{
  char buf[5] = {'a', 'b', 'c', 'd', 'e'};
  int fd_output;
  
   
  fd_output = open(OUTPUT, O_RDWR | O_NOCTTY);
  
  if (fd_output < 0) {
    perror(OUTPUT);
    exit(-1);
  }
  
  write(fd_output, buf, 5);
  fsync(fd_output);
  
   close(fd_output);
  
  return 0;
}
#include <stdio.h>
#include <fcntl.h>
#include <stdlib.h>
#include <unistd.h>
#define INPUT "/dev/ttyUSB0"
int 
main (int argc, char *argv[]) 
{
  char buf[6];
  int fd_input;
  
  fd_input = open(INPUT, O_RDWR | O_NOCTTY);
  
  
 
  if (fd_input < 0) {
    perror(INPUT);
    exit(-1);
  }
  
  read(fd_input, buf, 5);
  close(fd_input);
  
  buf[5] = '\0';
  printf("Buffer: %s", buf);
  
  return 0;
}
Запускаю чтение (2ая программка), затем пишу. Но! чтение не заканчивается и висит, пока я не сделаю echo 'anything' > /dev/ttyS0 (т.е. в выход).
После этого, мой буфер печатается и все ок. Подскажите, что нужно сделать: или какой-то символ конца передачи добавить. Не пойму куда копать.




