1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
|
#include <iostream>
#include <stdio.h> /* Standard input/output definitions */
#include <fcntl.h> /* File control definitions */
using namespace std;
int main(void)
{
char buffer[255]; /* Input buffer */
int fd = open("/dev/ttyS0", O_RDWR | O_NOCTTY | O_NDELAY);
if (fd == -1)
{
perror("open_port: Unable to open /dev/ttyS0 - ");
return 1;
}
else
{
fcntl(fd, F_SETFL, 0);
write(fd, "VLIM\r",5);
read(fd, buffer, sizeof(buffer) - 1);
cout << buffer << endl;
close(fd);
}
return (0);
} |