Reading Serial Data From C (OSX /dev/tty)

后端 未结 4 1184
南方客
南方客 2021-01-22 21:46

I am trying to read data from a bluetooth barcode scanner (KDC300) using C. Here is the code I have so far, and the program successfully establishes a bluetooth connection to th

4条回答
  •  感情败类
    2021-01-22 21:48

    In your code

    printf("%s", strcat("Unable to open /dev/tty.", argv[1]));
    

    Why did you do that? It would be easier to do it this way:

    printf("%s: Unable to open /dev/tty.KDC1", argv[0]); 
    

    Why the parameter referencing to the command line?

    res = read(fd,buf,255)
    

    Why did you have buf declaration commented out above?

提交回复
热议问题